PageSourceSearch

https://www.anicura.ch/dist/clinic-finder.js?v=bAFHdr7n1u9dVY5ciCub0E4QxUgkXtTMOsmq1uJslf8

js anicura.ch collected 2026-10-04 06:48:50 UTC 1,794,159 bytes, 3,289 lines download raw bytes

1"use strict";(()=>{var e2=Object.create;var I1=Object.defineProperty;var t2=Object.getOwnPropertyDescriptor;var i2=Object.getOwnPropertyNames;var n2=Object.getPrototypeOf,r2=Object.prototype.hasOwnProperty;var o2=(ot,bt)=>()=>(bt||ot((bt={exports:{}}).exports,bt),bt.exports);var s2=(ot,bt,jt,Ai)=>{if(bt&&typeof bt=="object"||typeof bt=="function")for(let mi of i2(bt))!r2.call(ot,mi)&&mi!==jt&&I1(ot,mi,{get:()=>bt[mi],enumerable:!(Ai=t2(bt,mi))||Ai.enumerable});return ot};var a2=(ot,bt,jt)=>(jt=ot!=null?e2(n2(ot)):{},s2(bt||!ot||!ot.__esModule?I1(jt,"default",{value:ot,enumerable:!0}):jt,ot));var M1=o2((Gy,Hy)=>{(function(ot,bt){typeof Gy=="object"&&typeof Hy<"u"?Hy.exports=bt():typeof define=="function"&&define.amd?define(bt):(ot=typeof globalThis<"u"?globalThis:ot||self,ot.mapboxgl=bt())})(Gy,function(){"use strict";let ot,bt,jt;function Ai(h,U){if(!ot)ot=U;else if(!bt)bt=U;else{let Pn={};ot(void 0,Pn),jt=U(Pn);let wi="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+ot+")(undefined, sharedChunk); ("+bt+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(jt.workerUrl=window.URL.createObjectURL(new Blob([wi],{type:"text/javascript"})))}}Ai(["require","exports"],function(h,U){var Pn=1e-6,wi=typeof Float32Array<"u"?Float32Array:Array;function Fn(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=i*l-s*r;return u?(n[0]=l*(u=1/u),n[1]=-r*u,n[2]=-s*u,n[3]=i*u,n):null}function yr(){var n=new wi(9);return wi!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function Qr(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=e[4],p=e[5],f=e[6],g=e[7],x=e[8];return n[0]=u*x-p*g,n[1]=s*g-r*x,n[2]=r*p-s*u,n[3]=p*f-l*x,n[4]=i*x-s*f,n[5]=s*l-i*p,n[6]=l*g-u*f,n[7]=r*f-i*g,n[8]=i*u-r*l,n}function Xn(n,e,i){var r=e[0],s=e[1],l=e[2],u=e[3],p=e[4],f=e[5],g=e[6],x=e[7],b=e[8],w=i[0],S=i[1],I=i[2],M=i[3],C=i[4],R=i[5],F=i[6],L=i[7],j=i[8];return n[0]=w*r+S*u+I*g,n[1]=w*s+S*p+I*x,n[2]=w*l+S*f+I*b,n[3]=M*r+C*u+R*g,n[4]=M*s+C*p+R*x,n[5]=M*l+C*f+R*b,n[6]=F*r+L*u+j*g,n[7]=F*s+L*p+j*x,n[8]=F*l+L*f+j*b,n}function eo(){var n=new wi(16);return wi!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function Rr(n){var e=new wi(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function Mt(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Bn(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=e[4],p=e[5],f=e[6],g=e[7],x=e[8],b=e[9],w=e[10],S=e[11],I=e[12],M=e[13],C=e[14],R=e[15],F=i*p-r*u,L=i*f-s*u,j=i*g-l*u,H=r*f-s*p,$=r*g-l*p,ie=s*g-l*f,W=x*M-b*I,Q=x*C-w*I,Y=x*R-S*I,ee=b*C-w*M,me=b*R-S*M,ge=w*R-S*C,Te=F*ge-L*me+j*ee+H*Y-$*Q+ie*W;return Te?(n[0]=(p*ge-f*me+g*ee)*(Te=1/Te),n[1]=(s*me-r*ge-l*ee)*Te,n[2]=(M*ie-C*$+R*H)*Te,n[3]=(w*$-b*ie-S*H)*Te,n[4]=(f*Y-u*ge-g*Q)*Te,n[5]=(i*ge-s*Y+l*Q)*Te,n[6]=(C*j-I*ie-R*L)*Te,n[7]=(x*ie-w*j+S*L)*Te,n[8]=(u*me-p*Y+g*W)*Te,n[9]=(r*Y-i*me-l*W)*Te,n[10]=(I*$-M*j+R*F)*Te,n[11]=(b*j-x*$-S*F)*Te,n[12]=(p*Q-u*ee-f*W)*Te,n[13]=(i*ee-r*Q+s*W)*Te,n[14]=(M*L-I*H-C*F)*Te,n[15]=(x*H-b*L+w*F)*Te,n):null}function xi(n,e,i){var r=e[0],s=e[1],l=e[2],u=e[3],p=e[4],f=e[5],g=e[6],x=e[7],b=e[8],w=e[9],S=e[10],I=e[11],M=e[12],C=e[13],R=e[14],F=e[15],L=i[0],j=i[1],H=i[2],$=i[3];return n[0]=L*r+j*p+H*b+$*M,n[1]=L*s+j*f+H*w+$*C,n[2]=L*l+j*g+H*S+$*R,n[3]=L*u+j*x+H*I+$*F,n[4]=(L=i[4])*r+(j=i[5])*p+(H=i[6])*b+($=i[7])*M,n[5]=L*s+j*f+H*w+$*C,n[6]=L*l+j*g+H*S+$*R,n[7]=L*u+j*x+H*I+$*F,n[8]=(L=i[8])*r+(j=i[9])*p+(H=i[10])*b+($=i[11])*M,n[9]=L*s+j*f+H*w+$*C,n[10]=L*l+j*g+H*S+$*R,n[11]=L*u+j*x+H*I+$*F,n[12]=(L=i[12])*r+(j=i[13])*p+(H=i[14])*b+($=i[15])*M,n[13]=L*s+j*f+H*w+$*C,n[14]=L*l+j*g+H*S+$*R,n[15]=L*u+j*x+H*I+$*F,n}function $n(n,e,i){var r,s,l,u,p,f,g,x,b,w,S,I,M=i[0],C=i[1],R=i[2];return e===n?(n[12]=e[0]*M+e[4]*C+e[8]*R+e[12],n[13]=e[1]*M+e[5]*C+e[9]*R+e[13],n[14]=e[2]*M+e[6]*C+e[10]*R+e[14],n[15]=e[3]*M+e[7]*C+e[11]*R+e[15]):(s=e[1],l=e[2],u=e[3],p=e[4],f=e[5],g=e[6],x=e[7],b=e[8],w=e[9],S=e[10],I=e[11],n[0]=r=e[0],n[1]=s,n[2]=l,n[3]=u,n[4]=p,n[5]=f,n[6]=g,n[7]=x,n[8]=b,n[9]=w,n[10]=S,n[11]=I,n[12]=r*M+p*C+b*R+e[12],n[13]=s*M+f*C+w*R+e[13],n[14]=l*M+g*C+S*R+e[14],n[15]=u*M+x*C+I*R+e[15]),n}function Yn(n,e,i){var r=i[0],s=i[1],l=i[2];return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*s,n[5]=e[5]*s,n[6]=e[6]*s,n[7]=e[7]*s,n[8]=e[8]*l,n[9]=e[9]*l,n[10]=e[10]*l,n[11]=e[11]*l,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Go(n,e,i){var r=Math.sin(i),s=Math.cos(i),l=e[4],u=e[5],p=e[6],f=e[7],g=e[8],x=e[9],b=e[10],w=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=l*s+g*r,n[5]=u*s+x*r,n[6]=p*s+b*r,n[7]=f*s+w*r,n[8]=g*s-l*r,n[9]=x*s-u*r,n[10]=b*s-p*r,n[11]=w*s-f*r,n}function Ho(n,e,i){var r=Math.sin(i),s=Math.cos(i),l=e[0],u=e[1],p=e[2],f=e[3],g=e[8],x=e[9],b=e[10],w=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=l*s-g*r,n[1]=u*s-x*r,
vendor: 4,453 bytes, line 1
1n[2]=p*s-b*r,n[3]=f*s-w*r,n[8]=l*r+g*s,n[9]=u*r+x*s,n[10]=p*r+b*s,n[11]=f*r+w*s,n}function fo(n,e,i){var r=Math.sin(i),s=Math.cos(i),l=e[0],u=e[1],p=e[2],f=e[3],g=e[4],x=e[5],b=e[6],w=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=l*s+g*r,n[1]=u*s+x*r,n[2]=p*s+b*r,n[3]=f*s+w*r,n[4]=g*s-l*r,n[5]=x*s-u*r,n[6]=b*s-p*r,n[7]=w*s-f*r,n}function _s(n,e){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}function $o(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function ta(n,e,i){var r,s,l,u=i[0],p=i[1],f=i[2],g=Math.sqrt(u*u+p*p+f*f);return g<Pn?null:(u*=g=1/g,p*=g,f*=g,r=Math.sin(e),s=Math.cos(e),n[0]=u*u*(l=1-s)+s,n[1]=p*u*l+f*r,n[2]=f*u*l-p*r,n[3]=0,n[4]=u*p*l-f*r,n[5]=p*p*l+s,n[6]=f*p*l+u*r,n[7]=0,n[8]=u*f*l+p*r,n[9]=p*f*l-u*r,n[10]=f*f*l+s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function Kl(n,e){var i=e[0],r=e[1],s=e[2],l=e[4],u=e[5],p=e[6],f=e[8],g=e[9],x=e[10];return n[0]=Math.sqrt(i*i+r*r+s*s),n[1]=Math.sqrt(l*l+u*u+p*p),n[2]=Math.sqrt(f*f+g*g+x*x),n}function Ql(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=i+i,p=r+r,f=s+s,g=i*u,x=r*u,b=r*p,w=s*u,S=s*p,I=s*f,M=l*u,C=l*p,R=l*f;return n[0]=1-b-I,n[1]=x+R,n[2]=w-C,n[3]=0,n[4]=x-R,n[5]=1-g-I,n[6]=S+M,n[7]=0,n[8]=w+C,n[9]=S-M,n[10]=1-g-b,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}var ec=xi;function ai(){var n=new wi(3);return wi!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function tc(n){var e=new wi(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function Dn(n){var e=n[0],i=n[1],r=n[2];return Math.sqrt(e*e+i*i+r*r)}function kn(n,e,i){var r=new wi(3);return r[0]=n,r[1]=e,r[2]=i,r}function Mi(n,e,i,r){return n[0]=e,n[1]=i,n[2]=r,n}function nn(n,e,i){return n[0]=e[0]+i[0],n[1]=e[1]+i[1],n[2]=e[2]+i[2],n}function mo(n,e,i){return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],n}function ic(n,e,i){return n[0]=e[0]*i[0],n[1]=e[1]*i[1],n[2]=e[2]*i[2],n}function Rn(n,e,i){return n[0]=Math.min(e[0],i[0]),n[1]=Math.min(e[1],i[1]),n[2]=Math.min(e[2],i[2]),n}function Lr(n,e,i){return n[0]=Math.max(e[0],i[0]),n[1]=Math.max(e[1],i[1]),n[2]=Math.max(e[2],i[2]),n}function Fi(n,e,i){return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n}function zr(n,e,i,r){return n[0]=e[0]+i[0]*r,n[1]=e[1]+i[1]*r,n[2]=e[2]+i[2]*r,n}function ia(n,e){var i=e[0]-n[0],r=e[1]-n[1],s=e[2]-n[2];return Math.sqrt(i*i+r*r+s*s)}function qo(n,e){var i=e[0]-n[0],r=e[1]-n[1],s=e[2]-n[2];return i*i+r*r+s*s}function nc(n){var e=n[0],i=n[1],r=n[2];return e*e+i*i+r*r}function _o(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function hi(n,e){var i=e[0],r=e[1],s=e[2],l=i*i+r*r+s*s;return l>0&&(l=1/Math.sqrt(l)),n[0]=e[0]*l,n[1]=e[1]*l,n[2]=e[2]*l,n}function en(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Jn(n,e,i){var r=e[0],s=e[1],l=e[2],u=i[0],p=i[1],f=i[2];return n[0]=s*f-l*p,n[1]=l*u-r*f,n[2]=r*p-s*u,n}function na(n,e,i,r){var s=e[0],l=e[1],u=e[2];return n[0]=s+r*(i[0]-s),n[1]=l+r*(i[1]-l),n[2]=u+r*(i[2]-u),n}function Bi(n,e,i){var r=e[0],s=e[1],l=e[2],u=i[3]*r+i[7]*s+i[11]*l+i[15];return n[0]=(i[0]*r+i[4]*s+i[8]*l+i[12])/(u=u||1),n[1]=(i[1]*r+i[5]*s+i[9]*l+i[13])/u,n[2]=(i[2]*r+i[6]*s+i[10]*l+i[14])/u,n}function gs(n,e,i){var r=e[0],s=e[1],l=e[2];return n[0]=r*i[0]+s*i[3]+l*i[6],n[1]=r*i[1]+s*i[4]+l*i[7],n[2]=r*i[2]+s*i[5]+l*i[8],n}function Za(n,e,i){var r=i[0],s=i[1],l=i[2],u=i[3],p=e[0],f=e[1],g=e[2],x=s*g-l*f,b=l*p-r*g,w=r*f-s*p;return n[0]=p+u*(x+=x)+s*(w+=w)-l*(b+=b),n[1]=f+u*b+l*x-r*w,n[2]=g+u*w+r*b-s*x,n}function Wa(n){return n[0]=0,n[1]=0,n[2]=0,n}function Po(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}var $i=mo,Xa=ic,ra=Dn;function Ya(){var n=new wi(4);return wi!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function oa(n,e,i){return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=e[3]*i,n}function Zo(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=i*i+r*r+s*s+l*l;return u>0&&(u=1/Math.sqrt(u)),n[0]=i*u,n[1]=r*u,n[2]=s*u,n[3]=l*u,n}function xr(n,e,i){var r=e[0],s=e[1],l=e[2],u=e[3];return n[0]=i[0]*r+i[4]*s+i[8]*l+i[12]*u,n[1]=i[1]*r+i[5]*s+i[9]*l+i[13]*u,n[2]=i[2]*r+i[6]*s+i[10]*l+i[14]*u,n[3]=i[3]*r+i[7]*s+i[11]*l+i[15]*u,n}function ys(){var n=new wi(4);return wi!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function xs(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function Ja(n,e,i){i*=.5;var r=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),f=Math.cos(i);
1return n[0]=r*f+u*p,n[1]=s*f+l*p,n[2]=l*f-s*p,n[3]=u*f-r*p,n}function sa(n,e,i){i*=.5;var r=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),f=Math.cos(i);return n[0]=r*f-l*p,n[1]=s*f+u*p,n[2]=l*f+r*p,n[3]=u*f-s*p,n}ai(),Ya();var vr,rc,Or,cu=Zo,oc=(vr=ai(),rc=kn(1,0,0),Or=kn(0,1,0),function(n,e,i){var r=en(e,i);return r<-.999999?(Jn(vr,rc,e),ra(vr)<1e-6&&Jn(vr,Or,e),hi(vr,vr),function(s,l,u){u*=.5;var p=Math.sin(u);s[0]=p*l[0],s[1]=p*l[1],s[2]=p*l[2],s[3]=Math.cos(u)}(n,vr,Math.PI),n):r>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Jn(vr,e,i),n[0]=vr[0],n[1]=vr[1],n[2]=vr[2],n[3]=1+r,cu(n,n))});function Kn(){var n=new wi(2);return wi!=Float32Array&&(n[0]=0,n[1]=0),n}function go(n,e){var i=new wi(2);return i[0]=n,i[1]=e,i}function Wo(n,e,i){return n[0]=e,n[1]=i,n}function aa(n,e,i){return n[0]=e[0]+i[0],n[1]=e[1]+i[1],n}function yo(n,e,i){return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n}function la(n,e,i){return n[0]=e[0]*i,n[1]=e[1]*i,n}function ca(n){var e=n[0],i=n[1];return Math.sqrt(e*e+i*i)}function sc(n,e){var i=e[0],r=e[1],s=i*i+r*r;return s>0&&(s=1/Math.sqrt(s)),n[0]=e[0]*s,n[1]=e[1]*s,n}function Do(n,e){return n[0]*e[0]+n[1]*e[1]}ys(),ys(),yr();var ac,uu,Ka=yo;function hu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}Kn();var Oh=function(){if(uu)return ac;function n(e,i,r,s){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(s-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=r,this.p2y=s}return uu=1,ac=n,n.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,i){if(i===void 0&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,s=0;s<8;s++){var l=this.sampleCurveX(r)-e;if(Math.abs(l)<i)return r;var u=this.sampleCurveDerivativeX(r);if(Math.abs(u)<1e-6)break;r-=l/u}var p=0,f=1;for(r=e,s=0;s<20&&(l=this.sampleCurveX(r),!(Math.abs(l-e)<i));s++)e>l?p=r:f=r,r=.5*(f-p)+p;return r},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},ac}(),Qa=hu(Oh);function ke(n,e){this.x=n,this.y=e}function Xo(n,e){if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(!Xo(n[i],e[i]))return!1;return!0}if(typeof n=="object"&&n!==null&&e!==null){if(typeof e!="object"||Object.keys(n).length!==Object.keys(e).length)return!1;for(let i in n)if(!Xo(n[i],e[i]))return!1;return!0}return n===e}ke.prototype={clone(){return new ke(this.x,this.y)},add(n){return this.clone()._add(n)},sub(n){return this.clone()._sub(n)},multByPoint(n){return this.clone()._multByPoint(n)},divByPoint(n){return this.clone()._divByPoint(n)},mult(n){return this.clone()._mult(n)},div(n){return this.clone()._div(n)},rotate(n){return this.clone()._rotate(n)},rotateAround(n,e){return this.clone()._rotateAround(n,e)},matMult(n){return this.clone()._matMult(n)},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(n){return this.x===n.x&&this.y===n.y},dist(n){return Math.sqrt(this.distSqr(n))},distSqr(n){let e=n.x-this.x,i=n.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(n){return Math.atan2(this.y-n.y,this.x-n.x)},angleWith(n){return this.angleWithSep(n.x,n.y)},angleWithSep(n,e){return Math.atan2(this.x*e-this.y*n,this.x*n+this.y*e)},_matMult(n){let e=n[2]*this.x+n[3]*this.y;return this.x=n[0]*this.x+n[1]*this.y,this.y=e,this},_add(n){return this.x+=n.x,this.y+=n.y,this},_sub(n){return this.x-=n.x,this.y-=n.y,this},_mult(n){return this.x*=n,this.y*=n,this},_div(n){return this.x/=n,this.y/=n,this},_multByPoint(n){return this.x*=n.x,this.y*=n.y,this},_divByPoint(n){return this.x/=n.x,this.y/=n.y,this},_unit(){return this._div(this.mag()),this},_perp(){let n=this.y;return this.y=this.x,this.x=-n,this},_rotate(n){let e=Math.cos(n),i=Math.sin(n),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround(n,e){let i=Math.cos(n),r=Math.sin(n),s=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ke},ke.convert=function(n){if(n instanceof ke)return n;if(Array.isArray(n))return new ke(+n[0],+n[1]);if(n.x!==void 0&&n.y!==void 0)return new ke(+n.x,+n.y);throw new Error("Expected [x, y] or {x, y} point format")};let vs=Math.PI/180,ua=180/Math.PI,el=/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,_e=/\b(iPad|iPhone|iPod)\b/,B=/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/;function V(n){return n*vs}function X(n){return n*ua}let ae=[[0,0],[1,0],[1,1],[0,1]];function le(n){if(n<=0)return 0;if(n>=1)return 1;let e=n*n,i=e*n;return 4*(n<.5?i:3*(n-e)+i-.75)}function ce(n,e,i,r){let s=new Qa(n,e,i,r);return function(l){return s.solve(l)}}let we=ce(.25,.1,.25,1);function ne(n,e,i){return Math.min(i,Math.max(e,n))}function ye(n,e,i){return(i=ne((i-n)/(e-n),0,1))*i*(3-2*i)}function Ne(n,e,i){let r=i-e,s=((n-e)%r+r)%r+e;return s===e?i:s}function Oe(n,e,i){if(!n.length)return i(null,[]);let r=n.length,s=new Array(n.length),l=null;
1n.forEach((u,p)=>{e(u,(f,g)=>{f&&(l=f),s[p]=g,--r===0&&i(l,s)})})}function Ke(n,e){let i={};for(let r=0;r<e.length;r++){let s=e[r];s in n&&(i[s]=n[s])}return i}let ut=1;function dt(){return ut++}function Ft(n){return n<=1?1:Math.pow(2,Math.ceil(Math.log2(n)))}function It(n,e){n.forEach(i=>{e[i]&&(e[i]=e[i].bind(e))})}function Dt(n,e,i){let r={};for(let s in n)r[s]=e.call(this,n[s],s,n);return r}function Ve(n,e,i){let r={};for(let s in n)e.call(this,n[s],s,n)&&(r[s]=n[s]);return r}function Gt(n){return Array.isArray(n)?n.map(Gt):typeof n=="object"&&n?Dt(n,Gt):n}function qi(n,e){for(let i=0;i<n.length;i++)if(e.includes(n[i]))return!0;return!1}let Zi={};function Bt(n){Zi[n]||(typeof console<"u"&&console.warn(n),Zi[n]=!0)}function ni(n,e,i){return(i.y-n.y)*(e.x-n.x)>(e.y-n.y)*(i.x-n.x)}function Di(n){let e=0;for(let i,r,s=0,l=n.length,u=l-1;s<l;u=s++)i=n[s],r=n[u],e+=(r.x-i.x)*(i.y+r.y);return e}function rn([n,e,i]){let r=V(e+90),s=V(i);return{x:n*Math.cos(r)*Math.sin(s),y:n*Math.sin(r)*Math.sin(s),z:n*Math.cos(s),azimuthal:e,polar:i}}function ri(n){return(typeof self<"u"||n!==void 0)&&typeof WorkerGlobalScope<"u"&&(n!==void 0?n:self)instanceof WorkerGlobalScope}function Ci(n){let e={};if(n.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,r,s,l)=>{let u=s||l;return e[r]=!u||u.toLowerCase(),""}),e["max-age"]){let i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e}let Ni,vi=null;function Xi(n,e){return[n[4*e],n[4*e+1],n[4*e+2],n[4*e+3]]}function Nn(n,e,i,r){for(;e<i;){let s=e+i>>1;n[s]<r?e=s+1:i=s}return e}function gn(n,e,i,r){for(;e<i;){let s=e+i>>1;n[s]<=r?e=s+1:i=s}return e}function Ln(n){return n>0?1/(1.001-n):1+n}function Fr(n){return n>0?1-1/(1.001-n):-n}function xo(n,e,i){return(n-e.min)*(i.max-i.min)/(e.max-e.min)+i.min}let di={API_URL:"https://api.mapbox.com",API_URL_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i,API_TILEJSON_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i,API_SPRITE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i,API_FONTS_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i,API_STYLE_REGEX:/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i,API_CDN_URL_REGEX:/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i,get EVENTS_URL(){if(!di.API_URL)return null;try{let n=new URL(di.API_URL);return n.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":n.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/plugins/mapbox-gl-pmtiles-provider/v0.0.2/mapbox-gl-pmtiles-provider.js"})};function ha(){return new URL(di.DRACO_URL,di.API_URL).href}function da(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(Ni===void 0){if(typeof WebAssembly!="object")return!1;let n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);Ni=WebAssembly.validate(n)}return Ni}()?di.MESHOPT_SIMD_URL:di.MESHOPT_URL,di.API_URL).href}function pa(){return new URL(di.BUILDING_GEN_URL,di.API_URL).href}function bs(n){return di.API_URL_REGEX.test(n)}function tl(n){return di.API_SPRITE_REGEX.test(n)}
1let du,lc,pu,Ri,Sn,cc;function Fh(){return du==null&&(du=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),du}let yn={requestIdleCallback:n=>{if(typeof requestIdleCallback<"u")return requestIdleCallback(n);setTimeout(()=>n({didTimeout:!1,timeRemaining:()=>50}),0)},now:()=>Ri!==void 0?Ri:performance.now(),setNow(n){Ri=n},restoreNow(){Ri=void 0},frame(n){let e=requestAnimationFrame(n);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(n,e=0){let{width:i,height:r}=n;Sn||(Sn=document.createElement("canvas"));let s=Sn.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("failed to create canvas 2d context");return(i>Sn.width||r>Sn.height)&&(Sn.width=i,Sn.height=r),s.clearRect(-e,-e,i+2*e,r+2*e),s.drawImage(n,0,0,i,r),s.getImageData(-e,-e,i+2*e,r+2*e)},resolveURL:n=>(lc||(lc=document.createElement("a")),lc.href=n,lc.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(pu==null&&(pu=window.matchMedia("(prefers-reduced-motion: reduce)")),pu.matches)},hasCanvasFingerprintNoise(){if(cc!==void 0)return cc;if(!Fh())return cc=!1,!1;let n=new OffscreenCanvas(85,1),e=n.getContext("2d",{willReadFrequently:!0}),i=0;for(let s=0;s<n.width;++s)e.fillStyle=`rgba(${i++},${i++},${i++}, 255)`,e.fillRect(s,0,1,1);let r=e.getImageData(0,0,n.width,n.height);i=0;for(let s=0;s<r.data.length;++s)if(s%4!=3&&i++!==r.data[s])return cc=!0,!0;return cc=!1,!1}};function Yp(n,e){let i=n.indexOf("?");if(i<0)return`${n}?${new URLSearchParams(e).toString()}`;let r=new URLSearchParams(n.slice(i));for(let s in e)r.set(s,e[s]);return`${n.slice(0,i)}?${r.toString()}`}
1function Bh(n,e={persistentParams:[]}){let i=n.indexOf("?");if(i<0)return n;let r=new URLSearchParams,s=new URLSearchParams(n.slice(i));for(let u of e.persistentParams){let p=s.get(u);p&&r.set(u,p)}let l=r.toString();return`${n.slice(0,i)}${l.length>0?`?${l}`:""}`}let Jp="mapbox-tiles",Kp=500,Qp=50,ef=["language","worldview","jobid"],Yo;function tf(){try{return caches}catch{}}function fa(){let n=tf();n&&Yo==null&&(Yo=n.open(Jp))}let kh=1/0,Nh={supported:!1,testSupport:function(n){!ma&&qn&&(hc?Vh(n):uc=n)}},uc,qn,ma=!1,hc=!1,Uh=typeof self<"u"?self:{};function Vh(n){let e=n.createTexture();n.bindTexture(n.TEXTURE_2D,e);try{if(n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,qn),n.isContextLost())return;Nh.supported=!0}catch{}n.deleteTexture(e),ma=!0}Uh.document&&(qn=Uh.document.createElement("img"),qn.onload=function(){uc&&Vh(uc),uc=null,hc=!0},qn.onerror=function(){ma=!0,uc=null},qn.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");let ws={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(ws);class jh extends Error{constructor(e,i,r){i===401&&bs(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=i,this.url=r}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function Ts(n){return typeof n=="object"&&n!==null&&"status"in n&&n.status===404}let il=ri()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,nf=/^\w+:/,rf=/[\r\n]+/,Br=function(n,e){return(i=n.url).startsWith("file:")||il().startsWith("file:")&&!nf.test(i)?function(r,s){let l=new XMLHttpRequest;l.open(r.method||"GET",r.url,!0),r.type==="arrayBuffer"&&(l.responseType="arraybuffer");for(let u in r.headers)l.setRequestHeader(u,r.headers[u]);return r.type==="json"&&(l.responseType="text",l.setRequestHeader("Accept","application/json")),l.withCredentials=r.credentials==="include",l.onerror=()=>{s(new Error(l.statusText))},l.onload=()=>{if((l.status>=200&&l.status<300||l.status===0)&&l.response!==null){let u=l.response;if(r.type==="json")try{u=JSON.parse(l.response)}catch(f){return s(f)}let p=new Headers;l.getAllResponseHeaders().trim().split(rf).forEach(f=>{let g=f.split(": "),x=g.shift(),b=g.join(": ");p.append(x,b)}),s(null,u,p)}else s(new jh(l.statusText,l.status,r.url))},l.send(r.body),{cancel:()=>l.abort()}}(n,e):function(r,s){let l=new AbortController,u=new Request(r.url,{method:r.method||"GET",body:r.body,credentials:r.credentials,headers:r.headers,referrer:il(),referrerPolicy:r.referrerPolicy,signal:l.signal}),p=!1,f=!1,g=(x=u.url).indexOf("sku=")>0&&bs(x);var x;r.type==="json"&&u.headers.set("Accept","application/json");let b=(S,I,M)=>{if(f)return;if(S&&S.message!=="SecurityError"&&Bt(S.toString()),I&&M)return w(I);let C=Date.now();fetch(u).then(R=>{if(R.ok){let F=g?R.clone():null;return w(R,F,C)}return s(new jh(R.statusText,R.status,r.url))}).catch(R=>{R.name!=="AbortError"&&s(new Error(`${R.message} ${r.url}`))})},w=(S,I,M)=>{(r.type==="arrayBuffer"?S.arrayBuffer():r.type==="json"?S.json():S.text()).then(C=>{f||(I&&M&&function(R,F,L){if(fa(),Yo==null)return;let j=Ci(F.headers.get("cache-control")||"");if(j["no-store"])return;let H={status:F.status,statusText:F.statusText,headers:new Headers};F.headers.forEach((Y,ee)=>H.headers.set(ee,Y)),j["max-age"]&&H.headers.set("Expires",new Date(L+1e3*j["max-age"]).toUTCString());let $=H.headers.get("expires");if(!$||new Date($).getTime()-L<42e4)return;
1let ie=Bh(R.url,{persistentParams:ef});if(F.status===206){let Y=R.headers.get("Range");if(!Y)return;H.status=200,ie=Yp(ie,{range:Y})}let W=new Response((Q=F.status)!==200&&Q!==404&&[101,103,204,205,304].includes(Q)?null:F.body,H);var Q;fa(),Yo?.then(Y=>Y.put(ie,W)).catch(Y=>Bt(Y.message))}(u,I,M),p=!0,s(null,C,S.headers))}).catch(C=>{f||s(new Error(C.message))})};return g?function(S,I){if(fa(),Yo==null)return I(null);Yo.then(M=>{let C=Bh(S.url,{persistentParams:ef}),R=S.headers.get("Range");R&&(C=Yp(C,{range:R})),M.match(C).then(F=>{let L=function(j){if(!j)return!1;let H=new Date(j.headers.get("expires")||0),$=Ci(j.headers.get("cache-control")||"");return Number(H)>Date.now()&&!$["no-cache"]}(F);M.delete(C).catch(I),L&&M.put(C,F.clone()).catch(I),I(null,F,L)}).catch(I)}).catch(I)}(u,b):b(null,null),{cancel:()=>{f=!0,p||l.abort()}}}(n,e);var i},of=function(n,e){return Br(Object.assign(n,{type:"json"}),e)},nl=function(n,e){return Br(Object.assign(n,{type:"arrayBuffer"}),e)};function sf(n){let e=document.createElement("a");return e.href=n,e.protocol===location.protocol&&e.host===location.host}let fu,dc;fu=[],dc=0;let to=function(n,e){if(Nh.supported&&(n.headers||(n.headers={}),n.headers.accept="image/webp,*/*"),dc>=di.MAX_PARALLEL_IMAGE_REQUESTS){let l={requestParameters:n,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return fu.push(l),l}dc++;let i=!1,r=()=>{if(!i)for(i=!0,dc--;fu.length&&dc<di.MAX_PARALLEL_IMAGE_REQUESTS;){let l=fu.shift(),{requestParameters:u,callback:p,cancelled:f}=l;f||(l.cancel=to(u,p).cancel)}},s=nl(n,(l,u,p)=>{r(),l?e(l):u&&function(f,g){let x=new Blob([new Uint8Array(f)],{type:"image/png"});createImageBitmap(x).then(b=>{g(null,b)}).catch(b=>{g(new Error(`Could not load image because of ${b.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(u,(f,g)=>e(f,g,p))});return{cancel:()=>{s.cancel(),r()}}};var af,mu,Ss,Es={exports:{}},Gh={exports:{}},Hh={exports:{}},z_=function(){if(Ss)return Es.exports;Ss=1;var n=(af||(af=1,Gh.exports=function(i,r){var s,l,u,p,f,g,x,b;for(l=i.length-(s=3&i.length),u=r,f=3432918353,g=461845907,b=0;b<l;)x=255&i.charCodeAt(b)|(255&i.charCodeAt(++b))<<8|(255&i.charCodeAt(++b))<<16|(255&i.charCodeAt(++b))<<24,++b,u=27492+(65535&(p=5*(65535&(u=(u^=x=(65535&(x=(x=(65535&x)*f+(((x>>>16)*f&65535)<<16)&4294967295)<<15|x>>>17))*g+(((x>>>16)*g&65535)<<16)&4294967295)<<13|u>>>19))+((5*(u>>>16)&65535)<<16)&4294967295))+(((p>>>16)+58964&65535)<<16);switch(x=0,s){case 3:x^=(255&i.charCodeAt(b+2))<<16;case 2:x^=(255&i.charCodeAt(b+1))<<8;case 1:u^=x=(65535&(x=(x=(65535&(x^=255&i.charCodeAt(b)))*f+(((x>>>16)*f&65535)<<16)&4294967295)<<15|x>>>17))*g+(((x>>>16)*g&65535)<<16)&4294967295}return u^=i.length,u=2246822507*(65535&(u^=u>>>16))+((2246822507*(u>>>16)&65535)<<16)&4294967295,u=3266489909*(65535&(u^=u>>>13))+((3266489909*(u>>>16)&65535)<<16)&4294967295,(u^=u>>>16)>>>0}
1),Gh.exports),e=(mu||(mu=1,Hh.exports=function(i,r){for(var s,l=i.length,u=r^l,p=0;l>=4;)s=1540483477*(65535&(s=255&i.charCodeAt(p)|(255&i.charCodeAt(++p))<<8|(255&i.charCodeAt(++p))<<16|(255&i.charCodeAt(++p))<<24))+((1540483477*(s>>>16)&65535)<<16),u=1540483477*(65535&u)+((1540483477*(u>>>16)&65535)<<16)^(s=1540483477*(65535&(s^=s>>>24))+((1540483477*(s>>>16)&65535)<<16)),l-=4,++p;switch(l){case 3:u^=(255&i.charCodeAt(p+2))<<16;case 2:u^=(255&i.charCodeAt(p+1))<<8;case 1:u=1540483477*(65535&(u^=255&i.charCodeAt(p)))+((1540483477*(u>>>16)&65535)<<16)}return u=1540483477*(65535&(u^=u>>>13))+((1540483477*(u>>>16)&65535)<<16),(u^=u>>>15)>>>0}),Hh.exports);return Es.exports=n,Es.exports.murmur3=n,Es.exports.murmur2=e,Es.exports}(),pc=hu(z_);class Jo{constructor(e,...i){Object.assign(this,i[0]||{}),this.type=e}}class rl extends Jo{constructor(e,i={}){super("error",Object.assign({error:e},i))}}function _u(n,e,i){i[n]&&i[n].includes(e)||(i[n]=i[n]||[],i[n].push(e))}function _a(n,e,i){if(i&&i[n]){let r=i[n].indexOf(e);r!==-1&&i[n].splice(r,1)}}class ol{on(e,i){return this._listeners=this._listeners||{},_u(e,i,this._listeners),this}off(e,i){return _a(e,i,this._listeners),_a(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},_u(e,i,this._oneTimeListeners),this):new Promise(r=>{this.once(e,r)})}fire(e,i){let r=typeof e=="string"?new Jo(e,i):e,s=r.type;if(this.listens(s)){r.target=this;let l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(let f of l)f.call(this,r);let u=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(let f of u)_a(s,f,this._oneTimeListeners),f.call(this,r);let p=this._eventedParent;if(p){let f=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(r,f),p.fire(r)}}else r instanceof rl&&console.error(r.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,i){return this._eventedParent=e,this._eventedParentData=i,this}}class br{constructor(e){typeof e=="string"?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new br(e)}static toString(e){return e.iconsetId?`${e.name}�${e.iconsetId}`:e.name}static parse(e){let[i,r]=e.split("�");return new br({name:i,iconsetId:r})}static isEqual(e,i){return e.name===i.name&&e.iconsetId===i.iconsetId}toString(){return br.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var ga,gu={},fc=function(){if(ga)return gu;ga=1;var n={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function e(l){return(l=Math.round(l))<0?0:l>255?255:l}function i(l){return e(l[l.length-1]==="%"?parseFloat(l)/100*255:parseInt(l))}function r(l){return(u=l[l.length-1]==="%"?parseFloat(l)/100:parseFloat(l))<0?0:u>1?1:u;var u}function s(l,u,p){return p<0?p+=1:p>1&&(p-=1),6*p<1?l+(u-l)*p*6:2*p<1?u:3*p<2?l+(u-l)*(2/3-p)*6:l}try{gu.parseCSSColor=function(l){var u,p=l.replace(/ /g,"").toLowerCase();if(p in n)return n[p].slice();if(p[0]==="#")return p.length===4?(u=parseInt(p.substr(1),16))>=0&&u<=4095?[(3840&u)>>4|(3840&u)>>8,240&u|(240&u)>>4,15&u|(15&u)<<4,1]:null:p.length===7&&(u=parseInt(p.substr(1),16))>=0&&u<=16777215?[(16711680&u)>>16,(65280&u)>>8,255&u,1]:null;var f=p.indexOf("("),g=p.indexOf(")");if(f!==-1&&g+1===p.length){var x=p.substr(0,f),b=p.substr(f+1,g-(f+1)).split(","),w=1;switch(x){case"rgba":if(b.length!==4)return null;w=r(b.pop());case"rgb":return b.length!==3?null:[i(b[0]),i(b[1]),i(b[2]),w];case"hsla":if(b.length!==4)return null;w=r(b.pop());case"hsl":if(b.length!==3)return null;var S=(parseFloat(b[0])%360+360)%360/360,I=r(b[1]),M=r(b[2]),C=M<=.5?M*(I+1):M+I-M*I,R=2*M-C;return[e(255*s(R,C,S+1/3)),e(255*s(R,C,S)),e(255*s(R,C,S-1/3)),w];default:return null}}return null}}catch{}return gu}();function mt(n,e,i){return n*(1-i)+e*i}class Ht{constructor(e,i,r,s=1){this.r=e,this.g=i,this.b=r,this.a=s}static parse(e){if(!e)return;if(e instanceof Ht)return e;if(typeof e!="string")return;let i=fc.parseCSSColor(e);return i?new Ht(i[0]/255,i[1]/255,i[2]/255,i[3]):void 0}toString(){let{r:e,g:i,b:r,a:s}=this;return`rgba(${Math.round(255*e)},${Math.round(255*i)},${Math.round(255*r)},${s})`}toNonPremultipliedRenderColor(e){let{r:i,g:r,b:s,a:l}=this;return new $h(e,i,r,s,l)}toPremultipliedRenderColor(e){let{r:i,g:r,b:s,a:l}=this;return new lf(e,i*l,r*l,s*l,l)}clone(){return new Ht(this.r,this.g,this.b,this.a)}}class yu{constructor(e,i,r,s,l,u=!1){if(this.premultiplied=!1,this.premultiplied=u,e){let p=e.image.height,f=p*p;this.premultiplied?(i=l===0?0:i/l*(p-1),r=l===0?0:r/l*(p-1),s=l===0?0:s/l*(p-1)):(i*=p-1,r*=p-1,s*=p-1),i=Math.max(0,Math.min(p-1,i)),r=Math.max(0,Math.min(p-1,r)),s=Math.max(0,Math.min(p-1,s));let g=Math.floor(i),x=Math.floor(r),b=Math.floor(s),w=Math.ceil(i),S=Math.ceil(r),I=Math.ceil(s),M=i-g,C=r-x,R=s-b,F=e.image.data,L=4*(g+x*f+b*p),j=4*(g+x*f+I*p),H=4*(g+S*f+b*p),$=4*(g+S*f+I*p),ie=4*(w+x*f+b*p),W=4*(w+x*f+I*p),Q=4*(w+S*f+b*p),Y=4*(w+S*f+I*p);this.r=mt(mt(mt(F[L],F[j],R),mt(F[H],F[$],R),C),mt(mt(F[ie],F[W],R),mt(F[Q],F[Y],R),C),M)/255*(this.premultiplied?l:1),this.g=mt(mt(mt(F[L+1],F[j+1],R),mt(F[H+1],F[$+1],R),C),mt(mt(F[ie+1],F[W+1],R),mt(F[Q+1],F[Y+1],R),C),M)/255*(this.premultiplied?l:1),this.b=mt(mt(mt(F[L+2],F[j+2],R),mt(F[H+2],F[$+2],R),C),mt(mt(F[ie+2],F[W+2],R),mt(F[Q+2],F[Y+2],R),C),M)/255*(this.premultiplied?l:1),this.a=l}else this.r=i,this.g=r,this.b=s,this.a=l}toArray(){let{r:e,g:i,b:r,a:s}=this;return[255*e,255*i,255*r,s]}toHslaArray(){let{r:e,g:i,b:r,a:s}=this;if(this.premultiplied){if(s===0)return[0,0,0,0];let I=1/s;e*=I,i*=I,r*=I}let l=Math.min(Math.max(e,0),1),u=Math.min(Math.max(i,0),1),p=Math.min(Math.max(r,0),1),f=Math.min(l,u,p),g=Math.max(l,u,p),x=g-f,b=.5*(f+g);if(x===0)return[0,0,100*b,s];let w=b>.5?x/(2-g-f):x/(g+f),S;switch(g){case l:S=60*((u-p)/x+(u<p?6:0));break;case u:S=60*((p-l)/x+2);break;default:S=60*((l-u)/x+4)}return[S,100*w,100*b,s]}toArray01(){let{r:e,g:i,b:r,a:s}=this;return[e,i,r,s]}toArray01Scaled(e){let{r:i,g:r,b:s}=this;return[i*e,r*e,s*e]}toArray01Linear(){let{r:e,g:i,b:r,a:s}=this;return[Math.pow(e,2.2),Math.pow(i,2.2),Math.pow(r,2.2),s]}}class $h extends yu{constructor(e,i,r,s,l){super(e,i,r,s,l,!1)}}class lf extends yu{constructor(e,i,r,s,l){super(e,i,r,s,l,!0)}}function qh(n,e,i){return n.map((r,s)=>mt(r,e[s],i))}Ht.black=new Ht(0,0,0,1),Ht.white=new Ht(1,1,1,1),Ht.transparent=new Ht(0,0,0,0),Ht.red=new Ht(1,0,0,1),Ht.blue=new Ht(0,0,1,1);var xu=Object.freeze({__proto__:null,array:qh,color:function(n,e,i){return new Ht(mt(n.r,e.r,i),mt(n.g,e.g,i),mt(n.b,e.b,i),mt(n.a,e.a,i))},number:mt});
1class vo extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}class Zh{constructor(e,i=[]){this.parent=e,this.bindings={};for(let[r,s]of i)this.bindings[r]=s}concat(e){return new Zh(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}let ya={kind:"null"},at={kind:"number"},ei={kind:"string"},oi={kind:"boolean"},on={kind:"color"},xa={kind:"object"},Wt={kind:"value"},vu={kind:"collator"},Ko={kind:"formatted"},sl={kind:"resolvedImage"};function Qn(n,e){return{kind:"array",itemType:n,N:e}}function sn(n){if(n.kind==="array"){let e=sn(n.itemType);return typeof n.N=="number"?`array<${e}, ${n.N}>`:n.itemType.kind==="value"?"array":`array<${e}>`}return n.kind}let Yt=[ya,at,ei,oi,on,Ko,xa,Qn(Wt),sl];function al(n,e){if(e.kind==="error")return null;if(n.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!al(n.itemType,e.itemType))&&(typeof n.N!="number"||n.N===e.N))return null}else{if(n.kind===e.kind)return null;if(n.kind==="value"){for(let i of Yt)if(!al(i,e))return null}}return`Expected ${sn(n)} but found ${sn(e)} instead.`}function bu(n,e){return e.some(i=>i.kind===n.kind)}function mc(n,e){return e.some(i=>i==="null"?n===null:i==="array"?Array.isArray(n):i==="object"?n&&!Array.isArray(n)&&typeof n=="object":i===typeof n)}function wu(n,e){return n.kind==="array"&&e.kind==="array"?n.N===e.N&&wu(n.itemType,e.itemType):n.kind===e.kind}class ll{constructor(e,i,r){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class va{constructor(e,i,r,s,l){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=r,this.fontStack=s,this.textColor=l}}class Un{constructor(e){this.sections=e}static fromString(e){return new Un([new va(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof Un?e:Un.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){let e=["format"];for(let i of this.sections){if(i.image){let s=i.image.getPrimary().id.toString();e.push(["image",s]);continue}e.push(i.text);let r={};i.fontStack&&(r["text-font"]=["literal",i.fontStack.split(",")]),i.scale&&(r["font-scale"]=i.scale),i.textColor&&(r["text-color"]=["rgba"].concat(i.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(r)}return e}}class wr{constructor(e,i={}){this.id=br.from(e),this.params=i.params,this.sx=i.sx||1,this.sy=i.sy||1}toString(){return JSON.stringify(this)}static parse(e){let i,r,s,l;try{({id:i,params:r,sx:s,sy:l}=JSON.parse(e)||{})}catch{return null}return i?new wr(i,{params:r,sx:s,sy:l}):null}scaleSelf(e,i=e){return this.sx*=e,this.sy*=i,this}}class dr{constructor(e,i,r,s,l=!1){this.primaryId=br.from(e),this.primaryOptions=i,r&&(this.secondaryId=br.from(r)),this.secondaryOptions=s,this.available=l}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new wr(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new wr(this.secondaryId,this.secondaryOptions):null}static from(e){return typeof e=="string"?dr.build({name:e}):e}static build(e,i,r,s){return!e||typeof e=="object"&&!("name"in e)?null:new dr(e,r,i,s)}}function Tu(n,e,i,r){return typeof n=="number"&&n>=0&&n<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?r===void 0||typeof r=="number"&&r>=0&&r<=1?null:`Invalid rgba value [${[n,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r=="number"?[n,e,i,r]:[n,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function cl(n){if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||n instanceof Ht||n instanceof ll||n instanceof Un||n instanceof dr)return!0;
1if(Array.isArray(n)){for(let e of n)if(!cl(e))return!1;return!0}if(typeof n=="object"){for(let e in n)if(!cl(n[e]))return!1;return!0}return!1}function xn(n){if(n===null)return ya;if(typeof n=="string")return ei;if(typeof n=="boolean")return oi;if(typeof n=="number")return at;if(n instanceof Ht)return on;if(n instanceof ll)return vu;if(n instanceof Un)return Ko;if(n instanceof dr)return sl;if(Array.isArray(n)){let e=n.length,i;for(let r of n){let s=xn(r);if(i){if(i===s)continue;i=Wt;break}i=s}return Qn(i||Wt,e)}return xa}function Tr(n){let e=typeof n;return n===null?"":e==="string"||e==="number"||e==="boolean"?String(n):n instanceof Un||n instanceof dr||n instanceof Ht?n.toString():JSON.stringify(n)}class bo{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!cl(e[1]))return i.error("invalid value");let r=e[1],s=xn(r),l=i.expectedType;return s.kind!=="array"||s.N!==0||!l||l.kind!=="array"||typeof l.N=="number"&&l.N!==0||(s=l),new bo(s,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Ht?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Un?this.value.serialize():this.value}}class an{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}let kr={string:ei,number:at,boolean:oi,object:xa};class io{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r,s=1,l=e[0];if(l==="array"){let p,f;if(e.length>2){let g=e[1];if(typeof g!="string"||!(g in kr)||g==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);p=kr[g],s++}else p=Wt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);f=e[2],s++}r=Qn(p,f)}else r=kr[l];let u=[];for(;s<e.length;s++){let p=i.parse(e[s],s,Wt);if(!p)return null;u.push(p)}return new io(r,u)}evaluate(e){for(let i=0;i<this.args.length;i++){let r=this.args[i].evaluate(e);if(!al(this.type,xn(r)))return r;if(i===this.args.length-1)throw new an(`The expression ${JSON.stringify(this.args[i].serialize())} evaluated to ${sn(xn(r))} but was expected to be of type ${sn(this.type)}.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){let e=this.type,i=[e.kind];if(e.kind==="array"){let r=e.itemType;if(r.kind==="string"||r.kind==="number"||r.kind==="boolean"){i.push(r.kind);let s=e.N;(typeof s=="number"||this.args.length>1)&&i.push(s)}}return i.concat(this.args.map(r=>r.serialize()))}}class _c{constructor(e){this.type=Ko,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=e[1];if(!Array.isArray(r)&&typeof r=="object")return i.error("First argument must be an image or text section.");let s=[],l=!1;for(let u=1;u<=e.length-1;++u){let p=e[u];if(l&&typeof p=="object"&&!Array.isArray(p)){l=!1;let f=null;if(p["font-scale"]&&(f=i.parseObjectValue(p["font-scale"],u,"font-scale",at),!f))return null;let g=null;if(p["text-font"]&&(g=i.parseObjectValue(p["text-font"],u,"text-font",Qn(ei)),!g))return null;let x=null;if(p["text-color"]&&(x=i.parseObjectValue(p["text-color"],u,"text-color",on),!x))return null;let b=s.at(-1);b.scale=f,b.font=g,b.textColor=x}else{let f=i.parse(e[u],u,Wt);if(!f)return null;let g=f.type.kind;if(g!=="string"&&g!=="value"&&g!=="null"&&g!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");l=!0,s.push({content:f,scale:null,font:null,textColor:null})}}return new _c(s)}evaluate(e){return new Un(this.sections.map(i=>{let r=i.content.evaluate(e);return wu(xn(r),sl)?new va("",r,null,null,null):new va(Tr(r),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null)}))}eachChild(e){for(let i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor)}outputDefined(){return!1}serialize(){let e=["format"];for(let i of this.sections){e.push(i.content.serialize());let r={};i.scale&&(r["font-scale"]=i.scale.serialize()),i.font&&(r["text-font"]=i.font.serialize()),i.textColor&&(r["text-color"]=i.textColor.serialize()),e.push(r)}return e}}
1class gc{constructor(e,i,r,s){this._imageWarnHistory={},this.type=sl,this.namePrimary=e,this.nameSecondary=i,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),s&&(this.paramsSecondary=s.params,this.iconsetIdSecondary=s.iconset?s.iconset.id:void 0)}static parse(e,i){if(e.length<2)return i.error("Expected two or more arguments.");let r=1,s=[];function l(){if(r<e.length){let p=i.parse(e[r],r++,ei);return p?(s.push({image:p,options:{}}),!0):(i.error(s.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function u(){if(r<e.length){let f=e[r];if((p=f)===null||typeof p!="object"||Array.isArray(p))return!0;let g=f.params,x=f.iconset,b=i.concat(r);if(!g&&!x)return r++,!0;if(g){if(typeof g!="object"||g.constructor!==Object)return b.error('Image options "params" should be an object'),!1;let w={},S=b.concat(void 0,"params");for(let I in g){if(!I)return S.error("Image parameter name should be non-empty"),!1;let M=S.concat(void 0,I).parse(g[I],void 0,on,void 0,{typeAnnotation:"coerce"});if(!M)return!1;w[I]=M}s.at(-1).options.params=w}if(x){if(typeof x!="object"||x.constructor!==Object)return b.error('Image options "iconset" should be an object'),!1;if(!x.id)return b.error('Image options "iconset" should have an "id" property'),!1;s.at(-1).options.iconset=x}return r++,!0}var p;return!0}for(let p=0;p<2;p++)if(!l()||!u())return;return new gc(s[0].image,s[1]?s[1].image:void 0,s[0].options,s[1]?s[1].options:void 0)}evaluateParams(e,i){let r={};if(i){for(let s in i)if(i[s])try{r[s]=i[s].evaluate(e)}catch{continue}if(Object.keys(r).length!==0)return{params:r}}}evaluate(e){let i={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},r=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,s=dr.build(i,r,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(s&&e.availableImages){let l=s.getPrimary().id;if(s.available=e.availableImages.some(u=>br.isEqual(u,l)),s.available){let u=s.getSecondary()?s.getSecondary().id:null;u&&(s.available=e.availableImages.some(p=>br.isEqual(p,u)))}}return s}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(let i in this.paramsPrimary)this.paramsPrimary[i]&&e(this.paramsPrimary[i]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(let i in this.paramsSecondary)this.paramsSecondary[i]&&e(this.paramsSecondary[i])}outputDefined(){return!1}serializeOptions(e,i){let r={};if(i&&(r.iconset={id:i}),e){r.params={};for(let s in e)e[s]&&(r.params[s]=e[s].serialize())}return Object.keys(r).length>0?r:void 0}serialize(){let e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){let i=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);i&&e.push(i)}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){let i=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);i&&e.push(i)}return e}}function Su(n){return Xh(n)?"string":yc(n)?"number":Yh(n)?"boolean":Array.isArray(n)?"array":n===null?"null":Wh(n)?"object":typeof n}function Wh(n){return n!=null&&!Array.isArray(n)&&typeof n!="function"&&!(n instanceof String||n instanceof Number||n instanceof Boolean)&&typeof n=="object"}function Xh(n){return typeof n=="string"||n instanceof String}function yc(n){return typeof n=="number"||n instanceof Number}function Yh(n){return typeof n=="boolean"||n instanceof Boolean}let Eu={"to-boolean":oi,"to-color":on,"to-number":at,"to-string":ei};class Sr{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=e[0],s=[],l=ya;if(r==="to-array"){if(!Array.isArray(e[1]))return null;let u=e[1].length;if(i.expectedType){if(i.expectedType.kind!=="array")return i.error(`Expected ${i.expectedType.kind} but found array.`);l=Qn(i.expectedType.itemType,u)}else{if(!(u>0&&cl(e[1][0])))return null;l=Qn(xn(e[1][0]),u)}for(let p=0;p<u;p++){let f=e[1][p],g;if(Array.isArray(f))g=i.parse(f,void 0,l.itemType);else{let x=Su(f);if(x!==l.itemType.kind)return i.error(`Expected ${l.itemType.kind} but found ${x}.`);g=i.registry.literal.parse(["literal",f===void 0?null:f],i)}if(!g)return null;s.push(g)}}else{if((r==="to-boolean"||r==="to-string")&&e.length!==2)return i.error("Expected one argument.");l=Eu[r];for(let u=1;u<e.length;u++){let p=i.parse(e[u],u,Wt);if(!p)return null;s.push(p)}}return new Sr(l,s)}
1evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let i,r;for(let s of this.args){if(i=s.evaluate(e),r=null,i instanceof Ht)return i;if(typeof i=="string"){let l=e.parseColor(i);if(l)return l}else if(Array.isArray(i)&&(r=i.length<3||i.length>4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:Tu(i[0],i[1],i[2],i[3]),!r))return new Ht(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new an(r||`Could not parse color from value '${typeof i=="string"?i:String(JSON.stringify(i))}'`)}if(this.type.kind==="number"){let i=null;for(let r of this.args){if(i=r.evaluate(e),i===null)return 0;let s=Number(i);if(!isNaN(s))return s}throw new an(`Could not convert ${JSON.stringify(i)} to number.`)}return this.type.kind==="formatted"?Un.fromString(Tr(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?dr.build(Tr(this.args[0].evaluate(e))):this.type.kind==="array"?this.args.map(i=>i.evaluate(e)):Tr(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new _c([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new gc(this.args[0]).serialize();let e=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}let cf=["Unknown","Point","LineString","Polygon"];class no{constructor(e,i,r){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=i,this.iconImageUseTheme=r}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?cf[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||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){let e=this.featureDistanceData.center,i=this.featureDistanceData.scale,{x:r,y:s}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*i-e[0])+this.featureDistanceData.bearing[1]*(s*i-e[1])}return 0}parseColor(e){let i=this._parseColorCache[e];return i||(i=this._parseColorCache[e]=Ht.parse(e)),i}getConfig(e){return this.options?this.options.get(e):null}}class pr{constructor(e,i,r,s,l){this.name=e,this.type=i,this._evaluate=r,this.args=s,this._overloadIndex=l}evaluate(e){if(!this._evaluate){let i=pr.definitions[this.name];this._evaluate=Array.isArray(i)?i[2]:i.overloads[this._overloadIndex][1]}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,i){let r=e[0],s=pr.definitions[r];if(!s)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let l=Array.isArray(s)?s[0]:s.type,u=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,p=[],f=null,g=-1;for(let[x,b]of u){if(Array.isArray(x)&&x.length!==e.length-1)continue;p.push(x),g++,f===null?f=new Ec(i.registry,i.path,null,i.scope,[],i._scope,i.options,i.iconImageUseTheme):f.errors.length=0;let w=[],S=!1;for(let I=1;I<e.length;I++){let M=e[I],C=Array.isArray(x)?x[I-1]:x.type,R=f.parse(M,1+w.length,C);if(!R){S=!0;break}w.push(R)}if(!S)if(Array.isArray(x)&&x.length!==w.length)f.error(`Expected ${x.length} arguments, but found ${w.length} instead.`);else{for(let I=0;I<w.length;I++){let M=Array.isArray(x)?x[I]:x.type;f.checkSubtype(M,w[I].type,I+1)}if(f.errors.length===0)return new pr(r,l,b,w,g)}}if(p.length===1)i.errors.push(...f.errors);else{let x=(p.length?p:u.map(([w])=>w)).map(uf).join(" | "),b=[];for(let w=1;w<e.length;w++){let S=i.parse(e[w],1+b.length);if(!S)return null;b.push(sn(S.type))}i.error(`Expected arguments of type ${x}, but found (${b.join(", ")}) instead.`)}return null}static register(e,i){pr.definitions=i;for(let r in i)e[r]=pr}}function uf(n){return Array.isArray(n)?`(${n.map(sn).join(", ")})`:`(${sn(n.type)}...)`}class Is{constructor(e,i,r){this.type=vu,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(e.length!==2)return i.error("Expected one argument."),null;let r=e[1];if(typeof r!="object"||Array.isArray(r))return i.error("Collator options argument must be an object."),null;let s=r["case-sensitive"]===void 0?i.parse(!1,1,oi):i.parseObjectValue(r["case-sensitive"],1,"case-sensitive",oi);if(!s)return null;let l=r["diacritic-sensitive"]===void 0?i.parse(!1,1,oi):i.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",oi);if(!l)return null;let u=null;return r.locale&&(u=i.parseObjectValue(r.locale,1,"locale",ei),!u)?null:new Is(s,l,u)}evaluate(e){return new ll(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){let e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function xc(n,e,i=0,r=n.length-1,s=O_){for(;r>i;){if(r-i>600){let f=r-i+1,g=e-i+1,x=Math.log(f),b=.5*Math.exp(2*x/3),w=.5*Math.sqrt(x*b*(f-b)/f)*(g-f/2<0?-1:1);xc(n,e,Math.max(i,Math.floor(e-g*b/f+w)),Math.min(r,Math.floor(e+(f-g)*b/f+w)),s)}let l=n[e],u=i,p=r;for(vc(n,i,e),s(n[r],l)>0&&vc(n,i,r);u<p;){for(vc(n,u,p),u++,p--;s(n[u],l)<0;)u++;for(;s(n[p],l)>0;)p--}s(n[i],l)===0?vc(n,i,p):(p++,vc(n,p,r)),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function vc(n,e,i){let r=n[e];n[e]=n[i],n[i]=r}function O_(n,e){return n<e?-1:n>e?1:0}function F_(n){let e=0;for(let i,r,s=0,l=n.length,u=l-1;s<l;u=s++)i=n[s],r=n[u],e+=(r.x-i.x)*(i.y+r.y);return e}function ul(n,e){n[0]=Math.min(n[0],e[0]),n[1]=Math.min(n[1],e[1]),n[2]=Math.max(n[2],e[0]),n[3]=Math.max(n[3],e[1])}function ba(n,e){return!(n[0]<=e[0]||n[2]>=e[2]||n[1]<=e[1]||n[3]>=e[3])}function B_(n,e,i){let r=n[0]-e[0],s=n[1]-e[1],l=n[0]-i[0],u=n[1]-i[1];return r*u-l*s===0&&r*l<=0&&s*u<=0}function Iu(n,e,i){return e[1]>n[1]!=i[1]>n[1]&&n[0]<(i[0]-e[0])*(n[1]-e[1])/(i[1]-e[1])+e[0]}function hl(n,e,i=!1){let r=!1;for(let s=0,l=e.length;s<l;s++){let u=e[s];for(let p=0,f=u.length,g=f-1;p<f;g=p++){let x=u[g],b=u[p];if(B_(n,x,b))return i;Iu(n,x,b)&&(r=!r)}}return r}function hf(n,e,i,r){let s=r[0]-i[0],l=r[1]-i[1],u=(n[0]-i[0])*l-s*(n[1]-i[1]),p=(e[0]-i[0])*l-s*(e[1]-i[1]);return u>0&&p<0||u<0&&p>0}function Au(n,e,i,r){return(s=[r[0]-i[0],r[1]-i[1]])[0]*(l=[e[0]-n[0],e[1]-n[1]])[1]-s[1]*l[0]!==0&&!(!hf(n,e,i,r)||!hf(i,r,n,e));var s,l}function Jh(n){let e=new ke(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new ke(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(let r of n[0])e.x>r.x&&(e.x=r.x),e.y>r.y&&(e.y=r.y),i.x<r.x&&(i.x=r.x),i.y<r.y&&(i.y=r.y);return{min:e,max:i}}let As=8192;function k_(n,e){let i=(180+n[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(i*s*As),Math.round(r*s*As)]}function N_(n,e){for(let i=0;i<e.length;i++)if(hl(n,e[i]))return!0;return!1}function df(n,e,i){for(let r of i)for(let s=0,l=r.length,u=l-1;s<l;u=s++)if(Au(n,e,r[u],r[s]))return!0;return!1}function wa(n,e){for(let i=0;i<n.length;++i)if(!hl(n[i],e))return!1;for(let i=0;i<n.length-1;++i)if(df(n[i],n[i+1],e))return!1;return!0}function U_(n,e){for(let i=0;i<e.length;i++)if(wa(n,e[i]))return!0;return!1}function Mu(n,e,i){let r=[];for(let s=0;s<n.length;s++){let l=[];for(let u=0;u<n[s].length;u++){let p=k_(n[s][u],i);ul(e,p),l.push(p)}r.push(l)}return r}function Cu(n,e,i){let r=[];for(let s=0;s<n.length;s++){let l=Mu(n[s],e,i);r.push(l)}return r}function pf(n,e,i,r){if(n[0]<i[0]||n[0]>i[2]){let s=.5*r,l=n[0]-i[0]>s?-r:i[0]-n[0]>s?r:0;l===0&&(l=n[0]-i[2]>s?-r:i[2]-n[0]>s?r:0),n[0]+=l}ul(e,n)}function ff(n,e,i,r){let s=Math.pow(2,r.z)*As,l=[r.x*As,r.y*As],u=[];
1if(!n)return u;for(let p of n)for(let f of p){let g=[f.x+l[0],f.y+l[1]];pf(g,e,i,s),u.push(g)}return u}function mf(n,e,i,r){let s=Math.pow(2,r.z)*As,l=[r.x*As,r.y*As],u=[];if(!n)return u;for(let f of n){let g=[];for(let x of f){let b=[x.x+l[0],x.y+l[1]];ul(e,b),g.push(b)}u.push(g)}if(e[2]-e[0]<=s/2){(p=e)[0]=p[1]=1/0,p[2]=p[3]=-1/0;for(let f of u)for(let g of f)pf(g,e,i,s)}var p;return u}class Ta{constructor(e,i){this.type=oi,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(cl(e[1])){let r=e[1];if(r.type==="FeatureCollection")for(let s=0;s<r.features.length;++s){let l=r.features[s].geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new Ta(r,r.features[s].geometry)}else if(r.type==="Feature"){let s=r.geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new Ta(r,r.geometry)}else if(r.type==="Polygon"||r.type==="MultiPolygon")return new Ta(r,r)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(i,r){let s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(!u)return!1;if(r.type==="Polygon"){let p=Mu(r.coordinates,l,u),f=ff(i.geometry(),s,l,u);if(!ba(s,l))return!1;for(let g of f)if(!hl(g,p))return!1}if(r.type==="MultiPolygon"){let p=Cu(r.coordinates,l,u),f=ff(i.geometry(),s,l,u);if(!ba(s,l))return!1;for(let g of f)if(!N_(g,p))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(i,r){let s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(!u)return!1;if(r.type==="Polygon"){let p=Mu(r.coordinates,l,u),f=mf(i.geometry(),s,l,u);if(!ba(s,l))return!1;for(let g of f)if(!wa(g,p))return!1}if(r.type==="MultiPolygon"){let p=Cu(r.coordinates,l,u),f=mf(i.geometry(),s,l,u);if(!ba(s,l))return!1;for(let g of f)if(!U_(g,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}let Sa={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},Ms=1/298.257223563,_t=Ms*(2-Ms),nt=Math.PI/180;class Ea{static fromTile(e,i,r){let s=Math.PI*(1-2*(e+.5)/Math.pow(2,i)),l=Math.atan(.5*(Math.exp(s)-Math.exp(-s)))/nt;return new Ea(l,r)}static get units(){return Sa}constructor(e,i){if(e===void 0)throw new Error("No latitude given.");if(i&&!Sa[i])throw new Error(`Unknown unit ${i}. Use one of: ${Object.keys(Sa).join(", ")}`);let r=6378.137*nt*(i?Sa[i]:1),s=Math.cos(e*nt),l=1/(1-_t*(1-s*s)),u=Math.sqrt(l);this.kx=r*u*s,this.ky=r*u*l*(1-_t)}distance(e,i){let r=Er(e[0]-i[0])*this.kx,s=(e[1]-i[1])*this.ky;return Math.sqrt(r*r+s*s)}bearing(e,i){let r=Er(i[0]-e[0])*this.kx;return Math.atan2(r,(i[1]-e[1])*this.ky)/nt}destination(e,i,r){let s=r*nt;return this.offset(e,Math.sin(s)*i,Math.cos(s)*i)}offset(e,i,r){return[e[0]+i/this.kx,e[1]+r/this.ky]}lineDistance(e){let i=0;for(let r=0;r<e.length-1;r++)i+=this.distance(e[r],e[r+1]);return i}area(e){let i=0;for(let r=0;r<e.length;r++){let s=e[r];for(let l=0,u=s.length,p=u-1;l<u;p=l++)i+=Er(s[l][0]-s[p][0])*(s[l][1]+s[p][1])*(r?-1:1)}return Math.abs(i)/2*this.kx*this.ky}along(e,i){let r=0;if(i<=0)return e[0];for(let s=0;s<e.length-1;s++){let l=e[s],u=e[s+1],p=this.distance(l,u);if(r+=p,r>i)return bc(l,u,(i-(r-p))/p)}return e[e.length-1]}pointToSegmentDistance(e,i,r){let[s,l]=i,u=Er(r[0]-s)*this.kx,p=(r[1]-l)*this.ky;if(u!==0||p!==0){let f=(Er(e[0]-s)*this.kx*u+(e[1]-l)*this.ky*p)/(u*u+p*p);f>1?(s=r[0],l=r[1]):f>0&&(s+=u/this.kx*f,l+=p/this.ky*f)}return u=Er(e[0]-s)*this.kx,p=(e[1]-l)*this.ky,Math.sqrt(u*u+p*p)}pointOnLine(e,i){let r=1/0,s=e[0][0],l=e[0][1],u=0,p=0;for(let f=0;f<e.length-1;f++){let g=e[f][0],x=e[f][1],b=Er(e[f+1][0]-g)*this.kx,w=(e[f+1][1]-x)*this.ky,S=0;b===0&&w===0||(S=(Er(i[0]-g)*this.kx*b+(i[1]-x)*this.ky*w)/(b*b+w*w),S>1?(g=e[f+1][0],x=e[f+1][1]):S>0&&(g+=b/this.kx*S,x+=w/this.ky*S)),b=Er(i[0]-g)*this.kx,w=(i[1]-x)*this.ky;let I=b*b+w*w;I<r&&(r=I,s=g,l=x,u=f,p=S)}return{point:[s,l],index:u,t:Math.max(0,Math.min(1,p))}}lineSlice(e,i,r){let s=this.pointOnLine(r,e),l=this.pointOnLine(r,i);if(s.index>l.index||s.index===l.index&&s.t>l.t){let g=s;s=l,l=g}let u=[s.point],p=s.index+1,f=l.index;!yt(r[p],u[0])&&p<=f&&u.push(r[p]);for(let g=p+1;g<=f;g++)u.push(r[g]);return yt(r[f],l.point)||u.push(l.point),u}lineSliceAlong(e,i,r){let s=0,l=[];for(let u=0;u<r.length-1;u++){let p=r[u],f=r[u+1],g=this.distance(p,f);if(s+=g,s>e&&l.length===0&&l.push(bc(p,f,(e-(s-g))/g)),s>=i)return l.push(bc(p,f,(i-(s-g))/g)),l;s>e&&l.push(f)}return l}bufferPoint(e,i){let r=i/this.ky,s=i/this.kx;return[e[0]-s,e[1]-r,e[0]+s,e[1]+r]}bufferBBox(e,i){let r=i/this.ky,s=i/this.kx;return[e[0]-s,e[1]-r,e[2]+s,e[3]+r]}insideBBox(e,i){return Er(e[0]-i[0])>=0&&Er(e[0]-i[2])<=0&&e[1]>=i[1]&&e[1]<=i[3]}}function yt(n,e){return n[0]===e[0]&&n[1]===e[1]}function bc(n,e,i){let r=Er(e[0]-n[0]);return[n[0]+r*i,n[1]+(e[1]-n[1])*i]}function Er(n){for(;n<-180;)n+=360;for(;n>180;)n-=360;return n}class pt{constructor(e=[],i=(r,s)=>r<s?-1:r>s?1:0){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;let e=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){let{data:i,compare:r}=this,s=i[e];for(;e>0;){let l=e-1>>1,u=i[l];if(r(s,u)>=0)break;i[e]=u,e=l}i[e]=s}_down(e){let{data:i,compare:r}=this,s=this.length>>1,l=i[e];for(;e<s;){let u=1+(e<<1),p=u+1;if(p<this.length&&r(i[p],i[u])<0&&(u=p),r(i[u],l)>=0)break;i[e]=i[u],e=u}i[e]=l}}var Xe=8192;function Pu(n,e){return e.dist-n.dist}function Kh(n){let e=[1/0,1/0,-1/0,-1/0];if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==n[i])return!1;return!0}function wc(n){return n[1]-n[0]+1}function ro(n,e){let i=n[1]>=n[0]&&n[1]<e;return i||console.warn("Distance Expression: Index is out of range"),i}function Qh(n,e){if(n[0]>
1n[1])return[null,null];let i=wc(n);if(e){if(i===2)return[n,null];let r=Math.floor(i/2);return[[n[0],n[0]+r],[n[0]+r,n[1]]]}{if(i===1)return[n,null];let r=Math.floor(i/2)-1;return[[n[0],n[0]+r],[n[0]+r+1,n[1]]]}}function Qo(n,e){let i=[1/0,1/0,-1/0,-1/0];if(!ro(e,n.length))return i;for(let r=e[0];r<=e[1];++r)ul(i,n[r]);return i}function Ro(n){let e=[1/0,1/0,-1/0,-1/0];for(let i=0;i<n.length;++i)for(let r=0;r<n[i].length;++r)ul(e,n[i][r]);return e}function Cs(n,e,i){if(Kh(n)||Kh(e))return NaN;let r=0,s=0;return n[2]<e[0]&&(r=e[0]-n[2]),n[0]>e[2]&&(r=n[0]-e[2]),n[1]>e[3]&&(s=n[1]-e[3]),n[3]<e[1]&&(s=e[1]-n[3]),i.distance([0,0],[r,s])}function Ps(n){return 360*n-180}function _f(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function Tc(n,e,i=8192){let r=Math.pow(2,e.z),s=(n.y/i+e.y)/r;return[Ps((n.x/i+e.x)/r),_f(s)]}function V_(n,e){let i=[];for(let r=0;r<n.length;++r)i.push(Tc(n[r],e));return i}function gf(n,e,i){let r=i.pointOnLine(e,n).point;return i.distance(n,r)}function yf(n,e,i,r,s){let l=i.slice(r[0],r[1]+1),u=1/0;for(let p=e[0];p<=e[1];++p)if((u=Math.min(u,gf(n[p],l,s)))===0)return 0;return u}function dl(n,e,i,r,s){let l=Math.min(s.pointToSegmentDistance(n,i,r),s.pointToSegmentDistance(e,i,r)),u=Math.min(s.pointToSegmentDistance(i,n,e),s.pointToSegmentDistance(r,n,e));return Math.min(l,u)}function xf(n,e,i,r,s){if(!ro(e,n.length)||!ro(r,i.length))return NaN;let l=1/0;for(let u=e[0];u<e[1];++u)for(let p=r[0];p<r[1];++p){if(Au(n[u],n[u+1],i[p],i[p+1]))return 0;l=Math.min(l,dl(n[u],n[u+1],i[p],i[p+1],s))}return l}function Ia(n,e,i,r,s){if(!ro(e,n.length)||!ro(r,i.length))return NaN;let l=1/0;for(let u=e[0];u<=e[1];++u)for(let p=r[0];p<=r[1];++p)if((l=Math.min(l,s.distance(n[u],i[p])))===0)return l;return l}function j_(n,e,i){if(hl(n,e,!0))return 0;let r=1/0;for(let s of e){let l=s.length;if(l<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(s[0]!==s[l-1]&&(r=Math.min(r,i.pointToSegmentDistance(n,s[l-1],s[0])))===0||(r=Math.min(r,gf(n,s,i)))===0)return r}return r}function G_(n,e,i,r){if(!ro(e,n.length))return NaN;for(let l=e[0];l<=e[1];++l)if(hl(n[l],i,!0))return 0;let s=1/0;for(let l=e[0];l<e[1];++l)for(let u of i)for(let p=0,f=u.length,g=f-1;p<f;g=p++){if(Au(n[l],n[l+1],u[g],u[p]))return 0;s=Math.min(s,dl(n[l],n[l+1],u[g],u[p],r))}return s}function vf(n,e){for(let i of n)for(let r=0;r<=i.length-1;++r)if(hl(i[r],e,!0))return!0;return!1}function H_(n,e,i,r=1/0){let s=Ro(n),l=Ro(e);if(r!==1/0&&Cs(s,l,i)>=r)return r;if(ba(s,l)){if(vf(n,e))return 0}else if(vf(e,n))return 0;let u=r;for(let p of n)for(let f=0,g=p.length,x=g-1;f<g;x=f++)for(let b of e)for(let w=0,S=b.length,I=S-1;w<S;I=w++){if(Au(p[x],p[f],b[I],b[w]))return 0;u=Math.min(u,dl(p[x],p[f],b[I],b[w],i))}return u}function pl(n,e,i,r,s,l,u){if(l===null||u===null)return;let p=Cs(Qo(r,l),Qo(s,u),i);p<e&&n.push({dist:p,range1:l,range2:u})}function $_(n,e,i,r,s=1/0){let l=Math.min(r.distance(n[0],i[0][0]),s);if(l===0)return l;let u=new pt([{dist:0,range1:[0,n.length-1],range2:[0,0]}],Pu),p=e?50:100,f=Ro(i);for(;u.length;){let g=u.pop();if(g.dist>=l)continue;let x=g.range1;if(wc(x)<=p){if(!ro(x,n.length))return NaN;if(e){let b=G_(n,x,i,r);if((l=Math.min(l,b))===0)return l}else for(let b=x[0];b<=x[1];++b){let w=j_(n[b],i,r);if((l=Math.min(l,w))===0)return l}}else{let b=Qh(x,e);if(b[0]!==null){let w=Cs(Qo(n,b[0]),f,r);w<l&&u.push({dist:w,range1:b[0],range2:[0,0]})}if(b[1]!==null){let w=Cs(Qo(n,b[1]),f,r);w<l&&u.push({dist:w,range1:b[1],range2:[0,0]})}}}return l}function Du(n,e,i,r,s,l=1/0){let u=Math.min(l,s.distance(n[0],i[0]));if(u===0)return u;let p=new pt([{dist:0,range1:[0,n.length-1],range2:[0,i.length-1]}],Pu),f=e?50:100,g=r?50:100;for(;p.length;){let x=p.pop();if(x.dist>=u)continue;let b=x.range1,w=x.range2;if(wc(b)<=f&&wc(w)<=g){if(!ro(b,n.length)||!ro(w,i.length))return NaN;if(e&&r?u=Math.min(u,xf(n,b,i,w,s)):e||r?e&&!r?u=Math.min(u,yf(i,w,n,b,s)):!e&&r&&(u=Math.min(u,yf(n,b,i,w,s))):u=Math.min(u,Ia(n,b,i,w,s)),u===0)return u}else{let S=Qh(b,e),I=Qh(w,r);pl(p,u,s,n,i,S[0],I[0]),pl(p,u,s,n,i,S[0],I[1]),pl(p,u,s,n,i,S[1],I[0]),pl(p,u,s,n,i,S[1],I[1])}}return u}function ed(n,e,i,r,s=1/0){let l=s,u=Qo(n,[0,n.length-1]);for(let p of i)if(!(l!==1/0&&Cs(u,Qo(p,[0,p.length-1]),r)>=l)&&(l=Math.min(l,Du(n,e,p,!0,r,l)),l===0))return l;return l}function Ru(n,e,i,r,s=1/0){let l=s,u=Qo(n,[0,n.length-1]);for(let p of i){if(l!==1/0&&Cs(u,Ro(p),r)>=l)continue;let f=$_(n,e,p,r,l);if(isNaN(f))return f;if((l=Math.min(l,f))===0)return l}return l}function Lu(n){return n==="Point"||n==="MultiPoint"||n==="LineString"||n==="MultiLineString"||n==="Polygon"||n==="MultiPolygon"}class Aa{constructor(e,i){this.type=at,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(cl(e[1])){let r=e[1];if(r.type==="FeatureCollection"){for(let s=0;s<r.features.length;++s)if(Lu(r.features[s].geometry.type))return new Aa(r,r.features[s].geometry)}else if(r.type==="Feature"){if(Lu(r.geometry.type))return new Aa(r,r.geometry)}else if(Lu(r.type))return new Aa(r,r)}return i.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){let i=e.geometry(),r=e.canonicalID();if(i!=null&&r!=null){if(e.geometryType()==="Point")return function(s,l,u){let p=[];for(let g of s)for(let x of g)p.push(Tc(x,l));let f=new Ea(p[0][1],"meters");return u.type==="Point"||u.type==="MultiPoint"||u.type==="LineString"?Du(p,!1,u.type==="Point"?[u.coordinates]:u.coordinates,u.type==="LineString",f):u.type==="MultiLineString"?ed(p,!1,u.coordinates,f):u.type==="Polygon"||u.type==="MultiPolygon"?Ru(p,!1,u.type==="Polygon"?[u.coordinates]:u.coordinates,f):null}(i,r,this.geometries);if(e.geometryType()==="LineString")return function(s,l,u){let p=[];for(let g of s){let x=[];for(let b of g)x.push(Tc(b,l));p.push(x)}let f=new Ea(p[0][0][1],"meters");if(u.type==="Point"||u.type==="MultiPoint"||u.type==="LineString")return ed(u.type==="Point"?[u.coordinates]:u.coordinates,u.type==="LineString",p,f);if(u.type==="MultiLineString"){let g=1/0;for(let x=0;x<u.coordinates.length;x++){let b=ed(u.coordinates[x],!0,p,f,g);if(isNaN(b))return b;if((g=Math.min(g,b))===0)return g}return g}if(u.type==="Polygon"||u.type==="MultiPolygon"){let g=1/0;for(let x=0;x<p.length;x++){let b=Ru(p[x],!0,u.type==="Polygon"?[u.coordinates]:u.coordinates,f,g);if(isNaN(b))return b;if((g=Math.min(g,b))===0)return g}return g}return null}(i,r,this.geometries);if(e.geometryType()==="Polygon")return function(s,l,u){let p=[];for(let g of function(x){let b=x.length;if(b<=1)return[x];let w=[],S,I;for(let M=0;M<b;M++){let C=F_(x[M]);C!==0&&(x[M].area=Math.abs(C),I===void 0&&(I=C<0),I===C<0?(S&&w.push(S),S=[x[M]]):S.push(x[M]))}return S&&w.push(S),w}(s)){let x=[];for(let b=0;b<g.length;++b)x.push(V_(g[b],l));p.push(x)}let f=new Ea(p[0][0][0][1],"meters");if(u.type==="Point"||u.type==="MultiPoint"||u.type==="LineString")return Ru(u.type==="Point"?[u.coordinates]:u.coordinates,u.type==="LineString",p,f);if(u.type==="MultiLineString"){let g=1/0;for(let x=0;x<u.coordinates.length;x++){let b=Ru(u.coordinates[x],!0,p,f,g);if(isNaN(b))return b;if((g=Math.min(g,b))===0)return g}return g}return u.type==="Polygon"||u.type==="MultiPolygon"?function(g,x,b){let w=1/0;for(let S of g)for(let I of x){let M=H_(S,I,b,w);if(isNaN(M))return M;if((w=Math.min(w,M))===0)return w}return w}(u.type==="Polygon"?[u.coordinates]:u.coordinates,p,f):null}(i,r,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requires valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function Ma(n){if(n instanceof pr&&(n.name==="get"&&n.args.length===1||n.name==="feature-state"||n.name==="has"&&n.args.length===1||n.name==="properties"||n.name==="geometry-type"||n.name==="id"||n.name.startsWith("filter-"))||n instanceof Ta||n instanceof Aa)return!1;if(n instanceof ml)return n.featureConstant;let e=!0;return n.eachChild(i=>{e&&!Ma(i)&&(e=!1)}),e}function fl(n){if(n instanceof pr&&n.name==="feature-state")return!1;let e=!0;return n.eachChild(i=>{e&&!fl(i)&&(e=!1)}),e}
1function rr(n,e){if(n instanceof pr&&e.includes(n.name))return!1;let i=!0;return n.eachChild(r=>{i&&!rr(r,e)&&(i=!1)}),i}function bf(n,e,i){return[n,e,i].filter(Boolean).join("�")}function td(n,e){switch(n){case"string":return Tr(e);case"number":return+e;case"boolean":return!!e;case"color":return Ht.parse(e);case"formatted":return Un.fromString(Tr(e));case"resolvedImage":return dr.build(Tr(e))}return e}function zu(n,e,i,r){return r!==void 0&&(n=r*Math.round(n/r)),e!==void 0&&n<e&&(n=e),i!==void 0&&n>i&&(n=i),n}class ml{constructor(e,i,r,s=!1){this.type=e,this.key=i,this.scope=r,this.featureConstant=s}static parse(e,i){let r=i.expectedType;if(r==null&&(r=Wt),e.length<2||e.length>3)return i.error("Invalid number of arguments for 'config' expression.");let s=i.parse(e[1],1);if(!(s instanceof bo))return i.error("Key name of 'config' expression must be a string literal.");let l,u=!0,p=Tr(s.value);if(e.length>=3){let f=i.parse(e[2],2);if(!(f instanceof bo))return i.error("Scope of 'config' expression must be a string literal.");l=Tr(f.value)}if(i.options){let f=bf(p,l,i._scope),g=i.options.get(f);g&&(u=Ma(g.value||g.default))}return new ml(r,p,l,u)}evaluate(e){let i=bf(this.key,this.scope,e.scope),r=e.getConfig(i);if(!r)return null;let{type:s,value:l,values:u,minValue:p,maxValue:f,stepValue:g}=r,x=r.default.evaluate(e),b=x;if(l){let w=e.scope;e.scope=(w||"").split("�").slice(1).join("�"),b=l.evaluate(e),e.scope=w}return s&&(b=td(s,b)),b===void 0||p===void 0&&f===void 0&&g===void 0||(typeof b=="number"?b=zu(b,p,f,g):Array.isArray(b)&&(b=b.map(w=>typeof w=="number"?zu(w,p,f,g):w))),l!==void 0&&b!==void 0&&u&&!u.includes(b)&&(b=x,s&&(b=td(s,b))),(s&&s!==this.type||b!==void 0&&!wu(xn(b),this.type))&&(b=td(this.type.kind,b)),b}eachChild(){}outputDefined(){return!1}serialize(){let e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Sc{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(e.length!==2||typeof e[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");let r=e[1];return i.scope.has(r)?new Sc(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Ec{constructor(e,i=[],r,s=new Zh,l=[],u,p,f){this.registry=e,this.path=i,this.scope=s,this.errors=l,this.expectedType=r,this._scope=u,this.options=p,this.iconImageUseTheme=f}get key(){if(this._key===void 0){let e=this.path,i="";for(let r=0;r<e.length;r++){let s=e[r];i+=typeof s=="string"?`['${s}']`:`[${s}]`}this._key=i}return this._key}parse(e,i,r,s,l={}){return i||r?this.concat(i,null,r,s)._parse(e,l):this._parse(e,l)}parseObjectValue(e,i,r,s,l,u={}){return this.concat(i,r,s,l)._parse(e,u)}_parse(e,i){function r(s,l,u){return u==="assert"?new io(l,[s]):u==="coerce"?new Sr(l,[s]):s}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let s=typeof e[0]=="string"?this.registry[e[0]]:void 0;if(s){let l=s.parse(e,this);if(!l)return null;if(this.expectedType){let u=this.expectedType,p=l.type;if(u.kind!=="string"&&u.kind!=="number"&&u.kind!=="boolean"&&u.kind!=="object"&&u.kind!=="array"||p.kind!=="value")if(u.kind!=="color"&&u.kind!=="formatted"&&u.kind!=="resolvedImage"||p.kind!=="value"&&p.kind!=="string"){if(this.checkSubtype(u,p))return null}else l=r(l,u,i.typeAnnotation||"coerce");else l=r(l,u,i.typeAnnotation||"assert")}if(!(l instanceof bo)&&l.type.kind!=="resolvedImage"&&Nr(l)){let u=new no(this._scope,this.options,this.iconImageUseTheme);try{l=new bo(l.type,l.evaluate(u))}catch(p){return this.error(p.message),null}}return l}return Sr.parse(["to-array",e],this)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}
1concat(e,i,r,s){let l=typeof e=="number"?this.path.concat(e):this.path;l=typeof i=="string"?l.concat(i):l;let u=s?this.scope.concat(s):this.scope;return new Ec(this.registry,l,r||null,u,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...i){let r=`${this.key}${i.map(s=>`[${s}]`).join("")}`;this.errors.push(new vo(r,e))}checkSubtype(e,i,r){let s=al(e,i);return s&&this.error(s,...typeof r=="number"?[r]:[]),s}}function Nr(n){if(n instanceof Sc)return Nr(n.boundExpression);if(n instanceof pr&&n.name==="error"||n instanceof Is||n instanceof Ta||n instanceof Aa||n instanceof ml)return!1;let e=n instanceof Sr||n instanceof io,i=!0;return n.eachChild(r=>{i=e?i&&Nr(r):i&&r instanceof bo}),!!i&&Ma(n)&&rr(n,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function _l(n,e){let i=n.length-1,r,s,l=0,u=i,p=0;for(;l<=u;)if(p=Math.floor((l+u)/2),r=n[p],s=n[p+1],r<=e){if(p===i||e<s)return p;l=p+1}else{if(!(r>e))throw new an("Input is not a number.");u=p-1}return 0}class gl{constructor(e,i,r){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(let[s,l]of r)this.labels.push(s),this.outputs.push(l)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(e[1],1,at);if(!r)return null;let s=[],l=null;i.expectedType&&i.expectedType.kind!=="value"&&(l=i.expectedType);for(let u=1;u<e.length;u+=2){let p=u===1?-1/0:e[u],f=e[u+1],g=u,x=u+1;if(typeof p!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',g);if(s.length&&s.at(-1)[0]>=p)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',g);let b=i.parse(f,x,l);if(!b)return null;l=l||b.type,s.push([p,b])}return new gl(l,r,s)}evaluate(e){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(e);let s=this.input.evaluate(e);if(s<=i[0])return r[0].evaluate(e);let l=i.length;return s>=i[l-1]?r[l-1].evaluate(e):r[_l(i,s)].evaluate(e)}eachChild(e){e(this.input);for(let i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e=["step",this.input.serialize()];for(let i=0;i<this.labels.length;i++)i>0&&e.push(this.labels[i]),e.push(this.outputs[i].serialize());return e}}let id=.95047,nd=1.08883,rd=4/29,Ca=6/29,od=3*Ca*Ca,sd=Ca*Ca*Ca,wf=Math.PI/180,Tf=180/Math.PI;function Ou(n){return n>sd?Math.pow(n,1/3):n/od+rd}function Fu(n){return n>Ca?n*n*n:od*(n-rd)}function Bu(n){return 255*(n<=.0031308?12.92*n:1.055*Math.pow(n,1/2.4)-.055)}function ad(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Sf(n){let e=ad(n.r),i=ad(n.g),r=ad(n.b),s=Ou((.4124564*e+.3575761*i+.1804375*r)/id),l=Ou((.2126729*e+.7151522*i+.072175*r)/1);return{l:116*l-16,a:500*(s-l),b:200*(l-Ou((.0193339*e+.119192*i+.9503041*r)/nd)),alpha:n.a}}function Ic(n){let e=(n.l+16)/116,i=isNaN(n.a)?e:e+n.a/500,r=isNaN(n.b)?e:e-n.b/200;return e=1*Fu(e),i=id*Fu(i),r=nd*Fu(r),new Ht(Bu(3.2404542*i-1.5371385*e-.4985314*r),Bu(-.969266*i+1.8760108*e+.041556*r),Bu(.0556434*i-.2040259*e+1.0572252*r),n.alpha)}function Ac(n,e,i){let r=e-n;return n+i*(r>180||r<-180?r-360*Math.round(r/360):r)}let Ds={forward:Sf,reverse:Ic,interpolate:function(n,e,i){return{l:mt(n.l,e.l,i),a:mt(n.a,e.a,i),b:mt(n.b,e.b,i),alpha:mt(n.alpha,e.alpha,i)}}},yl={forward:function(n){let{l:e,a:i,b:r}=Sf(n),s=Math.atan2(r,i)*Tf;return{h:s<0?s+360:s,c:Math.sqrt(i*i+r*r),l:e,alpha:n.a}},reverse:function(n){let e=n.h*wf,i=n.c;return Ic({l:n.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:n.alpha})},interpolate:function(n,e,i){return{h:Ac(n.h,e.h,i),c:mt(n.c,e.c,i),l:mt(n.l,e.l,i),alpha:mt(n.alpha,e.alpha,i)}}};var ld=Object.freeze({__proto__:null,hcl:yl,lab:Ds});class Ir{constructor(e,i,r,s,l){this.type=e,this.operator=i,this.interpolation=r,this.input=s,this.labels=[],this.outputs=[];for(let[u,p]of l)this.labels.push(u),this.outputs.push(p)}
1static interpolationFactor(e,i,r,s){let l=0;if(e.name==="exponential")l=ku(i,e.base,r,s);else if(e.name==="linear")l=ku(i,1,r,s);else if(e.name==="cubic-bezier"){let u=e.controlPoints;l=new Qa(u[0],u[1],u[2],u[3]).solve(ku(i,1,r,s))}return l}static parse(e,i){let[r,s,l,...u]=e;if(!Array.isArray(s)||s.length===0)return i.error("Expected an interpolation type expression.",1);if(s[0]==="linear")s={name:"linear"};else if(s[0]==="exponential"){let g=s[1];if(typeof g!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:g}}else{if(s[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(s[0])}`,1,0);{let g=s.slice(1);if(g.length!==4||g.some(x=>typeof x!="number"||x<0||x>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:g}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(l=i.parse(l,2,at),!l)return null;let p=[],f=null;r==="interpolate-hcl"||r==="interpolate-lab"?f=on:i.expectedType&&i.expectedType.kind!=="value"&&(f=i.expectedType);for(let g=0;g<u.length;g+=2){let x=u[g],b=u[g+1],w=g+3,S=g+4;if(typeof x!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',w);if(p.length&&p.at(-1)[0]>=x)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',w);let I=i.parse(b,S,f);if(!I)return null;f=f||I.type,p.push([x,I])}return f.kind==="number"||f.kind==="color"||f.kind==="array"&&f.itemType.kind==="number"&&typeof f.N=="number"?new Ir(f,r,s,l,p):i.error(`Type ${sn(f)} is not interpolatable.`)}evaluate(e){let i=this.labels,r=this.outputs;if(i.length===1)return r[0].evaluate(e);let s=this.input.evaluate(e);if(s<=i[0])return r[0].evaluate(e);let l=i.length;if(s>=i[l-1])return r[l-1].evaluate(e);let u=_l(i,s),p=Ir.interpolationFactor(this.interpolation,s,i[u],i[u+1]),f=r[u].evaluate(e),g=r[u+1].evaluate(e);return this.operator==="interpolate"?xu[this.type.kind.toLowerCase()](f,g,p):this.operator==="interpolate-hcl"?yl.reverse(yl.interpolate(yl.forward(f),yl.forward(g),p)):Ds.reverse(Ds.interpolate(Ds.forward(f),Ds.forward(g),p))}eachChild(e){e(this.input);for(let i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];let i=[this.operator,e,this.input.serialize()];for(let r=0;r<this.labels.length;r++)i.push(this.labels[r],this.outputs[r].serialize());return i}}function ku(n,e,i,r){let s=r-i,l=n-i;return s===0?0:e===1?l/s:(Math.pow(e,l)-1)/(Math.pow(e,s)-1)}class Nu{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expectected at least one argument."),null;let r=null,s=i.expectedType;s&&s.kind!=="value"&&(r=s);let l=[];for(let p of e.slice(1)){let f=i.parse(p,1+l.length,r,void 0,{typeAnnotation:"omit"});if(!f)return null;r=r||f.type,l.push(f)}let u=s&&l.some(p=>al(s,p.type));return new Nu(u?Wt:r,l)}evaluate(e){let i,r=null,s=0;for(let l of this.args){if(s++,r=l.evaluate(e),r&&r instanceof dr&&!r.available&&(i||(i=r),r=null,s===this.args.length))return i;if(r!==null)break}return r}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){let e=["coalesce"];return this.eachChild(i=>{e.push(i.serialize())}),e}}let q_=/[^a-zA-Z0-9_]/;class Uu{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(let i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let r=[];for(let l=1;l<e.length-1;l+=2){let u=e[l];if(typeof u!="string")return i.error(`Expected string, but found ${typeof u} instead.`,l);if(q_.test(u))return i.error("Variable names must contain only alphanumeric characters or '_'.",l);let p=i.parse(e[l+1],l+1);if(!p)return null;r.push([u,p])}let s=i.parse(e.at(-1),e.length-1,i.expectedType,r);return s?new Uu(r,s):null}outputDefined(){return this.result.outputDefined()}serialize(){let e=["let"];for(let[i,r]of this.bindings)e.push(i,r.serialize());return e.push(this.result.serialize()),e}}class Rs{constructor(e,i,r){this.type=e,this.index=i,this.input=r}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,at),s=i.parse(e[2],2,Qn(i.expectedType||Wt));return r&&s?new Rs(s.type.itemType,r,s):null}evaluate(e){let i=this.index.evaluate(e),r=this.input.evaluate(e);if(i<0)throw new an("Array index out of bounds: negative index");if(i>=r.length)throw new an("Array index out of bounds: index exceeds array size");if(i!==Math.floor(i))throw new an("Array index must be an integer. Use at-interpolated for fractional indices");return r[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Vu{constructor(e,i,r){this.type=e,this.index=i,this.input=r}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,at),s=i.parse(e[2],2,Qn(i.expectedType||Wt));return r&&s?new Vu(s.type.itemType,r,s):null}evaluate(e){let i=this.index.evaluate(e),r=this.input.evaluate(e);if(i<0)throw new an(`Array index out of bounds: ${i} < 0.`);if(i>r.length-1)throw new an(`Array index out of bounds: ${i} > ${r.length-1}.`);if(i===Math.floor(i))return r[i];let s=Math.floor(i),l=Math.ceil(i),u=r[s],p=r[l];if(typeof u!="number"||typeof p!="number")throw new an(`Cannot interpolate between non-number values at index ${i}.`);let f=i-s;return u*(1-f)+p*f}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class Ot{constructor(e,i){this.type=oi,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`),null;let r=i.parse(e[1],1,Wt),s=i.parse(e[2],2,Wt);return r&&s?bu(r.type,[oi,ei,at,ya,Wt])?new Ot(r,s):(i.error(`Expected first argument to be of type boolean, string, number or null, but found ${sn(r.type)} instead`),null):null}evaluate(e){let i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(r==null)return!1;if(!mc(i,["boolean","string","number","null"]))throw new an(`Expected first argument to be of type boolean, string, number or null, but found ${sn(xn(i))} instead.`);if(!mc(r,["string","array"]))throw new an(`Expected second argument to be of type array or string, but found ${sn(xn(r))} instead.`);return r.includes(i)}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ju{constructor(e,i,r){this.type=at,this.needle=e,this.haystack=i,this.fromIndex=r}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;let r=i.parse(e[1],1,Wt),s=i.parse(e[2],2,Wt);if(!r||!s)return null;if(!bu(r.type,[oi,ei,at,ya,Wt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${sn(r.type)} instead`),null;if(e.length===4){let l=i.parse(e[3],3,at);return l?new ju(r,s,l):null}return new ju(r,s)}evaluate(e){let i=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!mc(i,["boolean","string","number","null"]))throw new an(`Expected first argument to be of type boolean, string, number or null, but found ${sn(xn(i))} instead.`);if(!mc(r,["string","array"]))throw new an(`Expected second argument to be of type array or string, but found ${sn(xn(r))} instead.`);if(this.fromIndex){let s=this.fromIndex.evaluate(e);return r.indexOf(i,s)}return r.indexOf(i)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){let e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class cd{constructor(e,i,r,s,l,u){this.inputType=e,this.type=i,this.input=r,this.cases=s,this.outputs=l,this.otherwise=u}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let r,s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);let l={},u=[];for(let g=2;g<e.length-1;g+=2){let x=e[g],b=e[g+1];Array.isArray(x)||(x=[x]);let w=i.concat(g);if(x.length===0)return w.error("Expected at least one branch label.");for(let I of x){if(typeof I!="number"&&typeof I!="string")return w.error("Branch labels must be numbers or strings.");if(typeof I=="number"&&Math.abs(I)>Number.MAX_SAFE_INTEGER)return w.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof I=="number"&&Math.floor(I)!==I)return w.error("Numeric branch labels must be integer values.");if(r){if(w.checkSubtype(r,xn(I)))return null}else r=xn(I);if(l[String(I)]!==void 0)return w.error("Branch labels must be unique.");l[String(I)]=u.length}let S=i.parse(b,g,s);if(!S)return null;s=s||S.type,u.push(S)}let p=i.parse(e[1],1,Wt);if(!p)return null;let f=i.parse(e.at(-1),e.length-1,s);return f?p.type.kind!=="value"&&i.concat(1).checkSubtype(r,p.type)?null:new cd(r,s,p,l,u,f):null}evaluate(e){let i=this.input.evaluate(e);return(wu(xn(i),this.inputType)&&this.outputs[this.cases[i]]||this.otherwise).evaluate(e)}
1eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){let e=["match",this.input.serialize()],i=Object.keys(this.cases).sort(),r=[],s={};for(let u of i){let p=s[this.cases[u]];p===void 0?(s[this.cases[u]]=r.length,r.push([this.cases[u],[u]])):r[p][1].push(u)}let l=u=>this.inputType.kind==="number"?Number(u):u;for(let[u,p]of r)e.push(p.length===1?l(p[0]):p.map(l)),e.push(this.outputs[u].serialize());return e.push(this.otherwise.serialize()),e}}class ud{constructor(e,i,r){this.type=e,this.branches=i,this.otherwise=r}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return i.error("Expected an odd number of arguments."),null;let r;i.expectedType&&i.expectedType.kind!=="value"&&(r=i.expectedType);let s=[];for(let u=1;u<e.length-1;u+=2){let p=i.parse(e[u],u,oi);if(!p)return null;let f=i.parse(e[u+1],u+1,r);if(!f)return null;s.push([p,f]),r=r||f.type}let l=i.parse(e.at(-1),e.length-1,r);return l?new ud(r,s,l):null}evaluate(e){for(let[i,r]of this.branches)if(i.evaluate(e))return r.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(let[i,r]of this.branches)e(i),e(r);e(this.otherwise)}outputDefined(){return this.branches.every(([e,i])=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){let e=["case"];return this.eachChild(i=>{e.push(i.serialize())}),e}}class Mc{constructor(e,i,r,s){this.type=e,this.input=i,this.beginIndex=r,this.endIndex=s}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;let r=i.parse(e[1],1,Wt),s=i.parse(e[2],2,at);if(!r||!s)return null;if(!bu(r.type,[Qn(Wt),ei,Wt]))return i.error(`Expected first argument to be of type array or string, but found ${sn(r.type)} instead`),null;if(e.length===4){let l=i.parse(e[3],3,at);return l?new Mc(r.type,r,s,l):null}return new Mc(r.type,r,s)}evaluate(e){let i=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!mc(i,["string","array"]))throw new an(`Expected first argument to be of type array or string, but found ${sn(xn(i))} instead.`);if(this.endIndex){let s=this.endIndex.evaluate(e);return i.slice(r,s)}return i.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){let e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class hd{constructor(e,i){this.type=Qn(ei),this.str=e,this.delimiter=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,ei),s=i.parse(e[2],2,ei);return r&&s?new hd(r,s):void 0}evaluate(e){let i=this.str.evaluate(e),r=this.delimiter.evaluate(e);return i.split(r)}eachChild(e){e(this.str),e(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function Si(n,e){return n==="=="||n==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Ef(n,e,i,r){return r.compare(e,i)===0}function xl(n,e,i){let r=n!=="=="&&n!=="!=";return class A1{constructor(l,u,p){this.type=oi,this.lhs=l,this.rhs=u,this.collator=p,this.hasUntypedArgument=l.type.kind==="value"||u.type.kind==="value"}static parse(l,u){if(l.length!==3&&l.length!==4)return u.error("Expected two or three arguments.");let p=l[0],f=u.parse(l[1],1,Wt);if(!f)return null;if(!Si(p,f.type))return u.concat(1).error(`"${p}" comparisons are not supported for type '${sn(f.type)}'.`);let g=u.parse(l[2],2,Wt);if(!g)return null;if(!Si(p,g.type))return u.concat(2).error(`"${p}" comparisons are not supported for type '${sn(g.type)}'.`);if(f.type.kind!==g.type.kind&&f.type.kind!=="value"&&g.type.kind!=="value")return u.error(`Cannot compare types '${sn(f.type)}' and '${sn(g.type)}'.`);r&&(f.type.kind==="value"&&g.type.kind!=="value"?f=new io(g.type,[f]):f.type.kind!=="value"&&g.type.kind==="value"&&(g=ne
1w io(f.type,[g])));let x=null;if(l.length===4){if(f.type.kind!=="string"&&g.type.kind!=="string"&&f.type.kind!=="value"&&g.type.kind!=="value")return u.error("Cannot use collator to compare non-string types.");if(x=u.parse(l[3],3,vu),!x)return null}return new A1(f,g,x)}evaluate(l){let u=this.lhs.evaluate(l),p=this.rhs.evaluate(l);if(r&&this.hasUntypedArgument){let f=xn(u),g=xn(p);if(f.kind!==g.kind||f.kind!=="string"&&f.kind!=="number")throw new an(`Expected arguments for "${n}" to be (string, string) or (number, number), but found (${f.kind}, ${g.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){let f=xn(u),g=xn(p);if(f.kind!=="string"||g.kind!=="string")return e(l,u,p)}return this.collator?i(l,u,p,this.collator.evaluate(l)):e(l,u,p)}eachChild(l){l(this.lhs),l(this.rhs),this.collator&&l(this.collator)}outputDefined(){return!0}serialize(){let l=[n];return this.eachChild(u=>{l.push(u.serialize())}),l}}}let Z_=xl("==",function(n,e,i){return e===i},Ef),W_=xl("!=",function(n,e,i){return e!==i},function(n,e,i,r){return!Ef(0,e,i,r)}),X_=xl("<",function(n,e,i){return e<i},function(n,e,i,r){return r.compare(e,i)<0}),Y_=xl(">",function(n,e,i){return e>i},function(n,e,i,r){return r.compare(e,i)>0}),J_=xl("<=",function(n,e,i){return e<=i},function(n,e,i,r){return r.compare(e,i)<=0}),K_=xl(">=",function(n,e,i){return e>=i},function(n,e,i,r){return r.compare(e,i)>=0});class dd{constructor(e,i,r,s,l,u){this.type=ei,this.number=e,this.locale=i,this.currency=r,this.unit=s,this.minFractionDigits=l,this.maxFractionDigits=u}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");let r=i.parse(e[1],1,at);if(!r)return null;let s=e[2];if(typeof s!="object"||Array.isArray(s))return i.error("NumberFormat options argument must be an object.");let l=null;if(s.locale&&(l=i.parseObjectValue(s.locale,2,"locale",ei),!l))return null;let u=null;if(s.currency&&(u=i.parseObjectValue(s.currency,2,"currency",ei),!u))return null;let p=null;if(s.unit&&(p=i.parseObjectValue(s.unit,2,"unit",ei),!p))return null;let f=null;if(s["min-fraction-digits"]&&(f=i.parseObjectValue(s["min-fraction-digits"],2,"min-fraction-digits",at),!f))return null;let g=null;return s["max-fraction-digits"]&&(g=i.parseObjectValue(s["max-fraction-digits"],2,"max-fraction-digits",at),!g)?null:new dd(r,l,u,p,f,g)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){let e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class pd{constructor(e){this.type=at,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;let r=i.parse(e[1],1);return r?r.type.kind!=="array"&&r.type.kind!=="string"&&r.type.kind!=="value"?(i.error(`Expected argument of type string or array, but found ${sn(r.type)} instead.`),null):new pd(r):null}evaluate(e){let i=this.input.evaluate(e);if(typeof i=="string"||Array.isArray(i))return i.length;throw new an(`Expected value to be of type string or array, but found ${sn(xn(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){let e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}function fd(n){return function(){n=1831565813+(n|=0)|0;let e=Math.imul(n^n>>>15,1|n);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}let vl={"==":Z_,"!=":W_,">":Y_,"<":X_,">=":K_,"<=":J_,array:io,at:Rs,"at-interpolated":Vu,boolean:io,case:ud,coalesce:Nu,collator:Is,format:_c,image:gc,in:Ot,"index-of":ju,interpolate:Ir,"interpolate-hcl":Ir,"interpolate-lab":Ir,length:pd,let:Uu,literal:bo,match:cd,number:io,"number-format":dd,object:io,slice:Mc,step:gl,string:io,"to-boolean":Sr,"to-color":Sr,"to-number":Sr,"to-string":Sr,var:Sc,within:Ta,distance:Aa,config:ml,split:hd};function If(n,[e,i,r,s]){e=e.evaluate(n),i=i.evaluate(n),r=r.evaluate(n);let l=s?s.evaluate(n):1,u=Tu(e,i,r,l);if(u)throw new an(u);return new Ht(e/255,i/255,r/255,l)}function Af(n,[e,i,r,s]){e=e.evaluate(n),i=i.evaluate(n),r=r.evaluate(n);let l=s?s.evaluate(n):1,u=function(g,x,b,w){return typeof g=="number"&&g>=0&&g<=360?typeof x=="number"&&x>=0&&x<=100&&typeof b=="number"&&b>=0&&b<=100?w===void 0||typeof w=="number"&&w>=0&&w<=1?null:`Invalid hsla value [${[g,x,b,w].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof w=="number"?[g,x,b,w]:[g,x,b]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof w=="number"?[g,x,b,w]:[g,x,b]).join(", ")}]: 'h' must be between 0 and 360.`}(e,i,r,l);if(u)throw new an(u);let p=`hsla(${e}, ${i}%, ${r}%, ${l})`,f=Ht.parse(p);if(!f)throw new an(`Failed to parse HSLA color: ${p}`);return f}function Mf(n,e){return n in e}function md(n,e){let i=e[n];return i===void 0?null:i}function Ls(n){return{type:n}}function Gu(n){if(n instanceof ml)return new Set([n.key]);let e=new Set;return n.eachChild(i=>{e=new Set([...e,...Gu(i)])}),e}function Hu(n){if(n instanceof pr&&n.name==="is-active-floor")return!0;let e=!1;return n.eachChild(i=>{!e&&Hu(i)&&(e=!0)}),e}function Cf(n){return{result:"success",value:n}}function zs(n){return{result:"error",value:n}}function _d(n,e){return!!n&&!!n.parameters&&n.parameters.includes(e)}function $u(n){return n["property-type"]==="data-driven"}function Pf(n){return _d(n.expression,"measure-light")}function Df(n){return _d(n.expression,"zoom")}function gd(n){return!!n.expression&&n.expression.interpolated}function yd(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Q_(n){return n}function Rf(n,e){let i=e.type==="color",r=n.stops&&typeof n.stops[0][0]=="object",s=r||!(r||n.property!==void 0),l=n.type||(gd(e)?"exponential":"interval");if(i&&((n=Object.assign({},n)).stops&&(n.stops=n.stops.map(g=>[g[0],Ht.parse(g[1])])),n.default=Ht.parse(n.default?n.default:e.default)),n.colorSpace&&n.colorSpace!=="rgb"&&!ld[n.colorSpace])throw new Error(`Unknown color space: ${n.colorSpace}`);let u,p,f;if(l==="exponential")u=Pc;else if(l==="interval")u=xd;else if(l==="categorical"){u=eg,p=Object.create(null);for(let g of n.stops)p[g[0]]=g[1];f=typeof n.stops[0][0]}else{if(l!=="identity")throw new Error(`Unknown function type "${l}"`);u=Lf}if(r){let g={},x=[];for(let S=0;S<n.stops.length;S++){let I=n.stops[S],M=I[0].zoom;g[M]===void 0&&(g[M]={zoom:M,type:n.type,property:n.property,default:n.default,stops:[]},x.push(M)),g[M].stops.push([I[0].value,I[1]])}let b=[];
vendor: 5,610 bytes, line 1
1for(let S of x)b.push([g[S].zoom,Rf(g[S],e)]);let w={name:"linear"};return{kind:"composite",interpolationType:w,interpolationFactor:Ir.interpolationFactor.bind(void 0,w),zoomStops:b.map(S=>S[0]),evaluate:({zoom:S},I)=>Pc({stops:b,base:n.base},e,S).evaluate(S,I)}}if(s){let g=l==="exponential"?{name:"exponential",base:n.base!==void 0?n.base:1}:null;return{kind:"camera",interpolationType:g,interpolationFactor:Ir.interpolationFactor.bind(void 0,g),zoomStops:n.stops.map(x=>x[0]),evaluate:({zoom:x})=>u(n,e,x,p,f)}}return{kind:"source",evaluate(g,x){let b=x&&x.properties?x.properties[n.property]:void 0;return b===void 0?Cc(n.default,e.default):u(n,e,b,p,f)}}}function Cc(n,e,i){return n!==void 0?n:e!==void 0?e:i!==void 0?i:void 0}function eg(n,e,i,r,s){return Cc(typeof i===s?r[i]:void 0,n.default,e.default)}function xd(n,e,i){if(!yc(i))return Cc(n.default,e.default);let r=n.stops.length;if(r===1||i<=n.stops[0][0])return n.stops[0][1];if(i>=n.stops[r-1][0])return n.stops[r-1][1];let s=_l(n.stops.map(l=>l[0]),i);return n.stops[s][1]}function Pc(n,e,i){let r=n.base!==void 0?n.base:1;if(!yc(i))return Cc(n.default,e.default);let s=n.stops.length;if(s===1||i<=n.stops[0][0])return n.stops[0][1];if(i>=n.stops[s-1][0])return n.stops[s-1][1];let l=_l(n.stops.map(x=>x[0]),i),u=function(x,b,w,S){let I=S-w,M=x-w;return I===0?0:b===1?M/I:(Math.pow(b,M)-1)/(Math.pow(b,I)-1)}(i,r,n.stops[l][0],n.stops[l+1][0]),p=n.stops[l][1],f=n.stops[l+1][1],g=xu[e.type]||Q_;if(n.colorSpace&&n.colorSpace!=="rgb"){let x=ld[n.colorSpace];g=(b,w)=>x.reverse(x.interpolate(x.forward(b),x.forward(w),u))}return typeof p.evaluate=="function"?{evaluate(...x){let b=p.evaluate.apply(void 0,x),w=f.evaluate.apply(void 0,x);if(b!==void 0&&w!==void 0)return g(b,w,u)}}:g(p,f,u)}function Lf(n,e,i){return e.type==="color"?i=Ht.parse(i):e.type==="formatted"?i=Un.fromString(i.toString()):e.type==="resolvedImage"?i=dr.build(i.toString()):Su(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0),Cc(i,n.default,e.default)}pr.register(vl,{error:[{kind:"error"},[ei],(n,[e])=>{throw new an(e.evaluate(n))}],typeof:[ei,[Wt],(n,[e])=>sn(xn(e.evaluate(n)))],"to-rgba":[Qn(at,4),[on],(n,[e])=>e.evaluate(n).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Qn(at,4),[on],(n,[e])=>e.evaluate(n).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[on,[at,at,at],If],rgba:[on,[at,at,at,at],If],hsl:[on,[at,at,at],Af],hsla:[on,[at,at,at,at],Af],has:{type:oi,overloads:[[[ei],(n,[e])=>Mf(e.evaluate(n),n.properties())],[[ei,xa],(n,[e,i])=>Mf(e.evaluate(n),i.evaluate(n))]]},get:{type:Wt,overloads:[[[ei],(n,[e])=>md(e.evaluate(n),n.properties())],[[ei,xa],(n,[e,i])=>md(e.evaluate(n),i.evaluate(n))]]},"feature-state":[Wt,[ei],(n,[e])=>md(e.evaluate(n),n.featureState||{})],properties:[xa,[],n=>n.properties()],"geometry-type":[ei,[],n=>n.geometryType()],worldview:[ei,[],n=>n.globals.worldview||""],"is-active-floor":[oi,Ls(ei),(n,e)=>{if(!(n.globals&&n.globals.activeFloors&&n.globals.activeFloors.size>0))return!1;if(e.length===0)return!0;let i=n.globals.activeFloors;return e.some(r=>{let s=r.evaluate(n);return i.has(s)})}],id:[Wt,[],n=>n.id()],zoom:[at,[],n=>n.globals.zoom],pitch:[at,[],n=>n.globals.pitch||0],"distance-from-center":[at,[],n=>n.distanceFromCenter()],"measure-light":[at,[ei],(n,[e])=>n.measureLight(e.evaluate(n))],"heatmap-density":[at,[],n=>n.globals.heatmapDensity||0],"line-progress":[at,[],n=>n.globals.lineProgress||0],"raster-value":[at,[],n=>n.globals.rasterValue||0],"raster-particle-speed":[at,[],n=>n.globals.rasterParticleSpeed||0],"sky-radial-progress":[at,[],n=>n.globals.skyRadialProgress||0],accumulated:[Wt,[],n=>n.globals.accumulated===void 0?null:n.globals.accumulated],"+":[at,Ls(at),(n,e)=>{let i=0;for(let r of e)i+=r.evaluate(n);return i}],"*":[at,Ls(at),(n,e)=>{let i=1;for(let r of e)i*=r.evaluate(n);return i}],"-":{type:at,overloads:[[[at,at],(n,[e,i])=>e.evaluate(n)-i.evaluate(n)],[[at],(n,[e])=>-e.evaluate(n)]]},"/":[at,[at,at],(n,[e,i])=>e.evaluate(n)/i.evaluate(n)],"%":[at,[at,at],(n,[e,i])=>e.evaluate(n)%i.evaluate(n)],ln2:[at,[],()=>Math.LN2],pi:[at,[],()=>Math.PI],e:[at,[],()=>Math.E],"^":[at,[at,at],(n,[e,i])=>Math.pow(e.evaluate(n),i.evaluate(n))],sqrt:[at,[at],(n,[e])=>Math.sqrt(e.evaluate(n))],log10:[at,[at],(n,[e])=>Math.log(e.evaluate(n))/Math.LN10],ln:[at,[at],(n,[e])=>Math.log(e.evaluate(n))],log2:[at,[at],(n,[e])=>Math.log2(e.evaluate(n))],sin:[at,[at],(n,[e])=>Math.sin(e.evaluate(n))],cos:[at,[at],(n,[e])=>Math.cos(e.evaluate(n))],tan:[at,[at],(n,[e])=>Math.tan(e.evaluate(n))],asin:[at,[at],(n,[e])=>Math.asin(e.evaluate(n))],acos:[at,[at],(n,[e])=>Math.acos(e.evaluate(n))],atan:[at,[at],(n,[e])=>Math.atan(e.evaluate(n))],min:[at,Ls(at),(n,e)=>Math.min(...e.map(i=>i.evaluate(n)))],max:[at,Ls(at),(n,e)=>Math.max(...e.map(i=>i.evaluate(n)))],abs:[at,[at],(n,[e])=>Math.abs(e.evaluate(n))],round:[at,[at],(n,[e])=>{let i=e.evaluate(n);return i<0?-Math.round(-i):Math.round(i)}],floor:[at,[at],(n,[e])=>Math.floor(e.evaluate(n))],ceil:[at,[at],(n,[e])=>Math.ceil(e.evaluate(n))],"filter-==":[oi,[ei,Wt],(n,[e,i])=>n.properties()[e.value]===i.value],"filter-id-==":[oi,[Wt],(n,[e])=>n.id()===e.value],"filter-type-==":[oi,[ei],(n,[e])=>n.geometryType()===e.value],"filter-<":[oi,[ei,Wt],(n,[e,i])=>{let r=n.properties()[e.value],s=i.value;return typeof r==typeof s&&r<s}],"filter-id-<":[oi,[Wt],(n,[e])=>{let i=n.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[oi,[ei,Wt],(n,[e,i])=>{let r=n.properties()[e.value],s=i.value;return typeof r==typeof s&&r>s}],"filter-id->":[oi,[Wt],(n,[e])=>{let i=n.id(),r=e.value;return typeof i==typeof r&&i>r}
1],"filter-<=":[oi,[ei,Wt],(n,[e,i])=>{let r=n.properties()[e.value],s=i.value;return typeof r==typeof s&&r<=s}],"filter-id-<=":[oi,[Wt],(n,[e])=>{let i=n.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[oi,[ei,Wt],(n,[e,i])=>{let r=n.properties()[e.value],s=i.value;return typeof r==typeof s&&r>=s}],"filter-id->=":[oi,[Wt],(n,[e])=>{let i=n.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[oi,[Wt],(n,[e])=>e.value in n.properties()],"filter-has-id":[oi,[],n=>n.id()!==null&&n.id()!==void 0],"filter-type-in":[oi,[Qn(ei)],(n,[e])=>e.value.includes(n.geometryType())],"filter-id-in":[oi,[Qn(Wt)],(n,[e])=>e.value.includes(n.id())],"filter-in-small":[oi,[ei,Qn(Wt)],(n,[e,i])=>i.value.includes(n.properties()[e.value])],"filter-in-large":[oi,[ei,Qn(Wt)],(n,[e,i])=>function(r,s,l,u){for(;l<=u;){let p=l+u>>1;if(s[p]===r)return!0;s[p]>r?u=p-1:l=p+1}return!1}(n.properties()[e.value],i.value,0,i.value.length-1)],all:{type:oi,overloads:[[[oi,oi],(n,[e,i])=>e.evaluate(n)&&i.evaluate(n)],[Ls(oi),(n,e)=>{for(let i of e)if(!i.evaluate(n))return!1;return!0}]]},any:{type:oi,overloads:[[[oi,oi],(n,[e,i])=>e.evaluate(n)||i.evaluate(n)],[Ls(oi),(n,e)=>{for(let i of e)if(i.evaluate(n))return!0;return!1}]]},"!":[oi,[oi],(n,[e])=>!e.evaluate(n)],"is-supported-script":[oi,[ei],(n,[e])=>{let i=n.globals&&n.globals.isSupportedScript;return!i||i(e.evaluate(n))}],upcase:[ei,[ei],(n,[e])=>e.evaluate(n).toUpperCase()],downcase:[ei,[ei],(n,[e])=>e.evaluate(n).toLowerCase()],concat:[ei,Ls(Wt),(n,e)=>e.map(i=>Tr(i.evaluate(n))).join("")],"resolved-locale":[ei,[vu],(n,[e])=>e.evaluate(n).resolvedLocale()],random:[at,[at,at,Wt],(n,e)=>{let[i,r,s]=e.map(u=>u.evaluate(n));if(i>r||i===r)return i;let l;if(typeof s=="string")l=function(u){let p=0;if(u.length===0)return p;for(let f=0;f<u.length;f++)p=(p<<5)-p+u.charCodeAt(f),p&=p;return p}(s);else{if(typeof s!="number")throw new an(`Invalid seed input: ${s}`);l=s}return i+fd(l)()*(r-i)}]});class vd{constructor(e,i,r,s,l){this.expression=e,this._warningHistory={},this._scope=r,this._options=s,this._iconImageUseTheme=l,this._evaluator=new no(r,s,l),this._defaultValue=i?function(u){return u.type==="color"&&(yd(u.default)||Array.isArray(u.default))?new Ht(0,0,0,0):u.type==="color"?Ht.parse(u.default)||null:u.default===void 0?null:u.default}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null,this.configDependencies=Gu(e),this.isIndoorDependent=Hu(e)}evaluateWithoutErrorHandling(e,i,r,s,l,u,p,f){return this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=r,this._evaluator.canonical=s||null,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=f||null,this.expression.evaluate(this._evaluator)}evaluate(e,i,r,s,l,u,p,f,g){this._evaluator||(this._evaluator=new no(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=r||null,this._evaluator.canonical=s||null,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=u||null,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=f||null,this._evaluator.iconImageUseTheme=g||null;try{let x=this.expression.evaluate(this._evaluator);if(x==null||typeof x=="number"&&x!=x)return this._defaultValue;if(this._enumValues&&!(x in this._enumValues))throw new an(`Expected value to be one of ${Object.keys(this._enumValues).map(b=>JSON.stringify(b)).join(", ")}, but found ${JSON.stringify(x)} instead.`);return x}catch(x){let b=x;return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${b.message}`)),this._defaultValue}}}function qu(n){return Array.isArray(n)&&n.length>0&&typeof n[0]=="string"&&n[0]in vl}function Pa(n,e,i,r,s){let l=new Ec(vl,[],e?function(p){let f={color:on,string:ei,number:at,enum:ei,boolean:oi,formatted:Ko,resolvedImage:sl};return p.type==="array"?Qn(f[p.value]||Wt,p.length):f[p.type]}(e):void 0,void 0,void 0,i,r,s),u=l.parse(n,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return u?Cf(new vd(u,e,i,r,s)):zs(l.errors)}
1class Dc{constructor(e,i,r,s){this.kind=e,this._styleExpression=i,this.isLightConstant=r,this.isLineProgressConstant=s,this.isStateDependent=e!=="constant"&&!fl(i.expression),this.configDependencies=Gu(i.expression),this.isIndoorDependent=Hu(i.expression)}evaluateWithoutErrorHandling(e,i,r,s,l,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,r,s,l,u)}evaluate(e,i,r,s,l,u,p){return this._styleExpression.evaluate(e,i,r,s,l,u,void 0,void 0,p)}}class bl{constructor(e,i,r,s,l,u){this.kind=e,this.zoomStops=r,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!fl(i.expression),this.isIndoorDependent=Hu(i.expression),this.isLightConstant=l,this.isLineProgressConstant=u,this.configDependencies=Gu(i.expression),this.interpolationType=s}evaluateWithoutErrorHandling(e,i,r,s,l,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,r,s,l,u)}evaluate(e,i,r,s,l,u){return this._styleExpression.evaluate(e,i,r,s,l,u)}interpolationFactor(e,i,r){return this.interpolationType?Ir.interpolationFactor(this.interpolationType,e,i,r):0}}function Da(n,e,i,r,s){if((n=Pa(n,e,i,r,s)).result==="error")return n;let l=n.value.expression,u=Ma(l);if(!u&&!$u(e))return zs([new vo("","data expressions not supported")]);let p=rr(l,["zoom","pitch","distance-from-center"]);if(!p&&!Df(e))return zs([new vo("","zoom expressions not supported")]);let f=rr(l,["measure-light"]);if(!f&&!Pf(e))return zs([new vo("","measure-light expression not supported")]);let g=rr(l,["line-progress"]);if(!g&&!function(w){return _d(w.expression,"line-progress")}(e))return zs([new vo("","line-progress expression not supported")]);let x=e.expression&&e.expression.relaxZoomRestriction,b=Zu(l);return b||p||x?b instanceof vo?zs([b]):b instanceof Ir&&!gd(e)?zs([new vo("",'"interpolate" expressions cannot be used with this property')]):Cf(b?new bl(u&&g?"camera":"composite",n.value,b.labels,b instanceof Ir?b.interpolation:void 0,f,g):new Dc(u&&g?"constant":"source",n.value,f,g)):zs([new vo("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Rc{constructor(e,i){this._parameters=e,this._specification=i,Object.assign(this,Rf(this._parameters,this._specification))}static deserialize(e){return new Rc(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Zu(n){let e=null;if(n instanceof Uu)e=Zu(n.result);else if(n instanceof Nu){for(let i of n.args)if(e=Zu(i),e)break}else(n instanceof gl||n instanceof Ir)&&n.input instanceof pr&&n.input.name==="zoom"&&(e=n);return e instanceof vo||n.eachChild(i=>{let r=Zu(i);r instanceof vo?e=r:e&&r&&e!==r&&(e=new vo("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class Ra{constructor(e,i,r){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,e instanceof ArrayBuffer){let s=new Int32Array(e);this.width=s[0],this.height=s[1],this.xCellCount=s[2],this.yCellCount=s[3],this.boxUid=s[4],this.circleUid=s[5];let l=this.xCellCount*this.yCellCount,u=[];for(let x=0;x<l;x++){let b=s[6+x],w=s[6+x+1];u.push(b===w?null:s.subarray(b,w))}let p=s[6+l],f=[];for(let x=0;x<l;x++){let b=s[p+x],w=s[p+x+1];f.push(b===w?null:s.subarray(b,w))}let g=s[p+l];this.boxCells=u,this.circleCells=f,this.boxKeys=s.subarray(g,g+this.boxUid),g+=this.boxUid,this.circleKeys=s.subarray(g,g+this.circleUid),g+=this.circleUid,this.bboxes=s.subarray(g,g+4*this.boxUid),g+=4*this.boxUid,this.circles=s.subarray(g,g+3*this.circleUid)}else{this.width=e,this.height=i,this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(i/r);let s=this.xCellCount*this.yCellCount,l=[],u=[];for(let p=0;p<s;p++)l.push([]),u.push([]);this.boxCells=l,this.circleCells=u,this.boxKeys=[],this.circleKeys=[],this.bboxes=[],this.circles=[],this.boxUid=0,this.circleUid=0}this.xScale=this.xCellCount/this.width,this.yScale=this.yCellCount/this.height}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,i,r,s,l){let u=this.boxUid++,p=this._xCell(i),f=this._yCell(r),g=this._xCell(s),x=this._yCell(l);for(let b=p;b<=g;b++)for(let w=f;w<=x;w++)this.boxCells[this.xCellCount*w+b].push(u);this.boxKeys.push(e),this.bboxes.push(i,r,s,l)}
1insertCircle(e,i,r,s){let l=this.circleUid++,u=this._xCell(i-s),p=this._yCell(r-s),f=this._xCell(i+s),g=this._yCell(r+s);for(let x=u;x<=f;x++)for(let b=p;b<=g;b++)this.circleCells[this.xCellCount*b+x].push(l);this.circleKeys.push(e),this.circles.push(i,r,s)}query(e,i,r,s,l){let u=[];if(r<0||e>this.width||s<0||i>this.height)return u;let p=this._nextGen(),{boxCells:f,circleCells:g,boxKeys:x,circleKeys:b,bboxes:w,circles:S,boxSeen:I,circleSeen:M,xCellCount:C}=this,R=this._xCell(e),F=this._yCell(i),L=this._xCell(r),j=this._yCell(s);for(let H=R;H<=L;H++)for(let $=F;$<=j;$++){let ie=C*$+H,W=f[ie];if(W)for(let Y=0;Y<W.length;Y++){let ee=W[Y];if(I[ee]===p)continue;I[ee]=p;let me=4*ee,ge=w[me],Te=w[me+1],Ae=w[me+2],Ie=w[me+3];e<=Ae&&i<=Ie&&r>=ge&&s>=Te&&(!l||l(x[ee]))&&u.push({key:x[ee],x1:ge,y1:Te,x2:Ae,y2:Ie})}let Q=g[ie];if(Q)for(let Y=0;Y<Q.length;Y++){let ee=Q[Y];if(M[ee]===p)continue;M[ee]=p;let me=3*ee,ge=S[me],Te=S[me+1],Ae=S[me+2];!this._circleAndRectCollide(ge,Te,Ae,e,i,r,s)||l&&!l(b[ee])||u.push({key:b[ee],x1:ge-Ae,y1:Te-Ae,x2:ge+Ae,y2:Te+Ae})}}return u}queryKeys(e,i,r,s,l){let u=[];if(r<0||e>this.width||s<0||i>this.height)return u;let p=this._nextGen(),{boxCells:f,boxKeys:g,bboxes:x,boxSeen:b,xCellCount:w,xScale:S,yScale:I}=this,M=this._xCell(e),C=this._yCell(i),R=this._xCell(r),F=this._yCell(s);for(let L=M;L<=R;L++)for(let j=C;j<=F;j++){if(l&&!l(L/S,j/I,(L+1)/S,(j+1)/I))continue;let H=f[w*j+L];if(H)for(let $=0;$<H.length;$++){let ie=H[$];if(b[ie]===p)continue;b[ie]=p;let W=4*ie,Q=x[W],Y=x[W+1],ee=x[W+2],me=x[W+3];(l?l(Q,Y,ee,me):e<=ee&&i<=me&&r>=Q&&s>=Y)&&u.push(g[ie])}}return u}hitTest(e,i,r,s,l){if(r<0||e>this.width||s<0||i>this.height)return!1;let u=this._nextGen(),{boxCells:p,circleCells:f,boxKeys:g,circleKeys:x,bboxes:b,circles:w,boxSeen:S,circleSeen:I,xCellCount:M}=this,C=this._xCell(e),R=this._yCell(i),F=this._xCell(r),L=this._yCell(s);for(let j=C;j<=F;j++)for(let H=R;H<=L;H++){let $=M*H+j,ie=p[$];if(ie)for(let Q=0;Q<ie.length;Q++){let Y=ie[Q];if(S[Y]===u)continue;S[Y]=u;let ee=4*Y;if(e<=b[ee+2]&&i<=b[ee+3]&&r>=b[ee]&&s>=b[ee+1]&&(!l||l(g[Y])))return!0}let W=f[$];if(W)for(let Q=0;Q<W.length;Q++){let Y=W[Q];if(I[Y]===u)continue;I[Y]=u;let ee=3*Y;if(this._circleAndRectCollide(w[ee],w[ee+1],w[ee+2],e,i,r,s)&&(!l||l(x[Y])))return!0}}return!1}hitTestCircle(e,i,r,s){let l=e-r,u=i-r,p=e+r,f=i+r;if(p<0||l>this.width||f<0||u>this.height)return!1;let g=this._nextGen(),{boxCells:x,circleCells:b,boxKeys:w,circleKeys:S,bboxes:I,circles:M,boxSeen:C,circleSeen:R,xCellCount:F}=this,L=this._xCell(l),j=this._yCell(u),H=this._xCell(p),$=this._yCell(f);for(let ie=L;ie<=H;ie++)for(let W=j;W<=$;W++){let Q=F*W+ie,Y=x[Q];if(Y)for(let me=0;me<Y.length;me++){let ge=Y[me];if(C[ge]===g)continue;C[ge]=g;let Te=4*ge;if(this._circleAndRectCollide(e,i,r,I[Te],I[Te+1],I[Te+2],I[Te+3])&&(!s||s(w[ge])))return!0}let ee=b[Q];if(ee)for(let me=0;me<ee.length;me++){let ge=ee[me];if(R[ge]===g)continue;R[ge]=g;let Te=3*ge;if(this._circlesCollide(M[Te],M[Te+1],M[Te+2],e,i,r)&&(!s||s(S[ge])))return!0}}return!1}static serialize(e,i){let r=e.toArrayBuffer();return i&&i.add(r),{buffer:r}}static deserialize(e){return new Ra(e.buffer)}toArrayBuffer(){let e=this.xCellCount*this.yCellCount,i=0,r=0;for(let p=0;p<e;p++)i+=this.boxCells[p].length,r+=this.circleCells[p].length;let s=new Int32Array(6+(e+1)+i+(e+1)+r+this.boxUid+this.circleUid+4*this.boxUid+3*this.circleUid);s[0]=this.width,s[1]=this.height,s[2]=this.xCellCount,s[3]=this.yCellCount,s[4]=this.boxUid,s[5]=this.circleUid;let l=6+(e+1);for(let p=0;p<e;p++){s[6+p]=l;let f=this.boxCells[p];s.set(f,l),l+=f.length}s[6+e]=l;let u=l;l+=e+1;for(let p=0;p<e;p++){s[u+p]=l;let f=this.circleCells[p];s.set(f,l),l+=f.length}return s[u+e]=l,s.set(this.boxKeys,l),l+=this.boxUid,s.set(this.circleKeys,l),l+=this.circleUid,s.set(this.bboxes,l),l+=4*this.boxUid,s.set(this.circles,l),s.buffer}_xCell(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_yCell(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_nextGen(){return this.boxSeen.length<this.boxUid&&(this.boxSeen=new Uint32Array(this.boxUid)),this.circleSeen.length<this.circleUid&&(this.circleSeen=new Uint32Array(this.circleUid)),this.generation=this.generation+1>>>0,this.generation===0&&(this.boxSeen.fill(0),this.circleSeen.fill(0),this.generation=1),this.generation}
1_circlesCollide(e,i,r,s,l,u){let p=s-e,f=l-i,g=r+u;return g*g>p*p+f*f}_circleAndRectCollide(e,i,r,s,l,u,p){let f=(u-s)/2,g=Math.abs(e-(s+f));if(g>f+r)return!1;let x=(p-l)/2,b=Math.abs(i-(l+x));if(b>x+r)return!1;if(g<=f||b<=x)return!0;let w=g-f,S=b-x;return w*w+S*S<=r*r}}let wl={};function Qe(n,e,i={}){Object.defineProperty(n,"_classRegistryKey",{value:e,writable:!1}),wl[e]={klass:n,omit:i.omit||[]}}Qe(Object,"Object"),Qe(Ra,"Grid"),delete ke.prototype.constructor,Qe(Ht,"Color"),Qe(Error,"Error"),Qe(Un,"Formatted"),Qe(va,"FormattedSection"),Qe(jh,"AJAXError"),Qe(dr,"ResolvedImage"),Qe(Rc,"StylePropertyFunction"),Qe(vd,"StyleExpression",{omit:["_evaluator"]}),Qe(br,"ImageId"),Qe(wr,"ImageVariant"),Qe(bl,"ZoomDependentExpression"),Qe(Dc,"ZoomConstantExpression"),Qe(pr,"CompoundExpression",{omit:["_evaluate"]});for(let n in vl)wl[vl[n]._classRegistryKey]||Qe(vl[n],`Expression${n}`);function zf(n){return n&&(n instanceof ArrayBuffer||n.constructor&&n.constructor.name==="ArrayBuffer")}function Os(n,e){if(n===null)return null;let i=typeof n;if(i!=="object")return i==="bigint"?{$name:"BigInt",value:n.toString()}:n;if(Array.isArray(n)){let u=n.length,p=[];p.length=u;for(let f=0;f<u;f++)p[f]=Os(n[f],e);return p}if(ArrayBuffer.isView(n))return e&&e.add(n.buffer),n;if(zf(n)||n instanceof ImageBitmap)return e&&e.add(n),n;if(n instanceof ImageData)return e&&e.add(n.data.buffer),n;if(n instanceof Map){let u={$name:"Map",entries:[]};for(let[p,f]of n.entries())u.entries.push(Os(p),Os(f,e));return u}if(n instanceof Set){let u={$name:"Set"},p=0;for(let f of n.values())u[++p]=Os(f);return u}if(n instanceof Date||n instanceof RegExp||n instanceof Boolean||n instanceof Number||n instanceof String)return n;let r=n.constructor,s=r._classRegistryKey;if(!s)throw new Error(`Can't serialize object of unregistered class "${r.name}".`);let l=r.serialize?r.serialize(n,e):{};if(!r.serialize){let u=wl[s].omit,p=n;for(let f in p)Object.hasOwn(p,f)&&(u.includes(f)||(l[f]=Os(p[f],e)));n instanceof Error&&(l.message=n.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return s!=="Object"&&(l.$name=s),l}function es(n){if(n===null||typeof n!="object")return n;if(Array.isArray(n)){for(let s=0;s<n.length;s++)n[s]=es(n[s]);return n}if(ArrayBuffer.isView(n)||zf(n)||n instanceof ImageBitmap||n instanceof ImageData||n instanceof Date||n instanceof RegExp||n instanceof Boolean||n instanceof Number||n instanceof String)return n;let e=n.$name||"Object";if(e==="Map"){let s=n.entries||[],l=new Map;for(let u=0;u<s.length;u+=2)l.set(es(s[u]),es(s[u+1]));return l}if(e==="Set"){let s=new Set;for(let l in n)l!=="$name"&&s.add(es(n[l]));return s}if(e==="BigInt")return BigInt(n.value);let{klass:i}=wl[e];if(!i)throw new Error(`Can't deserialize unregistered class "${e}".`);if(i.deserialize)return i.deserialize(n);let r=Object.create(i.prototype);for(let s in n)s!=="$name"&&(r[s]=es(n[s]));return r}let bd=n=>n>=1536&&n<=1791,Of=n=>n>=1872&&n<=1919,Ff=n=>n>=2208&&n<=2303,Bf=n=>n>=11904&&n<=12031,wd=n=>n>=12032&&n<=12255,Td=n=>n>=12272&&n<=12287,La=n=>n>=12288&&n<=12351,Sd=n=>n>=12352&&n<=12447,Lc=n=>n>=12448&&n<=12543,kf=n=>n>=12544&&n<=12591,Nf=n=>n>=12704&&n<=12735,Ed=n=>n>=12736&&n<=12783,Id=n=>n>=12784&&n<=12799,Uf=n=>n>=12800&&n<=13055,Vf=n=>n>=13056&&n<=13311,Ad=n=>n>=13312&&n<=19903,Md=n=>n>=19968&&n<=40959,zc=n=>n>=40960&&n<=42127,jf=n=>n>=42128&&n<=42191,Gf=n=>n>=44032&&n<=55215,Hf=n=>n>=63744&&n<=64255,Oc=n=>n>=64336&&n<=65023,$f=n=>n>=65040&&n<=65055,Cd=n=>n>=65072&&n<=65103,Pd=n=>n>=65104&&n<=65135,Wu=n=>n>=65136&&n<=65279,Dd=n=>n>=65280&&n<=65519;function Xu(n){for(let e of n)if(Yu(e.charCodeAt(0)))return!0;return!1}function tg(n){for(let e of n)if(!qf(e.charCodeAt(0)))return!1;return!0}function qf(n){return!(bd(n)||Of(n)||Ff(n)||Oc(n)||Wu(n))}function Zf(n){return!(n<11904||!(Nf(n)||kf(n)||Cd(n)||Hf(n)||Vf(n)||Bf(n)||Ed(n)||La(n)||Ad(n)||Md(n)||Uf(n)||Dd(n)||Sd(n)||Td(n)||wd(n)||Id(n)||Lc(n)||$f(n)||jf(n)||zc(n)))}function Yu(n){return!(n!==746&&n!==747&&(n<4352||!(Nf(n)||kf(n)||Cd(n)&&!(n>=65097&&n<=65103)||Hf(n)||Vf(n)||Bf(n)||Ed(n)||!(!La(n)||n>=12296&&n<=12305||n>=12308&&n<=12319||n===12336)||Ad(n)||Md(n)||Uf(n)||(e=>e>=12592&&e<=12687)(n)||(e=>e>=43360&&e<=43391)(n)||(e=>e>=55216&&e<=55295)(n)||(e=>e>
1=4352&&e<=4607)(n)||Gf(n)||Sd(n)||Td(n)||(e=>e>=12688&&e<=12703)(n)||wd(n)||Id(n)||Lc(n)&&n!==12540||!(!Dd(n)||n===65288||n===65289||n===65293||n>=65306&&n<=65310||n===65339||n===65341||n===65343||n>=65371&&n<=65503||n===65507||n>=65512&&n<=65519)||!(!Pd(n)||n>=65112&&n<=65118||n>=65123&&n<=65126)||(e=>e>=5120&&e<=5759)(n)||(e=>e>=6320&&e<=6399)(n)||$f(n)||(e=>e>=19904&&e<=19967)(n)||zc(n)||jf(n))))}function Wf(n){return n===12312||n===12313||n===12316||n===12540||n===12448}function Ju(n){return!(Yu(n)||function(e){return!!((i=>i>=128&&i<=255)(e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||(i=>i>=8192&&i<=8303)(e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||(i=>i>=8448&&i<=8527)(e)||(i=>i>=8528&&i<=8591)(e)||(i=>i>=8960&&i<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||(i=>i>=9216&&i<=9279)(e)&&e!==9251||(i=>i>=9280&&i<=9311)(e)||(i=>i>=9312&&i<=9471)(e)||(i=>i>=9632&&i<=9727)(e)||(i=>i>=9728&&i<=9983)(e)&&!(e>=9754&&e<=9759)||(i=>i>=11008&&i<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||La(e)||Lc(e)||(i=>i>=57344&&i<=63743)(e)||Cd(e)||Pd(e)||Dd(e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(n))}function Rd(n){return bd(n)||Of(n)||Ff(n)||Oc(n)||Wu(n)}function Ld(n){return n>=1424&&n<=2303||Oc(n)||Wu(n)}function ig(n,e){return!(!e&&Ld(n)||n>=2304&&n<=3583||n>=3840&&n<=4255||(i=>i>=6016&&i<=6143)(n))}function Fs(n){for(let e of n)if(Ld(e.charCodeAt(0)))return!0;return!1}let Ar={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"},zd=null,En=Ar.unavailable,Bs=null,Fc=function(n){n&&(En=Ar.error),zd&&zd(n)};function Ku(){Tl.fire(new Jo("pluginStateChange",{pluginStatus:En,pluginURL:Bs}))}let Tl=new ol,Qu=function(){return En},Xf=function(){if(En!==Ar.deferred||!Bs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");En=Ar.loading,Ku(),Bs&&nl({url:Bs},n=>{n?Fc(n):(En=Ar.loaded,Ku())})},ts={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>En===Ar.loaded||ts.applyArabicShaping!=null,isLoading:()=>En===Ar.loading,setState(n){En=n.pluginStatus,Bs=n.pluginURL},isParsing:()=>En===Ar.parsing,isParsed:()=>En===Ar.parsed,getPluginURL:()=>Bs},Od=function(){ts.isLoading()||ts.isLoaded()||Qu()!=="deferred"||Xf()};class Jt{constructor(e,i){this.zoom=e,i?(this.now=i.now,this.fadeDuration=i.fadeDuration,this.transition=i.transition,this.pitch=i.pitch,this.brightness=i.brightness,this.worldview=i.worldview,this.activeFloors=i.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(i,r){for(let s of i)if(!ig(s.charCodeAt(0),r))return!1;return!0}(e,ts.isLoaded())}}class Sl{constructor(e,i,r,s,l){this.property=e,this.value=i,this.expression=function(u,p,f,g,x){if(yd(u))return new Rc(u,p);if(qu(u)||Array.isArray(u)&&u.length>0){let b=Da(u,p,f,g,x);if(b.result==="error")throw new Error(b.value.map(w=>`${w.key}: ${w.message}`).join(", "));return b.value}{let b=u;return typeof u=="string"&&p.type==="color"&&(b=Ht.parse(u)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>b}}}(i===void 0?e.specification.default:i,e.specification,r,s,l)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,i,r,s){return this.property.possiblyEvaluate(this,e,i,r,s)}}class eh{constructor(e,i,r,s){this.property=e,this.value=new Sl(e,void 0,i,r,s)}transitioned(e,i){return new Bc(this.property,this.value,i,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new Bc(this.property,this.value,null,{},0)}}class Yf{constructor(e,i,r,s){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=i,this._options=r,this._iconImageUseTheme=s,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return Gt(this._values[e].value.value)}setValue(e,i){Object.hasOwn(this._values,e)||(this._values[e]=new eh(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new Sl(this._values[e].property,i===null?void 0:Gt(i),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent())}setTransitionOrValue(e,i){i&&(this._options=i);let r=this._properties.properties;if(e)for(let s in e){let l=e[s];if(s.endsWith("-transition")){let u=s.slice(0,-11);r[u]&&this.setTransition(u,l)}else Object.hasOwn(r,s)&&this.setValue(s,l)}}getTransition(e){return Gt(this._values[e].transition)}setTransition(e,i){Object.hasOwn(this._values,e)||(this._values[e]=new eh(this._values[e].property)),this._values[e].transition=Gt(i)||void 0}serialize(){let e={};for(let i of Object.keys(this._values)){let r=this.getValue(i);r!==void 0&&(e[i]=r);let s=this.getTransition(i);s!==void 0&&(e[`${i}-transition`]=s)}return e}transitioned(e,i){let r=new kc(this._properties);for(let s of Object.keys(this._values))r._values[s]=this._values[s].transitioned(e,i._values[s]);return r}untransitioned(){let e=new kc(this._properties);for(let i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class Bc{constructor(e,i,r,s,l){let u=s.delay||0,p=s.duration||0;l=l||0,this.property=e,this.value=i,this.begin=l+u,this.end=this.begin+p,e.specification.transition&&(s.delay||s.duration)&&(this.prior=r)}possiblyEvaluate(e,i,r){let s=e.now||0,l=this.value.possiblyEvaluate(e,i,r),u=this.prior;if(u){if(s>this.end)return this.prior=null,l;if(this.value.isDataDriven())return this.prior=null,l;if(s<this.begin)return u.possiblyEvaluate(e,i,r);{let p=(s-this.begin)/(this.end-this.begin);return this.property.interpolate(u.possiblyEvaluate(e,i,r),l,le(p))}}return l}}class kc{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,r){let s=new is(this._properties);for(let l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(e,i,r);return s}hasTransition(){for(let e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}
1class Nc{constructor(e,i,r,s){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=i,this._options=r,this._iconImageUseTheme=s,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return Gt(this._values[e].value)}setValue(e,i){this._values[e]=new Sl(this._values[e].property,i===null?void 0:Gt(i),this._scope,this._options,this._iconImageUseTheme),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].isIndoorDependent())}serialize(){let e={};for(let i of Object.keys(this._values)){let r=this.getValue(i);r!==void 0&&(e[i]=r)}return e}possiblyEvaluate(e,i,r,s){let l=new is(this._properties);for(let u of Object.keys(this._values))l._values[u]=this._values[u].possiblyEvaluate(e,i,r,s);return l}isIndoorDependent(){return this._isIndoorDependent}}class ks{constructor(e,i,r,s){this.property=e,this.value=i,this.parameters=r,this.iconImageUseTheme=s}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,i,r,s,l){return this.property.evaluate(this.value,this.parameters,e,i,r,s,this.iconImageUseTheme,l)}}class is{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class qe{constructor(e){this.specification=e}possiblyEvaluate(e,i){return e.expression.evaluate(i)}interpolate(e,i,r){let s=xu[this.specification.type];return s?s(e,i,r):e}}class Ze{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,r,s,l){return e.expression.kind==="constant"||e.expression.kind==="camera"?new ks(this,{kind:"constant",value:e.expression.evaluate(i,null,{},r,s,void 0,l)},i):new ks(this,e.expression,i,l)}interpolate(e,i,r){if(e.value.kind!=="constant"||i.value.kind!=="constant")return e;if(e.value.value===void 0||i.value.value===void 0)return new ks(this,{kind:"constant",value:void 0},e.parameters);let s=xu[this.specification.type];return s?new ks(this,{kind:"constant",value:s(e.value.value,i.value.value,r)},e.parameters):e}evaluate(e,i,r,s,l,u,p,f){return e.kind==="constant"?e.value:e.evaluate(i,r,s,l,u,f,p)}}class za{constructor(e){this.specification=e}possiblyEvaluate(e,i,r,s){return!!e.expression.evaluate(i,null,{},r,s)}interpolate(){return!1}}class Ti{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];let i=new Jt(0,{});for(let r in e){let s=e[r],l=s.specification;l&&l.overridable&&this.overridableProperties.push(r);let u=this.defaultPropertyValues[r]=new Sl(s,void 0),p=this.defaultTransitionablePropertyValues[r]=new eh(s);this.defaultTransitioningPropertyValues[r]=p.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=u.possiblyEvaluate(i)}}}Qe(Ze,"DataDrivenProperty"),Qe(qe,"DataConstantProperty"),Qe(za,"ColorRampProperty");var he=JSON.parse('{"$version":8,"$root":{"version":{"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"snow":{"type":"snow"},"rain":{"type":"rain"},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"indoor":{"type":"indoor"},"imports":{"type":"array","value":"import"},"iconsets":{"type":"iconsets"},"schema":{"type":"schema"},"sources":{"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"type":"featuresets"}},"featuresets":{"*":{"type":"featureset"}}
1,"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","expression":{}},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string"},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false},"shadow-quality":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]}},"shadow-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"shadow-draw-before-layer":{"type":"string"}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"iconsets":{"*":{"type":"iconset"}},"iconset":["iconset_sprite","iconset_source"],"iconset_sprite":{"type":{"type":"enum","values":{"sprite":1}},"url":{"type":"string"}},"iconset_source":{"type":{"type":"enum","values":{"source":1}},"source":{"type":"string"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0}
1,"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"type":"enum","values":{"video":1}},"urls":{"type":"array","value":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"type":"enum","values":{"image":1}},"url":{"type":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"modelNodeOverride":{"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360}},"modelNodeOverrides":{"*":{"type":"modelNodeOverride"}},"modelMaterialOverride":{"model-color":{"type":"color"},"model-color-mix-intensity":{"type":"number"},"model-opacity":{"type":"number"},"model-emissive-strength":{"type":"number"}},"modelMaterialOverrides":{"*":{"type":"modelMaterialOverride"}},"modelSourceModel":{"uri":{"type":"string"},"position":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[-180,-90],"maximum":[180,90]},"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360},"nodeOverrides":{"type":"modelNodeOverrides"},"materialOverrides":{"type":"modelMaterialOverrides"},"nodeOverrideNames":{"type":"array","value":"string"},"materialOverrideNames":{"type":"array","value":"string"},"featureProperties":{"type":"*"}},"modelSourceModels":{"*":{"type":"modelSourceModel"}},"source_model":{"type":{"type":"enum","values":{"model":1,"batched-model":1}},"url":{"type":"string"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"},"models":{"type":"modelSourceModels"}},"layer":{"id":{"type":"string"},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"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"},"appearances":{"type":"array","value":"appearance","supported-layer-types":["symbol"]}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":true,"parameters":["zoom","pitch","feature","feature-state","measure-light","distance-from-center"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_building","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"model-allow-density-reduction":{"type":"boolean","default":true}},"layout_clip":{"clip-layer-types":{"type":"array","value":"enum","values":{"model":1,"symbol":1},"default":[],"expression":{}},"clip-layer-scope":{"type":"array","value":"string","default":[],"expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"default":"none","expression":{}},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-markup":1},"default":"none","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"source-max-zoom":{"type":"number","minimum":0,"maximum":24}},"layout_building":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","minimum":1,"maximum":200,"default":3,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-unit-width":{"type":"number","minimum":1,"maximum":20,"default":3.1,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-window":{"type":"array","length":2,"value":"number","minimum":0.1,"maximum":1,"default":[0.9,0.9],"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-roof-shape":{"type":"enum","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"default":"flat","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flip-roof-orientation":{"property-type":"data-driven","type":"boolean","default":false,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1,"none":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["zoom","feature","line-progress"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"default":"none","expression":{}},"line-cross-slope":{"type":"number","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"line-width-unit":{"type":"enum","values":{"pixels":1,"meters":1},"default":"pixels","expression":{"parameters":["zoom"]}},"line-elevation-ground-scale":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","line-progress"]},"transition":true,"property-type":"data-driven"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{"parameters":["zoom"]}},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"appearance":true,"use-theme":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}
1,"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]}},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_hillshade":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster-particle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_clip":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_model":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_building":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"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":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","meas
1ure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"}
1,"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"line-blend-mode":{"type":"enum","values":{"default":1,"multiply":1,"additive":1},"default":"default","expression":{"parameters":["zoom"]}},"line-blend-additive-clamp":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"n
1umber","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}},"model-ignore-line-cutout":{"type":"boolean","default":false,"expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function Uc(n){return n instanceof Number||n instanceof String||n instanceof Boolean?n.valueOf():n}function Vc(n){if(Array.isArray(n))return n.map(Vc);if(n instanceof Object&&!(n instanceof Number||n instanceof String||n instanceof Boolean)){let e={};for(let i in n)e[i]=Vc(n[i]);return e}return Uc(n)}function jc(n){if(n===!0||n===!1)return!0;if(!Array.isArray(n)||n.length===0)return!1;switch(n[0]){case"has":return n.length>=2&&n[1]!=="$id"&&n[1]!=="$type";case"in":return n.length>=3&&(typeof n[1]!="string"||Array.isArray(n[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return n.length!==3||Array.isArray(n[1])||Array.isArray(n[2]);case"any":case"all":for(let e of n.slice(1))if(!jc(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function oo(n,e="",i=null,r="fill"){if(n==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};jc(n)||(n=th(n));let s=n,l=!0;try{l=function(x){if(!El(x))return x;let b=Vc(x);return Kf(b),b=Jf(b),b}(s)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
2This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
3and paste the contents of this message in the report.
4Thank you!
5Filter Expression:
6${JSON.stringify(s,null,2)}
7        `)}let u=null,p=null;if(r!=="background"&&r!=="sky"&&r!=="slot"){p=he[`filter_${r}`];let x=Pa(l,p,e,i);if(x.result==="error")throw new Error(x.value.map(b=>`${b.key}: ${b.message}`).join(", "));u=(b,w,S)=>x.value.evaluate(b,w,{},S)}let f=null,g=null;if(l!==s){let x=Pa(s,p,e,i);if(x.result==="error")throw new Error(x.value.map(b=>`${b.key}: ${b.message}`).join(", "));f=(b,w,S,I,M)=>x.value.evaluate(b,w,{},S,void 0,void 0,I,M),g=!Ma(x.value.expression)}return{filter:u,dynamicFilter:f||void 0,needGeometry:em(l),needFeature:!!g}}function Jf(n){if(!Array.isArray(n))return n;let e=function(i){if(ng.has(i[0])){for(let r=1;r<i.length;r++)if(El(i[r]))return!0}return i}(n);return e===!0?e:e.map(i=>Jf(i))}function Kf(n){let e=!1,i=[];if(n[0]==="case"){for(let r=1;r<n.length-1;r+=2)e=e||El(n[r]),i.push(n[r+1]);i.push(n.at(-1))}else if(n[0]==="match"){e=e||El(n[1]);for(let r=2;r<n.length-1;r+=2)i.push(n[r+1]);i.push(n.at(-1))}else if(n[0]==="step"){e=e||El(n[1]);for(let r=1;r<n.length-1;r+=2)i.push(n[r+1])}e&&(n.length=0,n.push("any",...i));for(let r=1;r<n.length;r++)Kf(n[r])}function El(n){if(!Array.isArray(n))return!1;if((e=n[0])==="pitch"||e==="distance-from-center")return!0;var e;
7for(let i=1;i<n.length;i++)if(El(n[i]))return!0;return!1}let ng=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Qf(n,e){return n<e?-1:n>e?1:0}function em(n){if(!Array.isArray(n))return!1;if(n[0]==="within"||n[0]==="distance")return!0;for(let e=1;e<n.length;e++)if(em(n[e]))return!0;return!1}function th(n){if(!n)return!0;let e=n[0];return n.length<=1?e!=="any":e==="=="?Fd(n[1],n[2],"=="):e==="!="?Fa(Fd(n[1],n[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Fd(n[1],n[2],e):e==="any"?(i=n.slice(1),["any"].concat(i.map(th))):e==="all"?["all"].concat(n.slice(1).map(th)):e==="none"?["all"].concat(n.slice(1).map(th).map(Fa)):e==="in"?Bd(n[1],n.slice(2)):e==="!in"?Fa(Bd(n[1],n.slice(2))):e==="has"?Oa(n[1]):e!=="!has"||Fa(Oa(n[1]));var i}function Fd(n,e,i){switch(n){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,n,e]}}function Bd(n,e){if(e.length===0)return!1;switch(n){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(i=>typeof i!=typeof e[0])?["filter-in-large",n,["literal",e.sort(Qf)]]:["filter-in-small",n,["literal",e]]}}function Oa(n){switch(n){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",n]}}function Fa(n){return["!",n]}let Il="�";function Ns(n,e){return e?`${n}${Il}${e}`:n}function tm(n){let e=n.indexOf(Il);return e>=0?n.slice(e+1):""}let im,nm=()=>im||(im=new Ti({"icon-size":new Ze(he.layout_symbol["icon-size"]),"icon-image":new Ze(he.layout_symbol["icon-image"]),"icon-rotate":new Ze(he.layout_symbol["icon-rotate"]),"icon-offset":new Ze(he.layout_symbol["icon-offset"]),"text-size":new Ze(he.layout_symbol["text-size"]),"text-rotate":new Ze(he.layout_symbol["text-rotate"]),"text-offset":new Ze(he.layout_symbol["text-offset"])})),rm,om=()=>rm||(rm=new Ti({"icon-opacity":new Ze(he.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Ze(he.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Ze(he.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ze(he.paint_symbol["text-emissive-strength"]),"icon-color":new Ze(he.paint_symbol["icon-color"]),"icon-halo-color":new Ze(he.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ze(he.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ze(he.paint_symbol["icon-halo-blur"]),"icon-translate":new Ze(he.paint_symbol["icon-translate"]),"text-opacity":new Ze(he.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Ze(he.paint_symbol["text-occlusion-opacity"]),"text-color":new Ze(he.paint_symbol["text-color"],{runtimeType:on,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new Ze(he.paint_symbol["text-halo-color"]),"text-halo-width":new Ze(he.paint_symbol["text-halo-width"]),"text-halo-blur":new Ze(he.paint_symbol["text-halo-blur"]),"text-translate":new Ze(he.paint_symbol["text-translate"]),"symbol-z-offset":new Ze(he.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}));class rg{constructor(e,i,r,s,l,u){this._conditionSpec=e,this._propertiesSpec=r;let p=Pa(e,he.appearance.condition);if(p.result==="success"&&(this.condition=p.value),this.name=i,r){this.layoutProperties=new is(nm()),this.unevaluatedLayout=new Nc(nm(),s,l,u),this.paintProperties=new is(om()),this.unevaluatedPaint=new Nc(om(),s,l,"");for(let f in r)f in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(f,r[f]):f in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(f,r[f])}}isActive(e){return!(this.condition||!e.isHidden||this.name!=="hidden")||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,i,r){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,i,r)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,i,""))}serialize(){let e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);let i=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},r=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},s=Object.assign({},i,r);return Object.keys(s).length>0&&(e.properties=s),e}hasIconLayoutProperties(){let e=this.hasLayoutProperty("icon-image"),i=this.hasLayoutProperty("icon-size"),r=this.hasLayoutProperty("icon-offset"),s=this.hasLayoutProperty("icon-rotate");return e||i||r||s}hasTextLayoutProperties(){let e=this.hasLayoutProperty("text-size"),i=this.hasLayoutProperty("text-offset"),r=this.hasLayoutProperty("text-rotate");return e||i||r}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||e==="symbol-z-offset")&&this.hasPaintProperty(e))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||e==="symbol-z-offset")&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&this.unevaluatedLayout._values[e].value!==void 0}hasPaintProperty(e){return this.unevaluatedPaint&&this.unevaluatedPaint._values[e].value!==void 0}}let sm="-transition",am=new Set(["fill","line","background","hillshade","raster"]);class or extends ol{constructor(e,i,r,s,l,u){if(super(),this.id=e.id,this.fqid=Ns(this.id,r),this.type=e.type,this.scope=r,this.lut=s,this.options=l,this.iconImageUseTheme=u,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},e.type!=="custom"){if(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&e.type!=="background"&&e.type!=="sky"&&e.type!=="slot"){this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter;let p=Pa(this.filter,he[`filter_${e.type}`]);p.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...p.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||p.value.isIndoorDependent)}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),i.layout&&(this._unevaluatedLayout=new Nc(i.layout,this.scope,l,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),i.paint){this._transitionablePaint=new Yf(i.paint,this.scope,l);for(let p in e.paint)this.setPaintProperty(p,e.paint[p]);for(let p in e.layout)this.setLayoutProperty(p,e.layout[p]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new is(i.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&am.has(this.type)}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}
7setLayoutProperty(e,i){if(this.type==="custom"&&e==="visibility")return void(this.visibility=i);let r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,i),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),e==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach(i=>{this.appearances.push(new rg(i.condition,i.name,i.properties,this.scope,this.options,this.iconImageUseTheme))}),this.appearancesVersion++}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(sm)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return!!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,i){let r=this._transitionablePaint,s=r._properties.properties;if(e.endsWith(sm)){let b=e.slice(0,-11);return s[b]&&r.setTransition(b,i||void 0),!1}if(!s[e])return!1;let l=r._values[e],u=l.value.isDataDriven(),p=l.value;r.setValue(e,i),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);let f=r._values[e].value,g=f.isDataDriven(),x=e.endsWith("pattern")||e==="line-dasharray";return g||u||x||this._handleOverridablePaintPropertyUpdate(e,p,f)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,i,r){return null}_handleOverridablePaintPropertyUpdate(e,i,r){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}
7serialize(){let e={id:this.id,type:this.type,slot:this.slot,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.appearances.length!==0&&(e.appearances=this.appearances.map(i=>i.serialize())),Ve(e,(i,r)=>!(i===void 0||r==="layout"&&!Object.keys(i).length||r==="paint"&&!Object.keys(i).length))}is3D(e){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(let e in this.paint._values){let i=this.paint.get(e);if(i instanceof ks&&$u(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}for(let e of this.appearances)if(!fl(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=oo(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&(e.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(e,i,r){return{}}queryRadius(e){}queryIntersectsFeature(e,i,r,s,l,u,p,f,g,x){}}let og={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Gc{constructor(e,i){this._structArray=e,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}let sg=new ArrayBuffer(0);class gi{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(e,i){return e._trim(),i&&e.arrayBuffer&&i.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){let i=Object.create(this.prototype);return i.arrayBuffer=e.arrayBuffer,i.length=e.length,e.arrayBuffer?i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement:(i.capacity=0,i.arrayBuffer=sg),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(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this._reallocCount++,this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}reserveForAdditional(e){this.reserve(this.length+e)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Rt(n,e=1){let i=0,r=0;return{members:n.map(s=>{let l=og[s.type].BYTES_PER_ELEMENT,u=i=kd(i,Math.max(e,l)),p=s.components||1;return r=Math.max(r,l),i+=l*p,{name:s.name,type:s.type,components:p,offset:u}}),size:kd(i,Math.max(r,e)),alignment:e}}function kd(n,e){return Math.ceil(n/e)*e}class Zn extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let s=2*e;return this.int16[s+0]=i,this.int16[s+1]=r,e}}Zn.prototype.bytesPerElement=4,Qe(Zn,"StructArrayLayout2i4");class Us extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}
vendor: 18,521 bytes, line 7
7emplace(e,i,r,s){let l=3*e;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=s,e}}Us.prototype.bytesPerElement=6,Qe(Us,"StructArrayLayout3i6");class Ba extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=4*e;return this.int16[u+0]=i,this.int16[u+1]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,e}}Ba.prototype.bytesPerElement=8,Qe(Ba,"StructArrayLayout2i2ui8");class Lo extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[1*e+0]=i,e}}Lo.prototype.bytesPerElement=4,Qe(Lo,"StructArrayLayout1f4");class so extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}emplace(e,i,r,s){let l=4*e,u=2*e;return this.int16[l+0]=i,this.int16[l+1]=r,this.float32[u+1]=s,e}}so.prototype.bytesPerElement=8,Qe(so,"StructArrayLayout2i1f8");class ih extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}emplace(e,i,r,s){let l=4*e;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=s,e}}ih.prototype.bytesPerElement=8,Qe(ih,"StructArrayLayout3i8");class Hc extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=4*e;return this.int16[u+0]=i,this.int16[u+1]=r,this.int16[u+2]=s,this.int16[u+3]=l,e}}Hc.prototype.bytesPerElement=8,Qe(Hc,"StructArrayLayout4i8");class Nd extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,s,l)}emplace(e,i,r,s,l,u){let p=5*e;return this.int16[p+0]=i,this.int16[p+1]=r,this.int16[p+2]=s,this.int16[p+3]=l,this.int16[p+4]=u,e}}Nd.prototype.bytesPerElement=10,Qe(Nd,"StructArrayLayout5i10");class Ud extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,s,l,u,p)}emplace(e,i,r,s,l,u,p,f){let g=6*e,x=12*e,b=3*e;return this.int16[g+0]=i,this.int16[g+1]=r,this.uint8[x+4]=s,this.uint8[x+5]=l,this.uint8[x+6]=u,this.uint8[x+7]=p,this.float32[b+2]=f,e}}Ud.prototype.bytesPerElement=12,Qe(Ud,"StructArrayLayout2i4ub1f12");class Ur extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}emplace(e,i,r,s){let l=3*e;return this.float32[l+0]=i,this.float32[l+1]=r,this.float32[l+2]=s,e}}Ur.prototype.bytesPerElement=12,Qe(Ur,"StructArrayLayout3f12");class Vs extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,s,l)}emplace(e,i,r,s,l,u){let p=6*e,f=3*e;return this.uint16[p+0]=i,this.uint16[p+1]=r,this.uint16[p+2]=s,this.uint16[p+3]=l,this.float32[f+2]=u,e}}Vs.prototype.bytesPerElement=12,Qe(Vs,"StructArrayLayout4ui1f12");class Al extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=4*e;return this.uint16[u+0]=i,this.uint16[u+1]=r,this.uint16[u+2]=s,this.uint16[u+3]=l,e}}Al.prototype.bytesPerElement=8,Qe(Al,"StructArrayLayout4ui8");class nh extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,s,l,u)}emplace(e,i,r,s,l,u,p){let f=6*e;return this.int16[f+0]=i,this.int16[f+1]=r,this.int16[f+2]=s,this.int16[f+3]=l,this.int16[f+4]=u,this.int16[f+5]=p,e}}nh.prototype.bytesPerElement=12,Qe(nh,"StructArrayLayout6i12");class Vd extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b,w){let S=this.length;return this.resize(S+1),this.emplace(S,e,i,r,s,l,u,p,f,g,x,b,w)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S){let I=12*e;return this.int16[I+0]=i,this.int16[I+1]=r,this.int16[I+2]=s,this.int16[I+3]=l,this.uint16[I+4]=u,this.uint16[I+5]=p,this.uint16[I+6]=f,this.uint16[I+7]=g,this.int16[I+8]=x,this.int16[I+9]=b,this.int16[I+10]=w,this.int16[I+11]=S,e}}Vd.prototype.bytesPerElement=24,Qe(Vd,"StructArrayLayout4i4ui4i24");class jd extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,s,l,u)}emplace(e,i,r,s,l,u,p){let f=10*e,g=5*e;return this.int16[f+0]=i,this.int16[f+1]=r,this.int16[f+2]=s,this.float32[g+2]=l,this.float32[g+3]=u,this.float32[g+4]=p,e}}jd.prototype.bytesPerElement=20,Qe(jd,"StructArrayLayout3i3f20");class js extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=4*e;return this.float32[u+0]=i,this.float32[u+1]=r,this.float32[u+2]=s,this.float32[u+3]=l,e}}js.prototype.bytesPerElement=16,Qe(js,"StructArrayLayout4f16");class rh extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[1*e+0]=i,e}}rh.prototype.bytesPerElement=4,Qe(rh,"StructArrayLayout1ul4");class Vr extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let s=2*e;return this.uint16[s+0]=i,this.uint16[s+1]=r,e}}Vr.prototype.bytesPerElement=4,Qe(Vr,"StructArrayLayout2ui4");class Ml extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b,w,S){let I=this.length;return this.resize(I+1),this.emplace(I,e,i,r,s,l,u,p,f,g,x,b,w,S)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S,I){let M=20*e,C=10*e;return this.int16[M+0]=i,this.int16[M+1]=r,this.int16[M+2]=s,this.int16[M+3]=l,this.int16[M+4]=u,this.float32[C+3]=p,this.float32[C+4]=f,this.float32[C+5]=g,this.float32[C+6]=x,this.int16[M+14]=b,this.uint32[C+8]=w,this.uint16[M+18]=S,this.uint16[M+19]=I,e}}Ml.prototype.bytesPerElement=40,Qe(Ml,"StructArrayLayout5i4f1i1ul2ui40");class oh extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,s,l,u,p)}emplace(e,i,r,s,l,u,p,f){let g=8*e;return this.int16[g+0]=i,this.int16[g+1]=r,this.int16[g+2]=s,this.int16[g+4]=l,this.int16[g+5]=u,this.int16[g+6]=p,this.int16[g+7]=f,e}}oh.prototype.bytesPerElement=16,Qe(oh,"StructArrayLayout3i2i2i16");class Gd extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,s,l)}emplace(e,i,r,s,l,u){let p=4*e,f=8*e;return this.float32[p+0]=i,this.float32[p+1]=r,this.float32[p+2]=s,this.int16[f+6]=l,this.int16[f+7]=u,e}}Gd.prototype.bytesPerElement=16,Qe(Gd,"StructArrayLayout2f1f2i16");class zo extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,s,l,u)}emplace(e,i,r,s,l,u,p){let f=20*e,g=5*e;return this.uint8[f+0]=i,this.uint8[f+1]=r,this.float32[g+1]=s,this.float32[g+2]=l,this.float32[g+3]=u,this.float32[g+4]=p,e}}zo.prototype.bytesPerElement=20,Qe(zo,"StructArrayLayout2ub4f20");class Yi extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r){let s=this.length;return this.resize(s+1),this.emplace(s,e,i,r)}emplace(e,i,r,s){let l=3*e;return this.uint16[l+0]=i,this.uint16[l+1]=r,this.uint16[l+2]=s,e}}Yi.prototype.bytesPerElement=6,Qe(Yi,"StructArrayLayout3ui6");class Gs extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F,L,j,H){let $=this.length;return this.resize($+1),this.emplace($,e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F,L,j,H)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F,L,j,H,$){let ie=30*e,W=15*e,Q=60*e;return this.int16[ie+0]=i,this.int16[ie+1]=r,this.int16[ie+2]=s,this.float32[W+2]=l,this.float32[W+3]=u,this.uint16[ie+8]=p,this.uint16[ie+9]=f,this.uint32[W+5]=g,this.uint32[W+6]=x,this.uint32[W+7]=b,this.uint16[ie+16]=w,this.uint16[ie+17]=S,this.uint16[ie+18]=I,this.float32[W+10]=M,this.float32[W+11]=C,this.uint8[Q+48]=R,this.uint8[Q+49]=F,this.uint8[Q+50]=L,this.uint32[W+13]=j,this.int16[ie+28]=H,this.uint8[Q+58]=$,e}}Gs.prototype.bytesPerElement=60,Qe(Gs,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Hd extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F,L,j,H,$,ie,W,Q,Y,ee,me,ge,Te,Ae,Ie,Be){let xe=this.length;return this.resize(xe+1),this.emplace(xe,e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F,L,j,H,$,ie,W,Q,Y,ee,me,ge,Te,Ae,Ie,Be)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F,L,j,H,$,ie,W,Q,Y,ee,me,ge,Te,Ae,Ie,Be,xe){let Se=20*e,Me=40*e,Le=80*e;return this.float32[Se+0]=i,this.float32[Se+1]=r,this.int16[Me+4]=s,this.int16[Me+5]=l,this.int16[Me+6]=u,this.int16[Me+7]=p,this.int16[Me+8]=f,this.int16[Me+9]=g,this.int16[Me+10]=x,this.int16[Me+11]=b,this.int16[Me+12]=w,this.uint16[Me+13]=S,this.uint16[Me+14]=I,this.uint16[Me+15]=M,this.uint16[Me+16]=C,this.uint16[Me+17]=R,this.uint16[Me+18]=F,this.uint16[Me+19]=L,this.uint16[Me+20]=j,this.uint16[Me+21]=H,this.uint16[Me+22]=$,this.uint16[Me+23]=ie,this.uint16[Me+24]=W,this.uint16[Me+25]=Q,this.uint16[Me+26]=Y,this.uint16[Me+27]=ee,this.uint32[Se+14]=me,this.float32[Se+15]=ge,this.float32[Se+16]=Te,this.float32[Se+17]=Ae,this.float32[Se+18]=Ie,this.uint8[Le+76]=Be,this.uint16[Me+39]=xe,e}}Hd.prototype.bytesPerElement=80,Qe(Hd,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class $d extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u){let p=this.length;return this.resize(p+1),this.emplace(p,e,i,r,s,l,u)}emplace(e,i,r,s,l,u,p){let f=6*e;return this.float32[f+0]=i,this.float32[f+1]=r,this.float32[f+2]=s,this.float32[f+3]=l,this.float32[f+4]=u,this.float32[f+5]=p,e}}$d.prototype.bytesPerElement=24,Qe($d,"StructArrayLayout6f24");class ka extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l){let u=this.length;return this.resize(u+1),this.emplace(u,e,i,r,s,l)}emplace(e,i,r,s,l,u){let p=5*e;return this.float32[p+0]=i,this.float32[p+1]=r,this.float32[p+2]=s,this.float32[p+3]=l,this.float32[p+4]=u,e}}ka.prototype.bytesPerElement=20,Qe(ka,"StructArrayLayout5f20");class qd extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,s,l,u,p)}emplace(e,i,r,s,l,u,p,f){let g=7*e;return this.float32[g+0]=i,this.float32[g+1]=r,this.float32[g+2]=s,this.float32[g+3]=l,this.float32[g+4]=u,this.float32[g+5]=p,this.float32[g+6]=f,e}}qd.prototype.bytesPerElement=28,Qe(qd,"StructArrayLayout7f28");class Zd extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b){let w=this.length;return this.resize(w+1),this.emplace(w,e,i,r,s,l,u,p,f,g,x,b)}emplace(e,i,r,s,l,u,p,f,g,x,b,w){let S=11*e;return this.float32[S+0]=i,this.float32[S+1]=r,this.float32[S+2]=s,this.float32[S+3]=l,this.float32[S+4]=u,this.float32[S+5]=p,this.float32[S+6]=f,this.float32[S+7]=g,this.float32[S+8]=x,this.float32[S+9]=b,this.float32[S+10]=w,e}}Zd.prototype.bytesPerElement=44,Qe(Zd,"StructArrayLayout11f44");class fr extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g){let x=this.length;return this.resize(x+1),this.emplace(x,e,i,r,s,l,u,p,f,g)}emplace(e,i,r,s,l,u,p,f,g,x){let b=9*e;return this.float32[b+0]=i,this.float32[b+1]=r,this.float32[b+2]=s,this.float32[b+3]=l,this.float32[b+4]=u,this.float32[b+5]=p,this.float32[b+6]=f,this.float32[b+7]=g,this.float32[b+8]=x,e}}fr.prototype.bytesPerElement=36,Qe(fr,"StructArrayLayout9f36");class sr extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){let r=this.length;return this.resize(r+1),this.emplace(r,e,i)}emplace(e,i,r){let s=2*e;return this.float32[s+0]=i,this.float32[s+1]=r,e}}sr.prototype.bytesPerElement=8,Qe(sr,"StructArrayLayout2f8");class sh extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,r,s){let l=this.length;return this.resize(l+1),this.emplace(l,e,i,r,s)}emplace(e,i,r,s,l){let u=6*e;return this.uint32[3*e+0]=i,this.uint16[u+2]=r,this.uint16[u+3]=s,this.uint16[u+4]=l,e}}sh.prototype.bytesPerElement=12,Qe(sh,"StructArrayLayout1ul3ui12");class Cl extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[1*e+0]=i,e}}Cl.prototype.bytesPerElement=2,Qe(Cl,"StructArrayLayout1ui2");class Pl extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C){let R=this.length;return this.resize(R+1),this.emplace(R,e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C)}emplace(e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R){let F=16*e;return this.float32[F+0]=i,this.float32[F+1]=r,this.float32[F+2]=s,this.float32[F+3]=l,this.float32[F+4]=u,this.float32[F+5]=p,this.float32[F+6]=f,this.float32[F+7]=g,this.float32[F+8]=x,this.float32[F+9]=b,this.float32[F+10]=w,this.float32[F+11]=S,this.float32[F+12]=I,this.float32[F+13]=M,this.float32[F+14]=C,this.float32[F+15]=R,e}}Pl.prototype.bytesPerElement=64,Qe(Pl,"StructArrayLayout16f64");class Dl extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,r,s,l,u,p){let f=this.length;return this.resize(f+1),this.emplace(f,e,i,r,s,l,u,p)}emplace(e,i,r,s,l,u,p,f){let g=10*e,x=5*e;return this.uint16[g+0]=i,this.uint16[g+1]=r,this.uint16[g+2]=s,this.uint16[g+3]=l,this.float32[x+2]=u,this.float32[x+3]=p,this.float32[x+4]=f,e}}Dl.prototype.bytesPerElement=20,Qe(Dl,"StructArrayLayout4ui3f20");class Rl extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.int16[1*e+0]=i,e}}Rl.prototype.bytesPerElement=2,Qe(Rl,"StructArrayLayout1i2");class Ll extends gi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){let i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint8[1*e+0]=i,e}}Ll.prototype.bytesPerElement=1,Qe(Ll,"StructArrayLayout1ub1");class Wd extends Gc{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Wd.prototype.size=40;class $c extends Ml{get(e){return new Wd(this,e)}}Qe($c,"CollisionBoxArray");class zl extends Gc{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}
vendor: 5,877 bytes, line 7
7get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}zl.prototype.size=60;class Xd extends Gs{get(e){return new zl(this,e)}}Qe(Xd,"PlacedSymbolArray");class lm extends Gc{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}lm.prototype.size=80;class cm extends Hd{get(e){return new lm(this,e)}}Qe(cm,"SymbolInstanceArray");class Yd extends Lo{getoffsetX(e){return this.float32[1*e+0]}}Qe(Yd,"GlyphOffsetArray");class um extends Zn{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Qe(um,"SymbolLineVertexArray");class wo extends Gc{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]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}wo.prototype.size=12;class hm extends sh{get(e){return new wo(this,e)}}Qe(hm,"FeatureIndexArray");class Jd extends Vr{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Qe(Jd,"FillExtrusionCentroidArray");class dm extends Gc{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}dm.prototype.size=6;class pm extends Us{get(e){return new dm(this,e)}}Qe(pm,"FillExtrusionWallArray");let ag=Rt([{name:"a_pos",components:2,type:"Int16"}],4),lg=Rt([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),cg=Rt([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class pi{constructor(e=[]){this.segments=e}_prepareSegment(e,i,r,s,l){let u=this.segments.at(-1);return e>pi.MAX_VERTEX_ARRAY_LENGTH&&Bt(`Max vertices per segment is ${pi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!u||u.vertexLength+e>pi.MAX_VERTEX_ARRAY_LENGTH||u.sortKey!==s||l!==void 0&&u&&u.batchIndex!==void 0&&u.batchIndex!==l)&&(u={vertexOffset:i,primitiveOffset:r,vertexLength:0,primitiveLength:0},s!==void 0&&(u.sortKey=s),l!==void 0&&(u.batchIndex=l),this.segments.push(u)),u}prepareSegment(e,i,r,s,l){return this._prepareSegment(e,i.length,r.length,s,l)}get(){return this.segments}destroy(){for(let e of this.segments)for(let i in e.vaos)e.vaos[i].destroy()}
7static simpleSegment(e,i,r,s){return new pi([{vertexOffset:e,primitiveOffset:i,vertexLength:r,primitiveLength:s,vaos:{},sortKey:0}])}}function Ol(n,e){return 256*(n=ne(Math.floor(n),0,255))+ne(Math.floor(e),0,255)}pi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Qe(pi,"SegmentVector");let ug=Rt([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),ah=Rt([{name:"a_pattern_b",components:4,type:"Uint16"}]),Kd=Rt([{name:"a_dash",components:4,type:"Uint16"}]);class Fl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,i,r,s){this.ids.push(Qd(e)),this.positions.push(i,r,s)}eachPosition(e,i){let r=Qd(e),s=0,l=this.ids.length-1;for(;s<l;){let u=s+l>>1;this.ids[u]>=r?l=u:s=u+1}for(;this.ids[s]===r;)i(this.positions[3*s],this.positions[3*s+1],this.positions[3*s+2]),s++}static serialize(e,i){let r=new Float64Array(e.ids),s=new Uint32Array(e.positions);return ep(r,s,0,r.length-1),i&&(i.add(r.buffer),i.add(s.buffer)),{ids:r,positions:s}}static deserialize(e){let i=new Fl,r;i.ids=e.ids,i.positions=e.positions;for(let s of i.ids)s!==r&&i.uniqueIds.push(s),r=s;return i.indexed=!0,i}}function Qd(n){let e=+n;return Number.isSafeInteger(e)?e:pc(String(n))}function ep(n,e,i,r){for(;i<r;){let s=n[i+r>>1],l=i-1,u=r+1;for(;;){do l++;while(n[l]<s);do u--;while(n[u]>s);if(l>=u)break;qc(n,l,u),qc(e,3*l,3*u),qc(e,3*l+1,3*u+1),qc(e,3*l+2,3*u+2)}u-i<r-u?(ep(n,e,i,u),i=u+1):(ep(n,e,u+1,r),r=u)}}function qc(n,e,i){let r=n[e];n[e]=n[i],n[i]=r}Qe(Fl,"FeaturePositionMap");class Oo{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,i){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,i),this.initialized=!0),!!this.location}set(e,i,r){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class lh extends Oo{constructor(e){super(e),this.current=0}set(e,i,r){this.fetchUniformLocation(e,i)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}}class ln extends Oo{constructor(e){super(e),this.current=0}set(e,i,r){this.fetchUniformLocation(e,i)&&this.current!==r&&(this.current=r,this.gl.uniform1f(this.location,r))}}class mr extends Oo{constructor(e){super(e),this.current=[0,0]}set(e,i,r){this.fetchUniformLocation(e,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])))}}class Zc extends Oo{constructor(e){super(e),this.current=[0,0,0]}set(e,i,r){this.fetchUniformLocation(e,i)&&(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])))}}class hg extends Oo{constructor(e){super(e),this.current=[0,0,0,0]}set(e,i,r){this.fetchUniformLocation(e,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4ui(this.location,r[0],r[1],r[2],r[3])))}}class tp extends Oo{constructor(e){super(e),this.current=[0,0,0,0]}set(e,i,r){this.fetchUniformLocation(e,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4f(this.location,r[0],r[1],r[2],r[3])))}}class fm extends Oo{constructor(e){super(e),this.current=Ht.transparent.toPremultipliedRenderColor(null)}set(e,i,r){this.fetchUniformLocation(e,i)&&(r.r===this.current.r&&r.g===this.current.g&&r.b===this.current.b&&r.a===this.current.a||(this.current=r,this.gl.uniform4f(this.location,r.r,r.g,r.b,r.a)))}}class Wc extends Oo{constructor(e){super(e),this.current=new Float32Array(16)}set(e,i,r){if(!this.fetchUniformLocation(e,i))return;let s=this.current;if(r[12]!==s[12]||r[0]!==s[0])return s.set(r),void this.gl.uniformMatrix4fv(this.location,!1,s);for(let l=1;l<16;l++)if(r[l]!==s[l]){s.set(r),this.gl.uniformMatrix4fv(this.location,!1,s);break}}}class Bl extends Oo{constructor(e){super(e),this.current=new Float32Array(4)}set(e,i,r){if(!this.fetchUniformLocation(e,i))return;let s=this.current;for(let l=0;l<4;l++)if(r[l]!==s[l]){s.set(r),this.gl.uniformMatrix2fv(this.location,!1,s);break}}}function kl(n){return[Ol(255*n.r,255*n.g),Ol(255*n.b,255*n.a)]}function ar(n,e,i,r,s,l,u,p){return!!n&&(n.kind==="composite"||n.kind==="source"?n.evaluate(new Jt(0,{brightness:l,worldview:p}),e,i,s,r,u)==="none":n.value==="none")}
7class Na{constructor(e,i,r,s){this.value=e,this.uniformNames=i.map(l=>`u_${l}`),this.type=r,this.context=s}setUniform(e,i,r,s,l){let u=s.constantOr(this.value);i.set(e,l,u instanceof Ht?u.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):u)}getBinding(e,i){return this.type==="color"?new fm(e):new ln(e)}}class Xc{constructor(e,i){this.uniformNames=i.map(r=>`u_${r}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(e,i){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=i?i.tl.concat(i.br):this.pattern}setUniform(e,i,r,s,l){let u=null;l!=="u_pattern"&&l!=="u_dash"||(u=this.pattern),l==="u_pattern_b"&&(u=this.patternTransition),l==="u_pixel_ratio"&&(u=this.pixelRatio),u&&i.set(e,l,u)}getBinding(e,i){return i==="u_pattern"||i==="u_pattern_b"||i==="u_dash"?new hg(e):new ln(e)}}class ns{constructor(e,i,r,s){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=i.map(l=>({name:`a_${l}`,type:"Float32",components:r==="color"?2:1,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,i,r,s,l,u,p,f){let g=this.paintVertexArray.length,x=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Jt(0,{brightness:u,worldview:f}),i,{},l,s,p):this.expression.kind==="constant"&&this.expression.value,b=ar(this.lutExpression,i,{},s,l,u,p,f);this.paintVertexArray.resize(e),this._setPaintValue(g,e,x,b?null:this.context.lut)}updatePaintArray(e,i,r,s,l,u,p,f){let g=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:p,worldview:f},r,s,void 0,l):this.expression.kind==="constant"&&this.expression.value,x=ar(this.lutExpression,r,s,l,void 0,p,void 0,f);this._setPaintValue(e,i,g,x?null:this.context.lut)}_setPaintValue(e,i,r,s){if(this.type==="color"){let l=kl(r.toPremultipliedRenderColor(s));for(let u=e;u<i;u++)this.paintVertexArray.emplace(u,l[0],l[1])}else{for(let l=e;l<i;l++)this.paintVertexArray.emplace(l,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&this.lutExpression.kind!=="constant"&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||this.expression.kind!=="constant"&&(this.expression.isStateDependent||!this.expression.isLightConstant)))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Fo{constructor(e,i,r,s,l,u){this.expression=e,this.uniformNames=i.map(p=>`u_${p}_t`),this.type=r,this.useIntegerZoom=s,this.context=l,this.maxValue=0,this.paintVertexAttributes=i.map(p=>({name:`a_${p}`,type:"Float32",components:r==="color"?4:2,offset:0})),this.paintVertexArray=new u}populatePaintArray(e,i,r,s,l,u,p,f){let g=this.expression.evaluate(new Jt(this.context.zoom,{brightness:u,worldview:f}),i,{},l,s,p),x=this.expression.evaluate(new Jt(this.context.zoom+1,{brightness:u,worldview:f}),i,{},l,s,p),b=ar(this.lutExpression,i,{},s,l,u,p,f),w=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(w,e,g,x,b?null:this.context.lut)}updatePaintArray(e,i,r,s,l,u,p,f){let g=this.expression.evaluate({zoom:this.context.zoom,brightness:p,worldview:f},r,s,void 0,l),x=this.expression.evaluate({zoom:this.context.zoom+1,brightness:p,worldview:f},r,s,void 0,l),b=ar(this.lutExpression,r,s,l,void 0,p,void 0,f);this._setPaintValue(e,i,g,x,b?null:this.context.lut)}_setPaintValue(e,i,r,s,l){if(this.type==="color"){let u=kl(r.toPremultipliedRenderColor(l)),p=kl(s.toPremultipliedRenderColor(l));for(let f=e;f<i;f++)this.paintVertexArray.emplace(f,u[0],u[1],p[0],p[1])}else{for(let u=e;u<i;u++)this.paintVertexArray.emplace(u,r,s);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,i,r,s,l){let u=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,p=ne(this.expression.interpolationFactor(u,this.context.zoom,this.context.zoom+1),0,1);i.set(e,l,p)}getBinding(e,i){return new ln(e)}}class Bo{constructor(e,i,r,s,l){this.expression=e,this.layerId=l,this.paintVertexAttributes=(r==="array"?Kd:ug).members;for(let u=0;u<i.length;++u);this.paintVertexArray=new s,this.paintTransitionVertexArray=new Al}populatePaintArray(e,i,r,s){let l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(l,e,i.patterns&&i.patterns[this.layerId],r)}updatePaintArray(e,i,r,s,l,u,p){this._setPaintValues(e,i,r.patterns&&r.patterns[this.layerId],u)}_setPaintValues(e,i,r,s){if(!s||!r)return;let l=s[r[0]],u=s[r[1]];if(l){if(l){let{tl:p,br:f,pixelRatio:g}=l;for(let x=e;x<i;x++)this.paintVertexArray.emplace(x,p[0],p[1],f[0],f[1],g)}if(u){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);let{tl:p,br:f}=u;for(let g=e;g<i;g++)this.paintTransitionVertexArray.emplace(g,p[0],p[1],f[0],f[1])}}}upload(e){let i=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,i)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=e.createVertexBuffer(this.paintTransitionVertexArray,ah.members,i))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class rs{constructor(e,i,r=()=>!0){this.binders={},this._buffers=[],this.context=i;let s=[],l=e;for(let u in e.paint._values){let p=l.paint.get(u);if(u.endsWith("-use-theme")||!r(u)||!(p instanceof ks&&$u(p.property.specification)))continue;let f=dg(u,e.type),g=p.value,x=p.property.specification.type,b=!!p.property.useIntegerZoom,w=u==="line-dasharray"||u.endsWith("pattern"),S=l.paint.get(`${u}-use-theme`),I=u==="line-dasharray"&&l.layout.get("line-cap").value.kind!=="constant"||S&&S.value.kind!=="constant";if(g.kind!=="constant"||I)if(g.kind==="source"||I||w){let M=mm(u,x,"source");this.binders[u]=w?new Bo(g,f,x,M,e.id):new ns(g,f,x,M),s.push(`/a_${u}`)}else{let M=mm(u,x,"composite");this.binders[u]=new Fo(g,f,x,b,i,M),s.push(`/z_${u}`)}else this.binders[u]=w?new Xc(g.value,f):new Na(g.value,f,x,i),s.push(`/u_${u}`);S&&(this.binders[u].lutExpression=S.value)}this.cacheKey=s.sort().join("")}updateExpressions(e){let i=e;for(let r in this.binders){let s=this.binders[r];if(s instanceof ns||s instanceof Fo||s instanceof Bo){let l=i.paint.get(r);s.expression=l.value}}}getMaxValue(e){let i=this.binders[e];return i instanceof ns||i instanceof Fo?i.maxValue:0}populatePaintArrays(e,i,r,s,l,u,p,f){for(let g in this.binders){let x=this.binders[g];x.context=this.context,(x instanceof ns||x instanceof Fo||x instanceof Bo)&&x.populatePaintArray(e,i,r,s,l,u,p,f)}}setConstantPatternPositions(e,i){for(let r in this.binders){let s=this.binders[r];s instanceof Xc&&s.setConstantPatternPositions(e,i)}}getPatternTransitionVertexBuffer(e){let i=this.binders[e];return i instanceof Bo?i.paintTransitionVertexBuffer:null}updatePaintArrays(e,i,r,s,l,u,p,f,g,x){let b=!1,w=Object.keys(e),S=w.length!==0&&!f,I=S?w:i.uniqueIds;this.context.lut=l.lut;for(let M in this.binders){let C=this.binders[M];if(C.context=this.context,(C instanceof ns||C instanceof Fo||C instanceof Bo)&&C.expression&&C.expression.kind&&C.expression.kind!=="constant"&&(C.expression.isStateDependent===!0||C.expression.isLightConstant===!1)){let R=l.paint.get(M);C.expression=R.value;for(let F of I){let L=e[F.toString()];i.eachPosition(F,(j,H,$)=>{let ie=s.feature(j);C.updatePaintArray(H,$,ie,L,u,p,g,x)})}if(!S)for(let F of r.uniqueIds){let L=e[F.toString()];r.eachPosition(F,(j,H,$)=>{let ie=s.feature(j);C.updatePaintArray(H,$,ie,L,u,p,g,x)})}b=!0}}return b}
7defines(){let e=[];for(let i in this.binders){let r=this.binders[i];(r instanceof Na||r instanceof Xc)&&e.push(...r.uniformNames.map(s=>`#define HAS_UNIFORM_${s}`))}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){let i=[];for(let r in this.binders){let s=this.binders[r];if(s instanceof Na||s instanceof Xc||s instanceof Fo)for(let l of s.uniformNames)i.push({name:l,property:r,binding:s.getBinding(e,l)})}return i}setUniforms(e,i,r,s,l){for(let{name:u,property:p,binding:f}of r)this.binders[p].setUniform(e,f,l,s.get(p),u)}updatePaintBuffers(){this._buffers=[];for(let e in this.binders){let i=this.binders[e];(i instanceof ns||i instanceof Fo||i instanceof Bo)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer),i instanceof Bo&&i.paintTransitionVertexBuffer&&this._buffers.push(i.paintTransitionVertexBuffer)}}upload(e){for(let i in this.binders){let r=this.binders[i];(r instanceof ns||r instanceof Fo||r instanceof Bo)&&r.upload(e)}this.updatePaintBuffers()}destroy(){for(let e in this.binders){let i=this.binders[e];(i instanceof ns||i instanceof Fo||i instanceof Bo)&&i.destroy()}}}class To{constructor(e,i,r=()=>!0){this.programConfigurations={};for(let s of e)this.programConfigurations[s.id]=new rs(s,i,r);this.needsUpload=!1,this._featureMap=new Fl,this._featureMapWithoutIds=new Fl,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,i,r,s,l,u,p,f,g){for(let x in this.programConfigurations)this.programConfigurations[x].populatePaintArrays(e,i,s,l,u,p,f,g);i.id!==void 0?this._featureMap.add(i.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,r,s,l,u,p,f){for(let g of r)this.needsUpload=this.programConfigurations[g.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,i,g,s,l,u,p||0,f)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(let i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(let e in this.programConfigurations)this.programConfigurations[e].destroy()}updateExpressions(e){let i=new Set;for(let r of e){let s=this.programConfigurations[r.id];s&&(s.updateExpressions(r),i.add(r.id))}for(let r in this.programConfigurations)i.has(r)||delete this.programConfigurations[r]}}let ip={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function dg(n,e){return ip[n]||[n.replace(`${e}-`,"").replace(/-/g,"_")]}let pg={"line-pattern":{source:Vs,composite:Vs},"fill-pattern":{source:Vs,composite:Vs},"fill-extrusion-pattern":{source:Vs,composite:Vs},"line-dasharray":{source:Al,composite:Al}},fg={color:{source:sr,composite:js},number:{source:Lo,composite:sr}};function mm(n,e,i){let r=pg[n];return r&&r[i]||fg[e][i]}Qe(Na,"ConstantBinder"),Qe(Xc,"PatternConstantBinder"),Qe(ns,"SourceExpressionBinder",{omit:["expression"]}),Qe(Bo,"PatternCompositeBinder",{omit:["expression"]}),Qe(Fo,"CompositeExpressionBinder",{omit:["expression"]}),Qe(rs,"ProgramConfiguration",{omit:["_buffers"]}),Qe(To,"ProgramConfigurationSet");let er=Xe/Math.PI/2,Hs=64,np=[Hs,32,16],jr=-er,Gr=er;function Nl(n,e,i,r=er){return i=V(i),[n*Math.sin(i)*r,-e*r,n*Math.cos(i)*r]}function os(n,e,i){return Nl(Math.cos(V(n)),Math.sin(V(n)),e,i)}let ss=63710088e-1,ch=2*Math.PI*ss;class Kt{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);
7if(this.lng=+e,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 Kt(Ne(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){let i=Math.PI/180,r=this.lat*i,s=e.lat*i,l=Math.sin(r)*Math.sin(s)+Math.cos(r)*Math.cos(s)*Math.cos((e.lng-this.lng)*i);return ss*Math.acos(Math.min(l,1))}toBounds(e=0){let i=360*e/40075017,r=i/Math.cos(Math.PI/180*this.lat);return new as({lng:this.lng-r,lat:this.lat-i},{lng:this.lng+r,lat:this.lat+i})}toEcef(e){return os(this.lat,this.lng,er+e*er/ss)}static convert(e){if(e instanceof Kt)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Kt(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Kt(Number("lng"in e?e.lng:e.lon),Number(e.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>]")}}class as{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):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 Kt?new Kt(e.lng,e.lat):Kt.convert(e),this}setSouthWest(e){return this._sw=e instanceof Kt?new Kt(e.lng,e.lat):Kt.convert(e),this}extend(e){let i=this._sw,r=this._ne,s,l;if(e instanceof Kt)s=e,l=e;else{if(!(e instanceof as))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(as.convert(e)):this.extend(Kt.convert(e)):typeof e=="object"&&e!==null&&Object.hasOwn(e,"lat")&&(Object.hasOwn(e,"lon")||Object.hasOwn(e,"lng"))?this.extend(Kt.convert(e)):this;if(s=e._sw,l=e._ne,!s||!l)return this}return i||r?(i.lng=Math.min(s.lng,i.lng),i.lat=Math.min(s.lat,i.lat),r.lng=Math.max(l.lng,r.lng),r.lat=Math.max(l.lat,r.lat)):(this._sw=new Kt(s.lng,s.lat),this._ne=new Kt(l.lng,l.lat)),this}getCenter(){return new Kt((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 Kt(this.getWest(),this.getNorth())}getSouthEast(){return new Kt(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){let{lng:i,lat:r}=Kt.convert(e),s=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&s}static convert(e){if(e)return e instanceof as?e:new as(e)}}function rp(n){return ch*Math.cos(n*Math.PI/180)}function So(n){return(180+n)/360}function ko(n){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)))/360}function lr(n,e){return n/rp(e)}function Mr(n){return 360*n-180}function zn(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function uh(n,e){return n*rp(zn(e))}let Cr=85.051129;function _m(n){return Math.cos(V(ne(n,-85.051129,Cr)))}function Ua(n,e){let i=ne(e,0,25.5),r=Math.pow(2,i);return _m(n)*ch/(512*r)}function gm(n){return 1/Math.cos(n*Math.PI/180)}function Hr(n,e=0){let i=Math.exp(Math.PI*(1-(n.y+e/Xe)/(1<<n.z)*2));return 80150034*i/(i*i+1)/Xe/(1<<n.z)}class Wn{constructor(e,i,r=0){this.x=+e,this.y=+i,this.z=+r}static fromLngLat(e,i=0){let r=Kt.convert(e);return new Wn(So(r.lng),ko(r.lat),lr(i,r.lat))}toLngLat(){return new Kt(Mr(this.x),zn(this.y))}toAltitude(){return uh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ch*gm(zn(this.y))}}function op(n,e,i,r,s,l,u,p,f){let g=(e+r)/2,x=(i+s)/2,b=new ke(g,x);p(b),function(w,S,I,M,C,R){let F=I-C,L=M-R;return Math.abs((M-S)*F-(I-w)*L)/Math.hypot(F,L)}(b.x,b.y,l.x,l.y,u.x,u.y)>=f?(op(n,e,i,g,x,l,b,p,f),op(n,g,x,r,s,b,u,p,f)):n.push(u)}function ym(n,e,i){let r=n[0],s=r.x,l=r.y;e(r);let u=[r];for(let p=1;p<n.length;p++){let f=n[p],{x:g,y:x}=f;e(f),op(u,s,l,g,x,r,f,e,i),s=g,l=x,r=f}return u}function sp(n,e,i,r){if(r(e,i)){let s=e.add(i)._mult(.5);sp(n,e,s,r),sp(n,s,i,r)}else n.push(i)}function hh(n,e){let i=n[0],r=[i];for(let s=1;s<n.length;s++){let l=n[s];sp(r,i,l,e),i=l}return r}let ap=Math.pow(2,14)-1,xm=-ap-1;function dh(n,e){let i=Math.round(n.x*e),r=Math.round(n.y*e);return n.x=ne(i,xm,ap),n.y=ne(r,xm,ap),(i<n.x||i>n.x+1||r<n.y||r>n.y+1)&&Bt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),n}function $r(n,e,i){let r=n.loadGeometry(),s=n.extent,l=Xe/s;if(e&&i&&i.projection.isReprojectedInTileSpace){let u=1<<e.z,{scale:p,x:f,y:g,projection:x}=i,b=w=>{let S=Mr((e.x+w.x/s)/u),I=zn((e.y+w.y/s)/u),M=x.project(S,I);w.x=(M.x*p-f)*s,w.y=(M.y*p-g)*s};for(let w=0;w<r.length;w++)if(n.type!==1)r[w]=ym(r[w],b,1);else{let S=[];for(let I of r[w])I.x<0||I.x>=s||I.y<0||I.y>=s||(b(I),S.push(I));r[w]=S}}for(let u of r)for(let p of u)dh(p,l);return r}function qr(n,e){return{type:n.type,id:n.id,properties:n.properties,geometry:e?$r(n):[]}}class $s{constructor(e,i,r,s,l){this.properties={},this.extent=r,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=s,this._values=l,e.readFields(mg,this,i)}loadGeometry(){let e=this._pbf;e.pos=this._geometry;let i=e.readVarint()+e.pos,r=[],s,l=1,u=0,p=0,f=0;for(;e.pos<i;){if(u<=0){let g=e.readVarint();l=7&g,u=g>>3}if(u--,l===1||l===2)p+=e.readSVarint(),f+=e.readSVarint(),l===1&&(s&&r.push(s),s=[]),s&&s.push(new ke(p,f));else{if(l!==7)throw new Error(`unknown command ${l}`);
7s&&s.push(s[0].clone())}}return s&&r.push(s),r}bbox(){let e=this._pbf;e.pos=this._geometry;let i=e.readVarint()+e.pos,r=1,s=0,l=0,u=0,p=1/0,f=-1/0,g=1/0,x=-1/0;for(;e.pos<i;){if(s<=0){let b=e.readVarint();r=7&b,s=b>>3}if(s--,r===1||r===2)l+=e.readSVarint(),u+=e.readSVarint(),l<p&&(p=l),l>f&&(f=l),u<g&&(g=u),u>x&&(x=u);else if(r!==7)throw new Error(`unknown command ${r}`)}return[p,g,f,x]}toGeoJSON(e,i,r){let s=this.extent*Math.pow(2,r),l=this.extent*e,u=this.extent*i,p=this.loadGeometry();function f(w){return[360*(w.x+l)/s-180,360/Math.PI*Math.atan(Math.exp((1-2*(w.y+u)/s)*Math.PI))-90]}function g(w){return w.map(f)}let x;if(this.type===1){let w=[];for(let I of p)w.push(I[0]);let S=g(w);x=w.length===1?{type:"Point",coordinates:S[0]}:{type:"MultiPoint",coordinates:S}}else if(this.type===2){let w=p.map(g);x=w.length===1?{type:"LineString",coordinates:w[0]}:{type:"MultiLineString",coordinates:w}}else{if(this.type!==3)throw new Error("unknown feature type");{let w=function(I){let M=I.length;if(M<=1)return[I];let C=[],R,F;for(let L=0;L<M;L++){let j=vm(I[L]);j!==0&&(F===void 0&&(F=j<0),F===j<0?(R&&C.push(R),R=[I[L]]):R&&R.push(I[L]))}return R&&C.push(R),C}(p),S=[];for(let I of w)S.push(I.map(g));x=S.length===1?{type:"Polygon",coordinates:S[0]}:{type:"MultiPolygon",coordinates:S}}}let b={type:"Feature",geometry:x,properties:this.properties};return this.id!=null&&(b.id=this.id),b}}function mg(n,e,i){n===1?e.id=i.readVarint():n===2?function(r,s){let l=r.readVarint()+r.pos;for(;r.pos<l;){let u=s._keys[r.readVarint()],p=s._values[r.readVarint()];s.properties[u]=p}}(i,e):n===3?e.type=i.readVarint():n===4&&(e._geometry=i.pos)}function vm(n){let e=0;for(let i,r,s=0,l=n.length,u=l-1;s<l;u=s++)i=n[s],r=n[u],e+=(r.x-i.x)*(i.y+r.y);return e}$s.types=["Unknown","Point","LineString","Polygon"];class bm{constructor(e,i){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(wm,this,i),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let i=this._pbf.readVarint()+this._pbf.pos;return new $s(this._pbf,i,this.extent,this._keys,this._values)}}function wm(n,e,i){n===15?e.version=i.readVarint():n===1?e.name=i.readString():n===5?e.extent=i.readVarint():n===2?e._features.push(i.pos):n===3?e._keys.push(i.readString()):n===4&&e._values.push(function(r){let s=null,l=r.readVarint()+r.pos;for(;r.pos<l;){let u=r.readVarint()>>3;s=u===1?r.readString():u===2?r.readFloat():u===3?r.readDouble():u===4?r.readVarint64():u===5?r.readVarint():u===6?r.readSVarint():u===7?r.readBoolean():null}if(s==null)throw new Error("unknown feature value");return s}(i))}class lp{constructor(e,i){this.layers=e.readFields(_g,{},i)}}function _g(n,e,i){if(n===3){let r=new bm(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}let qs="3d_elevation_id",Tm="level";class gg{constructor(){this._valid=!1}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(e,i){return this._valid&&e(i(this._geometry)),this}require(e,i,r){return this.get(e,!0,i,r)}optional(e,i,r){return this.get(e,!1,i,r)}success(){return this._valid}get(e,i,r,s){let l=Object.hasOwn(this.feature.properties,e)?+this.feature.properties[e]:void 0;return this._valid&&l!==void 0&&!Number.isNaN(l)?r(s?s(l):l):i&&(this._valid=!1),this}}class Sm{constructor(e,i){this.featureFunc=e,this.vertexFunc=i}parseFeature(e,i,r){return this.featureFunc(e,i,r)}parseVertex(e,i,r){return this.vertexFunc(e,i,r)}}let yg=new Sm((n,e,i)=>n.reset(e).require(qs,r=>{i.id=r}).optional("fixed_height_relative",r=>{i.constantHeight=r},ls.decodeRelativeHeight).geometry(r=>{i.bounds=r},Jh).success(),(n,e,i)=>n.reset(e).require(qs,r=>{i.id=r}).require("elevation_idx",r=>{i.idx=r}).require("extent",r=>{i.extent=r}).require("height_relative",r=>{i.height=r},ls.decodeRelativeHeight).geometry(r=>{i.position=r},ls.getPoint).success()),xg=new Sm((n,e,i)=>n.reset(e).require(qs,r=>{i.id=r}).optional("fixed_height",r=>{i.constantHeight=r},ls.decodeMetricHeight).geometry(r=>{i.bounds=r},Jh).success(),(n,e,i)=>n.reset(e).require(qs,r=>{i.id=r}).require("elevation_idx",r=>{i.idx=r}).require("extent",r=>{i.extent=r}).require("height",r=>{i.height=r},ls.decodeMetricHeight).geometry(r=>{i.position=r},ls.getPoint).success());class ls{static getPoint(e){return go(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?e==="1.0.1"?xg:void 0:yg}static parse(e){let i=[],r=[],s=e.length,l=new gg;for(let u=0;u<s;u++){let p=e.feature(u),f=p.properties.version,g=ls.getVersionSchema(f);if(g===void 0){Bt(`Unknown elevation feature version number ${f||"(unknown)"}`);continue}let x=p.properties.type;if(!x)continue;let b=$s.types[p.type];if(b==="Point"&&x==="curve_point"){let w={};g.parseVertex(l,p,w)&&i.push(w)}else if(b==="Polygon"&&x==="curve_meta"){let w={};g.parseFeature(l,p,w)&&r.push(w)}}return{vertices:i,features:r}}}class Em{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,r){let s=Do(i,this.dir);if(Math.abs(s)<1e-6)return!1;let l=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1])/s;return r[0]=this.pos[0]+this.dir[0]*l,r[1]=this.pos[1]+this.dir[1]*l,!0}}class Yc{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,r){let s=en(i,this.dir);if(Math.abs(s)<1e-6)return!1;let l=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1]+(e[2]-this.pos[2])*i[2])/s;return r[0]=this.pos[0]+this.dir[0]*l,r[1]=this.pos[1]+this.dir[1]*l,r[2]=this.pos[2]+this.dir[2]*l,!0}closestPointOnSphere(e,i,r){if(function(S,I){var M=S[0],C=S[1],R=S[2],F=I[0],L=I[1],j=I[2];return Math.abs(M-F)<=Pn*Math.max(1,Math.abs(M),Math.abs(F))&&Math.abs(C-L)<=Pn*Math.max(1,Math.abs(C),Math.abs(L))&&Math.abs(R-j)<=Pn*Math.max(1,Math.abs(R),Math.abs(j))}(this.pos,e)||i===0)return r[0]=r[1]=r[2]=0,!1;let[s,l,u]=this.dir,p=this.pos[0]-e[0],f=this.pos[1]-e[1],g=this.pos[2]-e[2],x=s*s+l*l+u*u,b=2*(p*s+f*l+g*u),w=b*b-4*x*(p*p+f*f+g*g-i*i);if(w<0){let S=Math.max(-b/2,0),I=p+s*S,M=f+l*S,C=g+u*S,R=Math.hypot(I,M,C);return r[0]=I*i/R,r[1]=M*i/R,r[2]=C*i/R,!1}{let S=(-b-Math.sqrt(w))/(2*x);if(S<0){let I=Math.hypot(p,f,g);return r[0]=p*i/I,r[1]=f*i/I,r[2]=g*i/I,!1}return r[0]=p+s*S,r[1]=f+l*S,r[2]=g+u*S,!0}}}class cp{constructor(e,i,r,s,l){this.TL=e,this.TR=i,this.BR=r,this.BL=s,this.horizon=l}static fromInvProjectionMatrix(e,i,r){let s=[-1,1,1],l=[1,1,1],u=[1,-1,1],p=[-1,-1,1],f=Bi(s,s,e),g=Bi(l,l,e),x=Bi(u,u,e),b=Bi(p,p,e);return new cp(f,g,x,b,i/r)}}function ao(n,e,i,r){let s=e[0],l=e[1],u=e[2],p=i[0],f=i[1],g=i[2],x=1/0,b=-1/0;for(let w=0;w<n.length;w++){let S=n[w],I=(S[0]-s)*p+(S[1]-l)*f+(S[2]-u)*g;I<x&&(x=I),I>b&&(b=I)}return r[0]=x,r[1]=b,r}function ph(n,e){let i=!0;for(let r=0;r<n.planes.length;r++){let s=n.planes[r],l=0;for(let u=0;u<e.length;u++)l+=+(en(s,e[u])+s[3]>=0);if(l===0)return 0;l!==e.length&&(i=!1)}return i?2:1}let Im=[0,0];function Am(n,e){for(let i of n.projections){let r=ao(e,n.points[0],i.axis,Im);if(i.projection[1]<r[0]||i.projection[0]>r[1])return 0}return 1}function Mm(n,e){let i=e[0],r=e[1],s=e[2],l=e[3];for(let u=0;u<n.length;u++){let p=n[u];if(i*p[0]+r*p[1]+s*p[2]+l>=0)return!0}return!1}class up{constructor(e,i){this.points=e||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([
70,0,0,0]),this.bounds=Ei.fromPoints(this.points),this.projections=[],this.frustumEdges=[$i([],this.points[2],this.points[3]),$i([],this.points[0],this.points[3]),$i([],this.points[4],this.points[0]),$i([],this.points[5],this.points[1]),$i([],this.points[6],this.points[2]),$i([],this.points[7],this.points[3])];for(let r of this.frustumEdges){let s=[0,-r[2],r[1]],l=[r[2],0,-r[0]];this.projections.push({axis:s,projection:ao(this.points,this.points[0],s,[0,0])}),this.projections.push({axis:l,projection:ao(this.points,this.points[0],l,[0,0])})}}static fromInvProjectionMatrix(e,i,r,s){let l=Math.pow(2,r),u=[[-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(g=>{let x=xr([],g,e),b=1/x[3]/i*l;return(w=x)[0]=(S=x)[0]*(I=[b,b,s?1/x[3]:b,b])[0],w[1]=S[1]*I[1],w[2]=S[2]*I[2],w[3]=S[3]*I[3],w;var w,S,I}),p=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(g=>{let x=hi([],Jn([],$i([],u[g[0]],u[g[1]]),$i([],u[g[2]],u[g[1]]))),b=-en(x,u[g[1]]);return x.concat(b)}),f=[];for(let g=0;g<u.length;g++)f.push([u[g][0],u[g][1],u[g][2]]);return new up(f,p)}intersectsPrecise(e,i,r){for(let f=0;f<i.length;f++)if(!Mm(e,i[f]))return 0;for(let f=0;f<this.planes.length;f++)if(!Mm(e,this.planes[f]))return 0;let s=this.points,l=s[0][0],u=s[0][1],p=s[0][2];for(let f of r)for(let g of this.frustumEdges){let x=f[1]*g[2]-f[2]*g[1],b=f[2]*g[0]-f[0]*g[2],w=f[0]*g[1]-f[1]*g[0];if(x===0&&b===0&&w===0)continue;let S=1/0,I=-1/0;for(let R=0;R<s.length;R++){let F=s[R],L=(F[0]-l)*x+(F[1]-u)*b+(F[2]-p)*w;L<S&&(S=L),L>I&&(I=L)}let M=1/0,C=-1/0;for(let R=0;R<e.length;R++){let F=e[R],L=(F[0]-l)*x+(F[1]-u)*b+(F[2]-p)*w;L<M&&(M=L),L>C&&(C=L)}if(S>C||M>I)return 0}return 1}containsPoint(e){for(let i of this.planes){let r=i[3];if(en([i[0],i[1],i[2]],e)+r<0)return!1}return!0}}class Ei{static fromPoints(e){let i=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let s of e)Rn(i,i,s),Lr(r,r,s);return new Ei(i,r)}static fromTileIdAndHeight(e,i,r){let s=1<<e.canonical.z,l=e.canonical.x,u=e.canonical.y;return new Ei([l/s,u/s,i],[(l+1)/s,(u+1)/s,r])}static applyTransform(e,i){let r=e.getCorners();for(let s=0;s<r.length;++s)Bi(r[s],r[s],i);return Ei.fromPoints(r)}static applyTransformFast(e,i){let r=[i[12],i[13],i[14]],s=[...r];for(let l=0;l<3;l++)for(let u=0;u<3;u++){let p=i[4*u+l],f=p*e.min[u],g=p*e.max[u];r[l]+=Math.min(f,g),s[l]+=Math.max(f,g)}return new Ei(r,s)}static projectAabbCorners(e,i){let r=e.getCorners();for(let s=0;s<r.length;++s)Bi(r[s],r[s],i);return r}constructor(e,i){this.min=e,this.max=i,this.center=Fi([],nn([],this.min,this.max),.5)}quadrant(e){let i=[e%2==0,e<2],r=tc(this.min),s=tc(this.max);for(let l=0;l<i.length;l++)r[l]=i[l]?this.min[l]:this.center[l],s[l]=i[l]?this.center[l]:this.max[l];return s[2]=this.max[2],new Ei(r,s)}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]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){let e=this.min,i=this.max;return[[e[0],e[1],e[2]],[i[0],e[1],e[2]],[i[0],i[1],e[2]],[e[0],i[1],e[2]],[e[0],e[1],i[2]],[i[0],e[1],i[2]],[i[0],i[1],i[2]],[e[0],i[1],i[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?ph(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?ph(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,i){return i||this.intersects(e)?Am(e,this.getCorners()):0}intersectsPreciseFlat(e,i){return i||this.intersectsFlat(e)?Am(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let i=0;i<3;++i)if(this.min[i]>e.max[i]||e.min[i]>this.max[i])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],e.min[i]),this.max[i]=Math.max(this.max[i],e.max[i])}encapsulatePoint(e){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],e[i]),this.max[i]=Math.max(this.max[i],e[i])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}Qe(Ei,"Aabb");class Cm{constructor(e,i){this.feature=e,this.metersToTile=i,this.index=0}get(){let e=this.feature.vertices[this.index],i=this.feature.vertexProps[this.index].dir,r=i[1],s=-i[0],l=(e.extent+1)*this.metersToTile;return[new ke(Math.trunc(e.position[0]+r*l),Math.trunc(e.position[1]+s*l)),new ke(Math.trunc(e.position[0]-r*l),Math.trunc(e.position[1]-s*l))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class fh{constructor(e,i,r,s,l,u){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this._tmpVec2=[Kn(),Kn(),Kn(),Kn(),Kn(),Kn(),Kn()],this.id=e,this.heightRange={min:r,max:r},this.safeArea=i,this.constantHeight=r,this.constantHeight==null&&(this.constantHeight!=null||s.length!==0)){this.vertices=s,this.edges=l,this.edges=this.edges.filter(p=>{return p.a<this.vertices.length&&p.b<this.vertices.length&&!((f=this.vertices[p.a].position)[0]===(g=this.vertices[p.b].position)[0]&&f[1]===g[1]);var f,g}),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(let p of this.vertices)this.vertexProps.push({dir:go(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,p.height),this.heightRange.max=Math.max(this.heightRange.max,p.height);for(let p of this.edges){let f=this.vertices[p.a].position,g=this.vertices[p.b].position,x=yo(Kn(),g,f),b=ca(x),w=la(Kn(),x,1/b);this.edgeProps.push({vec:x,dir:w,len:b});let S=this.vertexProps[p.a].dir,I=this.vertexProps[p.b].dir;aa(S,S,w),aa(I,I,w)}for(let p of this.vertexProps)p.dir[0]===0&&p.dir[1]===0||sc(p.dir,p.dir);this.tessellate(u)}}pointElevation(e){if(this.constantHeight!=null)return this.constantHeight;let i=this.getClosestEdge(e);if(i==null)return 0;let[r,s]=i;return mt(this.vertices[this.edges[r].a].height,this.vertices[this.edges[r].b].height,s)}computeSlopeNormal(e,i){let r=this.getClosestEdge(e);
7if(!r)return kn(0,0,1);let s=r[0],l=this.edges[s],u=this.edgeProps[s].vec,p=kn(u[0],u[1],(this.vertices[l.b].height-this.vertices[l.a].height)*i),f=kn(p[1],-p[0],0);Jn(f,f,p);let g=Dn(f);return g>0?Fi(f,f,1/g):Mi(f,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(this.edges.length===0)return;let i=0,r=Number.POSITIVE_INFINITY,s=0,[l,u,p,f,g,x,b]=this._tmpVec2;Wo(b,e.x,e.y);let w=new Em(b,null);for(let S=0;S<this.edges.length;S++){let I=this.edges[S],M=this.edgeProps[S].dir;w.dir=M;let C=this.vertices[I.a].position,R=this.vertices[I.b].position,F=w.intersectsPlane(C,this.vertexProps[I.a].dir,l),L=w.intersectsPlane(R,this.vertexProps[I.b].dir,u);if(!F||!L)continue;yo(p,u,l),yo(f,b,l);let j=Do(p,p),H=j>0?Do(f,p)/j:0,$=ne(H,0,1),ie=Math.abs((H-$)*this.edgeProps[S].len);yo(g,b,C),Wo(x,M[1],-M[0]);let W=ie+Math.abs(Do(g,x));W<r&&(i=S,r=W,s=$)}return[i,s]}tessellate(e){let i=ai(),r=ai(),s=ai(),l=ai();for(let u=this.edges.length-1;u>=0;--u){let p=this.edges[u].a,f=this.edges[u].b,{position:g,height:x,extent:b}=this.vertices[p],{position:w,height:S,extent:I}=this.vertices[f],M=this.vertexProps[p].dir,C=this.vertexProps[f].dir;if(Mi(i,g[0]/e,g[1]/e,x),Mi(r,w[0]/e,w[1]/e,S),Mi(s,M[1],-M[0],0),Fi(s,s,b),Mi(l,C[1],-C[0],0),Fi(l,l,I),this.distSqLines(kn(i[0]+.5*s[0],i[1]+.5*s[1],i[2]+.5*s[2]),kn(r[0]-.5*l[0],r[1]-.5*l[1],r[2]-.5*l[2]),kn(i[0]-.5*s[0],i[1]-.5*s[1],i[2]-.5*s[2]),kn(r[0]+.5*l[0],r[1]+.5*l[1],r[2]+.5*l[2]))<=.0025000000000000005)continue;let R=this.vertices.length,F=aa(Kn(),g,w);this.vertices.push({position:la(F,F,.5),height:.5*(x+S),extent:.5*(b+I)});let L=aa(Kn(),M,C);this.vertexProps.push({dir:sc(L,L)}),this.edges.splice(u,1),this.edgeProps.splice(u,1),this.edges.push({a:p,b:R}),this.edges.push({a:R,b:f});let j=yo(Kn(),this.vertices[R].position,g),H=ca(j),$={vec:j,dir:la(Kn(),j,1/H),len:H};this.edgeProps.push($),this.edgeProps.push($)}}distSqLines(e,i,r,s){let l=mo(ai(),i,e),u=mo(ai(),s,r),p=mo(ai(),e,r),f=en(l,l),g=en(l,u),x=en(l,p),b=en(u,u),w=en(u,p),S=f*b-g*g;if(S===0)return qo(na(l,r,s,en(p,u)/en(u,u)),e);let I=(f*w-g*x)/S;return qo(na(l,e,i,(g*w-x*b)/S),na(u,r,s,I))}}class mh{static parseFrom(e,i){let r=ls.parse(e);if(!r)return[];let{vertices:s,features:l}=r,u=1/Hr(i);l.sort((x,b)=>x.id-b.id),s.sort((x,b)=>x.id-b.id||x.idx-b.idx),s=s.filter((x,b,w)=>b===w.findIndex(S=>S.id===x.id&&S.idx===x.idx));let p=new Array,f=0,g=s.length;for(let x of l){if(x.constantHeight){p.push(new fh(x.id,x.bounds,x.constantHeight));continue}for(;f!==g&&s[f].id<x.id;)f++;if(f===g||s[f].id!==x.id)continue;let b=new Array,w=new Array,S=f;for(;f!==g&&s[f].id===x.id;){let I=s[f];if(b.push({position:I.position,height:I.height,extent:I.extent}),f!==S&&s[f-1].idx===I.idx-1){let M=f-S;w.push({a:M-1,b:M})}f++}p.push(new fh(x.id,x.bounds,void 0,b,w,u))}return p}static getElevationFeature(e,i){if(!i)return;let r=+e.properties[qs];return Number.isNaN(r)?void 0:i.find(s=>s.id===r)}}class a{constructor(e,i){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(i)||(this.zScale=Math.pow(2,i.z-e.z),this.xOffset=(e.x*this.zScale-i.x)*Xe,this.yOffset=(e.y*this.zScale-i.y)*Xe)}constantElevation(e,i){if(e.constantHeight!=null)return this.computeBiasedHeight(e.constantHeight,i)}pointElevation(e,i,r){let s=this.constantElevation(i,r);return s??(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(i.pointElevation(e),r))}computeBiasedHeight(e,i){return i<=0?e:e+i*ye(0,i,e>=0?e:Math.abs(.5*e))}}function t(n){if(n===0)return[0,0,0];let e=fd(n);return[e(),e(),e()]}Qe(fh,"ElevationFeature");class o{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Zn,this.indexArray=new Yi,this.segments=new pi,this.programConfigurations=new To(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new Lo),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}
7populate(e,i,r,s){let l=this.layers[0],u=[],p=null;l.type==="circle"&&(p=l.layout.get("circle-sort-key"));for(let{feature:g,id:x,index:b,sourceLayerIndex:w}of e){let S=this.layers[0]._featureFilter.needGeometry,I=qr(g,S);if(!this.layers[0]._featureFilter.filter(new Jt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),I,r))continue;let M=p?p.evaluate(I,{},r):void 0,C={id:x,properties:g.properties,type:g.type,sourceLayerIndex:w,index:b,geometry:S?I.geometry:$r(g,r,s),patterns:{},sortKey:M};u.push(C)}p&&u.sort((g,x)=>g.sortKey-x.sortKey);let f=null;s.projection.name==="globe"&&(this.globeExtVertexArray=new nh,f=s.projection);for(let g of u){let{geometry:x,index:b,sourceLayerIndex:w}=g,S=e[b].feature;this.addFeature(g,x,b,i.availableImages,r,f,i.brightness,i.elevationFeatures),i.featureIndex.insert(S,x,b,w,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(e,i,r,s,l,u,p){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,this.worldview)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ag.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,cg.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,lg.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(e,i,r,s,l,u,p,f){let g;this.elevationMode!=="none"&&(g=mh.getElevationFeature(e,f));for(let x of i)for(let b of x){let w=b.x,S=b.y;if(w<0||w>=Xe||S<0||S>=Xe)continue;if(u){let C=u.projectTilePoint(w,S,l),R=u.upVector(l,w,S);this.addGlobeExtVertex(C,R),this.addGlobeExtVertex(C,R),this.addGlobeExtVertex(C,R),this.addGlobeExtVertex(C,R)}let I=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),M=I.vertexLength;if(this.addCircleVertex(w,S,-1,-1),this.addCircleVertex(w,S,1,-1),this.addCircleVertex(w,S,1,1),this.addCircleVertex(w,S,-1,1),this.elevationMode!=="none"){let C=g?g.pointElevation(new ke(w,S)):0;this.hasElevation=this.hasElevation||C!==0;for(let R=0;R<4;R++)this.elevatedLayoutVertexArray.emplaceBack(C)}this.indexArray.emplaceBack(M,M+1,M+2),this.indexArray.emplaceBack(M,M+2,M+3),I.vertexLength+=4,I.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},s,l,p,void 0,this.worldview)}addCircleVertex(e,i,r,s){this.layoutVertexArray.emplaceBack(2*e+(r+1)/2,2*i+(s+1)/2)}addGlobeExtVertex(e,i){this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}}function c(n,e){for(let i=0;i<n.length;i++)if(z(e,n[i]))return!0;for(let i=0;i<e.length;i++)if(z(n,e[i]))return!0;return!!y(n,e)}function d(n,e,i){return!!z(n,e)||!!P(e,n,i)}function m(n,e){if(n.length===1)return D(e,n[0]);for(let i=0;i<e.length;i++){let r=e[i];for(let s=0;s<r.length;s++)if(z(n,r[s]))return!0}for(let i=0;i<n.length;i++)if(D(e,n[i]))return!0;for(let i=0;i<e.length;i++)if(y(n,e[i]))return!0;return!1}function _(n,e,i){if(n.length>1){if(y(n,e))return!0;for(let r=0;r<e.length;r++)if(P(e[r],n,i))return!0}for(let r=0;r<n.length;r++)if(P(n[r],e,i))return!0;return!1}function y(n,e){if(n.length===0||e.length===0)return!1;for(let i=0;i<n.length-1;i++){let r=n[i],s=n[i+1];for(let l=0;l<e.length-1;l++)if(v(r,s,e[l],e[l+1]))return!0}return!1}function v(n,e,i,r){return ni(n,i,r)!==ni(e,i,r)&&ni(n,e,i)!==ni(n,e,r)}function T(n,e,i){return(n.x-i.x)*(e.y-i.y)-(n.y-i.y)*(e.x-i.x)}function E(n,e,i,r){let s=T(n,e,r),l=T(n,e,i);if(Math.sign(s)===Math.sign(l))return;let u=T(i,r,n),p=u+l-s;return Math.sign(u)!==Math.sign(p)?[u/(u-p),l/(l-s)]:void 0}function P(n,e,i){let r=i*i;if(e.length===1)return n.distSqr(e[0])<r;for(let s=1;s<e.length;s++)if(A(n,e[s-1],e[s])<r)return!0;return!1}function A(n,e,i){let r=e.distSqr(i);if(r===0)return n.distSqr(e);let s=((n.x-e.x)*(i.x-e.x)+(n.y-e.y)*(i.y-e.y))/r;return n.distSqr(s<0?e:s>1?i:i.sub(e)._mult(s)._add(e))}function D(n,e){let i,r,s,l=!1;for(let u=0;u<n.length;u++){i=n[u];for(let p=0,f=i.length-1;p<i.length;f=p++)r=i[p],s=i[f],r.y>e.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(l=!l)}return l}function z(n,e){let i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){let l=n[r],u=n[s];l.y>e.y!=u.y>e.y&&e.x<(u.x-l.x)*(e.y-l.y)/(u.y-l.y)+l.x&&(i=!i)}return i}function O(n,e,i,r,s){for(let u of n)if(e<=u.x&&i<=u.y&&r>=u.x&&s>=u.y)return!0;let l=[new ke(e,i),new ke(e,s),new ke(r,s),new ke(r,i)];if(n.length>2){for(let u of l)if(z(n,u))return!0}for(let u=0;u<n.length-1;u++)if(k(n[u],n[u+1],l))return!0;return!1}function k(n,e,i){let r=i[0],s=i[2];if(n.x<r.x&&e.x<r.x||n.x>s.x&&e.x>s.x||n.y<r.y&&e.y<r.y||n.y>s.y&&e.y>s.y)return!1;
7let l=ni(n,e,i[0]);return l!==ni(n,e,i[1])||l!==ni(n,e,i[2])||l!==ni(n,e,i[3])}function N(n,e,i,r,s,l){let u=e.y-n.y,p=n.x-e.x;if(l=l||0){let f=u*u+p*p;if(f===0)return!0;let g=Math.sqrt(f);u/=g,p/=g}return!((i.x-n.x)*u+(i.y-n.y)*p-l<0||(r.x-n.x)*u+(r.y-n.y)*p-l<0||(s.x-n.x)*u+(s.y-n.y)*p-l<0)}function q(n,e,i,r,s,l,u){return!(N(n,e,r,s,l,u)||N(e,i,r,s,l,u)||N(i,n,r,s,l,u)||N(r,s,n,e,i,u)||N(s,l,n,e,i,u)||N(l,r,n,e,i,u))}function Z(n,e,i){let r=e.paint.get(n).value;return r.kind==="constant"?r.value:i.programConfigurations.get(e.id).getMaxValue(n)}function G(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1])}function re(n,e,i,r,s){if(!e[0]&&!e[1])return n;let l=ke.convert(e)._mult(s);i==="viewport"&&l._rotate(-r);let u=[];for(let p=0;p<n.length;p++)u.push(n[p].sub(l));return u}function te(n,e,i,r){let s=ke.convert(n)._mult(r);return e==="viewport"&&s._rotate(-i),s}let se,K;Qe(o,"CircleBucket",{omit:["layers"]});class J{constructor(e,i,r){this.z=e,this.x=i,this.y=r,this.key=de(0,e,e,i,r)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){let i=this.z-e.z;return e.z===0||e.z<this.z&&e.x===this.x>>i&&e.y===this.y>>i}url(e,i){let r=function(l,u,p){let f=2**p,g=2*Math.PI*6378137,x=g*(l/f-.5),b=g*(.5-(u+1)/f);return`${x},${b},${x+g/f},${b+g/f}`}(this.x,this.y,this.z),s=function(l,u,p){let f,g="";for(let x=l;x>0;x--)f=1<<x-1,g+=(u&f?1:0)+(p&f?2:0);return g}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(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(i==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",s).replace("{bbox-epsg-3857}",r)}toString(){return`${this.z}/${this.x}/${this.y}`}}class oe{constructor(e,i){this.wrap=e,this.canonical=i,this.key=de(e,i.z,i.z,i.x,i.y)}}class ue{constructor(e,i,r,s,l){this.overscaledZ=e,this.wrap=i,this.canonical=new J(r,+s,+l),this.key=i===0&&e===r?this.canonical.key:de(i,e,r,s,l)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){let i=this.canonical.z-e;return e>this.canonical.z?new ue(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ue(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(e,i=!0){if(this.overscaledZ===e&&i)return this.key;if(e>this.canonical.z)return de(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y);{let r=this.canonical.z-e;return de(this.wrap*+i,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;let i=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new ue(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=2*this.canonical.x,s=2*this.canonical.y;return[new ue(i,this.wrap,i,r,s),new ue(i,this.wrap,i,r+1,s),new ue(i,this.wrap,i,r,s+1),new ue(i,this.wrap,i,r+1,s+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new ue(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new ue(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new oe(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function de(n,e,i,r,s){let l=1<<Math.min(i,22),u=l*(s%l)+r%l;return n&&i<22&&(u+=l*l*((n<0?-2*n-1:2*n)%(1<<2*(22-i)))),16*(32*u+i)+(e-i)}let be=[n=>{let e=n.canonical.x-1,i=n.wrap;return e<0&&(e=(1<<n.canonical.z)-1,i--),new ue(n.overscaledZ,i,n.canonical.z,e,n.canonical.y)},n=>{let e=n.canonical.x+1,i=n.wrap;return e===1<<n.canonical.z&&(e=0,i++),new ue(n.overscaledZ,i,n.canonical.z,e,n.canonical.y)},n=>new ue(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,(n.canonical.y===0?1<<n.canonical.z:n.canonical.y)-1),n=>new ue(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,n.canonical.y===(1<<n.canonical.z)-1?0:n.canonical.y+1)];Qe(J,"CanonicalTileID"),Qe(ue,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});let ve=Rt([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Fe}=ve,pe=Rt([{name:"a_pos_3",components:3,type:"Int16"}]);var Ee=Rt([{name:"a_pos",type:"Int16",components:2}]);function fe(n){return n*er/ss}let Pe=[new Ei([jr,jr,jr],[Gr,Gr,Gr]),new Ei([jr,jr,jr],[0,0,Gr]),new Ei([0,jr,jr],[Gr,0,Gr]),new Ei([jr,0,jr],[0,Gr,Gr]),new Ei([0,0,jr],[Gr,Gr,Gr])];function Ce(n,e,i,r=!0){let s=Fi([],n._camera.position,n.worldSize),l=[e,i,1,1];xr(l,l,n.pixelMatrixInverse),oa(l,l,1/l[3]);let u=hi([],$i([],l,s)),p=n.globeMatrix,f=[p[12],p[13],p[14]],g=$i([],f,s),x=Dn(g),b=hi([],g),w=n.worldSize/(2*Math.PI),S=en(b,u),I=Math.asin(w/x);if(I<Math.acos(S)){if(!r)return null;let Y=[],ee=[];Fi(Y,u,x/S),hi(ee,$i(ee,Y,g)),hi(u,nn(u,g,Fi(u,ee,Math.tan(I)*x)))}let M=[];new Yc(s,u).closestPointOnSphere(f,w,M);let C=hi([],Xi(p,0)),R=hi([],Xi(p,1)),F=hi([],Xi(p,2)),L=en(C,M),j=en(R,M),H=en(F,M),$=X(Math.asin(-j/w)),ie=X(Math.atan2(L,H));ie=n.center.lng+function(Y,ee){let me=(ee-Y+180)%360-180;return me<-180?me+360:me}(n.center.lng,ie);let W=So(ie),Q=ne(ko($),0,1);return new Wn(W,Q)}class Re{constructor(e,i,r){this.a=$i([],e,r),this.b=$i([],i,r),this.center=r;let s=hi([],this.a),l=hi([],this.b);this.angle=Math.acos(en(s,l))}}function Ye(n,e){if(n.angle===0)return null;let i;return i=n.a[e]===0?1/n.angle*.5*Math.PI:1/n.angle*Math.atan(n.b[e]/n.a[e]/Math.sin(n.angle)-1/Math.tan(n.angle)),i<0||i>1?null:function(r,s,l,u){let p=Math.sin(l);return r*(Math.sin((1-u)*l)/p)+s*(Math.sin(u*l)/p)}(n.a[e],n.b[e],n.angle,ne(i,0,1))+n.center[e]}function He(n){if(n.z<=1)return Pe[n.z+2*n.y+n.x];let e=it(et(n));return Ei.fromPoints(e)}function je(n,e,i){return Fi(n,n,1-i),zr(n,n,e,i)}function Ue(n,e){let i=qt(e.zoom);if(i===0)return He(n);let r=et(n),s=it(r),l=So(r.getWest())*e.worldSize,u=So(r.getEast())*e.worldSize,p=ko(r.getNorth())*e.worldSize,f=ko(r.getSouth())*e.worldSize,g=[l,p,0],x=[u,p,0],b=[l,f,0],w=[u,f,0],S=Bn([],e.globeMatrix);
7return Bi(g,g,S),Bi(x,x,S),Bi(b,b,S),Bi(w,w,S),s[0]=je(s[0],b,i),s[1]=je(s[1],w,i),s[2]=je(s[2],x,i),s[3]=je(s[3],g,i),Ei.fromPoints(s)}function lt(n,e,i){for(let r of n)Bi(r,r,e),Fi(r,r,i)}function st(n,e,i,r){let s=e/n.worldSize,l=n.globeMatrix;if(i.z<=1){let Q=He(i).getCorners();return lt(Q,l,s),Ei.fromPoints(Q)}let u=et(i,r),p=it(u,er+fe(n._tileCoverLift));lt(p,l,s);let f=Number.MAX_VALUE,g=[-f,-f,-f],x=[f,f,f];if(u.contains(n.center)){for(let ee of p)Rn(x,x,ee),Lr(g,g,ee);g[2]=0;let Q=n.point,Y=[Q.x*s,Q.y*s,0];return Rn(x,x,Y),Lr(g,g,Y),new Ei(x,g)}if(n._tileCoverLift>0){for(let Q of p)Rn(x,x,Q),Lr(g,g,Q);return new Ei(x,g)}let b=[l[12]*s,l[13]*s,l[14]*s],w=u.getCenter(),S=ne(n.center.lat,-85.051129,Cr),I=ne(w.lat,-85.051129,Cr),M=So(n.center.lng),C=ko(S),R=M-So(w.lng),F=C-ko(I);R>.5?R-=1:R<-.5&&(R+=1);let L=0;Math.abs(R)>Math.abs(F)?L=R>=0?1:3:(L=F>=0?0:2,zr(b,b,[l[4]*s,l[5]*s,l[6]*s],-Math.sin(V(F>=0?u.getSouth():u.getNorth()))*er));let j=p[L],H=p[(L+1)%4],$=new Re(j,H,b),ie=[Ye($,0)||j[0],Ye($,1)||j[1],Ye($,2)||j[2]],W=qt(n.zoom);if(W>0){let Q=function({x:ee,y:me,z:ge},Te,Ae,Ie,Be){let xe=1/(1<<ge),Se=ee*xe,Me=Se+xe,Le=me*xe,ze=Le+xe,We=0,De=(Se+Me)/2-Ie;return De>.5?We=-1:De<-.5&&(We=1),Se=((Se+We)*Te-(Ie*=Te))*Ae+Ie,Me=((Me+We)*Te-Ie)*Ae+Ie,Le=(Le*Te-(Be*=Te))*Ae+Be,ze=(ze*Te-Be)*Ae+Be,[[Se,ze,0],[Me,ze,0],[Me,Le,0],[Se,Le,0]]}(i,e,n._pixelsPerMercatorPixel,M,C);for(let ee=0;ee<p.length;ee++)je(p[ee],Q[ee],W);let Y=nn([],Q[L],Q[(L+1)%4]);Fi(Y,Y,.5),je(ie,Y,W)}for(let Q of p)Rn(x,x,Q),Lr(g,g,Q);return x[2]=Math.min(j[2],H[2]),Rn(x,x,ie),Lr(g,g,ie),new Ei(x,g)}function et({x:n,y:e,z:i},r=!1){let s=1/(1<<i),l=new Kt(Mr(n*s),e===(1<<i)-1&&r?-90:zn((e+1)*s)),u=new Kt(Mr((n+1)*s),e===0&&r?90:zn(e*s));return new as(l,u)}function it(n,e=er){let i=V(n.getNorth()),r=V(n.getSouth()),s=Math.cos(i),l=Math.cos(r),u=Math.sin(i),p=Math.sin(r),f=n.getWest(),g=n.getEast();return[Nl(l,p,f,e),Nl(l,p,g,e),Nl(s,u,g,e),Nl(s,u,f,e)]}function ht(n,e,i,r){let s=1<<i.z,l=(n/Xe+i.x)/s;return os(zn((e/Xe+i.y)/s),Mr(l),r)}function vt({min:n,max:e}){return 16383/Math.max(e[0]-n[0],e[1]-n[1],e[2]-n[2])}let gt=new Float64Array(16);function Et(n){let e=vt(n),i=$o(gt,[e,e,e]);return $n(i,i,_o([],n.min))}function xt(n){let e=1/vt(n);return _s(gt,n.min),Yn(gt,gt,[e,e,e])}function kt(n){let e=Xe/(2*Math.PI);return n/(2*Math.PI)/e}function Tt(n,e){return Xe/(512*Math.pow(2,n))*vt(He(e))}function Vt(n,e,i,r,s){let l=kt(i),u=[n,e,-i/(2*Math.PI)],p=Mt(new Float64Array(16));return $n(p,p,u),Yn(p,p,[l,l,l]),Go(p,p,V(-s)),Ho(p,p,V(-r)),p}function qt(n){return ye(5,6,n)}function bi(n,e){let i=os(e.lat,e.lng),r=function(I){let M=os(I._center.lat,I._center.lng),C=Jn([],kn(0,1,0),M),R=ta([],-I.angle,M);C=Bi(C,C,R),ta(R,-I._pitch,C);let F=hi([],M);return Fi(F,F,fe(I.cameraToCenterDistance/I.pixelsPerMeter)),Bi(F,F,R),nn([],M,F)}(n);return u=(s=mo([],r,i))[0],p=s[1],f=s[2],g=(l=i)[0],x=l[1],b=l[2],S=(w=Math.sqrt((u*u+p*p+f*f)*(g*g+x*x+b*b)))&&en(s,l)/w,Math.acos(Math.min(Math.max(S,-1),1));var s,l,u,p,f,g,x,b,w,S}function li(n,e){return bi(n,e)>Math.PI/2*1.01}let Xt=V(85),At=Math.cos(Xt),Ct=Math.sin(Xt),ci=eo(),Li=n=>{let e=[];return n.paint.get("circle-pitch-alignment")==="map"&&e.push("PITCH_WITH_MAP"),n.paint.get("circle-pitch-scale")==="map"&&e.push("SCALE_WITH_MAP"),e};function ti(n,e,i,r,s,l,u,p,f){if(l&&n.queryGeometry.isAboveHorizon)return!1;l&&(f*=n.pixelToTileUnitsFactor);let g=n.tileID.canonical,x=i.projection.upVectorScale(g,i.center.lat,i.worldSize).metersToTile;for(let b of e)for(let w of b){let S=w.add(p),I=s&&i.elevation?i.elevation.exaggeration()*s.getElevationAt(S.x,S.y,!0):0,M=i.projection.projectTilePoint(S.x,S.y,g);if(I>0){let L=i.projection.upVector(g,S.x,S.y);M.x+=L[0]*x*I,M.y+=L[1]*x*I,M.z+=L[2]*x*I}let C=l?S:wt(M.x,M.y,M.z,r),R=l?n.tilespaceRays.map(L=>Ui(L,I)):n.queryGeometry.screenGeometry,F=xr([],[M.x,M.y,M.z,1],r);if(!u&&l?f*=F[3]/i.cameraToCenterDistance:u&&!l&&(f*=i.cameraToCenterDistance/F[3]),l){let L=zn((w.y/Xe+g.y)/(1<<g.z));f/=i.projection.pixelsPerMeter(L,1)/lr(1,L)}if(d(R,C,f))return!0}return!1}function wt(n,e,i,r){let s=xr([],[n,e,i,1],r);return new ke(s[0]/s[3],s[1]/s[3])}let yi=kn(0,0,0),fi=kn(0,0,1);function Ui(n,e){let i=ai();return yi[2]=e,n.intersectsPlane(yi,fi,i),new ke(i[0],i[1])}class Nt extends o{}let Ji,Vn,pn,In;function cn(n,{width:e,height:i},r,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*r)throw new RangeError("mismatched image size")}else s=new Uint8Array(e*i*r);return n.width=e,n.height=i,n.data=s,n}function cr(n,e,i){let{width:r,height:s}=e;r===n.width&&s===n.height||(tr(n,e,{x:0,y:0},{x:0,y:0},{width:Math.min(n.width,r),height:Math.min(n.height,s)},i,null),n.width=r,n.height=s,n.data=e.data)}function tr(n,e,i,r,s,l,u,p){if(s.width===0||s.height===0)return e;if(s.width>n.width||s.height>n.height||i.x>n.width-s.width||i.y>n.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||r.x>e.width-s.width||r.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");let f=n.data,g=e.data,x=l===4&&p;for(let b=0;b<s.height;b++){let w=((i.y+b)*n.width+i.x)*l,S=((r.y+b)*e.width+r.x)*l;if(x)for(let I=0;I<s.width;I++){let M=w+I*l+3,C=S+I*l;g[C+0]=255,g[C+1]=255,g[C+2]=255,g[C+3]=f[M]}else if(u)for(let I=0;I<s.width;I++){let M=w+I*l,C=S+I*l,R=new Ht(f[M+0]/255,f[M+1]/255,f[M+2]/255,f[M+3]).toNonPremultipliedRenderColor(u).toArray();g[C+0]=R[0],g[C+1]=R[1],g[C+2]=R[2],g[C+3]=R[3]}else for(let I=0;I<s.width*l;I++)g[S+I]=f[w+I]}return e}Qe(Nt,"HeatmapBucket",{omit:["layers"]});class zi{constructor(e,i){cn(this,e,1,i)}resize(e){cr(this,new zi(e),1)}clone(){return new zi({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,r,s,l){tr(e,i,r,s,l,1,null)}}class Vi{constructor(e,i){cn(this,e,4,i)}resize(e){cr(this,new Vi(e),4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Vi({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,r,s,l,u,p){tr(e,i,r,s,l,4,u,p)}}class Ii{constructor(e,i){this.width=e.width,this.height=e.height,this.data=i instanceof Uint8Array?new Float32Array(i.buffer):i}}function ii(n){let e={},i=n.resolution||256,r=n.clips?n.clips.length:1,s=n.image||new Vi({width:i,height:r}),l=(u,p,f)=>{e[n.evaluationKey]=f;let g=n.expression.evaluate(e),x=g?g.toNonPremultipliedRenderColor(null):null;x&&(s.data[u+p+0]=Math.floor(255*x.r),s.data[u+p+1]=Math.floor(255*x.g),s.data[u+p+2]=Math.floor(255*x.b),s.data[u+p+3]=Math.floor(255*x.a))};if(n.clips)for(let u=0,p=0;u<r;++u,p+=4*i)for(let f=0,g=0;f<i;f++,g+=4){let x=f/(i-1),{start:b,end:w}=n.clips[u];l(p,g,b*(1-x)+w*x)}else for(let u=0,p=0;u<i;u++,p+=4)l(0,p,u/(i-1));return s}Qe(zi,"AlphaImage"),Qe(Vi,"RGBAImage");let si=Rt([{name:"a_pos",components:2,type:"Int16"}],4),Ki=Rt([{name:"a_road_z_offset",components:1,type:"Float32"}],4),vn=Rt([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),ki=Rt([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);function bn(n,e,i=2){let r=e&&e.length,s=r?e[0]*i:n.length,l=Zr(n,0,s,i,!0),u=[];
vendor: 5,519 bytes, line 7
7if(!l||l.next===l.prev)return u;let p,f,g;if(r&&(l=function(x,b,w,S){let I=[];for(let M=0,C=b.length;M<C;M++){let R=Zr(x,b[M]*S,M<C-1?b[M+1]*S:x.length,S,!1);R===R.next&&(R.steiner=!0),I.push(Pm(R))}I.sort(Zs);for(let M=0;M<I.length;M++)w=Va(I[M],w);return w}(n,e,l,i)),n.length>80*i){p=n[0],f=n[1];let x=p,b=f;for(let w=i;w<s;w+=i){let S=n[w],I=n[w+1];S<p&&(p=S),I<f&&(f=I),S>x&&(x=S),I>b&&(b=I)}g=Math.max(x-p,b-f),g=g!==0?32767/g:0}return lo(l,u,i,p,f,g,0),u}function Zr(n,e,i,r,s){let l;if(s===function(u,p,f,g){let x=0;for(let b=p,w=f-g;b<f;b+=g)x+=(u[w]-u[b])*(u[b+1]+u[w+1]),w=b;return x}(n,e,i,r)>0)for(let u=e;u<i;u+=r)l=Xy(u/r|0,n[u],n[u+1],l);else for(let u=i-r;u>=e;u-=r)l=Xy(u/r|0,n[u],n[u+1],l);return l&&_h(l,l.next)&&(fp(l),l=l.next),l}function ur(n,e){if(!n)return n;e||(e=n);let i,r=n;do if(i=!1,r.steiner||!_h(r,r.next)&&An(r.prev,r,r.next)!==0)r=r.next;else{if(fp(r),r=e=r.prev,r===r.next)break;i=!0}while(i||r!==e);return e}function lo(n,e,i,r,s,l,u){if(!n)return;!u&&l&&function(f,g,x,b){let w=f;do w.z===0&&(w.z=Kc(w.x,w.y,g,x,b)),w.prevZ=w.prev,w.nextZ=w.next,w=w.next;while(w!==f);w.prevZ.nextZ=null,w.prevZ=null,function(S){let I,M=1;do{let C,R=S;S=null;let F=null;for(I=0;R;){I++;let L=R,j=0;for(let $=0;$<M&&(j++,L=L.nextZ,L);$++);let H=M;for(;j>0||H>0&&L;)j!==0&&(H===0||!L||R.z<=L.z)?(C=R,R=R.nextZ,j--):(C=L,L=L.nextZ,H--),F?F.nextZ=C:S=C,C.prevZ=F,F=C;R=L}F.nextZ=null,M*=2}while(I>1)}(w)}(n,r,s,l);let p=n;for(;n.prev!==n.next;){let f=n.prev,g=n.next;if(l?us(n,r,s,l):cs(n))e.push(f.i,n.i,g.i),fp(n),n=g.next,p=g.next;else if((n=g)===p){u?u===1?lo(n=Eo(ur(n),e),e,i,r,s,l,2):u===2&&Jc(n,e,i,r,s,l):lo(ur(n),e,i,r,s,l,1);break}}}function cs(n){let e=n.prev,i=n,r=n.next;if(An(e,i,r)>=0)return!1;let s=e.x,l=i.x,u=r.x,p=e.y,f=i.y,g=r.y,x=Math.min(s,l,u),b=Math.min(p,f,g),w=Math.max(s,l,u),S=Math.max(p,f,g),I=r.next;for(;I!==e;){if(I.x>=x&&I.x<=w&&I.y>=b&&I.y<=S&&dp(s,p,l,f,u,g,I.x,I.y)&&An(I.prev,I,I.next)>=0)return!1;I=I.next}return!0}function us(n,e,i,r){let s=n.prev,l=n,u=n.next;if(An(s,l,u)>=0)return!1;let p=s.x,f=l.x,g=u.x,x=s.y,b=l.y,w=u.y,S=Math.min(p,f,g),I=Math.min(x,b,w),M=Math.max(p,f,g),C=Math.max(x,b,w),R=Kc(S,I,e,i,r),F=Kc(M,C,e,i,r),L=n.prevZ,j=n.nextZ;for(;L&&L.z>=R&&j&&j.z<=F;){if(L.x>=S&&L.x<=M&&L.y>=I&&L.y<=C&&L!==s&&L!==u&&dp(p,x,f,b,g,w,L.x,L.y)&&An(L.prev,L,L.next)>=0||(L=L.prevZ,j.x>=S&&j.x<=M&&j.y>=I&&j.y<=C&&j!==s&&j!==u&&dp(p,x,f,b,g,w,j.x,j.y)&&An(j.prev,j,j.next)>=0))return!1;j=j.nextZ}for(;L&&L.z>=R;){if(L.x>=S&&L.x<=M&&L.y>=I&&L.y<=C&&L!==s&&L!==u&&dp(p,x,f,b,g,w,L.x,L.y)&&An(L.prev,L,L.next)>=0)return!1;L=L.prevZ}for(;j&&j.z<=F;){if(j.x>=S&&j.x<=M&&j.y>=I&&j.y<=C&&j!==s&&j!==u&&dp(p,x,f,b,g,w,j.x,j.y)&&An(j.prev,j,j.next)>=0)return!1;j=j.nextZ}return!0}function Eo(n,e){let i=n;do{let r=i.prev,s=i.next.next;!_h(r,s)&&Zy(r,i,i.next,s)&&pp(r,s)&&pp(s,r)&&(e.push(r.i,i.i,s.i),fp(i),fp(i.next),i=n=s),i=i.next}while(i!==n);return ur(i)}function Jc(n,e,i,r,s,l){let u=n;do{let p=u.next.next;for(;p!==u.prev;){if(u.i!==p.i&&k1(u,p)){let f=Wy(u,p);return u=ur(u,u.next),f=ur(f,f.next),lo(u,e,i,r,s,l,0),void lo(f,e,i,r,s,l,0)}p=p.next}u=u.next}while(u!==n)}function Zs(n,e){let i=n.x-e.x;return i===0&&(i=n.y-e.y,i===0)&&(i=(n.next.y-n.y)/(n.next.x-n.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function Va(n,e){let i=function(s,l){let u=l,p=s.x,f=s.y,g,x=-1/0;if(_h(s,u))return u;do{if(_h(s,u.next))return u.next;if(f<=u.y&&f>=u.next.y&&u.next.y!==u.y){let M=u.x+(f-u.y)*(u.next.x-u.x)/(u.next.y-u.y);if(M<=p&&M>x&&(x=M,g=u.x<u.next.x?u:u.next,M===p))return g}u=u.next}while(u!==l);if(!g)return null;let b=g,w=g.x,S=g.y,I=1/0;u=g;do{if(p>=u.x&&u.x>=w&&p!==u.x&&Dm(f<S?p:x,f,w,S,f<S?x:p,f,u.x,u.y)){let M=Math.abs(f-u.y)/(p-u.x);pp(u,s)&&(M<I||M===I&&(u.x>g.x||u.x===g.x&&hp(g,u)))&&(g=u,I=M)}u=u.next}while(u!==b);return g}(n,e);if(!i)return e;let r=Wy(i,n);return ur(r,r.next),ur(i,i.next)}function hp(n,e){return An(n.prev,n,e.prev)<0&&An(e.next,n,n.next)<0}function Kc(n,e,i,r,s){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-i)*s|0)|n<<8))|n<<4))|n<<2))|n<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Pm(n){let e=n,i=n;do(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next;while(e!==n);return i}function Dm(n,e,i,r,s,l,u,p){return(s-u)*(e-p)>=(n-u)*(l-p)&&(n-u)*(r-p)>=(i-u)*(e-p)&&(i-u)*(l-p)>=(s-u)*(r-p)}function dp(n,e,i,r,s,l,u,p){return!(n===u&&e===p)&&Dm(n,e,i,r,s,l,u,p)}function k1(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!function(i,r){let s=i;do{if(s.i!==i.i&&s.next.i!==i.i&&s.i!==r.i&&s.next.i!==r.i&&Zy(s,s.next,i,r))return!0;s=s.next}while(s!==i);return!1}(n,e)&&(pp(n,e)&&pp(e,n)&&function(i,r){let s=i,l=!1,u=(i.x+r.x)/2,p=(i.y+r.y)/2;do s.y>p!=s.next.y>p&&s.next.y!==s.y&&u<(s.next.x-s.x)*(p-s.y)/(s.next.y-s.y)+s.x&&(l=!l),s=s.next;while(s!==i);return l}(n,e)&&(An(n.prev,n,e.prev)||An(n,e.prev,e))||_h(n,e)&&An(n.prev,n,n.next)>0&&An(e.prev,e,e.next)>0)}function An(n,e,i){return(e.y-n.y)*(i.x-e.x)-(e.x-n.x)*(i.y-e.y)}function _h(n,e){return n.x===e.x&&n.y===e.y}function Zy(n,e,i,r){let s=Lm(An(n,e,i)),l=Lm(An(n,e,r)),u=Lm(An(i,r,n)),p=Lm(An(i,r,e));return s!==l&&u!==p||!(s!==0||!Rm(n,i,e))||!(l!==0||!Rm(n,r,e))||!(u!==0||!Rm(i,n,r))||!(p!==0||!Rm(i,e,r))}function Rm(n,e,i){return e.x<=Math.max(n.x,i.x)&&e.x>=Math.min(n.x,i.x)&&e.y<=Math.max(n.y,i.y)&&e.y>=Math.min(n.y,i.y)}function Lm(n){return n>0?1:n<0?-1:0}function pp(n,e){return An(n.prev,n,n.next)<0?An(n,e,n.next)>=0&&An(n,n.prev,e)>=0:An(n,e,n.prev)<0||An(n,n.next,e)<0}
7function Wy(n,e){let i=vg(n.i,n.x,n.y),r=vg(e.i,e.x,e.y),s=n.next,l=e.prev;return n.next=e,e.prev=n,i.next=s,s.prev=i,r.next=i,i.prev=r,l.next=r,r.prev=l,r}function Xy(n,e,i,r){let s=vg(n,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function fp(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function vg(n,e,i){return{i:n,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function mp(n,e){let i=n.length;if(i<=1)return[n];let r=[],s,l;for(let u=0;u<i;u++){let p=Di(n[u]);p!==0&&(n[u].area=Math.abs(p),l===void 0&&(l=p<0),l===p<0?(s&&r.push(s),s=[n[u]]):s.push(n[u]))}if(s&&r.push(s),e>1)for(let u=0;u<r.length;u++)r[u].length<=e||(xc(r[u],e,1,r[u].length-1,N1),r[u]=r[u].slice(0,e));return r}function N1(n,e){return e.area-n.area}function Yy(n,e,i=1){if(!n)return null;let r=typeof n=="string"?dr.from(n).getPrimary():n.getPrimary(),s=typeof n=="string"?null:n.getSecondary();for(let l of[r,s]){if(!l)continue;let u=l.id.toString();e.has(u)||e.set(u,[]),l.scaleSelf(i),e.get(u).push(l)}return{primary:r.toString(),secondary:s?s.toString():null}}function bg(n,e,i,r){let s=r.patternDependencies,l=!1;for(let u of e){let p=u.paint.get(`${n}-pattern`);p.isConstant()||(l=!0),Yy(p.constantOr(null),s,i)&&(l=!0)}return l}function wg(n,e,i,r,s,l){let u=l.patternDependencies;for(let p of e){let f=p.paint.get(`${n}-pattern`).value;if(f.kind!=="constant"){let g=Yy(f.evaluate({zoom:r},i,{},void 0,l.availableImages),u,s);if(!g)continue;let{primary:x,secondary:b}=g;x&&(i.patterns[p.id]=[x,b].filter(Boolean))}}return i}class ja{constructor(){this.portals=[]}static isOnBorder(e,i){return e<=0&&i<=0||e>=Xe&&i>=Xe}static evaluate(e){if(e.length===0)return new ja;let i=[];for(let f of e)i.push(...f.portals);if(i.length===0)return new ja;for(let f of i){let g=f.va,x=f.vb;(ja.isOnBorder(g.x,x.x)||ja.isOnBorder(g.y,x.y))&&(f.type="border")}let r=i.filter(f=>f.type!=="unevaluated"),s=i.filter(f=>f.type==="unevaluated");if(s.length===0)return new ja;s.sort((f,g)=>f.hash===g.hash?f.isTunnel===g.isTunnel?0:f.isTunnel?-1:1:f.hash<g.hash?1:-1),i=r.concat(s);let l=r.length,u=l,p=l;do if(u++,u===i.length||i[l].hash!==i[u].hash){if(u-l===2){p<l&&(i[p]=i[l],i[l]=null);let f=i[p],g=i[u-1];f.type=f.isTunnel!==g.isTunnel?"tunnel":"polygon",f.connection={a:f.connection.a,b:g.connection.a},p++}l=u}while(l!==i.length);return i.splice(p),i.sort((f,g)=>f.hash<g.hash?1:-1),{portals:i}}}Qe(ja,"ElevationPortalGraph");class U1{constructor(e,i,r){this.outPositions=e,this.outNormals=i,this.outIndices=r,this.vertexLookup=new Map}addVertex(e,i,r){let s=e[2];r!=null&&(s*=r);let l=`${e[0]},${e[1]},${e[2]},${i[0]},${i[1]},${i[2]}`,u=this.vertexLookup.get(l);if(u!=null)return u;let p=this.outPositions.length;this.vertexLookup.set(l,p);let f=Math.trunc(16384*i[0]),g=Math.trunc(16384*i[1]),x=Math.trunc(16384*i[2]);return this.outPositions.emplaceBack(e[0],e[1],s),this.outNormals.emplaceBack(f,g,x),p}addTriangle(e,i,r){this.outIndices.emplaceBack(e,i,r)}addTriangles(e,i,r){if(e.length===0)return;let s=r.length===1,l=ai(),u=ai();for(let p=0;p<e.length;p+=3){let f=i[e[p+0]],g=i[e[p+1]],x=i[e[p+2]],b=s?r[0]:r[e[p+1]],w=s?r[0]:r[e[p+2]];Mi(l,f.x,f.y,s?r[0]:r[e[p+0]]);let S=this.addVertex(l,u);Mi(l,g.x,g.y,b);let I=this.addVertex(l,u);Mi(l,x.x,x.y,w);let M=this.addVertex(l,u);this.outIndices.emplaceBack(S,I,M)}}addQuad(e,i,r,s,l,u){let p=this.addVertex(e,l,u),f=this.addVertex(i,l,u),g=this.addVertex(r,l,u),x=this.addVertex(s,l,u);this.addTriangle(p,f,g),this.addTriangle(g,x,p)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class Wr{constructor(e,i,r,s){this.unevaluatedPortals=new ja,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new so,this.vertexNormals=new ih,this.indexArray=new Yi,this.tileToMeters=Hr(e),this.bridgeProgramConfigurations=new To(i,{zoom:r,lut:s},l=>l!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new To(i,{zoom:r,lut:s},l=>l!=="fill-bridge-guard-rail-color")}addVertices(e,i){let r=this.unevalVertices.length;for(let s=0;s<e.length;s++)this.unevalVertices.push(e[s]),this.unevalHeights.push(i[s]);return r}
7addTriangles(e,i,r){let s=r?this.unevalTunnelTriangles:this.unevalTriangles;for(let l of e)s.push(l+i)}addRenderableRing(e,i,r,s,l,u){let p=[new ke(l.min.x,l.min.y),new ke(l.max.x,l.min.y),new ke(l.max.x,l.max.y),new ke(l.min.x,l.max.y)];for(let f=0;f<r-1;f++){let g=i+f,x=g+1,b=this.unevalVertices[g],w=this.unevalVertices[x];if(!(b.x>=l.min.x&&b.x<=l.max.x&&b.y>=l.min.y&&b.y<=l.max.y||w.x>=l.min.x&&w.x<=l.max.x&&w.y>=l.min.y&&w.y<=l.max.y||k(b,w,p))||this.isOnBorder(b.x,w.x)||this.isOnBorder(b.y,w.y))continue;let S=Wr.computeEdgeHash(this.unevalVertices[g],this.unevalVertices[x]),I,M=this.vertexHashLookup.get(Wr.computePosHash(b));M!=null?I=M.next:(M=this.vertexHashLookup.get(Wr.computePosHash(w)),I=M!=null?M.prev:S),this.unevalEdges.push({polygonIdx:e,a:g,b:x,hash:S,portalHash:I,isTunnel:s,type:"unevaluated",featureInfo:u})}}addPortalCandidates(e,i,r,s,l){if(i.length!==0){this.vertexHashLookup.clear();for(let u of i){if(u.length===0)continue;let p=u[0],f=Wr.computeEdgeHash(p[p.length-2],p.at(-1));for(let g=0;g<p.length-1;g++){let x=p[g+0],b=p[g+1],w=go(b.x-x.x,b.y-x.y),S=ca(w);if(S===0)continue;let I="unevaluated",M=s.pointElevation(x),C=s.pointElevation(b);Math.abs(M)<.01&&Math.abs(C)<.01?I="entrance":(this.isOnBorder(x.x,b.x)||this.isOnBorder(x.y,b.y))&&(I="border");let R=Wr.computeEdgeHash(x,b);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:x,vb:b,vab:w,length:S,hash:R,isTunnel:r,type:I});let F=Wr.computePosHash(x);this.vertexHashLookup.set(F,{prev:f,next:R}),f=R}}}}construct(e){if(this.unevalVertices.length===0)return;let i=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=w=>{w.primitiveLength=this.indexArray.length-w.primitiveOffset},s=new U1(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);let l=i(),u=i(),p=i(),f=(w,S)=>{w.sort((M,C)=>M.type===S&&C.type!==S?-1:M.type!==S&&C.type===S?1:0);let I=w.findIndex(M=>M.type!==S);return I>=0?I:w.length},g=0;this.unevalEdges.length>0&&(g=f(this.unevalEdges,"none"),this.constructBridgeStructures(s,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:g},this.tileToMeters)),r(p);let x=i(),b=i();if(this.unevalEdges.length>0){let w=this.unevalEdges.splice(g),S=f(w,"tunnel")+g;this.unevalEdges.push(...w),this.constructTunnelStructures(s,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:g},{min:g,max:S})}r(x),s.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(b),s.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(u),s.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),r(l),this.maskSegments=pi.simpleSegment(0,b.primitiveOffset,0,b.primitiveLength),this.depthSegments=pi.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.renderableBridgeSegments=pi.simpleSegment(0,p.primitiveOffset,0,p.primitiveLength),this.renderableTunnelSegments=pi.simpleSegment(0,x.primitiveOffset,0,x.primitiveLength),this.shadowCasterSegments=pi.simpleSegment(0,l.primitiveOffset,0,l.primitiveLength)}update(e,i,r,s,l,u,p,f){this.bridgeProgramConfigurations.updatePaintArrays(e,i,l,r,s,u,p,f),this.tunnelProgramConfigurations.updatePaintArrays(e,i,l,r,s,u,p,f)}upload(e){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,vn.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,ki.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(e,i,r,s,l){let u=(p,f)=>{for(let g=0;g<f.length-1;g++){let x=f[g].featureIndex,b=f[g+1].vertexStart,w=e.feature(x);p.populatePaintArrays(b,w,x,{},r,i,s,void 0,l)}};u(this.bridgeProgramConfigurations,this.bridgeFeatureSections),u(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(e,i,r,s,l){let u=new Map;for(let p=s;p<l;p++){let f=r[p],g=f.a,x=f.b,b=Wr.computePosHash(e[g]),w=Wr.computePosHash(e[x]),S=u.get(b);
7S||(S={},u.set(b,S));let I=u.get(w);I||(I={},u.set(w,I)),i[g]<=0&&i[x]<=0||(S.to=x,I.from=g)}return u}isTerminalVertex(e,i){let r=Wr.computePosHash(this.unevalVertices[e]),s=i.get(r);return!s||!s.from||!s.to}constructBridgeStructures(e,i,r,s,l,u){e.clearVertexLookup();let p=this.computeVertexConnections(i,r,s,l.min,l.max),f=1/u,g=.5*f,x=(Ae,Ie)=>Mi(Ae,i[Ie].x,i[Ie].y,r[Ie]*f),b=ai(),w=ai(),S=ai(),I=ai(),M=ai(),C=(Ae,Ie)=>{let Be=p.get(Wr.computePosHash(i[Ie])),xe=Be.from,Se=Be.to;if(!xe||!Se)return;x(b,xe),x(w,Ie),x(S,Se),Wa(I),Po(b,w)||($i(M,w,b),hi(I,M)),Po(S,w)||($i(M,S,w),nn(I,I,hi(M,M)));let Me=ra(I);return Me>0?Fi(Ae,I,1/Me):void 0},R=Number.POSITIVE_INFINITY;this.sortSubarray(s,l.min,l.max,(Ae,Ie)=>Ae.featureInfo.featureIndex-Ie.featureInfo.featureIndex);let F=ai(),L=ai(),j=ai(),H=ai(),$=ai(),ie=ai(),W=ai(),Q=ai(),Y=ai(),ee=[ai(),ai(),ai(),ai()],me=[ai(),ai(),ai(),ai()],ge=[{coord:new ke(0,0),height:0},{coord:new ke(0,0),height:0}],Te=(Ae,Ie)=>Ae>Ie;for(let Ae=l.min;Ae<l.max;Ae++){let Ie=s[Ae];if(!Ie.featureInfo.guardRailEnabled||!this.prepareEdgePoints(ge,i,r,Ie,Te))continue;let[Be,xe]=ge;if(Mi(F,Be.coord.x,Be.coord.y,f*Be.height),Mi(L,xe.coord.x,xe.coord.y,f*xe.height),Po(F,L))continue;$i(j,L,F),hi(j,j);let Se=C(Q,Ie.a)||j,Me=C(Y,Ie.b)||j;Mi(H,Se[1],-Se[0],0),hi(H,H),Mi($,Me[1],-Me[0],0),hi($,$),Jn(Q,H,Se),hi(ie,Q),Jn(Q,$,Me),hi(W,Q),nn(ee[0],F,Fi(Q,$i(Q,H,ie),g)),nn(ee[1],F,Fi(Q,nn(Q,H,ie),g)),nn(ee[2],F,Fi(Q,ie,g)),ee[3]=F,nn(me[0],L,Fi(Q,$i(Q,$,W),g)),nn(me[1],L,Fi(Q,nn(Q,$,W),g)),nn(me[2],L,Fi(Q,W,g)),me[3]=L,R=this.addFeatureSection(Ie.featureInfo.featureIndex,R,this.bridgeFeatureSections,e);let Le=e.addVertex(ee[0],H,u),ze=e.addVertex(ee[1],H,u),We=e.addVertex(me[0],$,u),De=e.addVertex(me[1],$,u);e.addTriangle(Le,ze,We),e.addTriangle(ze,De,We);let Ge=e.addVertex(ee[1],ie,u),$e=e.addVertex(ee[2],ie,u),Je=e.addVertex(me[1],W,u),tt=e.addVertex(me[2],W,u);e.addTriangle(Ge,$e,Je),e.addTriangle($e,tt,Je),_o(H,H),_o($,$);let ct=e.addVertex(ee[2],H,u),rt=e.addVertex(ee[3],H,u),ft=e.addVertex(me[2],$,u),Zt=e.addVertex(me[3],$,u);e.addTriangle(ct,rt,ft),e.addTriangle(rt,Zt,ft);let St=this.isTerminalVertex(Ie.a,p),Ut=this.isTerminalVertex(Ie.b,p);Be.height<.01&&St&&e.addQuad(ee[3],ee[2],ee[1],ee[0],_o(Se,Se),u),xe.height<.01&&Ut&&e.addQuad(me[0],me[1],me[2],me[3],Me,u)}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}constructTunnelStructures(e,i,r,s,l,u){e.clearVertexLookup();let p=Number.POSITIVE_INFINITY,f=(R,F)=>R.featureInfo.featureIndex-F.featureInfo.featureIndex;this.sortSubarray(s,l.min,l.max,f),this.sortSubarray(s,u.min,u.max,f);let g=R=>hi(R,R),x=[{coord:new ke(0,0),height:0},{coord:new ke(0,0),height:0}],b=(R,F)=>R<F,w=ai(),S=ai(),I=ai(),M=ai(),C=ai();for(let R=l.min;R<l.max;R++){if(!this.prepareEdgePoints(x,i,r,s[R],b))continue;let[F,L]=x,j=g(Mi(C,-(L.coord.y-F.coord.y),L.coord.x-F.coord.x,0));p=this.addFeatureSection(s[R].featureInfo.featureIndex,p,this.tunnelFeatureSections,e),e.addQuad(Mi(w,F.coord.x,F.coord.y,F.height),Mi(S,L.coord.x,L.coord.y,L.height),Mi(I,L.coord.x,L.coord.y,s[R].isTunnel?-.1:0),Mi(M,F.coord.x,F.coord.y,s[R].isTunnel?-.1:0),j)}for(let R=u.min;R<u.max;R++){let F=s[R];F.isTunnel&&([F.a,F.b]=[F.b,F.a]);let L=i[F.a],j=i[F.b],H=g(Mi(C,-(j.y-L.y),j.x-L.x,0));p=this.addFeatureSection(F.featureInfo.featureIndex,p,this.tunnelFeatureSections,e),e.addQuad(Mi(w,j.x,j.y,0),Mi(S,L.x,L.y,0),Mi(I,L.x,L.y,r[F.a]+4),Mi(M,j.x,j.y,r[F.b]+4),H),e.addQuad(Mi(w,L.x,L.y,0),Mi(S,j.x,j.y,0),Mi(I,j.x,j.y,r[F.b]+4),Mi(M,L.x,L.y,r[F.a]+4),H)}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}setElevatedPoint(e,i,r,s){e.coord.x=i,e.coord.y=r,e.height=s}prepareEdgePoints(e,i,r,s,l){let u=i[s.a].x,p=i[s.a].y,f=i[s.b].x,g=i[s.b].y,x=r[s.a],b=r[s.b],w=l(x,0),S=l(b,0);if(w&&S)return this.setElevatedPoint(e[0],u,p,x),this.setElevatedPoint(e[1],f,g,b),!0;if(!w&&!S)return!1;if(w){if(!S){let I=b/(b-x);f=mt(f,u,I),g=mt(g,p,I),b=mt(b,x,I)}}else{let I=x/(x-b);u=mt(u,f,I),p=mt(p,g,I),x=mt(x,b,I)}return this.setElevatedPoint(e[0],u,p,x),this.setElevatedPoint(e[1],f,g,b),!0}prepareEdges(e,i){if(i.length===0)return;i.sort((p,f)=>p.hash===f.hash?f.polygonIdx-p.polygonIdx:f.hash>p.hash?1:-1);let r=0,s=0,l=0,u=i[r].polygonIdx;do s++,(s===i.length||i[r].hash!==i[s].hash)&&((s-r===1||i[s-1].polygonIdx!==u)&&(l<r&&(i[l]=i[r],i[r]=null),i[l].type="none",l++),r=s,r!==i.length&&(u=i[r].polygonIdx));while(r!==i.length);if(i.splice(l),i.length!==0&&e.length!==0){i.sort((g,x)=>g.portalHash<x.portalHash?1:-1);let p=0,f=0;for(;p!==i.length&&f!==e.length;){let g=i[p],x=e[f];g.portalHash>x.hash?p++:x.hash>g.portalHash?f++:(g.type=x.type,p++)}}}isOnBorder(e,i){return e<=0&&i<=0||e>=Xe&&i>=Xe}addFeatureSection(e,i,r,s){return e!==i&&(i=e,r.push({featureIndex:e,vertexStart:s.getVertexCount()}),s.clearVertexLookup()),i}sortSubarray(e,i,r,s){let l=e.slice(i,r);l.sort(s),e.splice(i,l.length,...l)}static computeEdgeHash(e,i){return(e.y===i.y&&e.x>i.x||e.y>i.y)&&([e,i]=[i,e]),BigInt(Wr.computePosHash(e))<<32n|BigInt(Wr.computePosHash(i))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}function V1(n,e){return n>e?1:n<e?-1:0}class Tg{constructor(e=V1,i=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!i}rotateLeft(e){var i=e.right;i&&(e.right=i.left,i.left&&(i.left.parent=e),i.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.left
vendor: 4,640 bytes, line 7
7=e),e.parent=i}rotateRight(e){var i=e.left;i&&(e.left=i.right,i.right&&(i.right.parent=e),i.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.right=e),e.parent=i}_splay(e){for(;e.parent;){var i=e.parent;i.parent?i.left===e&&i.parent.left===i?(this.rotateRight(i.parent),this.rotateRight(i)):i.right===e&&i.parent.right===i?(this.rotateLeft(i.parent),this.rotateLeft(i)):i.left===e&&i.parent.right===i?(this.rotateRight(i),this.rotateLeft(i)):(this.rotateLeft(i),this.rotateRight(i)):i.left===e?this.rotateRight(i):this.rotateLeft(i)}}splay(e){for(var i,r,s,l,u;e.parent;)(r=(i=e.parent).parent)&&r.parent?((s=r.parent).left===r?s.left=e:s.right=e,e.parent=s):(e.parent=null,this._root=e),l=e.left,u=e.right,e===i.left?(r&&(r.left===i?(i.right?(r.left=i.right,r.left.parent=r):r.left=null,i.right=r,r.parent=i):(l?(r.right=l,l.parent=r):r.right=null,e.left=r,r.parent=e)),u?(i.left=u,u.parent=i):i.left=null,e.right=i,i.parent=e):(r&&(r.right===i?(i.left?(r.right=i.left,r.right.parent=r):r.right=null,i.left=r,r.parent=i):(u?(r.left=u,u.parent=r):r.left=null,e.right=r,r.parent=e)),l?(i.right=l,l.parent=i):i.right=null,e.left=i,i.parent=e)}replace(e,i){e.parent?e===e.parent.left?e.parent.left=i:e.parent.right=i:this._root=i,i&&(i.parent=e.parent)}minNode(e=this._root){if(e)for(;e.left;)e=e.left;return e}maxNode(e=this._root){if(e)for(;e.right;)e=e.right;return e}insert(e,i){var r=this._root,s=null,l=this._compare;if(this._noDuplicates)for(;r;){if(s=r,l(r.key,e)===0)return;r=l(r.key,e)<0?r.right:r.left}else for(;r;)s=r,r=l(r.key,e)<0?r.right:r.left;return r={key:e,data:i,left:null,right:null,parent:s},s?l(s.key,r.key)<0?s.right=r:s.left=r:this._root=r,this.splay(r),this._size++,r}find(e){for(var i=this._root,r=this._compare;i;){var s=r(i.key,e);if(s<0)i=i.right;else{if(!(s>0))return i;i=i.left}}return null}contains(e){for(var i=this._root,r=this._compare;i;){var s=r(e,i.key);if(s===0)return!0;i=s<0?i.left:i.right}return!1}remove(e){var i=this.find(e);if(!i)return!1;if(this.splay(i),i.left)if(i.right){var r=this.minNode(i.right);r.parent!==i&&(this.replace(r,r.right),r.right=i.right,r.right.parent=r),this.replace(i,r),r.left=i.left,r.left.parent=r}else this.replace(i,i.left);else this.replace(i,i.right);return this._size--,!0}removeNode(e){if(!e)return!1;if(this.splay(e),e.left)if(e.right){var i=this.minNode(e.right);i.parent!==e&&(this.replace(i,i.right),i.right=e.right,i.right.parent=i),this.replace(e,i),i.left=e.left,i.left.parent=i}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var i=this.find(e);if(i){this.splay(i);var r=i.left,s=i.right,l=null;r&&(r.parent=null,l=this.maxNode(r),this.splay(l),this._root=l),s&&(r?l.right=s:this._root=s,s.parent=l),this._size--}}pop(){var e=this._root,i=null;if(e){for(;e.left;)e=e.left;i={key:e.key,data:e.data},this.remove(e.key)}return i}next(e){var i=e;if(i)if(i.right)for(i=i.right;i&&i.left;)i=i.left;else for(i=e.parent;i&&i.right===e;)e=i,i=i.parent;return i}prev(e){var i=e;if(i)if(i.left)for(i=i.left;i&&i.right;)i=i.right;else for(i=e.parent;i&&i.left===e;)e=i,i=i.parent;return i}forEach(e){for(var i=this._root,r=[],s=!1,l=0;!s;)i?(r.push(i),i=i.left):r.length>0?(e(i=r.pop(),l++),i=i.right):s=!0;return this}range(e,i,r,s){let l=[],u=this._compare,p,f=this._root;for(;l.length!==0||f;)if(f)l.push(f),f=f.left;else{if(f=l.pop(),p=u(f.key,i),p>0)break;if(u(f.key,e)>=0&&r.call(s,f))return this;f=f.right}return this}keys(){for(var e=this._root,i=[],r=[],s=!1;!s;)e?(i.push(e),e=e.left):i.length>0?(e=i.pop(),r.push(e.key),e=e.right):s=!0;return r}values(){for(var e=this._root,i=[],r=[],s=!1;!s;)e?(i.push(e),e=e.left):i.length>0?(e=i.pop(),r.push(e.data),e=e.right):s=!0;return r}at(e){for(var i=this._root,r=[],s=!1,l=0;!s;)if(i)r.push(i),i=i.left;else if(r.length>0){if(i=r.pop(),l===e)return i;l++,i=i.right}else s=!0;return null}load(e=[],i=[],r=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");let s=e.length;return r&&Eg(e,i,0,s-1,this._compare),this._root=Sg(null,e,i,0,s),this._size=s,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return this._root===null}get size(){return this._size}static createTree(e,i,r,s,l){return new Tg(r,l).load(e,i,s)}}function Sg(n,e,i,r,s){let l=s-r;if(l>0){let u=r+Math.floor(l/2),p={key:e[u],data:i[u],parent:n};return p.left=Sg(p,e,i,r,u),p.right=Sg(p,e,i,u+1,s),p}return null}function Eg(n,e,i,r,s){if(i>=r)return;let l=n[i+r>>1],u=i-1,p=r+1;for(;;){do u++;while(s(n[u],l)<0);do p--;while(s(n[p],l)>0);if(u>=p)break;let f=n[u];
7n[u]=n[p],n[p]=f,f=e[u],e[u]=e[p],e[p]=f}Eg(n,e,i,p,s),Eg(n,e,p+1,r,s)}let Jy=11102230246251565e-32,Pr=134217729,j1=(3+8*Jy)*Jy;function Ig(n,e,i,r,s){let l,u,p,f,g=e[0],x=r[0],b=0,w=0;x>g==x>-g?(l=g,g=e[++b]):(l=x,x=r[++w]);let S=0;if(b<n&&w<i)for(x>g==x>-g?(u=g+l,p=l-(u-g),g=e[++b]):(u=x+l,p=l-(u-x),x=r[++w]),l=u,p!==0&&(s[S++]=p);b<n&&w<i;)x>g==x>-g?(u=l+g,f=u-l,p=l-(u-f)+(g-f),g=e[++b]):(u=l+x,f=u-l,p=l-(u-f)+(x-f),x=r[++w]),l=u,p!==0&&(s[S++]=p);for(;b<n;)u=l+g,f=u-l,p=l-(u-f)+(g-f),g=e[++b],l=u,p!==0&&(s[S++]=p);for(;w<i;)u=l+x,f=u-l,p=l-(u-f)+(x-f),x=r[++w],l=u,p!==0&&(s[S++]=p);return l===0&&S!==0||(s[S++]=l),S}function _p(n){return new Float64Array(n)}let gh=_p(4),Ky=_p(8),Qy=_p(12),e0=_p(16),Xr=_p(4);function gp(n,e,i){e===null?(n.inOut=!1,n.otherInOut=!0):(n.isSubject===e.isSubject?(n.inOut=!e.inOut,n.otherInOut=e.otherInOut):(n.inOut=!e.otherInOut,n.otherInOut=e.isVertical()?!e.inOut:e.inOut),e&&(n.prevInResult=!t0(e,i)||e.isVertical()?e.prevInResult:e)),n.resultTransition=t0(n,i)?function(r,s){let l,u=!r.inOut,p=!r.otherInOut;switch(s){case 0:l=u&&p;break;case 1:l=u||p;break;case 3:l=u!==p;break;case 2:l=r.isSubject?u&&!p:p&&!u}return l?1:-1}(n,i):0}function t0(n,e){switch(n.type){case 0:switch(e){case 0:return!n.otherInOut;case 1:return n.otherInOut;case 2:return n.isSubject&&n.otherInOut||!n.isSubject&&!n.otherInOut;case 3:return!0}break;case 2:return e===0||e===1;case 3:return e===2;case 1:return!1}return!1}class yh{constructor(e,i,r,s,l){this.left=i,this.point=e,this.otherEvent=r,this.isSubject=s??!1,this.type=l||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(e){let i=this.point,r=this.otherEvent.point;return this.left?(i[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(i[1]-e[1])>0:(r[0]-e[0])*(i[1]-e[1])-(i[0]-e[0])*(r[1]-e[1])>0}isAbove(e){return!this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){let e=new yh(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function Ws(n,e){return n[0]===e[0]&&n[1]===e[1]}function Ag(n,e,i){let r=function(s,l,u,p,f,g){let x=(l-g)*(u-f),b=(s-f)*(p-g),w=x-b;if(x===0||b===0||x>0!=b>0)return w;let S=Math.abs(x+b);return Math.abs(w)>=33306690738754716e-32*S?w:-function(I,M,C,R,F,L,j){let H,$,ie,W,Q,Y,ee,me,ge,Te,Ae,Ie,Be,xe,Se,Me,Le,ze,We=I-F,De=C-F,Ge=M-L,$e=R-L;xe=We*$e,Y=Pr*We,ee=Y-(Y-We),me=We-ee,Y=Pr*$e,ge=Y-(Y-$e),Te=$e-ge,Se=me*Te-(xe-ee*ge-me*ge-ee*Te),Me=Ge*De,Y=Pr*Ge,ee=Y-(Y-Ge),me=Ge-ee,Y=Pr*De,ge=Y-(Y-De),Te=De-ge,Le=me*Te-(Me-ee*ge-me*ge-ee*Te),Ae=Se-Le,Q=Se-Ae,gh[0]=Se-(Ae+Q)+(Q-Le),Ie=xe+Ae,Q=Ie-xe,Be=xe-(Ie-Q)+(Ae-Q),Ae=Be-Me,Q=Be-Ae,gh[1]=Be-(Ae+Q)+(Q-Me),ze=Ie+Ae,Q=ze-Ie,gh[2]=Ie-(ze-Q)+(Ae-Q),gh[3]=ze;let Je=function(Zt,St){let Ut=St[0];for(let Pt=1;Pt<4;Pt++)Ut+=St[Pt];return Ut}(0,gh),tt=22204460492503146e-32*j;if(Je>=tt||-Je>=tt||(Q=I-We,H=I-(We+Q)+(Q-F),Q=C-De,ie=C-(De+Q)+(Q-F),Q=M-Ge,$=M-(Ge+Q)+(Q-L),Q=R-$e,W=R-($e+Q)+(Q-L),H===0&&$===0&&ie===0&&W===0)||(tt=11093356479670487e-47*j+j1*Math.abs(Je),Je+=We*W+$e*H-(Ge*ie+De*$),Je>=tt||-Je>=tt))return Je;xe=H*$e,Y=Pr*H,ee=Y-(Y-H),me=H-ee,Y=Pr*$e,ge=Y-(Y-$e),Te=$e-ge,Se=me*Te-(xe-ee*ge-me*ge-ee*Te),Me=$*De,Y=Pr*$,ee=Y-(Y-$),me=$-ee,Y=Pr*De,ge=Y-(Y-De),Te=De-ge,Le=me*Te-(Me-ee*ge-me*ge-ee*Te),Ae=Se-Le,Q=Se-Ae,Xr[0]=Se-(Ae+Q)+(Q-Le),Ie=xe+Ae,Q=Ie-xe,Be=xe-(Ie-Q)+(Ae-Q),Ae=Be-Me,Q=Be-Ae,Xr[1]=Be-(Ae+Q)+(Q-Me),ze=Ie+Ae,Q=ze-Ie,Xr[2]=Ie-(ze-Q)+(Ae-Q),Xr[3]=ze;let ct=Ig(4,gh,4,Xr,Ky);xe=We*W,Y=Pr*We,ee=Y-(Y-We),me=We-ee,Y=Pr*W,ge=Y-(Y-W),Te=W-ge,Se=me*Te-(xe-ee*ge-me*ge-ee*Te),Me=Ge*ie,Y=Pr*Ge,ee=Y-(Y-Ge),me=Ge-ee,Y=Pr*ie,ge=Y-(Y-ie),Te=ie-ge,Le=me*Te-(Me-ee*ge-me*ge-ee*Te),Ae=Se-Le,Q=Se-Ae,Xr[0]=Se-(Ae+Q)+(Q-Le),Ie=xe+Ae,Q=Ie-xe,Be=xe-(Ie-Q)+(Ae-Q),Ae=Be-Me,Q=Be-Ae,Xr[1]=Be-(Ae+Q)+(Q-Me),ze=Ie+Ae,Q=ze-Ie,Xr[2]=Ie-(ze-Q)+(Ae-Q),Xr[3]=ze;let rt=Ig(ct,Ky,4,Xr,Qy);xe=H*W,Y=Pr*H,ee=Y-(Y-H),me=H-ee,Y=Pr*W,ge=Y-(Y-W),Te=W-ge,Se=me*Te-(xe-ee*ge-me*ge-ee*Te),Me=$*ie,Y=Pr*$,ee=Y-(Y-$),me=$-ee,Y=Pr*ie,ge=Y-(Y-ie),Te=ie-ge,Le=me*Te-(Me-ee*ge-me*ge-ee*Te),Ae=Se-Le,Q=Se-Ae,Xr[0]=Se-(Ae+Q)+(Q-Le),Ie=xe+Ae,Q=Ie-xe,Be=xe
7-(Ie-Q)+(Ae-Q),Ae=Be-Me,Q=Be-Ae,Xr[1]=Be-(Ae+Q)+(Q-Me),ze=Ie+Ae,Q=ze-Ie,Xr[2]=Ie-(ze-Q)+(Ae-Q),Xr[3]=ze;let ft=Ig(rt,Qy,4,Xr,e0);return e0[ft-1]}(s,l,u,p,f,g,S)}(n[0],n[1],e[0],e[1],i[0],i[1]);return r>0?-1:r<0?1:0}function Ul(n,e){let i=n.point,r=e.point;return i[0]>r[0]?1:i[0]<r[0]?-1:i[1]!==r[1]?i[1]>r[1]?1:-1:function(s,l,u){return s.left!==l.left?s.left?1:-1:Ag(u,s.otherEvent.point,l.otherEvent.point)!==0?s.isBelow(l.otherEvent.point)?-1:1:!s.isSubject&&l.isSubject?1:-1}(n,e,i)}function Vl(n,e,i){let r=new yh(e,!1,n,n.isSubject),s=new yh(e,!0,n.otherEvent,n.isSubject);return Ws(n.point,n.otherEvent.point)&&console.warn("what is that, a collapsed segment?",n),r.contourId=s.contourId=n.contourId,Ul(s,n.otherEvent)>0&&(n.otherEvent.left=!0,s.left=!1),n.otherEvent.otherEvent=s,n.otherEvent=r,i.push(s),i.push(r),i}function zm(n,e){return n[0]*e[1]-n[1]*e[0]}function Mg(n,e){return n[0]*e[0]+n[1]*e[1]}function Cg(n,e,i){let r=function(f,g,x,b){let w=[g[0]-f[0],g[1]-f[1]],S=[b[0]-x[0],b[1]-x[1]];function I(ie,W,Q){return[ie[0]+W*Q[0],ie[1]+W*Q[1]]}let M=[x[0]-f[0],x[1]-f[1]],C=zm(w,S),R=C*C,F=Mg(w,w);if(R>0){let ie=zm(M,S)/C;if(ie<0||ie>1)return null;let W=zm(M,w)/C;return W<0||W>1?null:ie===0||ie===1?[I(f,ie,w)]:W===0||W===1?[I(x,W,S)]:[I(f,ie,w)]}if(C=zm(M,w),R=C*C,R>0)return null;let L=Mg(w,M)/F,j=L+Mg(w,S)/F,H=Math.min(L,j),$=Math.max(L,j);return H<=1&&$>=0?H===1?[I(f,H>0?H:0,w)]:$===0?[I(f,$<1?$:1,w)]:[I(f,H>0?H:0,w),I(f,$<1?$:1,w)]:null}
7(n.point,n.otherEvent.point,e.point,e.otherEvent.point),s=r?r.length:0;if(s===0||s===1&&(Ws(n.point,e.point)||Ws(n.otherEvent.point,e.otherEvent.point))||s===2&&n.isSubject===e.isSubject)return 0;if(s===1)return!Ws(n.point,r[0])&&!Ws(n.otherEvent.point,r[0])&&Vl(n,r[0],i),!Ws(e.point,r[0])&&!Ws(e.otherEvent.point,r[0])&&Vl(e,r[0],i),1;let l=[],u=!1,p=!1;return Ws(n.point,e.point)?u=!0:Ul(n,e)===1?l.push(e,n):l.push(n,e),Ws(n.otherEvent.point,e.otherEvent.point)?p=!0:Ul(n.otherEvent,e.otherEvent)===1?l.push(e.otherEvent,n.otherEvent):l.push(n.otherEvent,e.otherEvent),u&&p||u?(e.type=1,n.type=e.inOut===n.inOut?2:3,u&&!p&&Vl(l[1].otherEvent,l[0].point,i),2):p?(Vl(l[0],l[1].point,i),3):l[0]!==l[3].otherEvent?(Vl(l[0],l[1].point,i),Vl(l[1],l[2].point,i),3):(Vl(l[0],l[1].point,i),Vl(l[3].otherEvent,l[2].point,i),3)}function G1(n,e){if(n===e)return 0;if(Ag(n.point,n.otherEvent.point,e.point)!==0||Ag(n.point,n.otherEvent.point,e.otherEvent.point)!==0)return Ws(n.point,e.point)?n.isBelow(e.otherEvent.point)?-1:1:n.point[0]===e.point[0]?n.point[1]<e.point[1]?-1:1:Ul(n,e)===1?e.isAbove(n.point)?-1:1:n.isBelow(e.point)?-1:1;if(n.isSubject!==e.isSubject)return n.isSubject?-1:1;{let i=n.point,r=e.point;if(i[0]===r[0]&&i[1]===r[1])return i=n.otherEvent.point,r=e.otherEvent.point,i[0]===r[0]&&i[1]===r[1]?0:(n.contourId??0)>(e.contourId??0)?1:-1}return Ul(n,e)===1?1:-1}class H1{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function $1(n,e,i,r){let s,l=n+1,u=e[n].point,p=e.length;for(l<p&&(s=e[l].point);l<p&&s[0]===u[0]&&s[1]===u[1];){if(!i[l])return l;l++,l<p&&(s=e[l].point)}for(l=n-1;i[l]&&l>r;)l--;return l}function q1(n,e,i){let r=new H1;if(n.prevInResult!=null){let s=n.prevInResult,l=s.outputContourId;if(s.resultTransition>0){let u=e[l];if(u.holeOf!=null){let p=u.holeOf;e[p].holeIds.push(i),r.holeOf=p,r.depth=e[l].depth}else e[l].holeIds.push(i),r.holeOf=l,r.depth=e[l].depth+1}else r.holeOf=null,r.depth=e[l].depth}else r.holeOf=null,r.depth=0;return r}let i0=Math.max,n0=Math.min,Om=0;function r0(n,e,i,r,s,l){let u,p,f,g,x,b;for(u=0,p=n.length-1;u<p;u++){if(f=n[u],g=n[u+1],x=new yh(f,!1,void 0,e),b=new yh(g,!1,x,e),x.otherEvent=b,f[0]===g[0]&&f[1]===g[1])continue;x.contourId=b.contourId=i,l||(x.isExteriorRing=!1,b.isExteriorRing=!1),Ul(x,b)>0?b.left=!0:x.left=!0;let w=f[0],S=f[1];s[0]=n0(s[0],w),s[1]=n0(s[1],S),s[2]=i0(s[2],w),s[3]=i0(s[3],S),r.push(x),r.push(b)}}let Fm=[];function o0(n,e,i){let r=n,s=e;typeof n[0][0][0]=="number"&&(r=[n]),typeof e[0][0][0]=="number"&&(s=[e]);let l=function(w,S,I){let M=null;return w.length*S.length===0&&(I===0?M=Fm:I===2?M=w:(I===1||I===3)&&(M=w.length===0?S:w)),M}(r,s,i);if(l)return l===Fm?null:l;let u=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],f=function(w,S,I,M,C){let R=new pt(void 0,Ul),F,L,j,H,$,ie;for(j=0,H=w.length;j<H;j++)for(F=w[j],$=0,ie=F.length;$<ie;$++)L=$===0,L&&Om++,r0(F[$],!0,Om,R,I,L);for(j=0,H=S.length;j<H;j++)for(F=S[j],$=0,ie=F.length;$<ie;$++)L=$===0,C===2&&(L=!1),L&&Om++,r0(F[$],!1,Om,R,M,L);return R}(r,s,u,p,i);if(l=function(w,S,I,M,C){let R=null;return(I[0]>M[2]||M[0]>I[2]||I[1]>M[3]||M[1]>I[3])&&(C===0?R=Fm:C===2?R=w:(C===1||C===3)&&(R=w.concat(S))),R}(r,s,u,p,i),l)return l===Fm?null:l;let g=function(w,S,I,M,C,R){let F=new Tg(G1),L=[],j=Math.min(M[2],C[2]),H,$,ie;for(;w.length!==0;){let W=w.pop();if(L.push(W),R===0&&W.point[0]>j||R===2&&W.point[0]>M[2])break;if(W.left){$=H=F.insert(W),ie=F.minNode(),H=H!==ie?F.prev(H):null,$=F.next($);let Q=H?H.key:null,Y;if(gp(W,Q,R),$&&Cg(W,$.key,w)===2&&(gp(W,Q,R),gp($.key,W,R)),H&&Cg(H.key,W,w)===2){let ee=H;ee=ee!==ie?F.prev(ee):null,Y=ee?ee.key:null,gp(Q,Y,R),gp(W,Q,R)}}else W=W.otherEvent,$=H=F.find(W),H&&$&&(H=H!==ie?F.prev(H):null,$=F.next($),F.remove(W),$&&H&&Cg(H.key,$.key,w))}return L}(f,0,0,u,p,i),x=function(w){let S,I,M=function(F){let L,j,H,$,ie,W=[];for(j=0,H=F.length;j<H;j++)L=F[j],(L.left&&L.inResult||!L.left&&L.otherEvent.inResult)&&W.push(L);let Q=!1;for(;!Q;)for(Q=!0,j=0,H=W.length;j<H;j++)j+1<H&&Ul(W[j],W[j+1])===1&&($=W[j],W[j]=W[j+1],W[j+1]=$,Q=!1);for(j=0,H=W.length;j<H;j++)L=W[j],L.otherPos=j;for(j=0,H=W.length;j<H;j++)L=W[j],L.left||(ie=L.otherPos,L.otherPos=L.otherEvent.otherPos,L.otherEvent.otherPos=ie);return W}(w),C={},R=[];for(S=0,I=M.length;S<I;S++){if(C[S])continue;let F=R.length,L=q1(M[S],R,F),j=ie=>{C[ie]=!0,ie<M.length&&M[ie]&&(M[ie].outputContourId=F)},H=S,$=S;for(L.points.push(M[S].point);j(H),H=M[H].otherPos,j(H),L.points.push(M[H].point),H=$1(H,M,C,$),!(H==$||H>=M.length)&&M[H];);R.push(L)}return R}(g),b=[];for(let w=0;w<x.length;w++){let S=x[w];if(S.isExterior()){let I=[S.points];for(let M=0;M<S.holeIds.length;M++)I.push(x[S.holeIds[M]].points);b.push(I)}}return b}function Bm(n,e,i,r){let s=[],l=r===0?(u,p,f,g,x,b)=>{u.push(new ke(b,f+(b-p)/(g-p)*(x-f)))}:(u,p,f,g,x,b)=>{u.push(new ke(p+(b-f)/(x-f)*(g-p),b))};for(let u of n){let p=[];for(let f of u){if(f.length<=2)continue;let g=[];for(let w=0;w<f.length-1;w++){let S=f[w].x,I=f[w].y,M=f[w+1].x,C=f[w+1].y,R=r===0?S:I,F=r===0?M:C;R<e?F>e&&l(g,S,I,M,C,e):R>i?F<i&&l(g,S,I,M,C,i):g.push(f[w]),F<e&&R>=e&&l(g,S,I,M,C,e),F>i&&R<=i&&l(g,S,I,M,C,i)}let x=f.at(-1),b=r===0?x.x:x.y;b>=e&&b<=i&&g.push(x),g.length&&(x=g.at(-1),g[0].x===x.x&&g[0].y===x.y||g.push(g[0]),p.push(g))}p.length&&s.push(p)}return s}function Z1(n,e){let i=o0(Pg(n),Pg([e]),0);return i==null?[]:s0(i)}function W1(n,e,i=0){let s=Pg(n,65536),l=[];for(;e.valid();e.next()){let[u,p]=e.get(),f=u.x*65536,g=u.y*65536,x=p.x*65536,b=p.y*65536,w=x-f,S=b-g,I=Math.hypot(w,S);if(I===0)continue;
7f-=w*i,g-=S*i,x+=w*i,b+=S*i;let M=Math.trunc(S/I*3),C=-Math.trunc(w/I*3);l.push([[[f,g],[x,b],[x+M,b+C],[f+M,g+C],[f,g]]])}return l.length>0&&(s=o0(s,l,2)),s0(s,1/65536,128)}function Pg(n,e=1){return[n.map(i=>i.map(r=>[r.x*e,r.y*e]))]}function s0(n,e=1,i){return n.map(r=>r.map((s,l)=>{let u=s.map(p=>{let f=p[0],g=p[1];return i&&(f=Math.round(f/i)*i,g=Math.round(g/i)*i),new ke(f*e,g*e)._round()});return l>0&&u.reverse(),u}))}class Dg{constructor(e,i){this.layoutVertexArray=new Zn,this.indexArray=new Yi,this.lineIndexArray=new Vr,this.triangleSegments=new pi,this.lineSegments=new pi,this.programConfigurations=new To(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,i&&(this.elevatedLayoutVertexArray=new Lo)}update(e,i,r,s,l,u,p,f){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,f)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,si.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Ki.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(e,i,r,s,l,u,p){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,s,l,u,void 0,p)}}class km{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new Dg(e,!1),this.elevationBufferData=new Dg(e,!0),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,r,s){this.hasPattern=bg("fill",this.layers,this.pixelRatio,i);let l=this.layers[0].layout.get("fill-sort-key"),u=[];for(let{feature:p,id:f,index:g,sourceLayerIndex:x}of e){let b=this.layers[0]._featureFilter.needGeometry,w=qr(p,b);if(!this.layers[0]._featureFilter.filter(new Jt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),w,r))continue;let S=l?l.evaluate(w,{},r,i.availableImages):void 0,I={id:f,properties:p.properties,type:p.type,sourceLayerIndex:x,index:g,geometry:b?w.geometry:$r(p,r,s),patterns:{},sortKey:S};u.push(I)}l&&u.sort((p,f)=>p.sortKey-f.sortKey);for(let p of u){let{geometry:f,index:g,sourceLayerIndex:x}=p;if(this.hasPattern){let b=wg("fill",this.layers,p,this.zoom,this.pixelRatio,i);this.patternFeatures.push(b)}else this.addFeature(p,f,g,r,{},i.availableImages,i.brightness,i.elevationFeatures);i.featureIndex.insert(e[g].feature,f,g,x,this.index)}}update(e,i,r,s,l,u,p){this.bufferData.update(e,i,r,s,l,u,p,this.worldview),this.elevationBufferData.update(e,i,r,s,l,u,p,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,i,r,s,l,u,p,this.worldview)}updateExpressions(e){this.bufferData.programConfigurations.updateExpressions(e),this.elevationBufferData.programConfigurations.updateExpressions(e),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(e),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(e))}addFeatures(e,i,r,s,l,u){for(let p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,i,r,s,u,e.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}
7addFeature(e,i,r,s,l,u=[],p,f){let g=mp(i,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(e,g,s,r,f):this.addGeometry(g,this.bufferData),this.bufferData.populatePaintArrays(e,r,l,u,s,p,this.worldview),this.elevationBufferData.populatePaintArrays(e,r,l,u,s,p,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,i,r,s,l){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(i,r,s,l,this.worldview))}addElevatedRoadFeature(e,i,r,s,l){let u=new Array,p=mh.getElevationFeature(e,l);if(!p)return void this.addGeometry(i,this.bufferData);{let g=this.clipPolygonsToTile(i,1);g.length>0&&u.push({polygons:g,elevationFeature:p,elevationTileID:r})}let f={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},r),featureIndex:s};for(let g of u)if(g.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new Wr(g.elevationTileID,this.layers,this.zoom,this.lut));let b=g.elevationFeature.isTunnel(),w=0;Object.hasOwn(e.properties,Tm)&&(w=+e.properties[Tm]),this.elevatedStructures.addPortalCandidates(g.elevationFeature.id,g.polygons,b,g.elevationFeature,w)}g.elevationFeature.constantHeight==null&&(g.polygons=this.prepareElevatedPolygons(g.polygons,g.elevationFeature,g.elevationTileID));let x=new a(r,g.elevationTileID);this.addElevatedGeometry(g.polygons,x,g.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,s,f)}}addElevatedGeometry(e,i,r,s,l,u){let p={elevation:r,elevationSampler:i,bias:s,index:l,featureInfo:u},[f,g]=this.addGeometry(e,this.elevationBufferData,p);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:f,max:g}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,f),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,g))}addGeometry(e,i,r){let s=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,u=null;r&&(u=r.elevationSampler.constantElevation(r.elevation,r.bias),u!=null&&(s=u,l=u));let p=(f,g,x)=>{if(r!=null)if(g.push(f),u!=null)i.elevatedLayoutVertexArray.emplaceBack(u),x.push(u);else{let b=r.elevationSampler.pointElevation(f,r.elevation,r.bias);i.elevatedLayoutVertexArray.emplaceBack(b),x.push(b),s=Math.min(s,b),l=Math.max(l,b)}};for(let f of e){let g=0;for(let L of f)g+=L.length;let x=i.triangleSegments.prepareSegment(g,i.layoutVertexArray,i.indexArray),b=x.vertexLength,w=[],S=[],I=[],M=[],C=[],R=i.layoutVertexArray.length;for(let L of f){if(L.length===0)continue;L!==f[0]&&S.push(w.length/2);let j=i.lineSegments.prepareSegment(L.length,i.layoutVertexArray,i.lineIndexArray),H=j.vertexLength;r&&C.push(i.layoutVertexArray.length-R),p(L[0],I,M),i.layoutVertexArray.emplaceBack(L[0].x,L[0].y),i.lineIndexArray.emplaceBack(H+L.length-1,H),w.push(L[0].x),w.push(L[0].y);for(let $=1;$<L.length;$++)p(L[$],I,M),i.layoutVertexArray.emplaceBack(L[$].x,L[$].y),i.lineIndexArray.emplaceBack(H+$-1,H+$),w.push(L[$].x),w.push(L[$].y);j.vertexLength+=L.length,j.primitiveLength+=L.length}let F=bn(w,S);for(let L=0;L<F.length;L+=3)i.indexArray.emplaceBack(b+F[L],b+F[L+1],b+F[L+2]);if(F.length>0&&r&&this.elevationMode==="hd-road-base"){let L=r.elevation.isTunnel(),j=r.elevation.safeArea,H=this.elevatedStructures.addVertices(I,M);this.elevatedStructures.addTriangles(F,H,L);let $=C.length;if($>0){for(let ie=0;ie<$-1;ie++)this.elevatedStructures.addRenderableRing(r.index,C[ie]+H,C[ie+1]-C[ie],L,j,r.featureInfo);this.elevatedStructures.addRenderableRing(r.index,C[$-1]+H,I.length-C[$-1],L,j,r.featureInfo)}}x.vertexLength+=g,x.primitiveLength+=F.length/3}return[s,l]}prepareElevatedPolygons(e,i,r){let s=1/Hr(r),l=[];for(let u of e){let p=W1(u,new Cm(i,s),.1);l.push(...p)}return l}clipPolygonsToTile(e,i){let r=-i,s=-i,l=Xe+i,u=Xe+i,p=0,f=[],g=[];for(;p<e.length;p++){let w=e[p],S=Jh(w);(S.min.x>=r&&S.max.x<=l&&S.min.y>=s&&S.max.y<=u?f:g).push(w)}if(f.length===e.length)return e;let x=[new ke(r,s),new ke(l,s),new ke(l,u),new ke(r,u),new ke(r,s)],b=f;for(let w of g)b.push(...Z1(w,x));return b}}let a0,l0,c0,u0;Qe(km,"FillBucket",{omit:["layers","patternFeatures"]}),Qe(Dg,"FillBufferData"),Qe(Wr,"ElevatedStructures");
7class Nm{constructor(e,i,r,s){if(this.triangleCount=i.length/3,this.min=new ke(0,0),this.max=new ke(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||e.length===0)return;let[l,u]=[e[0].clone(),e[0].clone()];for(let b=1;b<e.length;++b){let w=e[b];l.x=Math.min(l.x,w.x),l.y=Math.min(l.y,w.y),u.x=Math.max(u.x,w.x),u.y=Math.max(u.y,w.y)}if(s){let b=Math.ceil(Math.max(u.x-l.x,u.y-l.y)/s);r=Math.max(r,b)}if(r===0)return;this.min=l,this.max=u;let p=this.max.sub(this.min);p.x=Math.max(p.x,1),p.y=Math.max(p.y,1);let f=Math.max(p.x,p.y)/r;this.cellsX=Math.max(1,Math.ceil(p.x/f)),this.cellsY=Math.max(1,Math.ceil(p.y/f)),this.xScale=1/f,this.yScale=1/f;let g=[];for(let b=0;b<this.triangleCount;b++){let w=e[i[3*b+0]].sub(this.min),S=e[i[3*b+1]].sub(this.min),I=e[i[3*b+2]].sub(this.min),M=Xs(Math.floor(Math.min(w.x,S.x,I.x)),this.xScale,this.cellsX),C=Xs(Math.floor(Math.max(w.x,S.x,I.x)),this.xScale,this.cellsX),R=Xs(Math.floor(Math.min(w.y,S.y,I.y)),this.yScale,this.cellsY),F=Xs(Math.floor(Math.max(w.y,S.y,I.y)),this.yScale,this.cellsY),L=new ke(0,0),j=new ke(0,0),H=new ke(0,0),$=new ke(0,0);for(let ie=R;ie<=F;++ie){L.y=j.y=ie*f,H.y=$.y=(ie+1)*f;for(let W=M;W<=C;++W)L.x=H.x=W*f,j.x=$.x=(W+1)*f,(q(w,S,I,L,j,$)||q(w,S,I,L,$,H))&&g.push({cellIdx:ie*this.cellsX+W,triIdx:b})}}if(g.length===0)return;g.sort((b,w)=>b.cellIdx-w.cellIdx||b.triIdx-w.triIdx);let x=0;for(;x<g.length;){let b=g[x].cellIdx,w={start:this.payload.length,len:0};for(;x<g.length&&g[x].cellIdx===b;)++w.len,this.payload.push(g[x++].triIdx);this.cells[b]=w}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(e,i){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;let r=Xs(e.x-this.min.x,this.xScale,this.cellsX),s=Xs(e.y-this.min.y,this.yScale,this.cellsY),l=this.cells[s*this.cellsX+r];if(l){this._lazyInitLookup();for(let u=0;u<l.len;u++){let p=this.payload[l.start+u],f=Math.floor(p/8),g=1<<p%8;if(!(this.lookup[f]&g)&&(this.lookup[f]|=g,i.push(p),i.length===this.triangleCount))return}}}query(e,i,r){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>i.x||e.y>this.max.y||this.min.y>i.y)return;this._lazyInitLookup();let s=Xs(e.x-this.min.x,this.xScale,this.cellsX),l=Xs(i.x-this.min.x,this.xScale,this.cellsX),u=Xs(e.y-this.min.y,this.yScale,this.cellsY),p=Xs(i.y-this.min.y,this.yScale,this.cellsY);for(let f=u;f<=p;f++)for(let g=s;g<=l;g++){let x=this.cells[f*this.cellsX+g];if(x)for(let b=0;b<x.len;b++){let w=this.payload[x.start+b],S=Math.floor(w/8),I=1<<w%8;if(!(this.lookup[S]&I)&&(this.lookup[S]|=I,r.push(w),r.length===this.triangleCount))return}}}}function Xs(n,e,i){return Math.max(0,Math.min(i-1,Math.floor(n*e)))}Qe(Nm,"TriangleGridIndex");class h0{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){for(let r of this.footprints)i.push({footprint:r,id:e})}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,r,s){let l=[];for(let{feature:u,id:p,index:f,sourceLayerIndex:g}of e){let x=this.layers[0]._featureFilter.needGeometry,b=qr(u,x);if(!this.layers[0]._featureFilter.filter(new Jt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),b,r))continue;let w={id:p,properties:u.properties,type:u.type,sourceLayerIndex:g,index:f,geometry:x?b.geometry:$r(u,r,s),patterns:{}};l.push(w)}for(let u of l){let{geometry:p,index:f,sourceLayerIndex:g}=u;this.addFeature(u,p,f,r,{},i.availableImages,i.brightness),i.featureIndex.insert(e[f].feature,p,f,g,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(e){}update(e,i,r,s,l,u,p){}destroy(){}addFeature(e,i,r,s,l,u=[],p){for(let f of mp(i,2)){let g=[],x=[],b=[],w=new ke(1/0,1/0),S=new ke(-1/0,-1/0);for(let C of f)if(C.length!==0){C!==f[0]&&b.push(x.length/2);for(let R=0;R<C.length;
vendor: 7,176 bytes, line 7
7R++)x.push(C[R].x),x.push(C[R].y),g.push(C[R]),w.x=Math.min(w.x,C[R].x),w.y=Math.min(w.y,C[R].y),S.x=Math.max(S.x,C[R].x),S.y=Math.max(S.y,C[R].y)}let I=bn(x,b),M=new Nm(g,I,8,256);this.footprints.push({vertices:g,indices:I,grid:M,min:w,max:S})}}}Qe(h0,"ClipBucket",{omit:["layers"]});let X1=Rt([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Y1=Rt([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),J1=Rt([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),K1=Rt([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Q1=Rt([{name:"a_join_normal_inside",components:3,type:"Int16"}]),eb=Rt([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),tb=Rt([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:ib}=X1,yp=Number.MAX_SAFE_INTEGER,nb=yp-1;function d0(n,e,i,r){return n.order<e||n.order===yp||!(n.clipMask&i)||function(s,l){if(l.length===0)return!1;let u=s;for(;u!=="";){if(l.includes(u))return!1;u=tm(u)}return!0}(r,n.clipScope)}function Um(n,e){return n.x-e.x||n.y-e.y}function p0(n,e){return Um(n.min,e.min)===0&&Um(n.max,e.max)===0}function Rg(n,e){return!(n.min.x>e.max.x||n.max.x<e.min.x||n.min.y>e.max.y||n.max.y<e.min.y)}function Vm(n,e){if(n.length!==e.length)return!1;for(let i=0;i<n.length;i++)if(n[i].sourceId!==e[i].sourceId||!p0(n[i],e[i])||n[i].order!==e[i].order||n[i].clipMask!==e[i].clipMask||!Xo(n[i].clipScope,e[i].clipScope))return!1;return!0}function f0(n,e,i){let r=1/Xe,s=1/(1<<i.canonical.z),l=(e.x*r+i.canonical.x)*s+i.wrap,u=(e.y*r+i.canonical.y)*s;return{min:new ke((n.x*r+i.canonical.x)*s+i.wrap,(n.y*r+i.canonical.y)*s),max:new ke(l,u)}}function rb(n,e,i){let r=1<<i.canonical.z,s=((e.x-i.wrap)*r-i.canonical.x)*Xe,l=(e.y*r-i.canonical.y)*Xe;return{min:new ke(((n.x-i.wrap)*r-i.canonical.x)*Xe,(n.y*r-i.canonical.y)*Xe),max:new ke(s,l)}}function Lg(n,e,i,r,s,l,u){let p=n.indices,f=n.vertices,g=[];for(let x=r;x<r+s;x+=3){let b=e[i[x+0]+l],w=e[i[x+1]+l],S=e[i[x+2]+l],I=Math.min(b.x,w.x,S.x),M=Math.max(b.x,w.x,S.x),C=Math.min(b.y,w.y,S.y),R=Math.max(b.y,w.y,S.y);g.length=0,n.grid.query(new ke(I,C),new ke(M,R),g);for(let F=0;F<g.length;F++){let L=g[F];if(q(f[p[3*L+0]],f[p[3*L+1]],f[p[3*L+2]],b,w,S,u))return!0}}return!1}function m0(n,e,i,r){if(!n||!i)return!1;let s=n.vertices;if(!e.canonical.equals(r.canonical)||e.wrap!==r.wrap){if(i.vertices.length<n.vertices.length)return m0(i,r,n,e);let l=e.canonical,u=r.canonical,p=Math.pow(2,u.z-l.z);s=n.vertices.map(f=>new ke((f.x+l.x*Xe)*p-u.x*Xe,(f.y+l.y*Xe)*p-u.y*Xe))}return Lg(i,s,n.indices,0,n.indices.length,0,0)}function _0(n,e,i,r){let s=Math.pow(2,r.z-i.z);return new ke((n+i.x*Xe)*s-r.x*Xe,(e+i.y*Xe)*s-r.y*Xe)}function g0(n,e){let i=[];e.grid.queryPoint(n,i);let r=e.indices,s=e.vertices;for(let l=0;l<i.length;l++){let u=i[l];if(z([s[r[3*u+0]],s[r[3*u+1]],s[r[3*u+2]]],n))return!0}return!1}let jm={None:0,Model:1,Symbol:2,FillExtrusion:4},zg=[new ke(0,0),new ke(Xe,0),new ke(Xe,Xe),new ke(0,Xe)];function y0(n,e){let i=[],r=[];if(!e||n.length<2)return[n];if(n.length===2)return k(n[0],n[1],zg)?[n]:[];for(let s=0;s<n.length+2;s++){let l=s===0?n.at(-1):n[(s-1)%n.length],u=n[s%n.length],p=n[(s+1)%n.length],f=k(l,u,zg),g=k(u,p,zg),x=f||g;x&&r.push(u),x&&g||r.length>0&&(r.length>1&&i.push(r),r=[])}return r.length>1&&i.push(r),i}let Og=$s.types,ob=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],sb=["fill-extrusion-flood-light-ground-radius"],ab=Math.pow(2,13),lb=Math.pow(2,15)-1,Gm=new ke(0,1),Ga=2147483648,Hm=1073741824;function xp(n,e,i,r,s,l,u,p){n.emplaceBack((e<<1)+u,(i<<1)+l,(Math.floor(r*ab)<<1)+s,Math.round(p))}function vp(n,e,i){n.emplaceBack(e.x*Xe,e.y*Xe,i?1:0)}function $m(n,e,i,r,s,l){n.emplaceBack(e.x,e.y,(i.x<<1)+r,(i.y<<1)+s,l)}function bp(n,e,i){n.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class x0{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class qm{constructor(){this.data=[]}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}static serialize(e,i){let r=e.data.length,s=new Uint32Array(4*r),l=[];l.length=r;for(let u=0;u<r;u++){let p=e.data[u],f=4*u;s[f]=p.vertexOffset,s[f+1]=p.vertexCount,s[f+2]=p.indexOffset,s[f+3]=p.indexCount,l[u]=p.ringIndices}return i&&i.add(s.buffer),{scalars:s,rings:l}}static deserialize(e){let{scalars:i,rings:r}=e,s=i.length/4,l=new qm,u=[];u.length=s,l.data=u;for(let p=0;p<s;p++){let f=4*p,g=new x0;g.vertexOffset=i[f],g.vertexCount=i[f+1],g.indexOffset=i[f+2],g.indexCount=i[f+3],g.ringIndices=r[p],l.data[p]=g}return l}}class Zm{constructor(){this.centroidXY=new ke(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new ke(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new ke(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new ke(0,0)}span(){return new ke(this.max.x-this.min.x,this.max.y-this.min.y)}}class Wm{constructor(){this.data=[],this.buffer=null}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}find(e){return this.data.find(e)}[Symbol.iterator](){return this.data[Symbol.iterator]()}static serialize(e,i){let r=e.data.length,s=new Float64Array(15*r);for(let l=0;l<r;l++){let u=e.data[l],p=15*l;s[p]=u.centroidXY.x,s[p+1]=u.centroidXY.y,s[p+2]=u.min.x,s[p+3]=u.min.y,s[p+4]=u.max.x,s[p+5]=u.max.y,s[p+6]=u.groupCentroidPos.x,s[p+7]=u.groupCentroidPos.y,s[p+8]=u.vertexArrayOffset,s[p+9]=u.vertexCount,s[p+10]=u.groundVertexArrayOffset,s[p+11]=u.groundVertexCount,s[p+12]=u.footprintSegLen,s[p+13]=u.height,s[p+14]=u.buildingId}return i&&i.add(s.buffer),{buffer:s}}static deserialize(e){let i=e.buffer,r=i.length/15,s=new Wm;s.buffer=i;let l=[];l.length=r,s.data=l;let u=0;for(let p=0;p<r;p++){let f=15*p,g=new Zm;g.centroidXY=new ke(i[f],i[f+1]),g.min=new ke(i[f+2],i[f+3]),g.max=new ke(i[f+4],i[f+5]),g.groupCentroidPos=new ke(i[f+6],i[f+7]),g.vertexArrayOffset=i[f+8],g.vertexCount=i[f+9],g.groundVertexArrayOffset=i[f+10],g.groundVertexCount=i[f+11],g.footprintSegLen=i[f+12],g.height=i[f+13],g.buildingId=i[f+14],g.footprintSegIdx=u,u+=g.footprintSegLen,s.data[p]=g}return s}}class Fg{constructor(){this.acc=new ke(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,i){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=i.x,e.min.y=e.max.y=i.y)}appendEdge(e,i,r){this.accCount++,this.acc._add(i);let s=!!this.borders;i.x<e.min.x?(e.min.x=i.x,s=!0):i.x>e.max.x&&(e.max.x=i.x,s=!0),i.y<e.min.y?(e.min.y=i.y,s=!0):i.y>e.max.y&&(e.max.y=i.y,s=!0),((i.x===0||i.x===Xe)&&i.x===r.x)!=((i.y===0||i.y===Xe)&&i.y===r.y)&&this.processBorderOverlap(i,r),s&&this.checkBorderIntersection(i,r)}checkBorderIntersection(e,i){i.x<0!=e.x<0&&this.addBorderIntersection(0,mt(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>Xe!=e.x>Xe&&this.addBorderIntersection(1,mt(i.y,e.y,(Xe-i.x)/(e.x-i.x))),i.y<0!=e.
7y<0&&this.addBorderIntersection(2,mt(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>Xe!=e.y>Xe&&this.addBorderIntersection(3,mt(i.x,e.x,(Xe-i.y)/(e.y-i.y)))}addBorderIntersection(e,i){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);let r=this.borders[e];i<r[0]&&(r[0]=i),i>r[1]&&(r[1]=i)}processBorderOverlap(e,i){if(e.x===i.x){if(e.y===i.y)return;let r=e.x===0?0:1;this.addBorderIntersection(r,i.y),this.addBorderIntersection(r,e.y)}else{let r=e.y===0?2:3;this.addBorderIntersection(r,i.x),this.addBorderIntersection(r,e.x)}}centroid(){return this.accCount===0?new ke(0,0):new ke(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,i)=>e+ +(i[0]!==Number.MAX_VALUE),0):0}}function v0(n,e){let i=n.add(e)._unit(),r=ne(n.x*i.x+n.y*i.y,-1,1);var s,l,u;return u=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(u)))/4*lb*((s=n).x*(l=e).y-s.y*l.x<0?-1:1)}let cb=[n=>n.x<0,n=>n.x>Xe,n=>n.y<0,n=>n.y>Xe];function ub(n,e,i,r){let s=[4];if(r===0)return s;i._mult(r);let l=n.sub(i),u=e.sub(i),p=[n,e,l,u];for(let f=0;f<4;f++)for(let g of p)if(cb[f](g)){s.push(f);break}return s}class Bg{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new Nd,this.indexArray=new Yi,this.programConfigurations=new To(e.layers,{zoom:e.zoom,lut:e.lut},i=>sb.includes(i)),this._segments=new pi,this.hiddenByLandmarkVertexArray=new Ll,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new pi}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(e,i,r,s=!1){let l=e.length;if(l>2){let u=Math.max(0,this._segments.get().length-1),p=this._segments._prepareSegment(4*l,this.vertexArray.length,2*this._segmentToGroundQuads[u].length),f;u!==this._segments.get().length-1&&(u++,this._segmentToGroundQuads[u]=[],this._segmentToRegionTriCounts[u]=[0,0,0,0,0]);{let g=e[0],x=e[1];f=v0(g.sub(e[l-1])._perp()._unit(),x.sub(g)._perp()._unit())}for(let g=0;g<l;g++){let x=g===l-1?0:g+1,b=e[g],w=e[x],S=e[x===l-1?0:x+1],I=w.sub(b)._perp()._unit(),M=v0(I,S.sub(w)._perp()._unit()),C=f,R=M;if(kg(b,w,i)||s&&T0(b,i)&&T0(w,i)){f=M;continue}let F=p.vertexLength;$m(this.vertexArray,b,w,1,1,C),$m(this.vertexArray,b,w,1,0,C),$m(this.vertexArray,b,w,0,1,R),$m(this.vertexArray,b,w,0,0,R),p.vertexLength+=4;let L=ub(b,w,I,r);for(let j of L)this._segmentToGroundQuads[u].push({id:F,region:j}),this._segmentToRegionTriCounts[u][j]+=2,p.primitiveLength+=2;f=M}}}prepareBorderSegments(){if(!this.hasData())return;let e=this._segments.get(),i=e.length;for(let r=0;r<i;r++)this._segmentToGroundQuads[r].sort((s,l)=>s.region-l.region);for(let r=0;r<i;r++){let s=this._segmentToGroundQuads[r],l=e[r],u=this._segmentToRegionTriCounts[r];u.reduce((f,g)=>f+g,0);let p=0;for(let f=0;f<=4;f++){let g=u[f];if(g!==0){let x=this.regionSegments[f];x||(x=this.regionSegments[f]=new pi);let b={vertexOffset:l.vertexOffset,primitiveOffset:l.primitiveOffset+p,vertexLength:l.vertexLength,primitiveLength:g};x.get().push(b)}p+=g}for(let f=0;f<s.length;f++){let g=s[f].id;this.indexArray.emplaceBack(g,g+1,g+3),this.indexArray.emplaceBack(g,g+3,g+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,i,r,s,l,u,p){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,i,r,s,l,u,void 0,p)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Y1.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.groundRadiusArray!=null&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,J1.members)))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,i,r,s,l,u,p,f){this.hasData()&&this.programConfigurations.updatePaintArrays(e,i,r,s,l,u,p,f)}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&Ga||e.flags&Hm))}updateHiddenByLandmarkRange(e,i,r){if(!this.hasData())return;let s=i+e;if(i!==0){for(let l=e;l<s;++l)this.hiddenByLandmarkVertexArray.emplace(l,r?1:0);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,eb.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){let i=this.regionSegments[e];i&&i.destroy()}}}}class Xm{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new Wm,this.footprintIndices=new Yi,this.footprintVertices=new Zn,this.footprintSegments=new qm,this.layoutVertexArray=new Hc,this.centroidVertexArray=new Jd,this.wallVertexArray=new pm,this.indexArray=new Yi,this.programConfigurations=new To(e.layers,{zoom:e.zoom,lut:e.lut},i=>ob.includes(i)),this.segments=new pi,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.groundEffect=new Bg(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}
7populate(e,i,r,s){this.features=[],this.hasPattern=bg("fill-extrusion",this.layers,this.pixelRatio,i),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Hr(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(let{feature:l,id:u,index:p,sourceLayerIndex:f}of e){let g=this.layers[0]._featureFilter.needGeometry,x=qr(l,g);if(!this.layers[0]._featureFilter.filter(new Jt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),x,r))continue;let b={id:u,sourceLayerIndex:f,index:p,geometry:g?x.geometry:$r(l,r,s),properties:l.properties,type:l.type,patterns:{}},w=this.layoutVertexArray.length,S=Og[b.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:l.id,feature:wg("fill-extrusion",this.layers,b,this.zoom,this.pixelRatio,i)});else if(this.wallMode)for(let I of b.geometry)for(let M of y0(I,S))this.addFeature(l.id,b,[M],p,r,{},i.availableImages,s,i.brightness);else this.addFeature(l.id,b,b.geometry,p,r,{},i.availableImages,s,i.brightness);i.featureIndex.insert(l,b.geometry,p,f,this.index,w)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,i,r,s,l,u){for(let{featureId:p,feature:f}of this.features){let g=Og[f.type]==="Polygon",{geometry:x}=f;if(this.wallMode)for(let b of x)for(let w of y0(b,g))this.addFeature(p,f,[w],f.index,i,r,s,l,u);else this.addFeature(p,f,x,f.index,i,r,s,l,u)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(e,i,r,s,l,u,p){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,this.worldview),this.groundEffect.update(e,i,l,r,s,u,p,this.worldview)}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ib),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Q1.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,tb.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,K1.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,i,r,s,l,u,p,f,g){let x=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(i,{})/this.tileToMeter,b=[new ke(0,0),new ke(Xe,Xe)],w=f.projection,S=w.name==="globe",I=this.wallMode||Og[i.type]==="Polygon",M=new Fg;M.centroidDataIndex=this.centroidData.length;let C=new Zm;C.buildingId=e,i.properties&&Object.hasOwn(i.properties,"building_id")&&(C.buildingId=Number(i.properties.building_id)),M.buildingId=C.buildingId;let R=this.layers[0].paint.get("fill-extrusion-base").evaluate(i,{},l)<=0,F=this.layers[0].paint.get("fill-extrusion-height").evaluate(i,{},l),L;if(C.height=F,C.vertexArrayOffset=this.layoutVertexArray.length,C.groundVertexArrayOffset=this.groundEffect.vertexArray.length,S&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new nh),this.wallMode){if(S)return void Bt("Non zero fill-extrusion-line-width is not yet supported on globe.");if(r.length!==1)return;L=function(Y){let ee=Y[0].x===Y.at(-1).x&&Y[0].y===Y.at(-1).y;(function(Ge){let $e=0,Je=Ge.length;for(let tt=0;tt<Je;tt++)$e+=(Ge[(tt+1)%Je].x-Ge[tt].x)*(Ge[(tt+1)%Je].y+Ge[tt].y);return $e>=0})(Y)||(Y=Y.reverse());let ge={geometry:[],joinNormals:[],indices:[]},Te=[],Ae=[],Ie=[],Be=Y.length;for(;Be>=2&&Y[Be-1].equals(Y[Be-2]);)Be--;if(Be<(ee?3:2))return ge;let xe,Se,Me,Le,ze,We=0;for(;We<Be-1&&Y[We].equals(Y[We+1]);)We++;ee&&(xe=Y[Be-2],ze=Y[We].sub(xe)._unit()._perp());for(let Ge=We;Ge<Be;Ge++){if(Me=Ge===Be-1?ee?Y[We+1]:void 0:Y[Ge+1],Me&&Y[Ge].equals(Me))continue;ze&&(Le=ze),xe&&(Se=xe),xe=Y[Ge],ze=Me?Me.sub(xe)._unit()._perp():Le,Le=Le||ze;let $e=Le.add(ze);$e.x===0&&$e.y===0||$e._unit();let Je=$e.x*ze.x+$e.y*ze.y,tt=Je!==0?1/Je:1/0,ct=Le.x*ze.y-Le.y*ze.x>0,rt="miter",ft=2;rt==="miter"&&tt>ft&&(rt="bevel"),rt==="bevel"&&(tt>100&&(rt="flipbevel"),tt<ft&&(rt="miter"));let Zt=(St,Ut,Pt,ji)=>{let Qt=new ke(St.x,St.y),$t=new ke(St.x,St.y);Qt.x+=Ut.x*ji,Qt.y+=Ut.y*ji,$t.x-=Ut.x*Math.max(Pt,1),$t.y-=Ut.y*Math.max(Pt,1),Ie.push(Ut),Te.push(Qt),Ae.push($t)};if(rt==="miter")$e._mult(tt),Zt(xe,$e,0,0);else if(rt==="flipbevel")$e=ze.mult(-1),Zt(xe,$e,0,0),Zt(xe,$e.mult(-1),0,0);else{let St=-Math.sqrt(tt*tt-1),Ut=ct?St:0,Pt=ct?0:St;Se&&Zt(xe,Le,Ut,Pt),Me&&Zt(xe,ze,Ut,Pt)}}ge.geometry=[...Te,...Ae.reverse(),Te[0]],ge.joinNormals=[...Ie,...Ie.reverse(),Ie.at(-1)];let De=ge.geometry.length-1;for(let Ge=0;Ge<De/2;Ge++)if(Ge+1<De/2){let $e=Ge,Je=Ge+1,tt=De-1-Ge,ct=De-2-Ge;$e=$e===0?De-1:$e-1,Je=Je===0?De-1:Je-1,tt=tt===0?De-1:tt-1,ct=ct===0?De-1:ct-1,ge.indices.push(tt),ge.indices.push(Je),ge.indices.push($e),ge.indices.push(tt),ge.indices.push(ct),ge.indices.push(Je)}return ge}(r[0]),r=[L.geometry]}let j=(Y,ee)=>Y<(ee.length-1)/2||Y===ee.length-1,H=this.wallMode?[r]:mp(r,500);for(let Y=H.length-1;Y>=0;Y--){let ee=H[Y];(ee.length===0||db(ee[0]))&&H.splice(Y,1)}let $;if(S)$=A0(H,b,l);else{$=[];for(let Y of H)$.push({polygon:Y,bounds:b})}let ie=I?this.edgeRadius:0,W=ie>0&&this.zoom<17,Q=(Y,ee)=>{if(Y.length===0)return!1;let me=Y.at(-1);return ee.x===me.x&&ee.y===me.y};for(let{polygon:Y,bounds:ee}of $){let me=0,ge=0;for(let Be of Y)I&&!Be[0].equals(Be.at(-1))&&Be.push(Be[0]),ge+=I?Be.length-1:Be.length;let Te=this.segments.prepareSegment((I?5:4)*ge,this.layoutVertexArray,this.indexArray);C.footprintSegIdx<0&&(C.footprintSegIdx=this.footprintSegments.length),C.pol
7ygonSegIdx<0&&(C.polygonSegIdx=this.polygonSegments.length);let Ae={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ie=new x0;if(Ie.vertexOffset=this.footprintVertices.length,Ie.indexOffset=3*this.footprintIndices.length,Ie.ringIndices=[],I){let Be=[],xe=[];me=Te.vertexLength;for(let Me=0;Me<Y.length;Me++){let Le=Y[Me];Le.length&&Me!==0&&xe.push(Be.length/2);let ze=[],We,De;We=Le[1].sub(Le[0])._perp()._unit(),Ie.ringIndices.push(Le.length-1);for(let Ge=1;Ge<Le.length;Ge++){let $e=Le[Ge],Je=Le[Ge===Le.length-1?1:Ge+1],tt=$e.clone();if(ie){De=Je.sub($e)._perp()._unit();let ct=We.add(De)._unit(),rt=ie*Math.min(4,1/(We.x*ct.x+We.y*ct.y));tt.x+=rt*ct.x,tt.y+=rt*ct.y,tt.x=Math.round(tt.x),tt.y=Math.round(tt.y),We=De}if(!R||ie!==0&&!W||Q(ze,tt)||ze.push(tt),xp(this.layoutVertexArray,tt.x,tt.y,0,0,1,1,0),this.wallMode){let ct=j(Ge,Le);vp(this.wallVertexArray,L.joinNormals[Ge],!ct)}Te.vertexLength++,this.footprintVertices.emplaceBack($e.x,$e.y),Be.push($e.x,$e.y),S&&bp(this.layoutVertexExtArray,w.projectTilePoint(tt.x,tt.y,l),w.upVector(l,tt.x,tt.y))}R&&(ie===0||W)&&(ze.length!==0&&Q(ze,ze[0])&&ze.pop(),this.groundEffect.addData(ze,ee,x))}let Se=this.wallMode?L.indices:bn(Be,xe);for(let Me=0;Me<Se.length;Me+=3)this.footprintIndices.emplaceBack(Ie.vertexOffset+Se[Me+0],Ie.vertexOffset+Se[Me+1],Ie.vertexOffset+Se[Me+2]),this.indexArray.emplaceBack(me+Se[Me],me+Se[Me+2],me+Se[Me+1]),Te.primitiveLength++;Ie.indexCount+=Se.length,Ie.vertexCount+=this.footprintVertices.length-Ie.vertexOffset}for(let Be=0;Be<Y.length;Be++){let xe=Y[Be];M.startRing(C,xe[0]);let Se=xe.length>4&&S0(xe[xe.length-2],xe[0],xe[1]),Me=ie?hb(xe[xe.length-2],xe[0],xe[1],ie):0,Le=[],ze,We,De;We=xe[1].sub(xe[0])._perp()._unit();let Ge=!0;for(let $e=1,Je=0;$e<xe.length;$e++){let tt=xe[$e-1],ct=xe[$e],rt=xe[$e===xe.length-1?1:$e+1];if(M.appendEdge(C,ct,tt),kg(ct,tt,ee)){ie&&(We=rt.sub(ct)._perp()._unit(),Ge=!Ge);continue}let ft=ct.sub(tt)._perp(),Zt=ft.x/(Math.abs(ft.x)+Math.abs(ft.y)),St=ft.y>0?1:0,Ut=tt.dist(ct);if(Je+Ut>32768&&(Je=0),ie){De=rt.sub(ct)._perp()._unit();let $t=w0(tt,ct,rt,b0(We,De),ie);isNaN($t)&&($t=0);let ui=ct.sub(tt)._unit();tt=tt.add(ui.mult(Me))._round(),ct=ct.add(ui.mult(-$t))._round(),Me=$t,We=De,R&&this.zoom>=17&&(Q(Le,tt)||Le.push(tt),Q(Le,ct)||Le.push(ct))}let Pt=Te.vertexLength,ji=xe.length>4&&S0(tt,ct,rt),Qt=E0(Je,Se,Ge);if(xp(this.layoutVertexArray,tt.x,tt.y,Zt,St,0,0,Qt),xp(this.layoutVertexArray,tt.x,tt.y,Zt,St,0,1,Qt),this.wallMode){let $t=j($e-1,xe),ui=L.joinNormals[$e-1];vp(this.wallVertexArray,ui,$t),vp(this.wallVertexArray,ui,$t)}if(Je+=Ut,Qt=E0(Je,ji,!Ge),Se=ji,xp(this.layoutVertexArray,ct.x,ct.y,Zt,St,0,0,Qt),xp(this.layoutVertexArray,ct.x,ct.y,Zt,St,0,1,Qt),this.wallMode){let $t=j($e,xe),ui=L.joinNormals[$e];vp(this.wallVertexArray,ui,$t),vp(this.wallVertexArray,ui,$t)}if(Te.vertexLength+=4,this.indexArray.emplaceBack(Pt+0,Pt+1,Pt+2),this.indexArray.emplaceBack(Pt+1,Pt+3,Pt+2),Te.primitiveLength+=2,ie){let $t=me+($e===1?xe.length-2:$e-2),ui=$e===1?me:$t+1;if(this.indexArray.emplaceBack(Pt+1,$t,Pt+3),this.indexArray.emplaceBack($t,ui,Pt+3),Te.primitiveLength+=2,ze===void 0&&(ze=Pt),!kg(rt,xe[$e],ee)){let Pi=$e===xe.length-1?ze:Te.vertexLength;this.indexArray.emplaceBack(Pt+2,Pt+3,Pi),this.indexArray.emplaceBack(Pt+3,Pi+1,Pi),this.indexArray.emplaceBack(Pt+3,ui,Pi+1),Te.primitiveLength+=3}Ge=!Ge}if(S){let $t=this.layoutVertexExtArray,ui=w.projectTilePoint(tt.x,tt.y,l),Pi=w.projectTilePoint(ct.x,ct.y,l),Tn=w.upVector(l,tt.x,tt.y),_i=w.upVector(l,ct.x,ct.y);bp($t,ui,Tn),bp($t,ui,Tn),bp($t,Pi,_i),bp($t,Pi,_i)}}I&&(me+=xe.length-1),R&&ie&&this.zoom>=17&&(Le.length!==0&&Q(Le,Le[0])&&Le.pop(),this.groundEffect.addData(Le,ee,x,ie>0))}this.footprintSegments.push(Ie),Ae.triangleCount=this.indexArray.length-Ae.triangleArrayOffset,this.polygonSegments.push(Ae),++C.footprintSegLen,++C.polygonSegLen}if(C.vertexCount=this.layoutVertexArray.length-C.vertexArrayOffset,C.groundVertexCount=this.groundEffect.vertexArray.length-C.groundVertexArrayOffset,C.vertexCount!==0){if(C.centroidXY=M.borders?Gm:this.encodeCentroid(M,C),i.properties&&Object.hasOwn(i.properties,"building_id")){let Y=C.buildingId,ee=this.buildingGroups.get(Y);ee||(ee={accX:0,accY:0,accCount:0,mergedMin:new ke(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new ke(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(Y,ee)),ee.accX+=M.acc.x,ee.accY+=M.acc.y,ee.accCount+=M.accCount,ee.mergedMin.x=Math.min(ee.mergedMin.x,C.min.x),ee.mergedMin.y=Math.min(ee.mergedMin.y,C.min.y),ee.mergedMax.x=Math.max(ee.mergedMax.x,C.max.x),ee.mergedMax.y=Math.max(ee.mergedMax.y,C.max.y),ee.partIndices.push(this.centroidData.length)}if(this.centroidData.push(C),M.borders){this.featuresOnBorder.push(M);let Y=this.featuresOnBorder.length-1;for(let ee=0;ee<M.borders.length;ee++)M.borders[ee][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[ee].push(Y)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,s,u,p,l,g,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(i,s,u,p,l,g,this.worldview),this.maxHeight=Math.max(this.maxHeight,F)}}_finalizeBuildingGroups(){for(let[,e]of this.buildingGroups){if(e.partIndices.length===0)continue;let i=new Fg;i.acc=new ke(e.accX,e.accY),i.accCount=e.accCount;let r=new Zm;r.min=e.mergedMin,r.max=e.mergedMax;let s=this.encodeCentroid(i,r),l=i.centroid();for(let u of e.partIndices){let p=this.centroidData.get(u);p.centroidXY.x===Gm.x&&p.centroidXY.y===Gm.y||(p.centroidXY=s),p.min=e.mergedMin,p.max=e.mergedMax,p.groupCentroidPos=l}}this.buildingGroups.clear()}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((i,r)=>this.featuresOnBorder[i].borders[e][0]-this.featuresOnBorder[r].borders[e][0])}splitToSubtiles(){let e=[];for(let p=0;p<this.centroidData.length;p++){let f=this.centroidData.get(p),g=+(f.min.y+f.max.y>Xe),x=2*g+(+(f.min.x+f.max.x>Xe)^g);for(let b=0;b<f.polygonSegLen;b++){let w=f.polygonSegIdx+b;e.push({centroidIdx:p,subtile:x,polygonSegmentIdx:w,triangleSegmentIdx:this.polygonSegments[w].triangleSegIdx})}}let i=new Yi;e.sort((p,f)=>p.triangleSegmentIdx===f.triangleSegmentIdx?p.subtile-f.subtile:p.triangleSegmentIdx-f.triangleSegmentIdx);let r=0,s=0,l=0;for(let p of e){if(p.triangleSegmentIdx!==r)break;l++}let u=e.length;for(;s!==e.length;){r=e[s].triangleSegmentIdx;let p=0,f=s,g=s;for(let x=f;x<l&&e[x].subtile===p;x++)g++;for(;f!==l;){let x=e[f];p=x.subtile;let b=this.centroidData.get(x.centroidIdx).min.clone(),w=this.centroidData.get(x.centroidIdx).max.clone(),S={vertexOffset:this.segments.segments[r].vertexOffset,primitiveOffset:i.length,vertexLength:this.segments.segments[r].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let I=f;I<g;I++){let M=e[I],C=this.polygonSegments[M.polygonSegmentIdx],R=this.centroidData.get(M.centroidIdx).min,F=this.centroidData.get(M.centroidIdx).max,L=this.indexArray.uint16;for(let j=C.triangleArrayOffset;j<C.triangleArrayOffset+C.triangleCount;j++)i.emplaceBack(L[3*j],L[3*j+1],L[3*j+2]);S.primitiveLength+=C.triangleCount,b.x=Math.min(b.x,R.x),b.y=Math.min(b.y,R.y),w.x=Math.max(w.x,F.x),w.y=Math.max(w.y,F.y)}S.primitiveLength>0&&this.triangleSubSegments.push({segment:S,min:b,max:w}),f=g;for(let I=f;I<l&&e[I].subtile===e[f].subtile;I++)g++}s=l;for(let x=s;x<u&&e[x].triangleSegmentIdx===e[s].triangleSegmentIdx;x++)l++}i._trim(),this.indexArray=i}getVisibleSegments(e,i,r){let s=new pi;if(this.wallMode){for(let M of this.triangleSubSegments)s.segments.push(M.segment);return s}let l=0,u=0,p=1<<e.canonical.z;if(i){let M=i.getMinMaxForTile(e);M&&(l=M.min,u=M.max)}u+=this.maxHeight;let f=e.toUnwrapped(),g,x=[f.canonical.x/p+f.wrap,f.canonical.y/p],b=[(f.canonical.x+1)/p+f.
7wrap,(f.canonical.y+1)/p],w=(M,C,R)=>[M[0]*(1-R[0])+C[0]*R[0],M[1]*(1-R[1])+C[1]*R[1]],S=[],I=[];for(let M of this.triangleSubSegments){S[0]=M.min.x/Xe,S[1]=M.min.y/Xe,I[0]=M.max.x/Xe,I[1]=M.max.y/Xe;let C=w(x,b,S),R=w(x,b,I);if(new Ei([C[0],C[1],l],[R[0],R[1],u]).intersectsPrecise(r)===0){g&&(s.segments.push(g),g=void 0);continue}let F=M.segment;g&&g.vertexOffset!==F.vertexOffset&&(s.segments.push(g),g=void 0),g?(g.vertexLength+=F.vertexLength,g.primitiveLength+=F.primitiveLength):g={vertexOffset:F.vertexOffset,primitiveLength:F.primitiveLength,vertexLength:F.vertexLength,primitiveOffset:F.primitiveOffset,sortKey:void 0,vaos:{}}}return g&&s.segments.push(g),s}encodeCentroid(e,i){let r=e.centroid(),s=i.span(),l=Math.min(7,Math.round(s.x*this.tileToMeter/10)),u=Math.min(6,Math.round(s.y*this.tileToMeter/10));return new ke(ne(r.x,1,8191)<<3|l,ne(r.y,1,8191)<<3|u)}encodeBorderCentroid(e){if(!e.borders)return new ke(0,0);let i=e.borders,r=Number.MAX_VALUE;if(i[0][0]!==r||i[1][0]!==r){let s=i[0][0]!==r?0:1;return new ke(6|(i[0][0]!==r?0:65528),(i[s][0]+i[s][1])/2<<3|6)}{let s=i[2][0]!==r?2:3;return new ke((i[s][0]+i[s][1])/2<<3|6,6|(i[2][0]!==r?0:65528))}}showCentroid(e){let i=this.centroidData.get(e.centroidDataIndex);if(i.flags&=Ga,i.groupCentroidPos.x!==0||i.groupCentroidPos.y!==0){let r=i.span(),s=Math.min(7,Math.round(r.x*this.tileToMeter/10)),l=Math.min(6,Math.round(r.y*this.tileToMeter/10));i.centroidXY=new ke(ne(i.groupCentroidPos.x,1,8191)<<3|s,ne(i.groupCentroidPos.y,1,8191)<<3|l)}else i.centroidXY=new ke(0,0);this.writeCentroidToBuffer(i)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);let i=e.vertexArrayOffset,r=e.vertexCount+e.vertexArrayOffset,s=-1073741824&e.flags?Gm:e.centroidXY,l=this.centroidVertexArray.geta_centroid_pos0(i);if(this.centroidVertexArray.geta_centroid_pos1(i)!==s.y||l!==s.x){for(let u=i;u<r;++u)this.centroidVertexArray.emplace(u,s.x,s.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(let e of this.centroidData)this.writeCentroidToBuffer(e)}updateReplacement(e,i,r){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let s=i.getReplacementRegionsForTile(e.toUnwrapped());if(Vm(this.activeReplacements,s))return;if(this.activeReplacements=s,this.centroidVertexArray.length===0)this.createCentroidsBuffer();else for(let u of this.centroidData)u.flags&=1073741823;let l=[];for(let u of this.activeReplacements){if(u.order<r)continue;let p=Math.max(1,Math.pow(2,u.footprintTileId.canonical.z-e.canonical.z));if(u.footprint.buildingIds)for(let f of this.centroidData)f.flags&Ga||f.flags&Hm||u.min.x>f.max.x||f.min.x>u.max.x||u.min.y>f.max.y||f.min.y>u.max.y||u.footprint.buildingIds.has(f.buildingId)&&(f.flags|=u.clipMask!==jm.None?-1073741824:Ga);else for(let f of this.centroidData)if(!(f.flags&Ga||f.flags&Hm||u.min.x>f.max.x||f.min.x>u.max.x||u.min.y>f.max.y||f.min.y>u.max.y))for(let g=0;g<f.footprintSegLen;g++){let x=this.footprintSegments.get(f.footprintSegIdx+g);if(l.length=0,pb(this.footprintVertices,x.vertexOffset,x.vertexCount,u.footprintTileId.canonical,e.canonical,l),Lg(u.footprint,l,this.footprintIndices.uint16,x.indexOffset,x.indexCount,-x.vertexOffset,-p)){f.flags|=u.clipMask!==jm.None?-1073741824:Ga;break}}}for(let u of this.centroidData)this.writeCentroidToBuffer(u);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,i,r){let s=!1;for(let l=0;l<r.footprintSegLen;l++){let u=this.footprintSegments.get(r.footprintSegIdx+l),p=0;for(let f of u.ringIndices){for(let g=p,x=f+p-1;g<f+p;x=g++){let b=this.footprintVertices.int16[2*(g+u.vertexOffset)+0],w=this.footprintVertices.int16[2*(g+u.vertexOffset)+1],S=this.footprintVertices.int16[2*(x+u.vertexOffset)+1];w>i!=S>i&&e<(this.footprintVertices.int16[2*(x+u.vertexOffset)+0]-b)*(i-w)/(S-w)+b&&(s=!s)}p=f}}return s}getHeightAtTileCoord(e,i){let r=Number.NEGATIVE_INFINITY,s=!0,l=4*(e+Xe)*Xe+(i+Xe);if(Object.hasOwn(this.partLookup,l)){let f=this.partLookup[l];return f?{height:f.height,hidden:!!(f.flags&Ga)}:void 0}let u=this.centroidData.buffer,p=this.centroidData.length;for(let f=0;f<p;f++){let g=15*f;if(e>u[g+4]||u[g+2]>e||i>u[g+5]||u[g+3]>i)continue;let x=u[g+13];if(x<=r)continue;let b=this.centroidData.get(f);this.footprintContainsPoint(e,i,b)&&(r=x,this.partLookup[l]=b,s=!!(b.flags&Ga))}if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:s};this.partLookup[l]=void 0}}function b0(n,e){let i=n.add(e)._unit();return n.x*i.x+n.y*i.y}function hb(n,e,i,r){let s=e.sub(n)._perp()._unit(),l=i.sub(e)._perp()._unit();return w0(n,e,i,b0(s,l),r)}function w0(n,e,i,r,s){let l=Math.sqrt(1-r*r);return Math.min(n.dist(e)/3,e.dist(i)/3,s*l/r)}function kg(n,e,i){return n.x<i[0].x&&e.x<i[0].x||n.x>i[1].x&&e.x>i[1].x||n.y<i[0].y&&e.y<i[0].y||n.y>i[1].y&&e.y>i[1].y}function T0(n,e){return n.x<e[0].x||n.x>e[1].x||n.y<e[0].y||n.y>e[1].y}function db(n){return n.every(e=>e.x<=0)||n.every(e=>e.x>=Xe)||n.every(e=>e.y<=0)||n.every(e=>e.y>=Xe)}function S0(n,e,i){if(n.x<0||n.x>=Xe||e.x<0||e.x>=Xe||i.x<0||i.x>=Xe)return!1;let r=i.sub(e),s=r.perp(),l=n.sub(e);return(r.x*l.x+r.y*l.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(l.x*l.x+l.y*l.y))>-.866&&s.x*l.x+s.y*l.y<0}function E0(n,e,i){let r=e?2|n:-3&n;return i?1|r:-2&r}function I0(){let n=Math.PI/32,e=Math.tan(n),i=ss;return i*Math.sqrt(1+2*e*e)-i}function A0(n,e,i){let r=1<<i.z,s=Mr(i.x/r),l=Mr((i.x+1)/r),u=zn(i.y/r),p=zn((i.y+1)/r);return function(f,g,x,b,w=0,S){let I=[];if(!f.length||!x||!b)return I;let M=($,ie)=>
7{for(let W of $)I.push({polygon:W,bounds:ie})},C=Math.ceil(Math.log2(x)),R=Math.ceil(Math.log2(b)),F=C-R,L=[];for(let $=0;$<Math.abs(F);$++)L.push(F>0?0:1);for(let $=0;$<Math.min(C,R);$++)L.push(0),L.push(1);let j=f;if(j=Bm(j,g[0].y-w,g[1].y+w,1),j=Bm(j,g[0].x-w,g[1].x+w,0),!j.length)return I;let H=[];for(L.length?H.push({polygons:j,bounds:g,depth:0}):M(j,g);H.length;){let $=H.pop(),ie=$.depth,W=L[ie],Q=$.bounds[0],Y=$.bounds[1],ee=W===0?Q.x:Q.y,me=W===0?Y.x:Y.y,ge=S?S(W,ee,me):.5*(ee+me),Te=Bm($.polygons,ee-w,ge+w,W),Ae=Bm($.polygons,ge-w,me+w,W);if(Te.length){let Ie=[Q,new ke(W===0?ge:Y.x,W===1?ge:Y.y)];L.length>ie+1?H.push({polygons:Te,bounds:Ie,depth:ie+1}):M(Te,Ie)}if(Ae.length){let Ie=[new ke(W===0?ge:Q.x,W===1?ge:Q.y),Y];L.length>ie+1?H.push({polygons:Ae,bounds:Ie,depth:ie+1}):M(Ae,Ie)}}return I}(n,e,Math.ceil((l-s)/11.25),Math.ceil((u-p)/11.25),1,(f,g,x)=>{if(f===0)return .5*(g+x);{let b=zn((i.y+g/Xe)/r);return(ko(.5*(zn((i.y+x/Xe)/r)+b))*r-i.y)*Xe}})}function pb(n,e,i,r,s,l){let u=Math.pow(2,r.z-s.z);for(let p=0;p<i;p++){let f=n.int16[2*(p+e)+0],g=n.int16[2*(p+e)+1];f=(f+s.x*Xe)*u-r.x*Xe,g=(g+s.y*Xe)*u-r.y*Xe,l.push(new ke(f,g))}}let M0,C0,P0,D0;Qe(Xm,"FillExtrusionBucket",{omit:["layers","features"]}),Qe(Zm,"PartData"),Qe(Wm,"PartDataArray"),Qe(qm,"FootprintSegmentArray"),Qe(Fg,"BorderCentroidData"),Qe(Bg,"GroundEffect");class Qc extends ke{constructor(e,i,r){super(e,i),this.z=r}}class R0 extends Qc{constructor(e,i,r,s){super(e,i,r),this.w=s}}function L0(n,e,i,r){let s=i==="x"?"y":"x",l=(r-n[i])/(e[i]-n[i]);n[s]=Math.round(n[s]+(e[s]-n[s])*l),n[i]=r,Object.hasOwn(n,"z")&&(n.z=mt(n.z,e.z,l)),Object.hasOwn(n,"w")&&(n.w=mt(n.w,e.w,l))}function z0(n,e,i,r){let s=i,l=r;for(let u of["x","y"]){let p=n,f=e;p[u]>=f[u]&&(p=e,f=n),p[u]<s&&f[u]>s&&L0(p,f,u,s),p[u]<l&&f[u]>l&&L0(f,p,u,l)}}function Ym(n,e,i,r,s,l){let u=[];for(let p=0;p<n.length;p++){let f=n[p],g,x=u.length,b=0;for(let w=0;w<f.length-1;w++){let S=f[w],I=f[w+1],M=0,C=b,R,F;l&&(M=Math.hypot(I.x-S.x,I.y-S.y),b+=M,R=S,F=I),S.x<e&&I.x<e||(S.x<e?S=new ke(e,S.y+(e-S.x)/(I.x-S.x)*(I.y-S.y))._round():I.x<e&&(I=new ke(e,S.y+(e-S.x)/(I.x-S.x)*(I.y-S.y))._round()),S.y<i&&I.y<i||(S.y<i?S=new ke(S.x+(i-S.y)/(I.y-S.y)*(I.x-S.x),i)._round():I.y<i&&(I=new ke(S.x+(i-S.y)/(I.y-S.y)*(I.x-S.x),i)._round()),S.x>=r&&I.x>=r||(S.x>=r?S=new ke(r,S.y+(r-S.x)/(I.x-S.x)*(I.y-S.y))._round():I.x>=r&&(I=new ke(r,S.y+(r-S.x)/(I.x-S.x)*(I.y-S.y))._round()),S.y>=s&&I.y>=s||(S.y>=s?S=new ke(S.x+(s-S.y)/(I.y-S.y)*(I.x-S.x),s)._round():I.y>=s&&(I=new ke(S.x+(s-S.y)/(I.y-S.y)*(I.x-S.x),s)._round()),g&&S.equals(g.at(-1))||(g=[S],u.push(g),l&&l.push({progress:{min:C+O0(R,F,S)*M,max:1},parentIndex:p,prevPoint:R,nextPoint:F})),g.push(I),l&&(l.at(-1).progress.max=C+O0(R,F,I)*M,l.at(-1).nextPoint=F)))))}if(l&&b>0)for(let w=x;w<u.length;w++)l[w].progress.min/=b,l[w].progress.max/=b}return u}function fb(n,e,i,r,s){if(n.length<2)return void r.push(n);let l=[];for(;e.valid();){let[g,x]=e.get();for(let b=0;b<n.length-1;b++){let w=n[b],S=n[b+1],I=E(w,S,g,x);if(I){let[M]=I,C=new ke(mt(w.x,S.x,M),mt(w.y,S.y,M));l.push({t:b+M,distance:0,point:C})}}e.next()}if(l.length===0)return void r.push(n);l.sort((g,x)=>g.t-x.t);let u=0,p=0,f=[];for(r.push(f);u!==n.length;){if(p===l.length){for(;u!==n.length;)f.length!==0&&f.at(-1).equals(n[u])||f.push(n[u]),u++;break}l[p].t<=u?(f.length!==0&&f.at(-1).equals(l[p].point)||f.push(l[p].point),Math.trunc(l[p].t),p++):(f.length!==0&&f.at(-1).equals(n[u])||f.push(n[u]),u++)}}function O0(n,e,i){return n.x!==e.x?(i.x-n.x)/(e.x-n.x):n.y!==e.y?(i.y-n.y)/(e.y-n.y):0}function wp(n,e){return n.x*e.x+n.y*e.y}function F0(n,e){if(n.length===1){let i=0,r=e[i++],s;for(;!s||r.equals(s);)if(s=e[i++],!s)return 1/0;for(;i<e.length;i++){let l=e[i],u=n[0],p=s.sub(r),f=l.sub(r),g=u.sub(r),x=wp(p,p),b=wp(p,f),w=wp(f,f),S=wp(g,p),I=wp(g,f),M=x*w-b*b,C=(w*S-b*I)/M,R=(x*I-b*S)/M,F=r.z*(1-C-R)+s.z*C+l.z*R;if(isFinite(F))return F}return 1/0}{let i=1/0;for(let r of e)i=Math.min(i,r.z);return i}}function B0(n,e,i){let r=1/0;m(i,e)&&(r=F0(i,e[0]));for(let s=0;s<e.length;s++){let l=e[s],u=n[s];for(let p=0;p<l.length-1;p++){let f=l[p],g=[f,l[p+1],u[p+1],u[p],f];c(i,g)&&(r=Math.min(r,F0(i,g)))}}return r!==1/0&&r}function k0(n,e,i,r,s,l,u,p,f,g,x){return n.projection.name==="globe"?function(b,w,S,I,M,C,R,F,L,j,H){let $=[],ie=[],W=b.projection.upVectorScale(H,b.center.lat,b.worldSize).metersToTile,Q=[0,0,0,1],Y=[0,0,0,1],ee=(ge,Te,Ae,Ie)=>{ge[0]=Te,ge[1]=Ae,ge[2]=Ie,ge[3]=1},me=I0();S>0&&(S+=me),I+=me;for(let ge of w){let Te=[],Ae=[];for(let Ie of ge){let Be=Ie.x+M.x,xe=Ie.y+M.y,Se=b.projection.projectTilePoint(Be,xe,H),Me=b.projection.upVector(H,Ie.x,Ie.y),Le=S,ze=I;if(R){let We=N0(Be,xe,S,I,R,F,L,j);Le+=We.base,ze+=We.top}S!==0?ee(Q,Se.x+Me[0]*W*Le,Se.y+Me[1]*W*Le,Se.z+Me[2]*W*Le):ee(Q,Se.x,Se.y,Se.z),ee(Y,Se.x+Me[0]*W*ze,Se.y+Me[1]*W*ze,Se.z+Me[2]*W*ze),Bi(Q,Q,C),Bi(Y,Y,C),Te.push(new Qc(Q[0],Q[1],Q[2])),Ae.push(new Qc(Y[0],Y[1],Y[2]))}
7$.push(Te),ie.push(Ae)}return[$,ie]}(n,e,i,r,s,l,u,p,f,g,x):u?function(b,w,S,I,M,C,R,F,L){let j=[],H=[],$=[0,0,0,1];for(let ie of b){let W=[],Q=[];for(let Y of ie){let ee=Y.x+I.x,me=Y.y+I.y,ge=N0(ee,me,w,S,C,R,F,L);$[0]=ee,$[1]=me,$[2]=ge.base,$[3]=1,xr($,$,M),$[3]=Math.max($[3],1e-5);let Te=new Qc($[0]/$[3],$[1]/$[3],$[2]/$[3]);$[0]=ee,$[1]=me,$[2]=ge.top,$[3]=1,xr($,$,M),$[3]=Math.max($[3],1e-5);let Ae=new Qc($[0]/$[3],$[1]/$[3],$[2]/$[3]);W.push(Te),Q.push(Ae)}j.push(W),H.push(Q)}return[j,H]}(e,i,r,s,l,u,p,f,g):function(b,w,S,I,M){let C=[],R=[],F=M[8]*w,L=M[9]*w,j=M[10]*w,H=M[11]*w,$=M[8]*S,ie=M[9]*S,W=M[10]*S,Q=M[11]*S;for(let Y of b){let ee=[],me=[];for(let ge of Y){let Te=ge.x+I.x,Ae=ge.y+I.y,Ie=M[0]*Te+M[4]*Ae+M[12],Be=M[1]*Te+M[5]*Ae+M[13],xe=M[2]*Te+M[6]*Ae+M[14],Se=M[3]*Te+M[7]*Ae+M[15],Me=Ie+F,Le=Be+L,ze=xe+j,We=Math.max(Se+H,1e-5),De=Ie+$,Ge=Be+ie,$e=xe+W,Je=Math.max(Se+Q,1e-5);ee.push(new Qc(Me/We,Le/We,ze/We)),me.push(new Qc(De/Je,Ge/Je,$e/Je))}C.push(ee),R.push(me)}return[C,R]}(e,i,r,s,l)}function N0(n,e,i,r,s,l,u,p){let f=u*s.getElevationAt(n,e,!0,!0),g=l[0]!==0,x=g?l[1]===0?u*(l[0]/7-450):u*function(b,w,S){let I=Math.floor(w[0]/8),M=Math.floor(w[1]/8),C=10*(w[0]-8*I),R=10*(w[1]-8*M),F=b.getElevationAt(I,M,!0,!0),L=b.getMeterToDEM(S),j=Math.floor(.5*(C*L-1)),H=Math.floor(.5*(R*L-1)),$=b.tileCoordToPixel(I,M),ie=2*j+1,W=2*H+1,Q=function(Ae,Ie,Be,xe,Se){return[Ae.getElevationAtPixel(Ie,Be,!0),Ae.getElevationAtPixel(Ie+Se,Be,!0),Ae.getElevationAtPixel(Ie,Be+Se,!0),Ae.getElevationAtPixel(Ie+xe,Be+Se,!0)]}(b,$.x-j,$.y-H,ie,W),Y=Math.abs(Q[0]-Q[1]),ee=Math.abs(Q[2]-Q[3]),me=Math.abs(Q[0]-Q[2])+Math.abs(Q[1]-Q[3]),ge=Math.min(.25,.5*L*(Y+ee)/ie),Te=Math.min(.25,.5*L*me/W);return F+Math.max(ge*C,Te*R)}(s,l,p):f;return{base:f+(i===0?-1:i),top:g?Math.max(x+r,f+i+2):f+r}}let hs=null,Jm=null,Ng=null,Km=null,U0=5120,V0=5121,j0=5122,G0=5123,H0=5125,$0=5126,Qm={[U0]:Int8Array,[V0]:Uint8Array,[j0]:Int16Array,[G0]:Uint16Array,[H0]:Uint32Array,[$0]:Float32Array},mb={[U0]:"DT_INT8",[V0]:"DT_UINT8",[j0]:"DT_INT16",[G0]:"DT_UINT16",[H0]:"DT_UINT32",[$0]:"DT_FLOAT32"},Tp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function q0(n,e,i){let r=i.json.bufferViews.length,s=i.buffers.length;e.bufferView=r,i.json.bufferViews[r]={buffer:s,byteLength:n.byteLength},i.buffers[s]=n}let Ug="KHR_draco_mesh_compression";function _b(n,e){let i=n.extensions&&n.extensions[Ug];if(!i)return;let r=new hs.Decoder,s=Y0(e,i.bufferView),l=new hs.Mesh;if(!r.DecodeArrayToMesh(s,s.byteLength,l))throw new Error("Failed to decode Draco mesh");let u=e.json.accessors[n.indices],p=Qm[u.componentType],f=u.count*p.BYTES_PER_ELEMENT,g=hs._malloc(f);p===Uint16Array?r.GetTrianglesUInt16Array(l,f,g):r.GetTrianglesUInt32Array(l,f,g),q0(hs.memory.buffer.slice(g,g+f),u,e),hs._free(g);for(let x of Object.keys(i.attributes)){let b=r.GetAttributeByUniqueId(l,i.attributes[x]),w=e.json.accessors[n.attributes[x]],S=mb[w.componentType],I=w.count*Tp[w.type]*Qm[w.componentType].BYTES_PER_ELEMENT,M=hs._malloc(I);r.GetAttributeDataArrayForAllPoints(l,b,hs[S],I,M),q0(hs.memory.buffer.slice(M,M+I),w,e),hs._free(M)}r.destroy(),l.destroy(),delete n.extensions[Ug]}let e_="EXT_meshopt_compression";function gb(n,e){if(!n.extensions||!n.extensions[e_])return;let i=n.extensions[e_],r=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),s=new Uint8Array(i.count*i.byteStride);Ng.decodeGltfBuffer(s,i.count,i.byteStride,r,i.mode,i.filter),n.buffer=e.buffers.length,n.byteOffset=0,e.buffers[n.buffer]=s.buffer,delete n.extensions[e_]}let Z0=1179937895,W0=new TextDecoder("utf8");function X0(n,e){return new URL(n,e).href}async function yb(n,e,i,r,s){let l=await fetch(X0(n.uri,r),{signal:s}),u=await l.arrayBuffer();e.buffers[i]=u}function Y0(n,e){let i=n.json.bufferViews[e];return new Uint8Array(n.buffers[i.buffer],i.byteOffset||0,i.byteLength)}async function xb(n,e,i,r,s){if(n.uri){let l=X0(n.uri,r),u=await fetch(l,{signal:s}),p=await u.blob(),f=await createImageBitmap(p);e.images[i]=f}else if(n.bufferView!==void 0){let l=Y0(e,n.bufferView),u=new Blob([l],{type:n.mimeType}),p=await createImageBitmap(u);e.images[i]=p}}async function J0(n,e=0,i,r){let s={json:null,images:[],buffers:[]};
7if(new Uint32Array(n,e,1)[0]===Z0){let S=new Uint32Array(n,e),I=2,M=(S[I++]>>2)-3,C=S[I++]>>2;if(I++,s.json=JSON.parse(W0.decode(S.subarray(I,I+C))),I+=C,I<M){let R=S[I++];I++;let F=e+(I<<2);s.buffers[0]=n.slice(F,F+R)}}else s.json=JSON.parse(W0.decode(new Uint8Array(n,e)));let{buffers:l,images:u,meshes:p,extensionsUsed:f,bufferViews:g}=s.json;if(l){let S=[];for(let I=0;I<l.length;I++){let M=l[I];M.uri?S.push(yb(M,s,I,i,r)):s.buffers[I]||(s.buffers[I]=null)}await Promise.all(S)}if(r&&r.aborted)throw new DOMException("Aborted","AbortError");let x=[],b=f&&f.includes(Ug),w=f&&f.includes(e_);if(b&&x.push(function(){if(!hs)return Jm!=null||(Jm=function(S){let I,M=null;function C(){I=new Uint8Array(M.buffer)}function R(){throw new Error("Unexpected Draco error.")}return WebAssembly.instantiateStreaming(S,{a:{a:R,d:function(F,L,j){return I.copyWithin(F,L,L+j)},c:function(F){let L=I.length,j=Math.max(F>>>0,Math.ceil(1.2*L)),H=Math.ceil((j-L)/65536);try{return M.grow(H),C(),!0}catch{return!1}},b:R}}).then(F=>{let{Rb:L,Qb:j,P:H,T:$,X:ie,Ja:W,La:Q,Qa:Y,Va:ee,Wa:me,eb:ge,jb:Te,f:Ae,e:Ie,yb:Be,zb:xe,Ab:Se,Bb:Me,Db:Le,Gb:ze}=F.instance.exports;M=Ie;let We=(()=>{let De=0,Ge=0,$e=0,Je=0;return tt=>{$e&&(L(Je),L(De),Ge+=$e,$e=De=0),De||(Ge+=128,De=j(Ge));let ct=tt.length+7&-8,rt=De;ct>=Ge&&($e=ct,rt=Je=j(ct));for(let ft=0;ft<tt.length;ft++)I[rt+ft]=tt[ft];return rt}})();return C(),Ae(),{memory:Ie,_free:L,_malloc:j,Mesh:class{constructor(){this.ptr=H()}destroy(){$(this.ptr)}},Decoder:class{constructor(){this.ptr=W()}destroy(){Te(this.ptr)}DecodeArrayToMesh(De,Ge,$e){let Je=We(De),tt=Q(this.ptr,Je,Ge,$e.ptr);return!!ie(tt)}GetAttributeByUniqueId(De,Ge){return{ptr:Y(this.ptr,De.ptr,Ge)}}GetTrianglesUInt16Array(De,Ge,$e){ee(this.ptr,De.ptr,Ge,$e)}GetTrianglesUInt32Array(De,Ge,$e){me(this.ptr,De.ptr,Ge,$e)}GetAttributeDataArrayForAllPoints(De,Ge,$e,Je,tt){ge(this.ptr,De.ptr,Ge.ptr,$e,Je,tt)}},DT_INT8:Be(),DT_UINT8:xe(),DT_INT16:Se(),DT_UINT16:Me(),DT_UINT32:Le(),DT_FLOAT32:ze()}})}(fetch(ha())).then(S=>{hs=S,Jm=null})),Jm}()),w&&x.push(function(){var S;if(!Ng)return Km!=null||(Km=(S=fetch(da()),WebAssembly.instantiateStreaming(S,{}).then(I=>{let{sbrk:M,memory:C,meshopt_decodeVertexBuffer:R,meshopt_decodeIndexBuffer:F,meshopt_decodeIndexSequence:L,meshopt_decodeFilterOct:j,meshopt_decodeFilterQuat:H,meshopt_decodeFilterExp:$}=I.instance.exports,ie={ATTRIBUTES:R,TRIANGLES:F,INDICES:L},W={OCTAHEDRAL:j,QUATERNION:H,EXPONENTIAL:$};return I.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(Q,Y,ee,me,ge,Te){let Ae=Y+3&-4,Ie=M(Ae*ee),Be=M(me.length),xe=new Uint8Array(C.buffer);xe.set(me,Be);let Se=ie[ge](Ie,Y,ee,Be,me.length);if(Se===0&&W[Te]&&W[Te](Ie,Ae,ee),Q.set(xe.subarray(Ie,Ie+Y*ee)),M(Ie-M(0)),Se!==0)throw new Error(`Malformed buffer data: ${Se}`)}}})).then(I=>{Ng=I,Km=null})),Km}()),u)for(let S=0;S<u.length;S++)x.push(xb(u[S],s,S,i,r));if(x.length&&await Promise.all(x),r&&r.aborted)throw new DOMException("Aborted","AbortError");if(b&&p)for(let{primitives:S}of p)for(let I of S)_b(I,s);if(w&&p&&g)for(let S of g)gb(S,s);return s}async function K0(n,e){let i=await async function(r,s){if(s&&s.aborted)throw new DOMException("Aborted","AbortError");return new Promise((l,u)=>{let p=Br(r,(f,g)=>{f?u(f):l(g)});s&&s.addEventListener("abort",()=>{p.cancel(),u(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:n,type:"arrayBuffer"},e);return J0(i,0,n,e)}function Vg(n){switch(n){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function jg(n){switch(n){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}
7class Ys{constructor(e,i,r,s){this.context=e,this.format=r,this.useMipmap=s&&s.useMipmap,this.texture=e.gl.createTexture(),this.update(i,{premultiply:s&&s.premultiply})}update(e,i){let r=e&&e instanceof HTMLVideoElement&&e.width===0?e.videoWidth:e.width,s=e&&e instanceof HTMLVideoElement&&e.height===0?e.videoHeight:e.height,{context:l}=this,{gl:u}=l,{x:p,y:f}=i&&i.position?i.position:{x:0,y:0},g=p+r,x=f+s;this.size&&(this.size[0]!==g||this.size[1]!==x)&&(!i||i.recreateWhenResize===void 0||i.recreateWhenResize)&&(u.bindTexture(u.TEXTURE_2D,null),u.deleteTexture(this.texture),this.texture=u.createTexture(),this.size=null),u.bindTexture(u.TEXTURE_2D,this.texture),l.pixelStoreUnpackFlipY.set(!1),l.pixelStoreUnpack.set(1),l.pixelStoreUnpackPremultiplyAlpha.set(this.format===u.RGBA8&&(!i||i.premultiply!==!1));let b=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&g>0&&x>0){let w=this.useMipmap?Math.floor(Math.log2(Math.max(g,x)))+1:1;u.texStorage2D(u.TEXTURE_2D,w,this.format,g,x),this.size=[g,x]}this.size&&(b?u.texSubImage2D(u.TEXTURE_2D,0,p,f,Vg(this.format),jg(this.format),e):"data"in e&&e.data&&u.texSubImage2D(u.TEXTURE_2D,0,p,f,r,s,Vg(this.format),jg(this.format),e.data)),this.useMipmap&&u.generateMipmap(u.TEXTURE_2D)}bind(e,i,r=!1){let{context:s}=this,{gl:l}=s;l.bindTexture(l.TEXTURE_2D,this.texture),e!==this.minFilter&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,e),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===l.NEAREST?l.NEAREST_MIPMAP_NEAREST:l.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,i),this.wrapS=i)}bindExtraParam(e,i,r,s,l){let{context:u}=this,{gl:p}=u;p.bindTexture(p.TEXTURE_2D,this.texture),i!==this.magFilter&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,i),this.magFilter=i),e!==this.minFilter&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,this.useMipmap?e===p.NEAREST?p.NEAREST_MIPMAP_NEAREST:p.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,r),this.wrapS=r),s!==this.wrapT&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,s),this.wrapT=s),l!==this.compareMode&&(l?(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_COMPARE_MODE,p.COMPARE_REF_TO_TEXTURE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_COMPARE_FUNC,l)):p.texParameteri(p.TEXTURE_2D,p.TEXTURE_COMPARE_MODE,p.NONE),this.compareMode=l)}destroy(){let{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Sp{constructor(e,i){this.context=e,this.texture=i}bind(e,i){let{context:r}=this,{gl:s}=r;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,e),this.minFilter=e),i!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i),this.wrapS=i)}}let vb=Rt([{name:"a_pos_3f",components:3,type:"Float32"}]),bb=Rt([{name:"a_color_3f",components:3,type:"Float32"}]),wb=Rt([{name:"a_color_4f",components:4,type:"Float32"}]),Tb=Rt([{name:"a_uv_2f",components:2,type:"Float32"}]),Sb=Rt([{name:"a_normal_3f",components:3,type:"Float32"}]),Eb=Rt([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Ib=Rt([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Q0(n,e){let i=t_(n.projection,n.zoom,n.width,n.height),r=function(l,u,p,f,g){let x=new Kt(p.lng-180*jl,p.lat),b=new Kt(p.lng+180*jl,p.lat),w=l.project(x.lng,x.lat),S=l.project(b.lng,b.lat),I=-Math.atan2(S.y-w.y,S.x-w.x),M=Wn.fromLngLat(p);M.y=ne(M.y,-1+jl,1-jl);let C=M.toLngLat(),R=l.project(C.lng,C.lat),F=Wn.fromLngLat(C);F.x+=jl;let L=F.toLngLat(),j=l.project(L.lng,L.lat),H=tx(j.x-R.x,j.y-R.y,I),$=Wn.fromLngLat(C);$.y+=jl;let ie=$.toLngLat(),W=l.project(ie.lng,ie.lat),Q=tx(W.x-R.x,W.y-R.y,I),Y=Math.abs(H.x)/Math.abs(Q.y),ee=Mt([]);fo(ee,ee,-I*(1-(g?0:f)));let me=Mt([]);return Yn(me,me,[1,1-(1-Y)*f,1]),me[4]=-Q.x/Q.y*f,fo(me,me,I),xi(me,ee,me),me}
7(n.projection,0,n.center,i,e),s=ex(n);return Yn(r,r,[s,s,1]),r}function ex(n){let e=n.projection,i=t_(n.projection,n.zoom,n.width,n.height),r=Gg(e,n.center),s=Gg(e,Kt.convert(e.center));return Math.pow(2,r*i+(1-i)*s)}function t_(n,e,i,r,s=1/0){let l=n.range;if(!l)return 0;let u=Math.min(s,Math.max(i,r)),p=Math.log2(u/1024);return ye(l[0]+p,l[1]+p,e)}let jl=1/4e4;function Gg(n,e){let i=ne(e.lat,-85.051129,Cr),r=new Kt(e.lng-180*jl,i),s=new Kt(e.lng+180*jl,i),l=n.project(r.lng,i),u=n.project(s.lng,i),p=Wn.fromLngLat(r),f=Wn.fromLngLat(s),g=u.x-l.x,x=u.y-l.y,b=f.x-p.x,w=f.y-p.y,S=Math.sqrt((b*b+w*w)/(g*g+x*x));return Math.log2(S)}function tx(n,e,i){let r=Math.cos(i),s=Math.sin(i);return{x:n*r-e*s,y:n*s+e*r}}let Ab=new Float64Array([1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);function ix(n,e,i){Mt(n),fo(n,n,V(e[2])),Go(n,n,V(e[0])),Ho(n,n,V(e[1])),Yn(n,n,i),xi(n,n,Ab)}function i_(n,e,i,r,s,l,u,p){let f=[i[0]-e[0],i[1]-e[1],0],g=[r[0]-e[0],r[1]-e[1],0];if(Dn(f)<1e-12||Dn(g)<1e-12)return xs(n);let x=Jn([],f,g);hi(x,x),mo(g,r,e),f[2]=(l-s)*p,g[2]=(u-s)*p;let b=f;return Jn(b,f,g),hi(b,b),oc(n,x,b)}function n_(n,e,i=!1){let r=qt(e.zoom),s=function(l,u,p){let f=u.worldSize,g=[l[12],l[13],l[14]],x=zn(g[1]/f),b=Mr(g[0]/f),w=Mt([]),S=lr(1,x)*f,I=lr(1,0)*f*Ua(x,u.zoom),M=1/kt(f),C=I*M;if(p){let j=t_(u.projection,u.zoom,u.width,u.height,1024);C=M*u.projection.pixelSpaceConversion(u.center.lat,f,j)}let R=os(x,b);nn(R,R,Fi([],hi([],R),S*C*g[2]));let F=function(j){let H=[j[0],j[1],j[2]],$=[0,1,0],ie=Jn([],$,H);return Jn($,H,ie),nc($)===0&&($=[0,1,0],Jn(ie,H,$)),hi(ie,ie),hi($,$),hi(H,H),[ie[0],ie[1],ie[2],0,$[0],$[1],$[2],0,H[0],H[1],H[2],0,j[0],j[1],j[2],1]}(R);Yn(w,w,[C,C,C*S]),$n(w,w,[-g[0],-g[1],-g[2]]);let L=xi([],u.globeMatrix,F);return xi(L,L,w),xi(L,L,l),L}(n,e,i);if(r>0){let l=function(u,p){let f=p.worldSize,g=lr(1,0)*f*Ua(p.center.lat,p.zoom)/kt(f),x=lr(1,p.center.lat)*f,b=Mt([]);Ho(b,b,V(p.center.lng)),Go(b,b,V(p.center.lat)),$n(b,b,[0,0,er]),Yn(b,b,[g,g,g*x]);let w=p.point;return $n(b,b,[-w.x,-w.y,0]),xi(b,b,u),xi(b,p.globeMatrix,b)}(n,e);return function(u,p,f){let g=(I,M,C)=>{let R=Dn(I),F=Dn(M),L=je(I,M,C);return Fi(L,L,1/Dn(L)*mt(R,F,C))},x=g([u[0],u[1],u[2]],[p[0],p[1],p[2]],f),b=g([u[4],u[5],u[6]],[p[4],p[5],p[6]],f),w=g([u[8],u[9],u[10]],[p[8],p[9],p[10]],f),S=je([u[12],u[13],u[14]],[p[12],p[13],p[14]],f);return[x[0],x[1],x[2],0,b[0],b[1],b[2],0,w[0],w[1],w[2],0,S[0],S[1],S[2],1]}(s,l,r)}return s}function Hg(n,e,i,r){let s=Ei.projectAabbCorners(r,i),l=Number.MAX_VALUE;for(let p=0;p<s.length;++p){let f=s[p];f[0]=(.5*f[0]+.5)*e.width,f[1]=(.5-.5*f[1])*e.height,f[2]<l&&(l=f[2])}let u=function(p){let f=[],g=0;for(let S=1;S<p.length;S++)(p[S][0]<p[g][0]||p[S][0]===p[g][0]&&p[S][1]<p[g][1])&&(g=S);let x,b=g,w=new Uint8Array(p.length);do{if(w[b])break;f.push(new ke(p[b][0],p[b][1])),w[b]=1,x=(b+1)%p.length;for(let S=0;S<p.length;S++){if(p[S][0]===p[x][0]&&p[S][1]===p[x][1]||p[S][0]===p[b][0]&&p[S][1]===p[b][1])continue;let I=[p[S][0]-p[b][0],p[S][1]-p[b][1]],M=[p[x][0]-p[b][0],p[x][1]-p[b][1]],C=I[0]*M[1]-I[1]*M[0];(C>0||C===0&&I[0]*M[0]+I[1]*M[1]>=0&&I[0]*I[0]+I[1]*I[1]>M[0]*M[0]+M[1]*M[1])&&(x=S)}b=x}while(b!==g);return f.length>0&&f.push(f[0]),f}(s);if(c(n,u))return l}let eu=64,xh={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function r_(n,e,i,r,s,l,u,p,f,g=!1){let x=i.zoom,b=i.project(r),w=Ua(r.lat,x),S=1/w;Mt(n),$n(n,n,[b.x+u[0]*S,b.y+u[1]*S,u[2]]);let I=1,M=1,C=i.worldSize;if(g){if(i.projection.name==="mercator"){let j=0;i.elevation&&(j=i.elevation.getAtPointOrZero(new Wn(b.x/C,b.y/C),0));let H=xr([],[b.x,b.y,j,1],i.projMatrix)[3]/i.cameraToCenterDistance;I=H,M=H*Ua(i.center.lat,x)}else if(i.projection.name==="globe"){let j=n_(n,i),H=[0,0,0,1];xr(H,H,xi([],i.projMatrix,j));let $=H[3]/i.cameraToCenterDistance,ie=qt(x),W=i.projection.pixelsPerMeter(r.lat,C)*Ua(r.lat,x),Q=i.projection.pixelsPerMeter(i.center.lat,C)*Ua(i.center.lat,x);I=$/mt(W,_m(i.center.lat),ie),M=$*w/W,I*=Q,M*=Q}}else I=S;Yn(n,n,[I,I,M]);let R=[...n],F=e.orientation,L=[];if(ix(L,[F[0]+(s?s[0]:0),F[1]+(s?s[1]:0),F[2]+(s?s[2]:0)],l),xi(n,R,L),p&&i.elevation){let j=0,H=[];if(f&&i.elevation){j=function(ie,W,Q,Y,ee){let me=W.elevation;if(!me)return 0;let ge=Ei.projectAabbCorners(Q,Y),Te=lr(1,ee.lat)*W.worldSize,Ae=function($e,Je){let tt=[0,0,1],ct=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(let rt of ct){let ft=$e[rt.corners[0]],Zt=$e[rt.corners[1]],St=$e[rt.corners[2]],Ut=[Zt[0]-ft[0],Zt[1]-ft[1],Je*(Zt[2]-ft[2])],Pt=Jn(Ut,Ut,[St[0]-ft[0],St[1]-ft[1],Je*(St[2]-ft[2])]);hi(Pt,Pt),rt.dotProductWithUp=en(Pt,tt)}return ct.sort((rt,ft)=>rt.dotProductWithUp-ft.dotProductWithUp),ct[0].corners}(ge,Te),Ie=ge[Ae[0]],Be=ge[Ae[1]],xe=ge[Ae[2]],Se=ge[Ae[3]],Me=me.getAtPointOrZero(new Wn(Ie[0]/W.worldSize,Ie[1]/W.worldSize),0),Le=me.getAtPointOrZero(new Wn(Be[0]/W.worldSize,Be[1]/W.worldSize),0),ze=me.getAtPointOrZero(new Wn(xe[0]/W.worldSize,xe[1]/W.worldSize),0),We=me.getAtPointOrZero(new Wn(Se[0]/W.worldSize,Se[1]/W.worldSize),0),De=(Me+We)/2,Ge=(Le+ze)/2;return De>Ge?Le<ze?i_(ie,Be,Se,Ie,Le,We,Me,Te):i_(ie,xe,Ie,Se,ze,Me,We,Te):Me<We?i_(ie,Ie,Be,xe,Me,Le,ze,Te):i_(ie,Se,xe,Be,We,ze,Le,Te),Math.max(De,Ge)}(H,i,e.aabb,n,r);let $=xi([],Ql([],H),L);xi(n,R,$)}else j=i.elevation.getAtPointOrZero(new Wn(b.x/C,b.y/C),0);j!==0&&(n[14]+=j)}}class nx{constructor(e,i,r,s,l){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=i,this.position=r!=null?new Kt(r[0],r[1]):new Kt(0,0),this.orientation=s??[0,0,0],this.nodes=l,this.uploaded=!1,this.aabb=new Ei([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,i){xi(e.globalMatrix,i,e.localMatrix);let r=this.nodeOverrides.get(e.name);if(r!==void 0){let u=[];l=r.orientation,Mt(s=u),Ho(s,s,V(l[1])),fo(s,s,V(l[2])),Go(s,s,V(l[0])),xi(e.globalMatrix,e.globalMatrix,u)}var s,l;if(e.meshes)for(let u of e.meshes){let p=Ei.applyTransformFast(u.aabb,e.globalMatrix);this.aabb.encapsulate(p)}if(e.children)for(let u of e.children)this._applyTransformations(u,e.globalMatrix)}computeBoundsAndApplyParent(){let e=Mt([]);this.aabb=new Ei([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(let i of this.nodes)this._applyTransformations(i,e)}computeModelMatrix(e,i,r,s,l,u,p=!1){r_(this.matrix,this,e.transform,this.position,i,r,s,l,u,p)}upload(e){if(!this.uploaded){for(let i of this.nodes)$g(i,e);for(let i of this.nodes)o_(i);this.uploaded=!0}}destroy(){for(let e of this.nodes)qg(e)}}function Ep(n,e,i=!1){n.uploaded||(n.gfxTexture=new Ys(e,n.image,i?e.gl.R8:e.gl.RGBA8,{useMipmap:n.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),n.uploaded=!0,n.image=null)}function rx(n,e,i){n.indexBuffer=e.createIndexBuffer(n.indexArray,!1,!0),n.vertexBuffer=e.createVertexBuffer(n.vertexArray,vb.members,!1,!0),n.normalArray&&(n.normalBuffer=e.createVertexBuffer(n.normalArray,Sb.members,!1,!0)),n.texcoordArray&&(n.texcoordBuffer=e.createVertexBuffer(n.texcoordArray,Tb.members,!1,!0)),n.colorArray&&(n.colorBuffer=e.createVertexBuffer(n.colorArray,(n.colorArray.bytesPerElement===12?bb:wb).members,!1,!0)),n.featureArray&&(n.pbrBuffer=e.createVertexBuffer(n.featureArray,Ib.members,!0)),n.segments=pi.simpleSegment(0,0,n.vertexArray.length,n.indexArray.length);let r=n.material;r.pbrMetallicRoughness.baseColorTexture&&Ep(r.pbrMetallicRoughness.baseColorTexture,e),r.pbrMetallicRoughness.metallicRoughnessTexture&&Ep(r.pbrMetallicRoughness.metallicRoughnessTexture,e),r.normalTexture&&Ep(r.normalTexture,e),r.occlusionTexture&&Ep(r.occlusionTexture,e,i),r.emissionTexture&&Ep(r.emissionTexture,e)}function $g(n,e,i){if(n.meshes)for(let r of n.meshes)rx(r,e,i);if(n.lodMeshes)for(let r of n.lodMeshes)rx(r,e,i);if(n.children)for(let r of n.children)$g(r,e,i)}function ox(n){n.indexArray.destroy(),n.vertexArray.destroy(),n.colorArray&&n.colorArray.destroy(),n.normalArray&&n.normalArray.destroy(),n.texcoordArray&&n.texcoordArray.destroy(),n.featureArray&&n.featureArray.destroy()}function o_(n){if(n.meshes)for(let e of n.meshes)ox(e);if(n.lodMeshes)for(let e of n.lodMeshes)ox(e);if(n.children)for(let e of n.children)o_(e)}function sx(n){var e;n.vertexBuffer&&(n.vertexBuffer.destroy(),n.indexBuffer.destroy(),n.normalBuffer&&n.normalBuffer.destroy(),n.texcoordBuffer&&n.texcoordBuffer.destroy(),n.colorBuffer&&n.colorBuffer.destroy(),n.pbrBuffer&&n.pbrBuffer.destroy(),n.segments.destroy(),n.material&&((e=n.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()))}function qg(n){if(n.meshes)for(let e of n.meshes)sx(e);if(n.lodMeshes)for(let e of n.lodMeshes)sx(e);if(n.footprintDebugMesh&&(n.footprintDebugMesh.vertexBuffer.destroy(),n.footprintDebugMesh.indexBuffer.destroy(),n.footprintDebugMesh.segments.destroy()),n.children)for(let e of n.children)qg(e)}function Zg(n,e,i,r){return n[0]<=r[0]&&e[0]>=i[0]&&n[1]<=r[1]&&e[1]>=i[1]&&n[2]<=r[2]&&e[2]>=i[2]}function Mb(n,e,i,r,s,l,u,p,f,g,x){let b=.5*(g[0]+x[0]),w=.5*(g[1]+x[1]),S=.5*(g[2]+x[2]),I=.5*(x[0]-g[0]),M=.5*(x[1]-g[1]),C=.5*(x[2]-g[2]),R=n-b,F=e-w,L=i-S,j=r-b,H=s-w,$=l-S,ie=u-b,W=p-w,Q=f-S,Y=j-R,ee=H-F,me=$-L,ge=ie-j,Te=W-H,Ae=Q-$,Ie=R-ie,Be=F-W,xe=L-Q,Se,Me,Le,ze,We,De;if(Se=L*ee-F*me,Me=$*ee-H*me,Le=Q*ee-W*me,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(me)*M+Math.abs(ee)*C,ze>De||We<-De||(Se=L*Te-F*Ae,Me=$*Te-H*Ae,Le=Q*Te-W*Ae,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(Ae)*M+Math.abs(Te)*C,ze>
7De||We<-De)||(Se=L*Be-F*xe,Me=$*Be-H*xe,Le=Q*Be-W*xe,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(xe)*M+Math.abs(Be)*C,ze>De||We<-De)||(Se=R*me-L*Y,Me=j*me-$*Y,Le=ie*me-Q*Y,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(me)*I+Math.abs(Y)*C,ze>De||We<-De)||(Se=R*Ae-L*ge,Me=j*Ae-$*ge,Le=ie*Ae-Q*ge,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(Ae)*I+Math.abs(ge)*C,ze>De||We<-De)||(Se=R*xe-L*Ie,Me=j*xe-$*Ie,Le=ie*xe-Q*Ie,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(xe)*I+Math.abs(Ie)*C,ze>De||We<-De)||(Se=F*Y-R*ee,Me=H*Y-j*ee,Le=W*Y-ie*ee,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(ee)*I+Math.abs(Y)*M,ze>De||We<-De)||(Se=F*ge-R*Te,Me=H*ge-j*Te,Le=W*ge-ie*Te,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(Te)*I+Math.abs(ge)*M,ze>De||We<-De)||(Se=F*Ie-R*Be,Me=H*Ie-j*Be,Le=W*Ie-ie*Be,ze=Math.min(Se,Me,Le),We=Math.max(Se,Me,Le),De=Math.abs(Be)*I+Math.abs(Ie)*M,ze>De||We<-De)||(ze=Math.min(R,j,ie),We=Math.max(R,j,ie),ze>I||We<-I)||(ze=Math.min(F,H,W),We=Math.max(F,H,W),ze>M||We<-M)||(ze=Math.min(L,$,Q),We=Math.max(L,$,Q),ze>C||We<-C))return!1;let Ge=ee*Ae-me*Te,$e=me*ge-Y*Ae,Je=Y*Te-ee*ge,tt=-(Ge*R+$e*F+Je*L);return De=I*Math.abs(Ge)+M*Math.abs($e)+C*Math.abs(Je),!(Math.abs(tt)>De)}let Cb=[];class ax{serializeFromGltf(e,i,r,s){if(e.length<7)return;let l=0;if(e[l++]!==109||e[l++]!==98||e[l++]!==120||e[l++]!==98||e[l++]!==118||e[l++]!==104||e[l++]!==43)return;let u=new DataView(e.buffer,e.byteOffset),p=u.getUint16(l,!0);if(l+=2,p===0)return;this._nodes=[];let f=0;for(let x=0;x<p;x++){let b=[i[3*f],i[3*f+1],i[3*f+2]],w=[r[3*f],r[3*f+1],r[3*f+2]];f++;let S=u.getUint16(l,!0);l+=2;let I=0,M=0;S===65535&&(I=u.getUint16(l,!0),l+=2,M=u.getUint32(l,!0),l+=4),this._nodes.push({aabbMin:b,aabbMax:w,backChild:S,indexCount:I,indexOffset:M})}let g=u.getUint32(l,!0);this._indices=s.slice(0,g)}setVertices(e){this._vertices=e}findHighestPoint(e,i){if(!this._nodes||this._nodes.length===0||!Zg(this._nodes[0].aabbMin,this._nodes[0].aabbMax,e,i))return null;let r=Cb;r.length=0,r.push(0);let s=-1/0;for(;r.length>0;){let l=r.pop(),u=this._nodes[l];if(u.aabbMax[2]<=s)continue;if(u.backChild===65535){for(let S=0;S<u.indexCount;S+=3){let I=3*this._indices[u.indexOffset+S],M=3*this._indices[u.indexOffset+S+1],C=3*this._indices[u.indexOffset+S+2];Mb(this._vertices[I],this._vertices[I+1],this._vertices[I+2],this._vertices[M],this._vertices[M+1],this._vertices[M+2],this._vertices[C],this._vertices[C+1],this._vertices[C+2],e,i)&&(s=Math.max(s,this._vertices[I+2],this._vertices[M+2],this._vertices[C+2]))}continue}let p=l+1,f=u.backChild,g=this._nodes[p],x=this._nodes[f],b=Zg(g.aabbMin,g.aabbMax,e,i),w=Zg(x.aabbMin,x.aabbMax,e,i);b&&w?g.aabbMax[2]<x.aabbMax[2]?(r.push(p),r.push(f)):(r.push(f),r.push(p)):b?r.push(p):w&&r.push(f)}return s>=0?s:null}}function tu(n,e){let i=n.json.bufferViews[e.bufferView],r=Qm[e.componentType];return new r(n.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==Tp[e.type]*r.BYTES_PER_ELEMENT?i.byteStride/r.BYTES_PER_ELEMENT:Tp[e.type]))}function Wg(n,e,i,r){let s=Qm[e.componentType],l=function(x){switch(x){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(s),u=n.json.bufferViews[e.bufferView],p=u.byteStride?u.byteStride/s.BYTES_PER_ELEMENT:Tp[e.type],f=i.float32,g=f.length/i.capacity;for(let x=0,b=0;x<e.count*p;x+=p,b+=g)for(let w=0;w<g;w++)f[b+w]=r[x+w]*l;i._trim()}function Pb(n,e,i){let r=n.indices,s=n.attributes,l={};l.indexArray=new Yi;let u=e.json.accessors[r],p=u.count/3;l.indexArray.reserve(p);let f=tu(e,u);for(let w=0;w<p;w++)l.indexArray.emplaceBack(f[3*w],f[3*w+1],f[3*w+2]);l.indexArray._trim(),l.vertexArray=new Ur;let g=e.json.accessors[s.POSITION];l.vertexArray.reserve(g.count);let x=tu(e,g);for(let w=0;w<g.count;w++)l.vertexArray.emplaceBack(x[3*w],x[3*w+1],x[3*w+2]);if(l.vertexArray._trim(),l.aabb=new Ei(g.min,g.max),l.centroid=function(w,S){let I=[0,0,0],M=w.length;if(M>0){for(let C=0;C<M;C++){let R=3*w[C];I[0]+=S[R],I[1]+=S[R+1],I[2]+=S[R+2]}I[0]/=M,I[1]/=M,I[2]/=M}return I}(f,x),s.COLOR_0!==void 0){let w=e.json.accessors[s.COLOR_0],S=Tp[w.type],I=tu(e,w);l.colorArray=S===3?new Ur:new js,l.colorArray.resize(w.count),Wg(e,w,l.colorArray,I)}if(s.NORMAL!==void 0){l.normalArray=new Ur;let w=e.json.accessors[s.NORMAL];l.normalArray.resize(w.count);let S=tu(e,w);Wg(e,w,l.normalArray,S)}if(s.TEXCOORD_0!==void 0&&i.length>0){l.texcoordArray=new sr;let w=e.json.accessors[s.TEXCOORD_0];l.texcoordArray.resize(w.count);let S=tu(e,w);Wg(e,w,l.texcoordArray,S)}if(s._FEATURE_ID_RGBA4444!==void 0){let w=e.json.accessors[s._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(l.featureData=tu(e,w))}s._FEATURE_RGBA4444!==void 0&&(l.featureData=new Uint32Array(tu(e,e.json.accessors[s._FEATURE_RGBA4444]).buffer));let b=n.material;return l.material=function(w,S){let{emissiveFactor:I=[0,0,0],alphaMode:M="OPAQUE",alphaCutoff:C=.5,normalTexture:R,occlusionTexture:F,emissiveTexture:L,doubleSided:j,name:H}=w,{baseColorFactor:$=[1,1,1,1],metallicFactor:ie=1,roughnessFactor:W=1,baseColorTexture:Q,metallicRoughnessTexture:Y}=w.pbrMetallicRoughness||{},ee=F?S[F.index]:void 0;if(F&&F.extensions&&F.extensions.KHR_texture_transform&&ee){let me=F.extensions.KHR_texture_transform;ee.offsetScale=[me.offset[0],me.offset[1],me.scale[0],me.scale[1]]}return{name:H,pbrMetallicRoughness:{baseColorFactor:new Ht(...$),metallicFactor:ie,roughnessFactor:W,baseColorTexture:Q?S[Q.index]:void 0,metallicRoughnessTexture:Y?S[Y.index]:void 0}
7,doubleSided:j,emissiveFactor:new Ht(...I),alphaMode:M,alphaCutoff:C,normalTexture:R?S[R.index]:void 0,occlusionTexture:ee,emissionTexture:L?S[L.index]:void 0,defined:w.defined===void 0}}(b!==void 0?e.json.materials[b]:{defined:!1},i),l}function Xg(n,e,i){let{matrix:r,rotation:s,translation:l,scale:u,mesh:p,extras:f,children:g,name:x}=n,b={};if(b.name=x,b.localMatrix=r||function(w,S,I,M){var C=S[0],R=S[1],F=S[2],L=S[3],j=C+C,H=R+R,$=F+F,ie=C*j,W=C*H,Q=C*$,Y=R*H,ee=R*$,me=F*$,ge=L*j,Te=L*H,Ae=L*$,Ie=M[0],Be=M[1],xe=M[2];return w[0]=(1-(Y+me))*Ie,w[1]=(W+Ae)*Ie,w[2]=(Q-Te)*Ie,w[3]=0,w[4]=(W-Ae)*Be,w[5]=(1-(ie+me))*Be,w[6]=(ee+ge)*Be,w[7]=0,w[8]=(Q+Te)*xe,w[9]=(ee-ge)*xe,w[10]=(1-(ie+Y))*xe,w[11]=0,w[12]=I[0],w[13]=I[1],w[14]=I[2],w[15]=1,w}([],s||[0,0,0,1],l||[0,0,0],u||[1,1,1]),b.globalMatrix=Rr(b.localMatrix),p!==void 0){b.meshes=i[p];let w=b.anchor=[0,0];for(let S of b.meshes){let{min:I,max:M}=S.aabb;w[0]+=I[0]+M[0],w[1]+=I[1]+M[1]}w[0]=Math.floor(w[0]/b.meshes.length/2),w[1]=Math.floor(w[1]/b.meshes.length/2)}if(f&&(f.id&&(b.id=f.id),f.lights&&(b.lights=function(w){if(!w.length)return[];let S=function(F){let L=atob(F),j=new Uint8Array(L.length);for(let H=0;H<L.length;H++)j[H]=L.codePointAt(H);return j}(w),I=[],M=S.length/24,C=new Uint16Array(S.buffer),R=new Float32Array(S.buffer);for(let F=0;F<M;F++){let L=C[2*F*6]/30,j=C[2*F*6+1]/30,H=C[2*F*6+10]/100,$=R[6*F+1],ie=R[6*F+2],W=R[6*F+3],Q=R[6*F+4],Y=W-$,ee=Q-ie,me=Math.hypot(Y,ee);I.push({pos:[$+.5*Y,ie+.5*ee,j],normal:[ee/me,-Y/me,0],width:me,height:L,depth:H,points:[$,ie,W,Q]})}return I}(f.lights)),f.MAPBOX_geometry_bloom&&(b.isGeometryBloom=f.MAPBOX_geometry_bloom)),g){let w=[];for(let S of g)w.push(Xg(e.json.nodes[S],e,i));b.children=w}if(n.extensions&&n.extensions.mbx_bvh&&(b.meshBVH=function(w,S,I){let M=S.binaryAccessor,C=S.positionMinAccessor,R=S.positionMaxAccessor,F=S.indexAccessor;if(!(Number.isInteger(M)&&Number.isInteger(C)&&Number.isInteger(R)&&Number.isInteger(F)))return null;let L=w.json.accessors;if(M>=L.length||C>=L.length||R>=L.length||F>=L.length)return null;let j=L[M],H=L[C],$=L[R],ie=L[F];if(j.bufferView===void 0||H.bufferView===void 0||$.bufferView===void 0||ie.bufferView===void 0)return null;let W=w.json.bufferViews;if(j.bufferView>=W.length||H.bufferView>=W.length||$.bufferView>=W.length||ie.bufferView>=W.length)return null;let Q=W[j.bufferView],Y=W[H.bufferView],ee=W[$.bufferView],me=W[ie.bufferView];if(Q.buffer>=w.buffers.length||Y.buffer>=w.buffers.length||ee.buffer>=w.buffers.length||me.buffer>=w.buffers.length)return null;let ge=(We,De,Ge)=>We>=0&&We<=Ge&&De<=Ge-We,Te=j.byteOffset||0,Ae=H.byteOffset||0,Ie=$.byteOffset||0,Be=ie.byteOffset||0;if(!(ge(Te,0,Q.byteLength)&&ge(Ae,3*H.count*4,Y.byteLength)&&ge(Ie,3*$.count*4,ee.byteLength)&&ge(Be,4*ie.count,me.byteLength)))return null;let xe=new Uint8Array(w.buffers[Q.buffer],(Q.byteOffset||0)+Te,Q.byteLength-Te),Se=new Float32Array(w.buffers[Y.buffer],(Y.byteOffset||0)+Ae,3*H.count),Me=new Float32Array(w.buffers[ee.buffer],(ee.byteOffset||0)+Ie,3*$.count),Le=new Uint32Array(w.buffers[me.buffer],(me.byteOffset||0)+Be,ie.count),ze=new ax;if(ze.serializeFromGltf(xe,Se,Me,Le),I!==void 0&&w.json.meshes&&w.json.meshes[I]){let We=w.json.meshes[I].primitives[0];if(We&&We.attributes.POSITION!==void 0&&We.attributes.POSITION<L.length){let De=L[We.attributes.POSITION];if(De.bufferView!==void 0&&De.bufferView<W.length){let Ge=W[De.bufferView];if(Ge.buffer<w.buffers.length){let $e=De.byteOffset||0,Je=Ge.byteStride?Ge.byteStride/4:3;if(ge($e,De.count*Je*4,Ge.byteLength)){let tt=(Ge.byteOffset||0)+$e;if(Je===3)ze.setVertices(new Float32Array(w.buffers[Ge.buffer],tt,3*De.count));else{let ct=new Float32Array(w.buffers[Ge.buffer],tt,De.count*Je),rt=new Float32Array(3*De.count);for(let ft=0;ft<De.count;ft++)rt[3*ft]=ct[ft*Je],rt[3*ft+1]=ct[ft*Je+1],rt[3*ft+2]=ct[ft*Je+2];ze.setVertices(rt)}}}}}}return ze}(e,n.extensions.mbx_bvh,p)),!b.meshBVH&&b.children){for(let w of b.children)if(w.meshBVH){b.meshBVH=w.meshBVH;break}}return b}function Db(n){if(n.vertices.length===0||n.indices.length===0)return null;let e=new Nm(n.vertices,n.indices,8,256),[i,r]=[e.min.clone(),e.max.clone()];return{vertices:n.vertices,indices:n.indices,grid:e,min:i,max:r}}function Rb(n){if(!n.extras||!n.extras.ground)return null;let e=n.extras.ground;if(!e||!Array.isArray(e)||e.length===0)return null;let i=e[0];if(!i||!Array.isArray(i)||i.length===0)return null;let r=[];for(let u of i){if(!Array.isArray(u)||u.length!==2)continue;let p=u[0],f=u[1];typeof p=="number"&&typeof f=="number"&&r.push(new ke(p,f))}if(r.length<3)return null;r.length>1&&r.at(-1).equals(r[0])&&r.pop();let s=0;for(let u=0;u<r.length;u++){let p=r[u],f=r[(u+1)%r.length],g=r[(u+2)%r.length];s+=(p.x-f.x)*(g.y-f.y)-(g.x-f.x)*(p.y-f.y)}s>0&&r.reverse();let l=bn(r.flatMap(u=>[u.x,u.y]),[]);return l.length===0?null:{vertices:r,indices:l}}
7function Lb(n,e){let i=[],r=[],s=0,l=[];for(let u of n){s=i.length;let p=u.vertexArray.float32,f=u.indexArray.uint16;for(let g=0;g<u.vertexArray.length;g++)l[0]=p[3*g+0],l[1]=p[3*g+1],l[2]=p[3*g+2],Bi(l,l,e),i.push(new ke(l[0],l[1]));for(let g=0;g<3*u.indexArray.length;g++)r.push(f[g]+s)}if(r.length%3!=0)return null;for(let u=0;u<r.length;u+=3){let p=i[r[u+0]],f=i[r[u+1]],g=i[r[u+2]];(p.x-f.x)*(g.y-f.y)-(g.x-f.x)*(p.y-f.y)>0&&([r[u+1],r[u+2]]=[r[u+2],r[u+1]])}return{vertices:i,indices:r}}function lx(n,e){for(let i=0;i<n.length;i++)if(n[i].name===e)return i;return-1}function Yg(n){let e=function(x,b){let w=[],S=WebGL2RenderingContext;if(x.json.textures)for(let I of x.json.textures){let M={magFilter:S.LINEAR,minFilter:S.NEAREST,wrapS:S.REPEAT,wrapT:S.REPEAT};I.sampler!==void 0&&Object.assign(M,x.json.samplers[I.sampler]),w.push({image:b[I.source],sampler:M,uploaded:!1})}return w}(n,n.images),i=function(x,b){let w=[];for(let S of x.json.meshes){let I=[];for(let M of S.primitives)I.push(Pb(M,x,b));w.push(I)}return w}(n,e),{scenes:r,scene:s,nodes:l}=n.json,u=r?lx(r,"Default Scene"):-1;u<0&&(u=s||0);let p=r?r[u].nodes:[...l.keys()],f=[];for(let x of p)f.push(Xg(l[x],n,i));(function(x,b,w){let S={},I=new Set;for(let M=0;M<x.length;M++){let C=w[b[M]];if(!C.extras)continue;let R=C.extras["mapbox:footprint:version"],F=C.extras["mapbox:footprint:id"];(R||F)&&I.add(M),R==="1.0.0"&&F&&(S[F]=M)}for(let M=0;M<x.length;M++){if(I.has(M))continue;let C=x[M],R=w[b[M]];if(!R.extras)continue;let F=null;C.id in S&&(F=Lb(x[S[C.id]].meshes,C.localMatrix)),F||(F=Rb(R)),F&&(C.footprint=Db(F))}if(I.size>0){let M=Array.from(I.values()).sort((C,R)=>C-R);for(let C=M.length-1;C>=0;C--)x.splice(M[C],1)}})(f,p,n.json.nodes);let g=r?lx(r,"LOD"):-1;if(g>=0){let x=r[g].nodes,b=new Map;for(let w of x){let S=Xg(l[w],n,i);S.id&&b.set(S.id,S)}for(let w of f)if(w.id){let S=b.get(w.id);S&&S.meshes&&(w.lodMeshes=S.meshes,S.meshBVH&&(w.meshBVH=S.meshBVH))}}return f}function zb(n){n.heightmap=new Float32Array(4096),n.heightmap.fill(-1);let e=n.vertexArray.float32,i=n.aabb.min[0]-1,r=n.aabb.min[1]-1,s=eu/(n.aabb.max[0]-i+2),l=eu/(n.aabb.max[1]-r+2);for(let u=0;u<e.length;u+=3){let p=e[u+2],f=(e[u+0]-i)*s|0,g=(e[u+1]-r)*l|0;p>n.heightmap[g*eu+f]&&(n.heightmap[g*eu+f]=p)}}function cx(n,e,i,r,s){i.reserve(i.length+4*n.length),r.reserve(r.length+10*n.length),s.reserve(s.length+10*n.length);let l=r.length;for(let u of n){let p=Math.min(10,Math.max(4,1.3*u.height))*e,f=[-u.normal[1],u.normal[0],0],g=Math.min(.29,.1*u.width/u.depth),x=u.width-2*u.depth*e*(g+.01),b=zr([],u.pos,f,x/2),w=zr([],u.pos,f,-x/2),S=[b[0],b[1],b[2]+u.height],I=[w[0],w[1],w[2]+u.height],M=zr([],u.normal,f,g);Fi(M,M,p);let C=zr([],u.normal,f,-g);Fi(C,C,p),nn(M,b,M),nn(C,w,C),b[2]+=.1,w[2]+=.1,r.emplaceBack(M[0],M[1],M[2]),r.emplaceBack(C[0],C[1],C[2]),r.emplaceBack(b[0],b[1],b[2]),r.emplaceBack(w[0],w[1],w[2]),r.emplaceBack(S[0],S[1],S[2]),r.emplaceBack(I[0],I[1],I[2]),r.emplaceBack(b[0],b[1],b[2]),r.emplaceBack(w[0],w[1],w[2]),r.emplaceBack(M[0],M[1],M[2]),r.emplaceBack(C[0],C[1],C[2]);let R=x/p/2;s.emplaceBack(-R-g,-1,R,.8),s.emplaceBack(R+g,-1,R,.8),s.emplaceBack(-R,0,R,1.3),s.emplaceBack(R,0,R,1.3),s.emplaceBack(R+g,-.8,R,.7),s.emplaceBack(R+g,-.8,R,.7),s.emplaceBack(0,0,R,1.3),s.emplaceBack(0,0,R,1.3),s.emplaceBack(R+g,-1.2,R,.8),s.emplaceBack(R+g,-1.2,R,.8),i.emplaceBack(6+l,4+l,8+l),i.emplaceBack(7+l,9+l,5+l),i.emplaceBack(0+l,1+l,2+l),i.emplaceBack(1+l,3+l,2+l),l+=10}}function Ob(n,e){let i={};i.indexArray=new Yi,i.vertexArray=new Ur,i.colorArray=new js,cx(n,e,i.indexArray,i.vertexArray,i.colorArray);let r={defined:!0};r.emissiveFactor=Ht.black;let s={};return s.baseColorFactor=Ht.white,r.pbrMetallicRoughness=s,i.material=r,i.aabb=new Ei([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}Qe(ax,"ModelBVH");let ux=Rt([{name:"a_pos_3f",components:3,type:"Float32"}]),Fb=Rt([{name:"a_normal_3",components:3,type:"Int16"}]),Bb=Rt([{name:"a_centroid_3",components:3,type:"Int16"}]),hx=Rt([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),kb=Rt([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Nb=Rt([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Ub=Rt([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Vb=Rt([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),jb=Rt([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),Jg=4096;class Gb{constructor(e){this.module=e,this.memoryStack=this.module.malloc(Jg),this.memoryStackNextFree=this.memoryStack}createIntArray(e){let i=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Jg?-1:(new Int32Array(this.module.heap32.buffer,i,e.length).set(e),i)}createFloatArray(e){let i=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Jg?-1:(new Float32Array(this.module.heapF32.buffer,i,e.length).set(e),i)}readStringBuffer(e){let i="";for(;this.module.heapU8[e]!==0;)i+=String.fromCharCode(this.module.heapU8[e]),++e;return i}setStyle(e){let i=e.normalScale;this.module.setStyle(i[0],i[1],i[2],e.tileToMeters)}setAOOptions(e,i){this.module.setAOOptions(e?1:0,i)}setMetricOptions(e,i){this.module.setMetricOptions(e?1:0,i)}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0)}setFacadeOptions(e,i){this.module.setFacadeOptions(e,i?1:0)}setFauxFacadeOptions(e,i,r){this.module.setFauxFacadeOptions(e?1:0,i?1:0,r)}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e)}generateMesh(e,i){this.memoryStackNextFree=this.memoryStack;for(let p of e){let f=this.createIntArray(p.ringIndices),g=this.createFloatArray(p.coordinates);if(f===-1||g===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(p.id,p.sourceId,p.minHeight,p.height,p.roofType,g,f,p.ringIndices.length-1)}for(let p of i){let f;f=p.entrances?JSON.parse(p.entrances):[];let g=this.createFloatArray(f),x=this.createFloatArray(p.coordinates);if(g===-1||x===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(p.sourceId,p.crossPerc,p.distanceToRoad,g,f.length,x,p.coordinates.length)}if(!this.module.generateMesh()){let p=this.module.getLastError();return this.readStringBuffer(p)}
7let r=this.module.getMeshCount(),s=new Array(r);for(let p=0;p<r;p++){let f=this.module.getPositionsPtr(p),g=this.module.getPositionsLength(p),x=new Float32Array(this.module.heapF32.buffer,f,g),b=this.module.getNormalsPtr(p),w=this.module.getNormalsLength(p),S=new Float32Array(this.module.heapF32.buffer,b,w),I=this.module.getAOPtr(p),M=this.module.getAOLength(p),C=new Float32Array(this.module.heapF32.buffer,I,M),R=this.module.getUVPtr(p),F=this.module.getUVLength(p),L=new Float32Array(this.module.heapF32.buffer,R,F),j=this.module.getFauxFacadePtr(p),H=this.module.getFauxFacadeLength(p),$=new Uint8Array(this.module.heapU8.buffer,j,H),ie=this.module.getIndicesPtr(p),W=this.module.getIndicesLength(p),Q=new Int16Array(this.module.heap16.buffer,ie,W),Y=this.module.getBuildingPart(p);s[p]={positions:x,normals:S,ao:C,uv:L,isFauxFacade:$,indices:Q,buildingPart:Y}}let l=this.module.getRingCount(),u=[];for(let p=0;p<l;p++){let f=this.module.getRingPtr(p),g=this.module.getRingLength(p),x=new Float32Array(this.module.heapF32.buffer,f,g);u.push(x)}return{meshes:s,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:u}}}let dx=$s.types,s_=32767;function Hb(n,e){let i=Xe+e;for(let r of n)for(let s of r)if(s.x<-e||s.x>i||s.y<-e||s.y>i)return!1;return!0}function $b(n){switch(n){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${n}`)}}let vh=null,px=null,Io=null;class Kg{constructor(){this.layoutVertexArray=new Ur,this.layoutAttenuationArray=new js,this.layoutColorArray=new Vr,this.indexArray=new Yi,this.indexArrayForConflation=new Yi,this.segmentsBucket=new pi}}class Qg{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new pi,this.entranceBloom=new Kg;let i=66560;this.layoutVertexArray=new Ur,this.layoutVertexArray.reserve(i),this.layoutNormalArray=new Us,this.layoutNormalArray.reserve(i),this.layoutCentroidArray=new Us,this.layoutCentroidArray.reserve(i),this.layoutColorArray=new Vr,this.layoutColorArray.reserve(i),this.layoutFloodLightDataArray=new Rl,this.layoutFloodLightDataArray.reserve(i),this.layoutAOArray=new Ll,this.layoutAOArray.reserve(i),this.indexArray=new Yi,this.indexArray.reserve(66560),this.indexArrayForConflation=new Yi,this.segmentsBucket=new pi,this.entranceBloom=new Kg,e&&(this.layoutFacadePaintArray=new Vr,this.layoutFacadeDataArray=new Al,this.layoutFacadeVerticalRangeArray=new Vr)}reserve(e,i,r){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(i),r&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e))}}class fx{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new sr,this.footprintsIndices=new Cl,this.footprintsMin=new ke(1/0,1/0),this.footprintsMax=new ke(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Qg(!1),this.buildingWithFacade=new Qg(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new To(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection,this.groundEffect=new Bg(e),this.groundEffect.groundRadiusArray=new Lo,this.hasAppearances=null}updateFootprints(e,i){let r=new Nm([],[],1),s={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};i.push({footprint:s,id:e})}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}
7populate(e,i,r,s){if(!Io)return;let l=Hr(r);this.tileToMeter=l,this.brightness=i.brightness,Io.setStyle({normalScale:[1,-1,l],tileToMeters:l}),Io.setAOOptions(!1,.3),Io.setMetricOptions(!1,16),Io.setStructuralOptions(!0),Io.setFacadeClassifierOptions(3);let u=new Map,p=new Map,f=0;for(let{feature:C}of e){if(dx[C.type]!=="LineString"){u.set(C.id,C.properties.source_id);continue}let R=this.layers[0]._featureFilter.needGeometry;if(R&&!this.layers[0]._featureFilter.filter(new Jt(this.zoom),C,r))continue;let F=qr(C,R);if(!R&&!this.layers[0]._featureFilter.filter(new Jt(this.zoom),F,r))continue;let L=R?F.geometry:$r(C,r,s),j=[];for(let W of L)for(let Q of W)j.push(Q.x),j.push(Q.y);let H={coordinates:j,crossPerc:C.properties.cross_perc,distanceToRoad:C.properties.distance_to_road,entrances:C.properties.entrances,sourceId:0},$=C.properties.source_id,ie=p.get($);ie||(ie=[],p.set($,ie)),ie.push(H),++f}this.maxHeight=0;let g=new Array,x=new Set,b=C=>{C!=null&&x.add(C)},w=(C,R)=>{C!=null&&g.push({buildingId:C,footprintIndex:R})},S=64*(e.length-f),I=S/2;this.buildingWithFacade.reserve(S,I,!0),this.buildingWithoutFacade.reserve(2*S,2*I,!1),this.footprintsIndices.reserve(16*(e.length-f)),this.footprintsVertices.reserve(8*(e.length-f));for(let{feature:C,id:R,index:F,sourceLayerIndex:L}of e){if(dx[C.type]==="LineString")continue;let j=this.layers[0]._featureFilter.needGeometry;if(j&&!this.layers[0]._featureFilter.filter(new Jt(this.zoom),C,r))continue;let H=null;if(C.properties&&Object.hasOwn(C.properties,"building_id")&&(H=Number(C.properties.building_id),x.has(H)))continue;let $=qr(C,j);if(!j&&!this.layers[0]._featureFilter.filter(new Jt(this.zoom),$,r))continue;let ie=j?$.geometry:$r(C,r,s),W=mp(ie,500),Q=!1;for(let zt of W)if(zt.length!==1){Q=!0;break}if(Q){b(H);continue}if(!Hb(ie,163)){b(H);continue}let Y=this.layers[0],ee=$b(Y.layout.get("building-roof-shape").evaluate(C,{},r)),me=Y.layout.get("building-base").evaluate(C,{},r),ge=Y.layout.get("building-height").evaluate(C,{},r),Te=Y.layout.get("building-flood-light-ground-radius").evaluate(C,{},r),Ae=Y.paint.get("building-ambient-occlusion-intensity"),Ie=Te/this.tileToMeter;C.properties["building-part"]="roof";let Be=Y.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),xe=Y.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="wall";let Se=Y.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),Me=Y.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="window";let Le=Y.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),ze=Y.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="door";let We=Y.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),De=Y.paint.get("building-emissive-strength").evaluate(C,{},this.canonical),Ge=Y.layout.get("building-flood-light-wall-radius").evaluate(C,{},r);Ge=ne(Ge,0,2048);let $e=Ge/2048*s_,Je=u.get(R),tt=p.get(Je)||[],ct=tt.length!==0&&Y.layout.get("building-facade").evaluate(C,{},r);Io.setFacadeOptions(4,!0),Io.setFauxFacadeOptions(ct,!1,1);let rt=0,ft=0,Zt=0,St=0,Ut=0,Pt=0,ji=0,Qt=0,$t=0,ui=0,Pi=0;if(ct){let zt=Math.round(Y.layout.get("building-facade-floors").evaluate(C,{},r));if(me===0){zt=Math.max(1,zt-(tt.length>0?1:0));let Hi=4;if(ge>100){let _n=[10,13,15];Hi=_n[C.id?C.id%_n.length:0]}else ge<=10&&(Hi=3);Io.setFacadeOptions(Hi,!0),Ut=(ge<15?1.3:1.61803)*Hi/l}else Ut=me/l;Pt=ge/l,Ut=Math.min(Ut,Pt),Zt=Y.layout.get("building-facade-unit-width").evaluate(C,{},r)/l,St=(Pt-Ut)/zt,Io.setFauxFacadeOptions(!0,!0,Zt);let Cn=Y.layout.get("building-facade-window").evaluate(C,{},r);rt=Cn[0],ft=Cn[1],ji=Math.floor(65535*Math.min(1,Ut/Xe)),Qt=Math.floor(65535*Math.min(1,Pt/Xe)),$t=Math.floor(255*rt)<<8|Math.floor(255*ft),ui=Math.floor(65535*Math.min(1,Zt/Xe)),Pi=Math.floor(65535*Math.min(1,St/Xe))}let Tn=Array(W.length),_i={x:1/0,y:1/0},Gi={x:-1/0,y:-1/0},un={x:0,y:0},tn=0;for(let zt=0;zt<W.length;zt++){let Cn=W[zt];if(Cn.length>0){let Hi=[],_n=Array(Cn.length+1);_n[0]=0;for(let Co=0;Co<Cn.length;Co++){let Jr=Cn[Co];for(let uo=0;uo<Jr.length;uo++){let Kr=Jr[Jr.length-uo-1];_i.x=Math.min(_i.x,Kr.x),_i.y=Math.min(_i.y,Kr.y),Gi.x=Math.max(Gi.x,Kr.x),Gi.y=Math.max(Gi.y,Kr.y),un.x+=Kr.x,un.y+=Kr.y,tn++,Hi.push(Kr.x),Hi.push(Kr.y)}_n[Co+1]=Hi.length}Tn[zt]={id:C.id?C.id:0,height:ge,minHeight:me,sourceId:0,roofType:ee,coordinates:Hi,ringIndices:_n}}}un.x/=tn||1,un.y/=tn||1;let hn=Io.generateMesh(Tn,tt);if(typeof hn=="string"){Bt(`Unable to generate building ${C.id}: ${hn}`),b(H);continue}if(hn.meshes.length===0||hn.modifiedPolygonRings.length===0){b(H);continue}let Lt=ct?this.buildingWithFacade:this.buildingWithoutFacade,jn=0;for(let zt of hn.meshes)jn+=zt.positions.length/3;let hr=Lt.segmentsBucket.prepareSegment(jn,Lt.layoutVertexArray,Lt.indexArray),Qi=[],Mn=null,ir=0,Gn=-1,Oi=Lt.layoutVertexArray.length,mn=Oi+jn;Lt.layoutVertexArray.resize(mn),Lt.layoutCentroidArray.resize(mn),Lt.layoutNormalArray.resize(mn),Lt.layoutAOArray.resize(mn),Lt.layoutColorArray.resize(mn),Lt.layoutFloodLightDataArray.resize(mn),ct&&(Lt.layoutFacadePaintArray.resize(mn),Lt.layoutFacadeDataArray.resize(mn),Lt.layoutFacadeVerticalRangeArray.resize(mn));let Dr=Lt.indexArray.length,Ph=0,_r=Oi;for(let zt of hn.meshes){let Cn,Hi;if(zt.buildingPart===1)Cn=Be,Hi=xe;else if(zt.buildingPart===0)Cn=Se,Hi=Me;else if(zt.buildingPart===2)Cn=Le,Hi=ze;else{if(zt.buildingPart!==3)continue;Cn=We,Hi=De}if(Hi=ne(Hi,0,1),zt.buildingPart===3){let dn=new Array;for(let gr=0;gr<zt.positions.length;gr+=12){let Hn=zt.positions[gr+0],nr=zt.positions[gr+1],po=zt.positions[gr+3],ea=zt.positions[gr+4],R_=zt.positions[gr+2],Ny=zt.positions[gr+8]-R_,Uy=1,Lh=po-Hn,ms=ea-nr,Wp=Math.hypot(Lh,ms);dn.push({pos:[Hn+.5*Lh,nr+.5*ms,R_],normal:[ms/Wp,-Lh/Wp,0],width:Wp,height:Ny,depth:Uy,points:[Hn,nr,po,ea]})}let On=Lt.entranceBloom.segmentsBucket.prepareSegment(10*dn.length,Lt.entranceBloom.layoutVertexArray,Lt.entranceBloom.indexArray),Wi=Lt.entranceBloom.layoutVertexArray.length;ir=Lt.entranceBloom.indexArray.length,cx(dn,.5/this.tileToMeter,Lt.entranceBloom.indexArray,Lt.entranceBloom.layoutVertexArray,Lt.entranceBloom.layoutAttenuationArray);let ho=Lt.entranceBloom.layoutVertexArray.length-Wi;Gn=Lt.entranceBloom.indexArray.length-ir;for(let gr=0;gr<ho;gr++)Lt.entranceBloom.layoutColorArray.emplaceBack(255*We.r<<8|255*We.g,255*We.b<<8|51*De);On.vertexLength+=ho,On.primitiveLength+=Gn,Mn={part:zt.buildingPart,vertexOffset:Wi,vertexLength:ho}}Lt.layoutVertexArray.float32.set(zt.positions,3*_r);let _n=zt.positions.length/3;for(let dn=0;dn<_n;++dn){let On=3*dn;Ph=Math.max(Ph,zt.positions[On+2]);let Wi=zt.normals[On+1]*s_,ho=zt.normals[On+2]*s_,gr=3*(_r+dn);Lt.layoutNormalArray.int16[gr]=zt.normals[On]*s_,Lt.layoutNormalArray.int16[gr+1]=Wi,Lt.layoutNormalArray.int16[gr+2]=ho;let Hn=zt.ao[dn];Lt.layoutAOArray.uint8[_r+dn]=255*Hn;let nr=1+(Hn-1)*Ae,po=255*Cn.b*nr<<8|255*Hi;Lt.layoutColorArray.uint16[2*(_r+dn)]=255*Cn.r*nr<<8|255*Cn.g*nr,Lt.layoutColorArray.uint16[2*(_r+dn)+1]=po}let Co=Math.min(8191,Math.max(0,Math.floor(un.x))),Jr=Math.min(8191,Math.max(0,Math.floor(un.y))),uo=Math.floor(ge),Kr=20,Zp=4*Co+Math.min(3,Math.round((Gi.x-_i.x)*this.tileToMeter/Kr)),jo=4*Jr+Math.min(3,Math.round((Gi.y-_i.y)*this.tileToMeter/Kr));for(let dn=0;dn<_n;++dn){let On=3*(_r+dn);Lt.layoutCentroidArray.int16[On]=Zp,Lt.layoutCentroidArray.int16[On+1]=jo,Lt.layoutCentroidArray.int16[On+2]=uo}if(Lt.layoutFloodLightDataArray.int16.fill(zt.buildingPart===0?$e:0,_r,_r+_n),ct){let dn=255*Le.r<<8|255*Le.g,On=255*Le.b<<8|255*ze;for(let Wi=0;
7Wi<_n;++Wi){let ho=2*(_r+Wi);Lt.layoutFacadePaintArray.uint16[ho]=dn,Lt.layoutFacadePaintArray.uint16[ho+1]=On}for(let Wi=0;Wi<_n;++Wi)if(zt.isFauxFacade[Wi]){let ho=Math.min(65535,Math.floor(zt.uv[2*Wi]*hn.outerRingLength));Lt.layoutFacadeDataArray.emplace(_r+Wi,1|ho,$t,ui,Pi),Lt.layoutFacadeVerticalRangeArray.emplace(_r+Wi,ji,Qt)}else Lt.layoutFacadeDataArray.emplace(_r+Wi,0,0,0,0),Lt.layoutFacadeVerticalRangeArray.emplace(_r+Wi,0,0)}let Dh=hr.vertexLength,Qs=zt.indices.length/3,Rh=Lt.indexArray.length;Lt.indexArray.resize(Rh+Qs);for(let dn=0;dn<Qs;++dn){let On=3*dn,Wi=3*Rh+On;Lt.indexArray.uint16[Wi]=Dh+zt.indices[On],Lt.indexArray.uint16[Wi+1]=Dh+zt.indices[On+1],Lt.indexArray.uint16[Wi+2]=Dh+zt.indices[On+2]}zt.buildingPart!==1&&zt.buildingPart!==0&&zt.buildingPart!==2&&zt.buildingPart!==3||Qi.push({part:zt.buildingPart,vertexOffset:_r,vertexLength:zt.positions.length/3}),_r+=_n,hr.vertexLength+=_n,hr.primitiveLength+=zt.indices.length/3}this.maxHeight=Math.max(this.maxHeight,Ph);let ky=Lt.indexArray.length-Dr,$p=this.footprintsIndices.length,qp=this.footprintsVertices.length,qa=[],co=new ke(1/0,1/0),Mo=new ke(-1/0,-1/0),Xl=this.groundEffect.vertexArray.length;for(let zt of hn.modifiedPolygonRings){let Cn=[],Hi=new ke(1/0,1/0),_n=new ke(-1/0,-1/0);for(let Co=0;Co<zt.length;Co+=2){let Jr=zt.length-Co-2;Hi.x=Math.min(Hi.x,zt[Jr]),Hi.y=Math.min(Hi.y,zt[Jr+1]),_n.x=Math.max(_n.x,zt[Jr]),_n.y=Math.max(_n.y,zt[Jr+1]);let uo=new ke(zt[Jr],zt[Jr+1]);Cn.push(uo),qa.push(uo.x,uo.y),this.footprintsVertices.emplaceBack(uo.x,uo.y)}co.x=Math.min(co.x,Hi.x),co.y=Math.min(co.y,Hi.y),Mo.x=Math.max(Mo.x,_n.x),Mo.y=Math.max(Mo.y,_n.y),this.groundEffect.addData(Cn,[Hi,_n],Ie)}let Yl=this.groundEffect.vertexArray.length-Xl;this.groundEffect.groundRadiusArray.reserveForAdditional(Yl);for(let zt=0;zt<Yl;zt++)this.groundEffect.groundRadiusArray.emplaceBack(Te);(_i.x<0||Gi.x>Xe||_i.y<0||Gi.y>Xe)&&this.featuresOnBorder.push({featureId:C.id,footprintIndex:this.footprints.length});{let zt=bn(qa,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+zt.length),this.footprintsIndices.uint16.set(zt,$p),this.buildingIds.add(H??C.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,co.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,co.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Mo.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Mo.y);let Cn={footprintVertexOffset:qp,footprintVertexLength:this.footprintsVertices.length-qp,footprintIndexOffset:$p,footprintIndexLength:this.footprintsIndices.length-$p,min:co,max:Mo,hiddenFlags:0,indicesOffset:Dr,indicesLength:ky,bloomIndicesOffset:ir,bloomIndicesLength:Gn,groundEffectVertexOffset:Xl,groundEffectVertexLength:Yl,hasFauxFacade:ct,height:Ph,promoteId:R,feature:$,parts:Qi,buildingBloom:Mn},Hi=this.footprints.length;C.id!==void 0&&this.featureFootprintLookup.set(C.id,Hi),w(H,Hi),this.footprints.push(Cn)}this.programConfigurations.populatePaintArrays(Lt.layoutVertexArray.length,C,F,{},i.availableImages,r,i.brightness),this.groundEffect.addPaintPropertiesData(C,F,{},i.availableImages,r,i.brightness),i.featureIndex.insert(C,ie,F,L,this.index,Oi)}g.forEach(({buildingId:C,footprintIndex:R})=>{x.has(C)&&(this.footprints[R].hiddenFlags|=4)});let M=new Set;this.buildingIds.forEach((C,R,F)=>{x.has(C)||M.add(C)}),this.buildingIds=M,this.groundEffect.prepareBorderSegments()}update(e,i,r,s,l,u,p){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p),this.groundEffect.update(e,i,l,r,s,u,p),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}updateExpressions(e){this.programConfigurations.updateExpressions(e),this.groundEffect.programConfigurations.updateExpressions(e)}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){let i=r=>{r.layoutVertexBuffer=e.createVertexBuffer(r.layoutVertexArray,ux.members),r.layoutNormalBuffer=e.createVertexBuffer(r.layoutNormalArray,Fb.members),r.layoutCentroidBuffer=e.createVertexBuffer(r.layoutCentroidArray,Bb.members),r.layoutFloodLightDataBuffer=e.createVertexBuffer(r.layoutFloodLightDataArray,jb.members),r.layoutFacadeDataArray&&r.layoutFacadeDataArray.length&&(r.layoutFacadeDataBuffer=e.createVertexBuffer(r.layoutFacadeDataArray,Nb.members)),r.layoutFacadeVerticalRangeArray&&r.layoutFacadeVerticalRangeArray.length&&(r.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(r.layoutFacadeVerticalRangeArray,Ub.members)),r.entranceBloom.layoutVertexArray.length&&(r.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(r.entranceBloom.layoutVertexArray,ux.members),r.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(r.entranceBloom.layoutAttenuationArray,Vb.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e)};this.uploaded||(i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){let e=i=>{i.layoutVertexBuffer&&(i.layoutVertexBuffer.destroy(),i.layoutNormalBuffer.destroy(),i.layoutColorBuffer.destroy(),i.segmentsBucket.destroy(),i.indexBuffer&&i.indexBuffer.destroy(),i.entranceBloom.layoutVertexBuffer&&(i.entranceBloom.layoutVertexBuffer.destroy(),i.entranceBloom.layoutColorBuffer.destroy(),i.entranceBloom.layoutAttenuationBuffer.destroy(),i.entranceBloom.indexBuffer.destroy(),i.entranceBloom.segmentsBucket.destroy()))};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(e,i,r=!0){let s=!1,l=r?i:0,u=0|(r?-1:~i);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(let p of e){let f=this.footprints[p],g=f.hiddenFlags&u|l;f.hiddenFlags!==g&&(f.hiddenFlags=g,s=!0,this.groundEffect.updateHiddenByLandmarkRange(f.groundEffectVertexOffset,f.groundEffectVertexLength,f.hiddenFlags!==0))}return s&&(this.indexArrayForConflationUploaded=!1),s}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;let i=s=>{s.indexArray.length!==0&&(s.indexArrayForConflation.resize(s.indexArray.length),s.indexArrayForConflation.uint16.set(s.indexArray.uint16),s.entranceBloom.indexArrayForConflation.resize(s.entranceBloom.indexArray.length),s.entranceBloom.indexArrayForConflation.uint16.set(s.entranceBloom.indexArray.uint16))};i(this.buildingWithoutFacade),i(this.buildingWithFacade);for(let s of this.footprints){let l=s.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,u=s.indicesOffset+s.indicesLength;if(s.hiddenFlags!==0){for(let f=s.indicesOffset;f<u;f++)l.indexArrayForConflation.uint16[3*f+0]=0,l.indexArrayForConflation.uint16[3*f+1]=0,l.indexArrayForConflation.uint16[3*f+2]=0;let p=s.bloomIndicesOffset+s.bloomIndicesLength;for(let f=s.bloomIndicesOffset;f<p;f++)l.entranceBloom.indexArrayForConflation.uint16[3*f+0]=0,l.entranceBloom.indexArrayForConflation.uint16[3*f+1]=0,l.entranceBloom.indexArrayForConflation.uint16[3*f+2]=0}}let r=s=>
7{s.indexArray.length!==0&&(s.indexBuffer?s.indexBuffer.updateData(s.indexArrayForConflation):s.indexBuffer=e.createIndexBuffer(s.indexArrayForConflation,!0),s.entranceBloom.indexBuffer?s.entranceBloom.indexBuffer.updateData(s.entranceBloom.indexArrayForConflation):s.entranceBloom.indexBuffer=e.createIndexBuffer(s.entranceBloom.indexArrayForConflation,!0))};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){let i=r=>{r.layoutColorBuffer?r.layoutColorBuffer.updateData(r.layoutColorArray):r.layoutColorBuffer=e.createVertexBuffer(r.layoutColorArray,hx.members,!0),r.layoutFacadePaintArray&&(r.layoutFacadePaintBuffer?r.layoutFacadePaintBuffer.updateData(r.layoutFacadePaintArray):r.layoutFacadePaintBuffer=e.createVertexBuffer(r.layoutFacadePaintArray,kb.members,!0)),r.entranceBloom.layoutColorBuffer?r.entranceBloom.layoutColorBuffer.updateData(r.entranceBloom.layoutColorArray):r.entranceBloom.layoutColorBuffer=e.createVertexBuffer(r.entranceBloom.layoutColorArray,hx.members,!0)};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,i){let r=e.paint.get("building-ambient-occlusion-intensity");for(let s of this.footprints){if(4&s.hiddenFlags)continue;let l=i[s.promoteId],u=s.feature;u.properties["building-part"]="roof";let p=e.paint.get("building-color").evaluate(u,l,this.canonical).toPremultipliedRenderColor(this.lut),f=e.paint.get("building-emissive-strength").evaluate(u,l,this.canonical);u.properties["building-part"]="wall";let g=e.paint.get("building-color").evaluate(u,l,this.canonical).toPremultipliedRenderColor(this.lut),x=e.paint.get("building-emissive-strength").evaluate(u,l,this.canonical);u.properties["building-part"]="window";let b=e.paint.get("building-color").evaluate(u,l,this.canonical).toPremultipliedRenderColor(this.lut),w=e.paint.get("building-emissive-strength").evaluate(u,l,this.canonical);u.properties["building-part"]="door";let S=e.paint.get("building-color").evaluate(u,l,this.canonical).toPremultipliedRenderColor(this.lut),I=e.paint.get("building-emissive-strength").evaluate(u,l,this.canonical),M=s.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(let R of s.parts){let F,L=p;R.part===1?(L=p,F=f):R.part===0?(L=g,F=x):R.part===2?(L=b,F=w):R.part===3&&(L=S,F=I),F=ne(F,0,1);for(let j=0;j<R.vertexLength;j++){let H=R.vertexOffset+j,$=1+(M.layoutAOArray.uint8[H]/255-1)*r;M.layoutColorArray.emplace(H,L.r*$*255<<8|L.g*$*255,L.b*$*255<<8|255*F),s.hasFauxFacade&&M.layoutFacadePaintArray.emplace(H,255*b.r<<8|255*b.g,255*b.b<<8|255*w)}}let C=s.buildingBloom;if(C)for(let R=0;R<C.vertexLength;R++)M.entranceBloom.layoutColorArray.emplace(C.vertexOffset+R,255*S.r<<8|255*S.g,255*S.b<<8|51*I)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(e,i,r){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let s=i.getReplacementRegionsForTile(e.toUnwrapped());if(Vm(this.activeReplacements,s))return;this.activeReplacements=s;for(let u of this.footprints)u.hiddenFlags&=-2;let l=[];for(let u of this.activeReplacements){if(u.order<r)continue;let p=Math.max(1,Math.pow(2,u.footprintTileId.canonical.z-e.canonical.z));for(let f of this.footprints)f.min.x>u.max.x||f.max.x<u.min.x||f.min.y>u.max.y||f.max.y<u.min.y||(l.length=0,Zb(this.footprintsVertices,f.footprintVertexOffset,f.footprintVertexLength,u.footprintTileId.canonical,e.canonical,l),Lg(u.footprint,l,this.footprintsIndices.uint16,f.footprintIndexOffset,f.footprintIndexLength,0,-p)&&(f.hiddenFlags|=1))}this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(let u of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(u.groundEffectVertexOffset,u.groundEffectVertexLength,u.hiddenFlags!==0);this.indexArrayForConflationUploaded=!1}getFootprint(e){if(e.id!==void 0){let i=this.featureFootprintLookup.get(e.id);return this.footprints[i]}return null}getHeightAtTileCoord(e,i){let r=Number.NEGATIVE_INFINITY,s=!0,l=4*(e+Xe)*Xe+(i+Xe);if(Object.hasOwn(this.footprintLookup,l)){let p=this.footprintLookup[l];return p?{height:p.height,hidden:p.hiddenFlags!==0}:void 0}let u=new ke(e,i);for(let p of this.footprints)e>p.max.x||p.min.x>e||i>p.max.y||p.min.y>i||p.height<=r||qb(u,this.footprintsVertices.float32.subarray(2*p.footprintVertexOffset,2*(p.footprintVertexOffset+p.footprintVertexLength)),this.footprintsIndices.uint16.subarray(p.footprintIndexOffset,p.footprintIndexOffset+p.footprintIndexLength))&&(r=p.height,this.footprintLookup[l]=p,s=p.hiddenFlags!==0);if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:s};this.footprintLookup[l]=void 0}}function qb(n,e,i){for(let r=0;r<i.length;r+=3){let s=i[r],l=i[r+1],u=i[r+2],p=e[2*s+0],f=e[2*s+1],g=e[2*l+0],x=e[2*l+1],b=e[2*u+0
7],w=e[2*u+1],S=(p-b)*(n.y-w)-(f-w)*(n.x-b),I=(g-p)*(n.y-f)-(x-f)*(n.x-p);if(S<0!=I<0&&S!==0&&I!==0)continue;let M=(b-g)*(n.y-x)-(w-x)*(n.x-g);if(M===0||M<0==S+I<=0)return!0}return!1}function Zb(n,e,i,r,s,l){let u=Math.pow(2,r.z-s.z);for(let p=0;p<i;p++){let f=n.float32[2*(p+e)+0],g=n.float32[2*(p+e)+1];f=(f+s.x*Xe)*u-r.x*Xe,g=(g+s.y*Xe)*u-r.y*Xe,l.push(new ke(f,g))}}async function mx(){return function(){if(!ri(self)||Io!=null||px!=null)return null;if(vh!=null)return vh;let n=fetch(pa());return vh=function(e){let i,r,s,l,u;function p(){i=new Uint8Array(u.buffer),r=new Int16Array(u.buffer),s=new Int32Array(u.buffer),l=new Float32Array(u.buffer)}function f(){throw new Error("Unexpected BuildingGen error.")}let g=()=>{},x={a:{a:f,f:function(b){let w=i.length,S=Math.max(b>>>0,Math.ceil(1.2*w)),I=Math.ceil((S-w)/65536);try{return u.grow(I),p(),!0}catch{return!1}},g:f,b:g,c:g,d:g,e:g}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,x):e.then(b=>b.arrayBuffer()).then(b=>WebAssembly.instantiate(b,x))).then(b=>{let w=b.instance.exports;return(0,w.g)(),u=w.f,p(),new Gb({setStyle:w.h,setAOOptions:w.i,setMetricOptions:w.j,setStructuralOptions:w.k,setFacadeOptions:w.l,setFauxFacadeOptions:w.m,setFacadeClassifierOptions:w.n,addFeature:w.o,addFacade:w.p,generateMesh:w.q,getLastError:w.r,getOuterRingLength:w.s,getMeshCount:w.t,getPositionsPtr:w.u,getPositionsLength:w.v,getNormalsPtr:w.w,getNormalsLength:w.x,getAOPtr:w.y,getAOLength:w.z,getUVPtr:w.A,getUVLength:w.B,getFauxFacadePtr:w.C,getFauxFacadeLength:w.D,getIndicesPtr:w.E,getIndicesLength:w.F,getBuildingPart:w.G,getRingCount:w.H,getRingPtr:w.I,getRingLength:w.J,malloc:w.K,free:w.L,heapU8:i,heap16:r,heap32:s,heapF32:l})})}(n).then(e=>{vh=null,Io=e}).catch(e=>{Bt("Could not load building-gen"),vh=null,px=e}),vh}()}Qe(fx,"BuildingBucket",{omit:["layers"]}),Qe(Qg,"BuildingGeometry"),Qe(Kg,"BuildingBloomGeometry");
7let Wb=Rt([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),Xb=Rt([{name:"a_z_offset_width",components:3,type:"Float32"}],4),Yb=Rt([{name:"a_elevation_id_col",components:3,type:"Float32"}],4),Jb=Rt([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:Kb}=Wb,Qb=Rt([{name:"a_packed",components:3,type:"Float32"}]),{members:ew}=Qb,tw=Rt([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:iw}=tw;class _x{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.image=new zi({width:e,height:i}),this.positions={},this.uploaded=!1}getDash(e,i){let r=this.getKey(e,i);return this.positions[r]}trim(){let e=this.width,i=this.height=Ft(this.nextRow);this.image.resize({width:e,height:i})}getKey(e,i){return e.join(",")+i}getDashRanges(e,i,r){let s=[],l=e.length%2==1?-e.at(-1)*r:0,u=e[0]*r,p=!0;s.push({left:l,right:u,isDash:p,zeroLength:e[0]===0});let f=e[0];for(let g=1;g<e.length;g++){p=!p;let x=e[g];l=f*r,f+=x,u=f*r,s.push({left:l,right:u,isDash:p,zeroLength:x===0})}return s}addRoundDash(e,i,r){let s=i/2;for(let l=-r;l<=r;l++){let u=this.width*(this.nextRow+r+l),p=0,f=e[p];for(let g=0;g<this.width;g++){g/f.right>1&&(f=e[++p]);let x=Math.abs(g-f.left),b=Math.abs(g-f.right),w=Math.min(x,b),S,I=l/r*(s+1);if(f.isDash){let M=s-Math.abs(I);S=Math.sqrt(w*w+M*M)}else S=s-Math.sqrt(w*w+I*I);this.image.data[u+g]=Math.max(0,Math.min(255,S+128))}}}addRegularDash(e,i){for(let f=e.length-1;f>=0;--f){let g=e[f],x=e[f+1];g.zeroLength?e.splice(f,1):x&&x.isDash===g.isDash&&(x.left=g.left,e.splice(f,1))}let r=e[0],s=e.at(-1);r.isDash===s.isDash&&(r.left=s.left-this.width,s.right=r.right+this.width);let l=this.width*this.nextRow,u=0,p=e[u];for(let f=0;f<this.width;f++){f/p.right>1&&(p=e[++u]);let g=Math.abs(f-p.left),x=Math.abs(f-p.right),b=Math.min(g,x);this.image.data[l+f]=Math.max(0,Math.min(255,(p.isDash?b:-b)+i+128))}}addDash(e,i){let r=this.getKey(e,i);if(this.positions[r])return this.positions[r];let s=i==="round",l=s?7:0,u=2*l+1;if(this.nextRow+u>this.height)return Bt("LineAtlas out of space"),null;e.length===0&&e.push(1);let p=0;for(let b=0;b<e.length;b++)e[b]<0&&(Bt("Negative value is found in line dasharray, replacing values with 0"),e[b]=0),p+=e[b];if(p!==0){let b=this.width/p,w=this.getDashRanges(e,this.width,b);s?this.addRoundDash(w,b,l):this.addRegularDash(w,i==="square"?.5*b:0)}let f=this.nextRow+l;this.nextRow+=u;let g=Math.floor(p),x={tl:[f,l],br:[g,Math.round(65535*(p-g))]};return this.positions[r]=x,x}}Qe(_x,"LineAtlas");let nw=$s.types,rw=Math.cos(Math.PI/180*37.5),ow=Math.cos(Math.PI/180*5);class a_{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.showElevationIdDebug=!1,this.zoom=e.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=e.overscaling,this.pixelRatio=e.pixelRatio,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new Ud,this.layoutVertexArray2=new Ur,this.patternVertexArray=new Ur,this.indexArray=new Yi,this.programConfigurations=new To(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new pi,this.maxLineLength=0,this.zOffsetVertexArray=new Ur,this.elevationIdColVertexArray=new Ur,this.elevationGroundScaleVertexArray=new Lo,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,r,s){this.showElevationIdDebug=i.showElevationIdDebug,this.hasPattern=bg("line",this.layers,this.pixelRatio,i);let l=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Hr(r);let u=this.layers[0].layout.get("line-elevation-reference");if(u==="hd-road-markup")this.elevationType="road";else{let w=this.layers[0].layout.get("line-z-offset"),S=w.isConstant()&&!w.constantOr(0);this.elevationType=u!=="sea"&&u!=="ground"&&S?"none":"offset",this.elevationType==="offset"&&u==="none"&&Bt(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference=u==="sea"}let p=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&p!==void 0;let f=[];for(let{feature:w,id:S,index:I,sourceLayerIndex:M}of e){let C=this.layers[0]._featureFilter.needGeometry,R=qr(w,C);if(!this.layers[0]._featureFilter.filter(new Jt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),R,r))continue;let F=l?l.evaluate(R,{},r):void 0,L={id:S,properties:w.properties,type:w.type,sourceLayerIndex:M,index:I,geometry:C?R.geometry:$r(w,r,s),patterns:{},sortKey:F};f.push(L)}l&&f.sort((w,S)=>w.sortKey-S.sortKey);let{lineAtlas:g,featureIndex:x}=i,b=this.addConstantDashes(g);for(let w of f){let{geometry:S,index:I,sourceLayerIndex:M}=w;if(b&&this.addFeatureDashes(w,g),this.hasPattern){let C=wg("line",this.layers,w,this.zoom,this.pixelRatio,i);this.patternFeatures.push(C)}else this.addFeature(w,S,I,r,g.positions,i.availableImages,i.brightness,i.elevationFeatures);x.insert(e[I].feature,S,I,M,this.index)}}addConstantDashes(e){let i=!1;for(let r of this.layers){let s=r.paint.get("line-dasharray").value,l=r.layout.get("line-cap").value;if(s.kind!=="constant"||l.kind!=="constant")i=!0;else{let u=l.value,p=s.value;if(!p)continue;e.addDash(p,u)}}return i}addFeatureDashes(e,i){let r=this.zoom;for(let s of this.layers){let l=s.paint.get("line-dasharray").value,u=s.layout.get("line-cap").value;if(l.kind==="constant"&&u.kind==="constant")continue;let p,f;if(l.kind==="constant"){if(p=l.value,!p)continue}else p=l.evaluate({zoom:r},e);f=u.kind==="constant"?u.value:u.evaluate({zoom:r},e),i.addDash(p,f),e.patterns[s.id]=[i.getKey(p,f)]}}update(e,i,r,s,l,u,p,f,g){this.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,g)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}addFeatures(e,i,r,s,l,u){for(let p of this.patternFeatures)this.addFeature(p,p.geometry,p.index,i,r,s,u,e.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,ew)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,iw)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Xb.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=e.createVertexBuffer(this.elevationIdColVertexArray,Yb.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,Jb.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Kb),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationIdColVertexBuffer&&this.elevationIdColVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,i){let r,s;if(i&&i>0?(r=`mapbox_clip_start_${i}`,s=`mapbox_clip_end_${i}`):(r="mapbox_clip_start",s="mapbox_clip_end"),e.properties&&Object.hasOwn(e.properties,r)&&Object.hasOwn(e.properties,s))return{start:+e.properties[r],end:+e.properties[s]}}addFeature(e,i,r,s,l,u,p,f){let g=this.layers[0].layout,x=g.get("line-join").evaluate(e,{}),b=g.get("line-cap").evaluate(e,{}),w=g.get("line-miter-limit"),S=g.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;let I=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=g.get("line-z-offset").value;let M=this.layers[0].paint.get("line-width").value;if(M.kind!=="constant"&&M.isLineProgressConstant===!1&&(this.variableWidthValue=M),this.isSeaLevelReference){let C=g.get("line-elevation-ground-scale").value;C.kind==="constant"&&C.value===0||(this.elevationGroundScaleValue=C)}if(this.elevationType==="road"){let C=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,i,s,f,x,b,w,S)){let[R,F]=this.clipRuntimeLinesToTile(i,1);for(let L=0;L<R.length;L++){let j=R[L],H=F[L],$={progress:{min:H.progress.min,max:H.progress.max},nextDir:this.computeSegNextDir(H,j),prevDir:this.computeSegPrevDir(H,j)};this.addLine(j,e,s,x,b,w,S,$,I&&H.parentIndex>0?H.parentIndex:null)}this.fillNonElevatedRoadSegment(C)}}else for(let C=0;C<i.length;C++)this.addLine(i[C],e,s,x,b,w,S,void 0,I&&C>0?C:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,l,u,s,p,void 0,this.worldview)}computeSegNextDir(e,i){return e.nextPoint.sub(i.at(-2)).unit()}computeSegPrevDir(e,i){return i[1].sub(e.prevPoint).unit()}clipLinesToTile(e,i){return Ym(e,-i,-i,Xe+i,Xe+i)}clipRuntimeLinesToTile(e,i){let r=[];return[Ym(e,-i,-i,Xe+i,Xe+i,r),r]}addElevatedRoadFeature(e,i,r,s,l,u,p,f){let g=[],x=mh.getElevationFeature(e,s);if(x){let b=this.clipLinesToTile(i,1),w=this.prepareElevatedLines(b,x,r);for(let S of w)g.push({geometry:S,elevation:x,elevationTileID:r,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(g.length===0)return!1;for(let b of g){let w=this.layoutVertexArray.length;this.addLine(b.geometry,e,r,l,u,p,f);let S=new a(r,b.elevationTileID);if(b.elevation){let I=this.showElevationIdDebug?t(b.elevation.id):null;for(let M=w;M<this.layoutVertexArray.length;M++){let C=new ke(this.layoutVertexArray.int16[6*M]>>1,this.layoutVertexArray.int16[6*M+1]>>1),R=S.pointElevation(C,b.elevation,.05);this.updateHeightRange(R),this.zOffsetVertexArray.emplaceBack(R,0,0),I?this.elevationIdColVertexArray.emplaceBack(I[0],I[1],I[2]):this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)}}else this.fillNonElevatedRoadSegment(w)}return!0}prepareElevatedLines(e,i,r){if(i.constantHeight!=null)return e;let s=[],l=1/Hr(r);for(let u of e)fb(u,new Cm(i,l),0,s);return s}fillNonElevatedRoadSegment(e){for(let i=e;i<this.layoutVertexArray.length;i++)this.zOffsetVertexArray.emplaceBack(0,0,0),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)}updateHeightRange(e){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,e),this.heightRange.max=Math.max(this.heightRange.max,e)):this.heightRange={min:e,max:e}}addLine(e,i,r,s,l,u,p,f,g){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineS
7oFar=0,this.currentVertex=void 0,this.lineClips=g?this.lineFeatureClips(i,g):this.lineClips;let x=s==="none";this.patternJoinNone=this.hasPattern&&x,this.currentLineJoinType=s,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];let b=f&&f.progress.min>0,w=f&&f.progress.max<1;if(this.lineClips){let Q={min:this.lineClips.start,max:this.lineClips.end},Y=1;if(f){let ge=this.lineClips.end-this.lineClips.start;Q=function(Te,Ae,Ie){return{min:xo(Te.min,Ae,Ie),max:xo(Te.max,Ae,Ie)}}(f.progress,{min:0,max:1},Q),ge>0&&(Y=(Q.max-Q.min)/ge)}let ee=+i.properties.mapbox_clip_feature_len,me=+i.properties.mapbox_clip_seg_len;if(Number.isNaN(ee)||Number.isNaN(me)){for(let Te=0;Te<e.length-1;Te++)this.totalDistance+=e[Te].dist(e[Te+1]);let ge=this.totalDistance/(Q.max-Q.min);this.totalFeatureLength=Number.isFinite(ge)?ge:0,this.lineClips.start=Q.min,this.lineClips.end=Q.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=ee,this.distance=me*Y,this.lineClips.start=Q.min,this.lineClips.end=Q.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}let S=nw[i.type]==="Polygon",I=e.length;for(;I>=2&&e[I-1].equals(e[I-2]);)I--;let M=0;for(;M<I-1&&e[M].equals(e[M+1]);)M++;if(I<(S?3:2))return;s==="bevel"&&(u=1.05);let C=this.segments.prepareSegment(10*I,this.layoutVertexArray,this.indexArray),R,F,L,j,H,$,ie,W;f&&f.prevDir&&($=f.prevDir.perp()),f&&f.nextDir&&(ie=f.nextDir.perp()),this.e1=this.e2=-1,S&&(R=e[I-2],H=e[M].sub(R)._unit()._perp());for(let Q=M;Q<I;Q++){if(L=Q===I-1?S?e[M+1]:void 0:e[Q+1],L&&e[Q].equals(L))continue;H&&(j=H),R&&(F=R),R=e[Q],W=this.evaluateLineProgressFeatures(F?F.dist(R):0),H=L?L.sub(R)._unit()._perp():j,j=j||H;let Y=F&&L,ee=Y?s:S||x?"butt":l,me=j.x*H.x+j.y*H.y;if(x){let Me=function(Le){if(Le.patternJoinNone){let ze=Le.segmentPoints.length/2,We=Le.lineSoFar-Le.segmentStart;for(let De=0;De<ze;++De){let Ge=Le.segmentPoints[2*De+1],$e=Math.round(Le.segmentPoints[2*De])+.5+.25*Ge;Le.patternVertexArray.emplaceBack($e,We,Le.segmentStart),Le.patternVertexArray.emplaceBack($e,We,Le.segmentStart)}Le.segmentPoints.length=0}Le.e1=Le.e2=-1};if(Y&&me<ow){this.updateDistance(F,R),this.addCurrentVertex(R,j,1,1,C,W),Me(this),this.addCurrentVertex(R,H,-1,-1,C,W);continue}if(F){if(!L){this.updateDistance(F,R),this.addCurrentVertex(R,j,1,1,C,W),Me(this);continue}ee="miter"}}let ge=j.add(H);ge.x===0&&ge.y===0||ge._unit();let Te=ge.x*H.x+ge.y*H.y,Ae=Te!==0?1/Te:1/0,Ie=2*Math.sqrt(2-2*Te),Be=Te<rw&&F&&L,xe=j.x*H.y-j.y*H.x>0,Se=this.overscaling<=16?122880/(512*this.overscaling):0;if(Y&&ee==="round"){if(Ae<p)ee="miter";else if(Ae<=2){let Me=ey(R,-10,8202);ee=this.elevationType==="offset"&&(Me||this.hasCrossSlope)?"miter":"fakeround"}}if(ee==="miter"&&Ae>u&&(ee="bevel"),ee==="bevel"&&(Ae>2&&(ee="flipbevel"),Ae<u&&(ee="miter")),F&&!(ee==="miter"&&Be)&&this.updateDistance(F,R),ee==="miter")if(Be){let Me=R.dist(F);if(Me>2*Se){let ze=R.sub(R.sub(F)._mult(Se/Me)._round());this.updateDistance(F,ze),this.addCurrentVertex(ze,j,0,0,C,W),F=ze}this.updateDistance(F,R),ge._mult(Ae),this.addCurrentVertex(R,ge,0,0,C,W);let Le=R.dist(L);if(Le>2*Se){let ze=R.add(L.sub(R)._mult(Se/Le)._round());this.updateDistance(R,ze),this.addCurrentVertex(ze,H,0,0,C,W),R=ze}}else ge._mult(Ae),this.addCurrentVertex(R,ge,0,0,C,W);else if(ee==="flipbevel"){if(Ae>100)ge=H.mult(-1);else{let Me=Ae*j.add(H).mag()/j.sub(H).mag();ge._perp()._mult(Me*(xe?-1:1))}this.addCurrentVertex(R,ge,0,0,C,W),this.addCurrentVertex(R,ge.mult(-1),0,0,C,W)}else if(ee==="bevel"||ee==="fakeround"){let Me=R.dist(F),Le=1;if(this.elevationType==="offset"&&ee==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&W!=null&&F&&L){let Je=4*Se;Me<Je&&(Le=Math.max(0,Me/Je))}W!=null&&F&&this.addCurrentVertex(R,ie||j,-Le,-Le,C,W);let ze=Me<=2*Se&&ee!=="bevel",We=ge.mult(xe?1:-1);We._mult(Ae);let De=H.mult(xe?-1:1),Ge=j.mult(xe?-1:1),$e=this.evaluateLineProgressFeatures(this.distance);if(W==null&&(this.addHalfVertex(R,We.x,We.y,!1,!xe,0,C,$e),ze||this.addHalfVertex(R,We.x+2*Ge.x,We.y+2*Ge.y,!1,xe,0,C,$e)),ee==="fakeround"){let Je=Math.round(180*Ie/Math.PI/20);this.addHalfVertex(R,Ge.x,Ge.y,!1,xe,0,C,$e);for(let tt=0;tt<Je;tt++){let ct=tt/Je;if(ct!==.5){let ft=ct-.5;ct+=ct*ft*(ct-1)*((1.0904+me*(me*(3.55645-1.43519*me)-3.2452))*ft*ft+(.848013+me*(.215638*me-1.06021)))}let rt=De.sub(Ge)._mult(ct)._add(Ge)._unit();this.addHalfVertex(R,rt.x,rt.y,!1,xe,0,C,$e)}this.addHalfVertex(R,De.x,De.y,!1,xe,0,C,$e)}ze||W!=null||this.addHalfVertex(R,We.x+2*De.x,We.y+2*De.y,!1,xe,0,C,$e),W!=null&&L&&this.addCurrentVertex(R,$||H,Le,Le,C,W)}else if(ee==="butt")this.addCurrentVertex(R,ge,0,0,C,W);else if(ee==="square"){if(!F){let Me=b?0:-1;this.addCurrentVertex(R,ge,Me,Me,C,W)}if(this.addCurrentVertex(R,ge,0,0,C,W),F){let Me=w?0:1;this.addCurrentVertex(R,ge,Me,Me,C,W)}}else if(ee==="round"){if(F){let Me=!Y&&ie?ie:j;this.addCurrentVertex(R,Me,0,0,C,W),!Y&&w||this.addCurrentVertex(R,Me,1,1,C,W,!0)}if(L){let Me=!Y&&$?$:H;!Y&&b||this.addCurrentVertex(R,Me,-1,-1,C,W,!0),this.addCurrentVertex(R,Me,0,0,C,W)}}}}addVerticesTo(e,i,r,s,l,u,p,f,g,x){let b=(i.w-e.w)/this.tessellationStep|0,w=0,S=this.scaledDistance;if(b>
71){this.lineSoFar=e.w;let M=(i.x-e.x)/b,C=(i.y-e.y)/b,R=(i.z-e.z)/b,F=(i.w-e.w)/b,L=i.x-e.x,j=i.y-e.y,H=Math.sqrt(L*L+j*j);if(H===0)return;let $=-j/H,ie=L/H,W=$,Q=ie,Y=-$,ee=-ie;for(let me=1;me<b;++me){e.x+=M,e.y+=C,e.z+=R,this.lineSoFar+=F,w+=F;let ge=this.evaluateLineProgressFeatures(this.prevDistance+w);this.scaledDistance=(this.prevDistance+w)/this.totalDistance,this.addHalfVertex(e,W,Q,x,!1,0,g,ge),this.addHalfVertex(e,Y,ee,x,!0,0,g,ge)}}this.lineSoFar=i.w,this.scaledDistance=S;let I=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(i,r,s,x,!1,p,g,I),this.addHalfVertex(i,l,u,x,!0,-f,g,I)}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&this.elevationType!=="offset")return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+e)/this.totalFeatureLength):Bt(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let i=0;this.variableWidthValue&&this.variableWidthValue.kind!=="constant"&&(i=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);let r=this.evaluateElevationGroundScale();return this.elevationType!=="offset"?{zOffset:0,variableWidth:i,elevationGroundScale:r}:this.zOffsetValue.kind==="constant"?{zOffset:this.zOffsetValue.value,variableWidth:i,elevationGroundScale:r}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:i,elevationGroundScale:r}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?this.elevationGroundScaleValue.kind==="constant"?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(e,i,r,s,l,u,p=!1){let f=i.x+i.y*r,g=i.y-i.x*r,x=i.y*s-i.x,b=-i.y-i.x*s;if(u!=null){let w=this.elevationType==="offset",S=this.elevationType==="offset"?2:10,I=-S,M=Xe+S,C=u.zOffset,R=new R0(e.x,e.y,C,this.lineSoFar),F=!!w&&ey(e,I,M),L=this.lineS
7oFar,j=this.distance;if(this.currentVertex)if(F){let H=this.currentVertexIsOutside,$=this.currentVertex,ie=new R0(e.x,e.y,C,this.lineSoFar);if(z0($,ie,I,M),!ey(ie,I,M)){if(H){this.e1=this.e2=-1,this.distance-=$.dist(R),this.lineSoFar=$.w;let W=this.evaluateLineProgressFeatures($.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex($,f,g,p,!1,r,l,W),this.addHalfVertex($,x,b,p,!0,-s,l,W),this.prevDistance=this.distance}this.distance=this.prevDistance+$.dist(ie),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo($,ie,f,g,x,b,r,s,l,p),this.distance=j,this.scaledDistance=this.distance/this.totalDistance}}else{let H=this.currentVertex;if(this.currentVertexIsOutside){z0(H,R,I,M),this.e1=this.e2=-1,this.distance-=H.dist(R),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=H.w;let $=this.evaluateLineProgressFeatures(H.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(H,f,g,p,!1,r,l,$),this.addHalfVertex(H,x,b,p,!0,-s,l,$),this.prevDistance=this.distance,this.distance=j,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(H,R,f,g,x,b,r,s,l,p)}else F||(this.addHalfVertex(e,f,g,p,!1,r,l,u),this.addHalfVertex(e,x,b,p,!0,-s,l,u));this.currentVertex=R,this.currentVertexIsOutside=F,this.lineSoFar=L}else this.addHalfVertex(e,f,g,p,!1,r,l,u),this.addHalfVertex(e,x,b,p,!0,-s,l,u)}addHalfVertex({x:e,y:i},r,s,l,u,p,f,g){if(this.patternJoinNone&&(this.segmentPoints.length===0&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),u||this.segmentPoints.push(this.lineSoFar-this.segmentStart,p)),this.layoutVertexArray.emplaceBack((e<<1)+(l?1:0),(i<<1)+(u?1:0),Math.round(63*r)+128,Math.round(63*s)+128,1+(p===0?0:p<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){let b=mt(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,b)}let x=f.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,x),f.primitiveLength++),u?this.e2=x:this.e1=x,g!=null&&(this.zOffsetVertexArray.emplaceBack(g.zOffset,g.variableWidth,g.variableWidth),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){let b=g?g.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(b)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(e,i){this.prevDistance=this.distance,this.distance+=e.dist(i),this.updateScaledDistance()}}function ey(n,e,i){return n.x<e||n.x>i||n.y<e||n.y>i}let gx,yx;function xx(n,e,i){return e*(Xe/(n.tileSize*Math.pow(2,i-n.tileID.overscaledZ)))}Qe(a_,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});let vx=(n,e,i)=>(1-i)*n+i*e;function bx(n,e){return 1/xx(n,1,e.tileZoom)}function wx(n,e,i,r){return n.translatePosMatrix(r||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}let Tx=n=>{let e=[];Sx(n)&&e.push("RENDER_LINE_DASH"),n.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT"),n.paint.get("line-blend-mode")==="multiply"&&e.push("LINE_BLEND_MULTIPLY"),n.paint.get("line-blend-mode")==="additive"&&e.push("LINE_BLEND_ADDITIVE");let i=n.paint.get("line-trim-offset");i[0]===0&&i[1]===0||e.push("RENDER_LINE_TRIM_OFFSET"),n.paint.get("line-border-width").constantOr(1)!==0&&e.push("RENDER_LINE_BORDER");let r=n.layout.get("line-join").constantOr("miter")==="none",s=!!n.paint.get("line-pattern").constantOr(1);return r&&s&&e.push("LINE_JOIN_NONE"),e};function Sx(n){let e=n.paint.get("line-dasharray").value;return e.kind!=="constant"||e.value}let ty,Ex=()=>ty||(ty={layout:gx||(gx=new Ti({"line-cap":new Ze(he.layout_line["line-cap"]),"line-join":new Ze(he.layout_line["line-join"]),"line-miter-limit":new qe(he.layout_line["line-miter-limit"]),"line-round-limit":new qe(he.layout_line["line-round-limit"]),"line-sort-key":new Ze(he.layout_line["line-sort-key"]),"line-z-offset":new Ze(he.layout_line["line-z-offset"]),"line-elevation-reference":new qe(he.layout_line["line-elevation-reference"]),"line-cross-slope":new qe(he.layout_line["line-cross-slope"]),visibility:new qe(he.layout_line.visibility),"line-width-unit":new qe(he.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Ze(he.layout_line["line-elevation-ground-scale"])})),paint:yx||(yx=new Ti({"line-opacity":new Ze(he.paint_line["line-opacity"]),"line-color":new Ze(he.paint_line["line-color"]),"line-translate":new qe(he.paint_line["line-translate"]),"line-translate-anchor":new qe(he.paint_line["line-translate-anchor"]),"line-width":new Ze(he.paint_line["line-width"]),"line-gap-width":new Ze(he.paint_line["line-gap-width"]),"line-offset":new Ze(he.paint_line["line-offset"]),"line-blur"
7:new Ze(he.paint_line["line-blur"]),"line-dasharray":new Ze(he.paint_line["line-dasharray"]),"line-pattern":new Ze(he.paint_line["line-pattern"]),"line-pattern-cross-fade":new qe(he.paint_line["line-pattern-cross-fade"]),"line-gradient":new za(he.paint_line["line-gradient"]),"line-trim-offset":new qe(he.paint_line["line-trim-offset"]),"line-trim-fade-range":new qe(he.paint_line["line-trim-fade-range"]),"line-trim-color":new qe(he.paint_line["line-trim-color"]),"line-emissive-strength":new Ze(he.paint_line["line-emissive-strength"]),"line-border-width":new Ze(he.paint_line["line-border-width"]),"line-border-color":new Ze(he.paint_line["line-border-color"]),"line-occlusion-opacity":new qe(he.paint_line["line-occlusion-opacity"]),"line-blend-mode":new qe(he.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new qe(he.paint_line["line-blend-additive-clamp"]),"line-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},ty);class sw extends Ze{possiblyEvaluate(e,i){return i=new Jt(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,transition:i.transition,worldview:i.worldview}),super.possiblyEvaluate(e,i)}evaluate(e,i,r,s){return i=Object.assign({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(e,i,r,s)}}let Ip;function Ix(n,e){return e>0?e+2*n:n}let aw=Rt([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),lw=Rt([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),cw=Rt([{name:"a_projected_pos",components:4,type:"Float32"}],4);Rt([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let uw=Rt([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),hw=Rt([{name:"a_feature_index",components:1,type:"Float32"}],4),dw=Rt([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),pw=Rt([{name:"a_texb",components:2,type:"Uint16"}]),fw=Rt([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),mw=Rt([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Rt([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);let Ax=Rt([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),_w=Rt([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Rt([{name:"triangle",components:3,type:"Uint16"}]),Rt([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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"},{type:"Uint8",name:"flipState"}]),Rt([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}
7]),Rt([{type:"Float32",name:"offsetX"}]),Rt([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);let iu=class Jl{constructor(e=null,i=0,r=4096){if(this.batchIndex=i,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=e||null,this.propsDwords=r,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array(Jl.HEADER_DWORDS),this.propertiesData=new Float32Array(this.propsDwords),!Jl._blockIndicesTemplate){Jl._blockIndicesTemplate=new Uint32Array(this.propsDwords);for(let s=0;s<this.propsDwords;s++)Jl._blockIndicesTemplate[s]=s}this.blockIndicesData=new Uint32Array(Jl._blockIndicesTemplate),e&&this._initBuffers(e)}_initBuffers(e){let i=e.gl;if(this.totalBytes>e.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${e.maxUniformBlockSize}`);if(this.headerBuffer=i.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferData(i.UNIFORM_BUFFER,Jl.HEADER_BYTES,i.DYNAMIC_DRAW),this.propertiesBuffer=i.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),this.blockIndicesBuffer=i.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferData(i.UNIFORM_BUFFER,this.totalBytes,i.DYNAMIC_DRAW),i.bindBuffer(i.UNIFORM_BUFFER,null)}writeHeader(e){let i=this.headerData;i[0]=e.dataDrivenMask,i[1]=e.zoomDependentMask,i[2]=e.dataDrivenBlockSizeVec4,i[3]=e.offsets[0],i[4]=e.offsets[1],i[5]=e.offsets[2],i[6]=e.offsets[3],i[7]=e.offsets[4],i[8]=e.offsets[5],i[9]=e.offsets[6],i[10]=e.offsets[7],i[11]=e.offsets[8]}writeDataDrivenBlock(e,i,r){let s=4*r.dataDrivenBlockSizeVec4;if(s===0)return;let l=i*s;if(l+s>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${i} exceeds propertiesData capacity`);for(let u=0;u<9;u++)r.dataDrivenMask&1<<u&&this._copyFromFlat(l+r.offsets[u],u,e,Jl.EVAL_FLAT_OFFSETS[u],r.zoomDependentMask)}static getMaxFeatureCount(e,i=4096){let r=4*e.dataDrivenBlockSizeVec4;return r===0?1/0:Math.floor(i/r)}_copyFromFlat(e,i,r,s,l){let u=this.propertiesData,p=i===8,f=!!(l&1<<i);i<2||p&&f?(u[e]=r[s],u[e+1]=r[s+1],u[e+2]=r[s+2],u[e+3]=r[s+3]):p||f?(u[e]=r[s],u[e+1]=r[s+1]):u[e]=r[s]}upload(e){this.context||(this.context=e);let i=e.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(e),i.bindBuffer(i.UNIFORM_BUFFER,this.headerBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,this.headerData),i.bindBuffer(i.UNIFORM_BUFFER,this.propertiesBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,this.propertiesData),i.bindBuffer(i.UNIFORM_BUFFER,this.blockIndicesBuffer),i.bufferSubData(i.UNIFORM_BUFFER,0,this.blockIndicesData),i.bindBuffer(i.UNIFORM_BUFFER,null)}bind(e,i){let r=e.gl,s=(u,p,f)=>{if(!p)return;let g=r.getUniformBlockIndex(i,u);g!==r.INVALID_INDEX&&(r.uniformBlockBinding(i,g,f),r.bindBufferBase(r.UNIFORM_BUFFER,f,p))},l=3*this.batchIndex;s("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,l),s("SymbolPaintPropertiesUniform",this.propertiesBuffer,l+1),s("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,l+2)}destroy(){if(this.context){let e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};iu.HEADER_DWORDS=12,iu.HEADER_BYTES=48,iu.EVAL_FLAT_OFFSETS=[0,4,8,10,12,14,16,18,20],iu.EVAL_FLAT_SIZES=[4,4,2,2,2,2,2,2,4],iu.EVAL_FLAT_TOTAL=24,iu._blockIndicesTemplate=null;let Gl=iu;function Mx(n,e,i,r,s,l,u,p){return!!n&&(n.kind==="constant"?n.value==="none":n.kind==="composite"||n.kind==="source"?n.evaluate({zoom:0,brightness:l,worldview:p},e,i,s,r,u)==="none":typeof n=="string"&&n==="none")}Qe(Gl,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class iy{constructor(e,i,r,s,l="",u,p){this.layer=e,this.zoom=i,this.lut=r,this.isText=s,this.propDefs=this._getPropDefs(),this.worldview=l,this.maxUniformBufferBindings=u||24,this.uboSizeDwords=p||4096,this.featureVertexRangesFromId=new Map,this.allFeatures=[],this.ubos=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex=new Map,this.canDeduplicate=this._checkIfAllPropertiesAreConstant(e,s),this.cachedParams=null,this.cachedParamsNext=null,this.cachedBrightness=void 0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=new Map,this.isLightConstant=!0,this._evalFlat=new Float32Array(Gl.EVAL_FLAT_TOTAL)}_getPropDefs(){let e=this.isText?"text":"icon";return[{name:`${e}-color`,useThemeName:`${e}-color-use-theme`,isColor:!0},{name:`${e}-halo-color`,useThemeName:`${e}-halo-color-use-theme`,isColor:!0},{name:`${e}-opacity`,useThemeName:null,isColor:!1},{name:`${e}-halo-width`,useThemeName:null,isColor:!1},{name:`${e}-halo-blur`,useThemeName:null,isColor:!1},{name:`${e}-emissive-strength`,useThemeName:null,isColor:!1},{name:`${e}-occlusion-opacity`,useThemeName:null,isColor:!1},{name:"symbol-z-offset",useThemeName:null,isColor:!1},{name:`${e}-translate`,useThemeName:null,isColor:!1,isVec2:!0}]}buildHeader(){let e=this.layer.paint,i=this.propDefs,r=0,s=0,l=0,u=0,p=!0,f=[0,0,0,0,0,0,0,0,0];for(let x=0;x<9;x++){let{name:b,isColor:w,isVec2:S}=i[x],I=e.get(b),M=!(!I||typeof I.isConstant!="function"||I.isConstant()),C=this._appearancesHavePaintProperties(b),R=M||C,F=!(!I||!I.value||I.value.kind!=="composite"),L=this.layer._transitionablePaint._values[b],j=!R&&(L&&L.value&&L.value.expression&&L.value.expression.kind)==="camera";if(R){r|=1<<x,F&&(s|=1<<x);let H=I&&I.value;H&&H.isLightConstant===!1&&(p=!1),w?(u%4!=0&&(u=u+3&-4),f[x]=u,u+=4):S?F?(u%4!=0&&(u=u+3&-4),f[x]=u,u+=4):(u%4==3&&u++,f[x]=u,u+=2):(f[x]=u,u+=F?2:1)}else j&&(l|=1<<x)}let g=(u===0?0:u+3&-4)/4;return this.isLightConstant=p,{dataDrivenMask:r,zoomDependentMask:s,cameraMask:l,dataDrivenBlockSizeVec4:g,offsets:f}}get hasCameraExpression(){return!(!this.cachedHeader||!this.cachedHeader.cameraMask)}evaluateAllProperties(e,i,r,s,l,u,p){let{params:f,paramsNext:g}=this._getCachedParams(l),x={feature:e,featureState:i,canonical:r,availableImages:s,params:f,paramsNext:g,formattedSection:u},b=this.cachedHeader,w=this.propDefs;this._evalFlat||(this._evalFlat=new Float32Array(Gl.EVAL_FLAT_TOTAL));let S=this._evalFlat;for(let I=0;I<9;I++){let{name:M,useThemeName:C,isColor:R,isVec2:F}=w[I],L=!!(b&&b.zoomDependentMask&1<<I),j=Gl.EVAL_FLAT_OFFSETS[I];R?this._evaluateColorValue(M,C,x,l,L,p,S,j):F?this._evaluateTranslateValue(M,L,x,p,S,j):this._evaluateFloatValue(M,L,x,p,S,j)}return S}_evaluateColorValue(e,i,r,s,l,u,p,f){let g=this.layer.paint,x=e,b=u&&u.hasPaintProperty(x)?u.paintProperties.get(x):g.get(e),w=i,S=i&&u&&u.hasPaintProperty(w)?u.paintProperties.get(w):i?g.get(i):void 0;if(!b)return p[f]=0,p[f+1]=0,p[f+2]=0,void(p[f+3]=1);
7let I=Mx(S&&typeof S!="string"?S.value:void 0,r.feature,r.featureState,r.availableImages,r.canonical,s,r.formattedSection,this.worldview)?null:this.lut,M,C;b.isConstant()?M=C=b.constantOr(Ht.transparent):(M=b.property.evaluate(b.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,b.iconImageUseTheme,r.formattedSection),C=l?b.property.evaluate(b.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,b.iconImageUseTheme,r.formattedSection):M);let R=(M||Ht.transparent).toNonPremultipliedRenderColor(I);if(p[f]=Ol(255*R.r,255*R.g),p[f+1]=Ol(255*R.b,255*R.a),l){let F=(C||Ht.transparent).toNonPremultipliedRenderColor(I);p[f+2]=Ol(255*F.r,255*F.g),p[f+3]=Ol(255*F.b,255*F.a)}else p[f+2]=0,p[f+3]=0}_evaluateFloatValue(e,i,r,s,l,u){let p=this.layer.paint,f=e.endsWith("opacity")?1:0,g=e,x=s&&s.hasPaintProperty(g)?s.paintProperties.get(g):p.get(e);if(!x)return l[u]=f,void(l[u+1]=0);if(x.isConstant())return l[u]=x.constantOr(f),void(l[u+1]=0);let b=x.property.evaluate(x.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,x.iconImageUseTheme,r.formattedSection);if(l[u]=b??f,i){let w=x.property.evaluate(x.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,x.iconImageUseTheme,r.formattedSection);l[u+1]=w??f}else l[u+1]=0}_evaluateTranslateValue(e,i,r,s,l,u){let p=this.layer.paint,f=e,g=s&&s.hasPaintProperty(f)?s.paintProperties.get(f):p.get(e);if(!g)return l[u]=0,l[u+1]=0,l[u+2]=0,void(l[u+3]=0);if(typeof g.isConstant!="function"){let b=g||[0,0];return l[u]=b[0],l[u+1]=b[1],l[u+2]=0,void(l[u+3]=0)}if(g.isConstant()){let b=g.constantOr([0,0]);return l[u]=b[0],l[u+1]=b[1],l[u+2]=0,void(l[u+3]=0)}let x=g.property.evaluate(g.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,g.iconImageUseTheme,r.formattedSection)||[0,0];if(l[u]=x[0],l[u+1]=x[1],i){let b=g.property.evaluate(g.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,g.iconImageUseTheme,r.formattedSection)||[0,0];l[u+2]=b[0],l[u+3]=b[1]}else l[u+2]=0,l[u+3]=0}_getCachedParams(e){return this.cachedParams&&this.cachedParamsNext&&this.cachedBrightness===e||(this.cachedParams=new Jt(this.zoom,{brightness:e,worldview:this.worldview}),this.cachedParamsNext=new Jt(this.zoom+1,{brightness:e,worldview:this.worldview}),this.cachedBrightness=e),{params:this.cachedParams,paramsNext:this.cachedParamsNext}}_appearancesHavePaintProperties(e){return this.layer.getAppearances().some(e!==void 0?i=>i.hasPaintProperty(e):this.isText?i=>i.hasTextPaintProperties():i=>i.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(e,i){let r=e.paint,s=i?"text":"icon",l=[`${s}-color`,`${s}-halo-color`,`${s}-opacity`,`${s}-halo-width`,`${s}-halo-blur`,`${s}-emissive-strength`,`${s}-occlusion-opacity`,"symbol-z-offset",`${s}-translate`];for(let u of l){let p=r.get(u);if(p&&typeof p=="object"&&"isConstant"in p&&!p.isConstant())return!1}return!this._appearancesHavePaintProperties()}_hashDataDrivenValues(e,i){if(i.dataDrivenMask===0)return"";let r=[];for(let s=0;s<this.propDefs.length;s++){if(!(i.dataDrivenMask&1<<s))continue;let l=Gl.EVAL_FLAT_OFFSETS[s],u=Gl.EVAL_FLAT_SIZES[s],p=String(e[l]);for(let f=1;f<u;f++)p+=`,${String(e[l+f])}`;r.push(p)}return r.join("|")}getCurrentBatchIndex(){return this.cachedHeader&&this.maxFeaturesPerBatch!==0?Math.floor(this.featureCount/this.maxFeaturesPerBatch):0}populateUBO(e,i,r,s,l,u,p){let f=e.id;if(!this.cachedHeader){this.cachedHeader=this.buildHeader();let C=Gl.getMaxFeatureCount(this.cachedHeader,this.uboSizeDwords);this.maxFeaturesPerBatch=isFinite(C)?C:Number.MAX_SAFE_INTEGER}let g=this.cachedHeader,x=this.evaluateAllProperties(e,{},r,s,l,u);if(this.canDeduplicate){let C=this._hashDataDrivenValues(x,g),R=this.propertyHashToUBOIndex.get(C);if(R!==void 0){let F=isFinite(this.maxFeaturesPerBatch)?Math.floor(R/this.maxFeaturesPerBatch):0,L=isFinite(this.maxFeaturesPerBatch)?R%this.maxFeaturesPerBatch:R,j={batchIndex:F,localFeatureIndex:L,vtFeatureIndex:i,featureId:f};return this.allFeatures.push(j),f!=null&&(this.featureVertexRangesFromId.has(f)||this.featureVertexRangesFromId.set(f,[]),this.featureVertexRangesFromId.get(f).push(j)),L}this.propertyHashToUBOIndex.set(C,this.featureCount)}
7let b=this.featureCount++,w=isFinite(this.maxFeaturesPerBatch)?Math.floor(b/this.maxFeaturesPerBatch):0,S=isFinite(this.maxFeaturesPerBatch)?b%this.maxFeaturesPerBatch:b,I=p?p.maxUniformBufferBindings:this.maxUniformBufferBindings;if(3*w+2>=I){Bt(`Too many symbol features: batch ${w} requires binding points up to ${3*w+2}, device limit ${I}. Some features will render incorrectly.`);let C={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:i,featureId:f};return this.allFeatures.push(C),f!=null&&(this.featureVertexRangesFromId.has(f)||this.featureVertexRangesFromId.set(f,[]),this.featureVertexRangesFromId.get(f).push(C)),0}this.ubos[w]||(this.ubos[w]=new Gl(p,w,this.uboSizeDwords),this.ubos[w].writeHeader(g)),this.ubos[w].writeDataDrivenBlock(x,S,g);let M={batchIndex:w,localFeatureIndex:S,vtFeatureIndex:i,featureId:f};return this.allFeatures.push(M),f!=null&&(this.featureVertexRangesFromId.has(f)||this.featureVertexRangesFromId.set(f,[]),this.featureVertexRangesFromId.get(f).push(M)),S}updateFeatures(e,i,r,s,l,u,p){if(this.layer=i,this.cachedConstantUniforms=null,!this.cachedHeader)return;let f=this.cachedHeader;for(let g of e){let x=this.featureVertexRangesFromId.get(g);if(!x)continue;let b=u[g]||{};for(let w of x){if(!r)continue;let S=r.feature(w.vtFeatureIndex);if(!S)continue;let I={type:S.type,id:g,properties:S.properties||{},geometry:[]},M=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(w.vtFeatureIndex):void 0,C=this.evaluateAllProperties(I,b,s,l,p,void 0,M);this.ubos[w.batchIndex]&&this.ubos[w.batchIndex].writeDataDrivenBlock(C,w.localFeatureIndex,f)}}}updateDynamicExpressions(e,i,r,s,l,u){if(this.layer=e,this.cachedConstantUniforms=null,!this.cachedHeader||this.cachedHeader.dataDrivenMask===0)return;let p=this.cachedHeader;for(let f of this.allFeatures){if(!i)continue;let g=i.feature(f.vtFeatureIndex);if(!g)continue;let x=f.featureId!=null&&l[f.featureId]||{},b={type:g.type,id:f.featureId,properties:g.properties||{},geometry:[]},w=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(f.vtFeatureIndex):void 0,S=this.evaluateAllProperties(b,x,r,s,u,void 0,w);this.ubos[f.batchIndex]&&this.ubos[f.batchIndex].writeDataDrivenBlock(S,f.localFeatureIndex,p)}}updateFeaturePaintForAppearance(e,i,r,s,l,u,p){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(e,p||null),!this.cachedHeader))return!1;let f=this.cachedHeader;if(f.dataDrivenMask===0)return!1;let g=!1;for(let x of this.allFeatures){if(x.vtFeatureIndex!==e)continue;let b=this.evaluateAllProperties(i,r,s,l,u,void 0,p);this.ubos[x.batchIndex]&&(this.ubos[x.batchIndex].writeDataDrivenBlock(b,x.localFeatureIndex,f),g=!0)}return g}getConstantUniformValues(e,i){let r=this.cachedHeader,s=!(!r||!r.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===i&&(!s||this.cachedConstantRenderZoom===e))return this.cachedConstantUniforms;let l=this.layer.paint,u=this.propDefs,p=s?new Jt(e,{brightness:i,worldview:this.worldview}):null,f={type:1,id:void 0,properties:{},geometry:[]},g=w=>{let S=u[w],I=l.get(S.name);if(!I)return[0,0,0,1];let M=S.useThemeName?l.get(S.useThemeName):void 0,C=Mx(M&&typeof M!="string"?M.value:void 0,f,{},[],void 0,i,void 0,this.worldview)?null:this.lut,R;R=r&&r.cameraMask&1<<w&&p?I.property.evaluate(I.value,p,f,{},void 0,[]):I.constantOr(Ht.transparent);let F=(R||Ht.transparent).toNonPremultipliedRenderColor(C);return[F.r,F.g,F.b,F.a]},x=(w,S)=>{let I=l.get(u[w].name);if(!I)return S;if(r&&r.cameraMask&1<<w&&p){let M=I.property.evaluate(I.value,p,f,{},void 0,[]);return M??S}return I.constantOr(S)},b={fill_np_color:g(0),halo_np_color:g(1),opacity:x(2,1),halo_width:x(3,0),halo_blur:x(4,0),emissive_strength:x(5,0),occlusion_opacity:x(6,1),z_offset:x(7,0)};return this.cachedConstantUniforms=b,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=i,b}upload(e){for(let i of this.ubos)i.upload(e)}bind(e,i,r=0){this.ubos[r]&&this.ubos[r].bind(e,i)}destroy(){for(let e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId.clear(),this.allFeatures=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex&&this.propertyHashToUBOIndex.clear()}}Qe(iy,"SymbolPropertyBinderUBO",{omit:["layer","cachedParams","cachedParamsNext","cachedBrightness","propertyHashToUBOIndex","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","activeAppearanceByVtIndex","_evalFlat"]});var wn=24;function gw(n,e,i){return n.sections.forEach(r=>{r.text=function(s,l,u){let p=l.layout.get("text-transform").evaluate(u,{});return p==="uppercase"?s=s.toLocaleUpperCase():p==="lowercase"&&(s=s.toLocaleLowerCase()),ts.applyArabicShaping&&(s=ts.applyArabicShaping(s)),s}(r.text,e,i)}),n}let Ap={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63"
vendor: 9,145 bytes, line 7
7:"\uFE42","\u2190":"\u2191","\u2192":"\u2193"};function yw(n){return n==="\uFE36"||n==="\uFE48"||n==="\uFE38"||n==="\uFE44"||n==="\uFE42"||n==="\uFE3E"||n==="\uFE3C"||n==="\uFE3A"||n==="\uFE18"||n==="\uFE40"||n==="\uFE10"||n==="\uFE13"||n==="\uFE14"||n==="\uFF40"||n==="\uFFE3"||n==="\uFE11"||n==="\uFE12"}function xw(n){return n==="\uFE35"||n==="\uFE47"||n==="\uFE37"||n==="\uFE43"||n==="\uFE41"||n==="\uFE3D"||n==="\uFE3B"||n==="\uFE39"||n==="\uFE17"||n==="\uFE3F"}let ny=4294967296,Cx=1/ny,Px=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),l_=class{constructor(n=new Uint8Array(16)){this.buf=ArrayBuffer.isView(n)?n:new Uint8Array(n),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(n,e,i=this.length){for(;this.pos<i;){let r=this.readVarint(),s=r>>3,l=this.pos;this.type=7&r,n(s,e,this),this.pos===l&&this.skip(r)}return e}readMessage(n,e){return this.readFields(n,e,this.readVarint()+this.pos)}readFixed32(){let n=this.dataView.getUint32(this.pos,!0);return this.pos+=4,n}readSFixed32(){let n=this.dataView.getInt32(this.pos,!0);return this.pos+=4,n}readFixed64(){let n=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*ny;return this.pos+=8,n}readSFixed64(){let n=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ny;return this.pos+=8,n}readFloat(){let n=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,n}readDouble(){let n=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,n}readVarint(n){let e=this.buf,i,r;return r=e[this.pos++],i=127&r,r<128?i:(r=e[this.pos++],i|=(127&r)<<7,r<128?i:(r=e[this.pos++],i|=(127&r)<<14,r<128?i:(r=e[this.pos++],i|=(127&r)<<21,r<128?i:(r=e[this.pos],i|=(15&r)<<28,function(s,l,u){let p=u.buf,f,g;if(g=p[u.pos++],f=(112&g)>>4,g<128||(g=p[u.pos++],f|=(127&g)<<3,g<128)||(g=p[u.pos++],f|=(127&g)<<10,g<128)||(g=p[u.pos++],f|=(127&g)<<17,g<128)||(g=p[u.pos++],f|=(127&g)<<24,g<128)||(g=p[u.pos++],f|=(1&g)<<31,g<128))return bh(s,f,l);throw new Error("Expected varint not more than 10 bytes")}(i,n,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){let n=this.readVarint();return n%2==1?(n+1)/-2:n/2}readBoolean(){return!!this.readVarint()}readString(){let n=this.readVarint()+this.pos,e=this.pos;return this.pos=n,n-e>=12&&Px?Px.decode(this.buf.subarray(e,n)):function(i,r,s){let l="",u=r;for(;u<s;){let p=i[u],f,g,x,b=null,w=p>239?4:p>223?3:p>191?2:1;if(u+w>s)break;w===1?p<128&&(b=p):w===2?(f=i[u+1],(192&f)==128&&(b=(31&p)<<6|63&f,b<=127&&(b=null))):w===3?(f=i[u+1],g=i[u+2],(192&f)==128&&(192&g)==128&&(b=(15&p)<<12|(63&f)<<6|63&g,(b<=2047||b>=55296&&b<=57343)&&(b=null))):w===4&&(f=i[u+1],g=i[u+2],x=i[u+3],(192&f)==128&&(192&g)==128&&(192&x)==128&&(b=(15&p)<<18|(63&f)<<12|(63&g)<<6|63&x,(b<=65535||b>=1114112)&&(b=null))),b===null?(b=65533,w=1):b>65535&&(b-=65536,l+=String.fromCharCode(b>>>10&1023|55296),b=56320|1023&b),l+=String.fromCharCode(b),u+=w}return l}(this.buf,e,n)}readBytes(){let n=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,n);return this.pos=n,e}readPackedVarint(n=[],e){let i=this.readPackedEnd();for(;this.pos<i;)n.push(this.readVarint(e));return n}readPackedSVarint(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSVarint());return n}readPackedBoolean(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readBoolean());return n}readPackedFloat(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFloat());return n}readPackedDouble(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readDouble());return n}readPackedFixed32(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFixed32());return n}readPackedSFixed32(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSFixed32());return n}readPackedFixed64(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFixed64());return n}readPackedSFixed64(n=[]){let e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSFixed64());return n}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(n){let e=7&n;if(e===0)for(;this.buf[this.pos++]>127;);else if(e===2)this.pos=this.readVarint()+this.pos;else if(e===5)this.pos+=4;else{if(e!==1)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(n,e){this.writeVarint(n<<3|e)}realloc(n){let e=this.length||16;for(;e<this.pos+n;)e*=2;if(e!==this.length){let i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.dataView=new DataView(i.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(n){this.realloc(4),this.dataView.setInt32(this.pos,n,!0),this.pos+=4}writeSFixed32(n){this.realloc(4),this.dataView.setInt32(this.pos,n,!0),this.pos+=4}writeFixed64(n){this.realloc(8),this.dataView.setInt32(this.pos,-1&n,!0),this.dataView.setInt32(this.pos+4,Math.floor(n*Cx),!0),this.pos+=8}writeSFixed64(n){this.realloc(8),this.dataView.setInt32(this.pos,-1&n,!0),this.dataView.setInt32(this.pos+4,Math.floor(n*Cx),!0),this.pos+=8}writeVarint(n){(n=+n||0)>268435455||n<0?function(e,i){let r,s;if(e>=0?(r=e%4294967296|0,s=e/4294967296|0):(r=~(-e%4294967296),s=~(-e/4294967296),4294967295^r?r=r+1|0:(r=0,s=s+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");i.realloc(10),function(l,u,p){p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,l>>>=7,p.buf[p.pos++]=127&l|128,p.buf[p.pos]=127&(l>>>=7)}(r,0,i),function(l,u){let p=(7&l)<<4;u.buf[u.pos++]|=p|((l>>>=3)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l|((l>>>=7)?128:0),l&&(u.buf[u.pos++]=127&l)))))}(s,i)}(n,this):(this.realloc(4),this.buf[this.pos++]=127&n|(n>127?128:0),n<=127||(this.buf[this.pos++]=127&(n>>>=7)|(n>127?128:0),n<=127||(this.buf[this.pos++]=127&(n>>>=7)|(n>127?128:0),n<=127||(this.buf[this.pos++]=n>>>7&127))))}writeSVarint(n){this.writeVarint(n<0?2*-n-1:2*n)}writeBoolean(n){this.writeVarint(+n)}writeString(n){n=String(n),this.realloc(4*n.length),this.pos++;let e=this.pos;this.pos=function(r,s,l){for(let u,p,f=0;f<s.length;f++){if(u=s.charCodeAt(f),u>55295&&u<57344){if(!p){u>56319||f+1===s.length?(r[l++]=239,r[l++]=191,r[l++]=189):p=u;continue}if(u<56320){r[l++]=239,r[l++]=191,r[l++]=189,p=u;continue}u=p-55296<<10|u-56320|65536,p=null}else p&&(r[l++]=239,r[l++]=191,r[l++]=189,p=null);u<128?r[l++]=u:(u<2048?r[l++]=u>>6|192:(u<65536?r[l++]=u>>12|224:(r[l++]=u>>18|240,r[l++]=u>>12&63|128),r[l++]=u>>6&63|128),r[l++]=63&u|128)}return l}(this.buf,n,this.pos);let i=this.pos-e;i>=128&&Dx(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i}writeFloat(n){this.realloc(4),this.dataView.setFloat32(this.pos,n,!0),this.pos+=4}writeDouble(n){this.realloc(8),this.dataView.setFloat64(this.pos,n,!0),this.pos+=8}writeBytes(n){let e=n.length;this.writeVarint(e),this.realloc(e);for(let i=0;i<e;i++)this.buf[this.pos++]=n[i]}writeRawMessage(n,e){this.pos++;let i=this.pos;n(e,this);let r=this.pos-i;r>=128&&Dx(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(n,e,i){this.writeTag(n,2),this.writeRawMessage(e,i)}writePackedVarint(n,e){e.length&&this.writeMessage(n,vw,e)}writePackedSVarint(n,e){e.length&&this.writeMessage(n,bw,e)}writePackedBoolean(n,e){e.length&&this.writeMessage(n,Sw,e)}writePackedFloat(n,e){e.length&&this.writeMessage(n,ww,e)}writePackedDouble(n,e){e.length&&this.writeMessage(n,Tw,e)}writePackedFixed32(n,e){e.length&&this.writeMessage(n,Ew,e)}writePackedSFixed32(n,e){e.length&&this.writeMessage(n,Iw,e)}writePackedFixed64(n,e){e.length&&this.writeMessage(n,Aw,e)}writePackedSFixed64(n,e){e.length&&this.writeMessage(n,Mw,e)}writeBytesField(n,e){this.writeTag(n,2),this.writeBytes(e)}writeFixed32Field(n,e){this.writeTag(n,5),this.writeFixed32(e)}writeSFixed32Field(n,e){this.writeTag(n,5),this.writeSFixed32(e)}writeFixed64Field(n,e){this.writeTag(n,1),this.writeFixed64(e)}writeSFixed64Field(n,e){this.writeTag(n,1),this.writeSFixed64(e)}writeVarintField(n,e){this.writeTag(n,0),this.writeVarint(e)}writeSVarintField(n,e){this.writeTag(n,0),this.writeSVarint(e)}writeStringField(n,e){this.writeTag(n,2),this.writeString(e)}writeFloatField(n,e){this.writeTag(n,5),this.writeFloat(e)}writeDoubleField(n,e){this.writeTag(n,1),this.writeDouble(e)}writeBooleanField(n,e){this.writeVarintField(n,+e)}};function bh(n,e,i){return i?4294967296*e+(n>>>0):4294967296*(e>>>0)+(n>>>0)}function Dx(n,e,i){let r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(let s=i.pos-1;s>=n;s--)i.buf[s+r]=i.buf[s]}function vw(n,e){for(let i=0;i<n.length;i++)e.writeVarint(n[i])}function bw(n,e){for(let i=0;i<n.length;i++)e.writeSVarint(n[i])}function ww(n,e){for(let i=0;i<n.length;i++)e.writeFloat(n[i])}function Tw(n,e){for(let i=0;i<n.length;i++)e.writeDouble(n[i])}function Sw(n,e){for(let i=0;i<n.length;i++)e.writeBoolean(n[i])}function Ew(n,e){for(let i=0;i<n.length;i++)e.writeFixed32(n[i])}function Iw(n,e){for(let i=0;i<n.length;i++)e.writeSFixed32(n[i])}function Aw(n,e){for(let i=0;i<n.length;
7i++)e.writeFixed64(n[i])}function Mw(n,e){for(let i=0;i<n.length;i++)e.writeSFixed64(n[i])}function Cw(n,e,i){e.glyphs=[],n===1&&i.readMessage(Pw,e)}function Pw(n,e,i){if(n===3){let{id:r,bitmap:s,width:l,height:u,left:p,top:f,advance:g}=i.readMessage(Dw,{});e.glyphs.push({id:r,bitmap:new zi({width:l+6,height:u+6},s),metrics:{width:l,height:u,left:p,top:f,advance:g}})}else n===4?e.ascender=i.readSVarint():n===5&&(e.descender=i.readSVarint())}function Dw(n,e,i){n===1?e.id=i.readVarint():n===2?e.bitmap=i.readBytes():n===3?e.width=i.readVarint():n===4?e.height=i.readVarint():n===5?e.left=i.readSVarint():n===6?e.top=i.readSVarint():n===7&&(e.advance=i.readVarint())}let Yr={horizontal:1,vertical:2,horizontalOnly:3};class Mp{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(e,i){let r=new Mp;return r.scale=e||1,r.fontStack=i,r}static forImage(e){let i=new Mp;return i.image=e,i}}class wh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i,r,s=1){let l=new wh;for(let u=0;u<e.sections.length;u++){let p=e.sections[u];p.image?l.addImageSection(p,r,s):l.addTextSection(p,i)}return l}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=function(i,r){let s="";for(let l=0;l<i.length;l++){let u=i.charCodeAt(l+1)||null,p=i.charCodeAt(l-1)||null;s+=!r&&(u&&Ju(u)&&!Ap[i[l+1]]||p&&Ju(p)&&!Ap[i[l-1]])||!Ap[i[l]]?i[l]:Ap[i[l]]}return s}(this.text,e)}trim(){let e=0;for(let r=0;r<this.text.length&&c_[this.text.charCodeAt(r)];r++)e++;let i=this.text.length;for(let r=this.text.length-1;r>=0&&r>=e&&c_[this.text.charCodeAt(r)];r--)i--;this.text=this.text.substring(e,i),this.sectionIndex=this.sectionIndex.slice(e,i)}substring(e,i){let r=new wh;return r.text=this.text.substring(e,i),r.sectionIndex=this.sectionIndex.slice(e,i),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,i)=>Math.max(e,this.sections[i].scale),0)}addTextSection(e,i){this.text+=e.text,this.sections.push(Mp.forText(e.scale,e.fontStack||i));let r=this.sections.length-1;for(let s=0;s<e.text.length;++s)this.sectionIndex.push(r)}addImageSection(e,i,r=1){let s=e.image?e.image.getPrimary():null;if(!s)return void Bt("Can't add FormattedSection with an empty image.");s.scaleSelf(i*r);let l=this.getNextImageSectionCharCode();l?(this.text+=String.fromCodePoint(l),this.sections.push(Mp.forImage(s)),this.sectionIndex.push(this.sections.length-1)):Bt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ry(n,e,i,r,s,l,u,p,f,g,x,b,w,S,I,M=1,C=1){let R=wh.fromFeature(n,s,M,C);b===Yr.vertical&&R.verticalizePunctuation(w);let F=[],L=function(W,Q,Y,ee,me,ge,Te=1){if(!W)return[];let Ae=[],Ie=function(Se,Me,Le,ze,We,De,Ge=1){let $e=0;for(let Je=0;Je<Se.length();Je++){let tt=Se.getSection(Je);$e+=Rx(Se.getCodePoint(Je),tt,ze,We,Me,De,Ge)}return $e/Math.max(1,Math.ceil($e/Le))}(W,Q,Y,ee,me,ge,Te),Be=W.text.includes("\u200B"),xe=0;for(let Se=0;Se<W.length();Se++){let Me=W.getSection(Se),Le=W.getCodePoint(Se);if(c_[Le]||(xe+=Rx(Le,Me,ee,me,Q,ge,Te)),Se<W.length()-1){let ze=Zf(Le);(Rw[Le]||ze||Me.image)&&Ae.push(zx(Se+1,xe,Ie,Ae,Lw(Le,W.getCodePoint(Se+1),ze&&Be),!1))}}return Ox(zx(W.length(),xe,Ie,Ae,0,!0))}(R,g,l,e,r,S,C),{processBidirectionalText:j,processStyledBidirectionalText:H}=ts;if(j&&R.sections.length===1){let W=j(R.toString(),L);for(let Q of W){let Y=new wh;Y.text=Q,Y.sections=R.sections;for(let ee=0;ee<Q.length;ee++)Y.sectionIndex.push(0);F.push(Y)}}else if(H){let W=H(R.text,R.sectionIndex,L);for(let Q of W){let Y=new wh;Y.text=Q[0],Y.sectionIndex=Q[1],Y.sections=R.sections,F.push(Y)}}else F=function(W,Q){let Y=[],ee=W.text,me=0;for(let ge of Q)Y.push(W.substring(me,ge)),me=ge;return me<ee.length&&Y.push(W.substring(me,ee.length)),Y}(R,L);let $=[],ie={positionedLines:$,text:R.toString(),top:x[1],bottom:x[1],left:x[0],right:x[0],writingMode:b,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(W,Q,Y,ee,me,ge,Te,Ae,Ie,Be,xe,Se,Me=1){let Le=0,ze=0,We=0,De=Ae==="right"?1:Ae==="left"?0:.5,Ge=!1;for(let rt of me){let ft=rt.getSections();for(let Zt of ft){if(Zt.image)continue;let St=Q[Zt.fontStack];if(St&&(Ge=St.ascender!==void 0&&St.descender!==void 0,!Ge))break}if(!Ge)break}let $e=0;for(let rt of me){rt.trim();let ft=rt.getMaxScale(),Zt=(ft-1)*wn,St={positionedGlyphs:[],lineOffset:0};W.positionedLines[$e]=St;let Ut=St.positionedGlyphs,Pt=0;if(!rt.length()){ze+=ge,++$e;continue}let ji=0,Qt=0;for(let ui=0;ui<rt.length();ui++){let Pi=rt.getSection(ui),Tn=rt.getSectionIndex(ui),_i=rt.getCodePoint(ui),Gi=Pi.scale,un=null,tn=null,hn=null,Lt=wn,jn=0,hr=Ie;hr===Yr.vertical&&Wf(_i)&&(hr=Yr.horizontal);let Qi=!(hr===Yr.horizontal||!xe&&!Yu(_i)||xe&&(c_[_i]||Rd(_i)));if(Pi.image){let Mn=ee.get(Pi.image.toString());if(!Mn)continue;hn=Pi.image,W.iconsInText=W.iconsInText||!0,tn=Mn.paddedRect;let ir=Mn.displaySize,Gn=ir[0]*Me,Oi=ir[1]*Me;Gi=Gi*wn/Se,un={width:Gn,height:Oi,left:0,top:-3,advance:Qi?Oi:Gn,localGlyph:!1},jn=Ge?-un.height*Gi:ft*wn-17-Oi*Gi,Lt=un.advance;let mn=(Qi?Gn:Oi)*Gi-wn*ft;mn>0&&mn>Pt&&(Pt=mn)}else{let Mn=Y[Pi.fontStack];if(!Mn)continue;Mn[_i]&&(tn=Mn[_i]);let ir=Q[Pi.fontStack];if(!ir)continue;let Gn=ir.glyphs[_i];if(!Gn)continue;if(un=Gn.metrics,Lt=_i!==8203?wn:0,Ge){let Oi=ir.ascender!==void 0?Math.abs(ir.ascender):0,mn=ir.descender!==void 0?Math.abs(ir.descender):0,Dr=(Oi+mn)*Gi;ji<Dr&&(ji=Dr,Qt=(Oi-mn)/2*Gi),jn=-Oi*Gi}else jn=(ft-Gi)*wn-17}
7Qi?(W.verticalizable=!0,Ut.push({glyph:_i,image:hn,x:Le,y:ze+jn,vertical:Qi,scale:Gi,localGlyph:un.localGlyph,fontStack:Pi.fontStack,sectionIndex:Tn,metrics:un,rect:tn}),Le+=Lt*Gi+Be):(Ut.push({glyph:_i,image:hn,x:Le,y:ze+jn,vertical:Qi,scale:Gi,localGlyph:un.localGlyph,fontStack:Pi.fontStack,sectionIndex:Tn,metrics:un,rect:tn}),Le+=un.advance*Gi+Be)}Ut.length!==0&&(We=Math.max(Le-Be,We),Ge?Fx(Ut,De,Pt,Qt,ge*ft/2):Fx(Ut,De,Pt,0,ge/2)),Le=0;let $t=ge*ft+Pt;St.lineOffset=Math.max(Pt,Zt),ze+=$t,++$e}let Je=ze,{horizontalAlign:tt,verticalAlign:ct}=oy(Te);(function(rt,ft,Zt,St,Ut,Pt){let ji=(ft-Zt)*Ut,Qt=-Pt*St;for(let $t of rt)for(let ui of $t.positionedGlyphs)ui.x+=ji,ui.y+=Qt})(W.positionedLines,De,tt,ct,We,Je),W.top+=-ct*Je,W.bottom=W.top+Je,W.left+=-tt*We,W.right=W.left+We,W.hasBaseline=Ge}(ie,e,i,r,F,u,p,f,b,g,w,I,C),!function(W){for(let Q of W)if(Q.positionedGlyphs.length!==0)return!1;return!0}($))return ie}let c_={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Rw={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Rx(n,e,i,r,s,l,u=1){if(e.image){let p=r.get(e.image.toString());return p?p.displaySize[0]*u*e.scale*wn/l+s:0}{let p=i[e.fontStack],f=p&&p.glyphs[n];return f?f.metrics.advance*e.scale+s:0}}function Lx(n,e,i,r){let s=Math.pow(n-e,2);return r?n<e?s/2:2*s:s+Math.abs(i)*i}function Lw(n,e,i){let r=0;return n===10&&(r-=1e4),i&&(r+=150),n!==40&&n!==65288||(r+=50),e!==41&&e!==65289||(r+=50),r}function zx(n,e,i,r,s,l){let u=null,p=Lx(e,i,s,l);for(let f of r){let g=Lx(e-f.x,i,s,l)+f.badness;g<=p&&(u=f,p=g)}return{index:n,x:e,priorBreak:u,badness:p}}function Ox(n){return n?Ox(n.priorBreak).concat(n.index):[]}function oy(n){let e=.5,i=.5;switch(n){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(n){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function Fx(n,e,i,r,s){if(!(e||i||r||s))return;let l=n.length-1,u=n[l],p=(u.x+u.metrics.advance*u.scale)*e;for(let f=0;f<=l;f++)n[f].x-=p,n[f].y+=i+r+s}function sy(n){return n.imagePrimary!==void 0&&n.top!==void 0&&n.bottom!==void 0&&n.left!==void 0&&n.right!==void 0}function u_(n,e,i,r){let{horizontalAlign:s,verticalAlign:l}=oy(r),u=i[0]-n.displaySize[0]*s,p=i[1]-n.displaySize[1]*l;return{imagePrimary:n,imageSecondary:e,top:p,bottom:p+n.displaySize[1],left:u,right:u+n.displaySize[0]}}function ay(n,e,i,r,s,l){let u=n.imagePrimary,p;if(u.content){let C=u.content,R=u.pixelRatio||1;p=[C[0]/R,C[1]/R,u.displaySize[0]-C[2]/R,u.displaySize[1]-C[3]/R]}let f=e.left*l,g=e.right*l,x,b,w,S;i==="width"||i==="both"?(S=s[0]+f-r[3],b=s[0]+g+r[1]):(S=s[0]+(f+g-u.displaySize[0])/2,b=S+u.displaySize[0]);let I=e.top*l,M=e.bottom*l;return i==="height"||i==="both"?(x=s[1]+I-r[0],w=s[1]+M+r[2]):(x=s[1]+(I+M-u.displaySize[1])/2,w=x+u.displaySize[1]),{imagePrimary:u,imageSecondary:void 0,top:x,right:b,bottom:w,left:S,collisionPadding:p}}function Bx(n){return!n.imagePrimary.stretchX}function kx(n){return!n.imagePrimary.stretchY}function Nx(n){return{width:n.right-n.left,height:n.bottom-n.top}}let Ha=128;function nu(n,e,i,r){let{expression:s}=e;if(s.kind==="constant")return{kind:"constant",layoutSize:s.evaluate(new Jt(n+1,{worldview:i}),void 0,void 0,void 0,r)};if(s.kind==="source")return{kind:"source"};{let{zoomStops:l,interpolationType:u}=s,p=0;for(;p<l.length&&l[p]<=n;)p++;p=Math.max(0,p-1);let f=p;for(;f<l.length&&l[f]<n+1;)f++;f=Math.min(l.length-1,f);let g=l[p],x=l[f];return s.kind==="composite"?{kind:"composite",minZoom:g,maxZoom:x,interpolationType:u}:{kind:"camera",minZoom:g,maxZoom:x,minSize:s.evaluate(new Jt(g,{worldview:i}),void 0,void 0,void 0,r),maxSize:s.evaluate(new Jt(x,{worldview:i}),void 0,void 0,void 0,r),interpolationType:u}}}function ly(n,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:s}){return n.kind==="source"?r/Ha:n.kind==="composite"?mt(r/Ha,s/Ha,i):e}function Th(n,e,i=1){let r=0,s=0;if(n.kind==="constant")s=n.layoutSize*i;else if(n.kind!=="source"){let{interpolationType:l,minZoom:u,maxZoom:p}=n,f=l?ne(Ir.interpolationFactor(l,e,u,p),0,1):0;n.kind==="camera"?s=mt(n.minSize,n.maxSize,f)*i:r=f*i}return{uSizeT:r,uSize:s}}class $a extends ke{constructor(e,i,r,s,l){super(e,i),this.angle=s,this.z=r,l!==void 0&&(this.segment=l)}clone(){return new $a(this.x,this.y,this.z,this.angle,this.segment)}}function Ux(n,e,i,r,s){if(e.segment===void 0)return!0;let l=e,u=e.segment+1,p=0;for(;p>-i/2;){if(u--,u<0)return!1;p-=n[u].dist(l),l=n[u]}p+=n[u].dist(n[u+1]),u++;let f=[],g=0;for(;p<i/2;){let x=n[u],b=n[u+1];if(!b)return!1;let w=n[u-1].angleTo(x)-x.angleTo(b);for(w=Math.abs((w+3*Math.PI)%(2*Math.PI)-Math.PI),f.push({distance:p,angleDelta:w}),g+=w;p-f[0].distance>r;)g-=f.shift().angleDelta;if(g>s)return!1;u++,p+=x.dist(b)}return!0}function Vx(n){let e=0;for(let i=0;i<n.length-1;
7i++)e+=n[i].dist(n[i+1]);return e}function jx(n,e,i){return n?.6*e*i:0}function Gx(n,e){return Math.max(n?n.right-n.left:0,e?e.right-e.left:0)}function zw(n,e,i,r,s,l){let u=jx(i,s,l),p=Gx(i,r)*l,f=0,g=Vx(n)/2;for(let x=0;x<n.length-1;x++){let b=n[x],w=n[x+1],S=b.dist(w);if(f+S>g){let I=(g-f)/S,M=mt(b.x,w.x,I),C=mt(b.y,w.y,I),R=new $a(M,C,0,w.angleTo(b),x);return!u||Ux(n,R,p,u,e)?R:void 0}f+=S}}function Ow(n,e,i,r,s,l,u,p,f){let g=jx(r,l,u),x=Gx(r,s),b=x*u,w=n[0].x===0||n[0].x===f||n[0].y===0||n[0].y===f;return e-b<e/4&&(e=b+e/4),Hx(n,w?e/2*p%e:(x/2+2*l)*u*p%e,e,g,i,b,w,!1,f)}function Hx(n,e,i,r,s,l,u,p,f){let g=l/2,x=Vx(n),b=0,w=e-i,S=[];for(let I=0;I<n.length-1;I++){let M=n[I],C=n[I+1],R=M.dist(C),F=C.angleTo(M);for(;w+i<b+R;){w+=i;let L=(w-b)/R,j=mt(M.x,C.x,L),H=mt(M.y,C.y,L);if(j>=0&&j<f&&H>=0&&H<f&&w-g>=0&&w+g<=x){let $=new $a(j,H,0,F,I);r&&!Ux(n,$,l,r,s)||S.push($)}}b+=R}return p||S.length||u||(S=Hx(n,b/2,i,r,s,l,u,!0,f)),S}function $x(n){let e=0,i=0;for(let u of n)e+=u.w*u.h,i=Math.max(i,u.w);n.sort((u,p)=>p.h-u.h);let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}],s=0,l=0;for(let u of n)for(let p=r.length-1;p>=0;p--){let f=r[p];if(!(u.w>f.w||u.h>f.h)){if(u.x=f.x,u.y=f.y,l=Math.max(l,u.y+u.h),s=Math.max(s,u.x+u.w),u.w===f.w&&u.h===f.h){let g=r.pop();g&&p<r.length&&(r[p]=g)}else u.h===f.h?(f.x+=u.w,f.w-=u.w):u.w===f.w?(f.y+=u.h,f.h-=u.h):(r.push({x:f.x+u.w,y:f.y,w:f.w-u.w,h:u.h}),f.y+=u.h,f.h-=u.h);break}}return{w:s,h:l,fill:e/(s*l)||0}}function h_(n,e){return n.id<e.id?-1:n.id>e.id?1:n.version<e.version?-1:n.version>e.version?1:n.sx<e.sx?-1:n.sx>e.sx?1:n.sy<e.sy?-1:n.sy>e.sy?1:0}function cy(n){let e=0;for(let i=0;i<n.length;i++)e=(e<<5)-e+n.charCodeAt(i),e&=e;return e}function ds(n,e){return(n<<5)-n+e}function qx(n,e,i,r){for(let[s]of n.entries()){let l=r&&r.get(s)||wr.parse(s),u=l.id.toString(),p=e.get(u)||0;i.push({id:s,version:p,sx:l.sx,sy:l.sy})}}Qe($a,"Anchor");class uy{constructor(e,i,r,s,l){this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=i.size>0,qx(e,r,this.iconDescriptors,l),qx(i,r,this.patternDescriptors,l),this.iconDescriptors.sort(h_),this.patternDescriptors.sort(h_);let u=0,p=s?s.data:"";p&&(u=ds(u,cy(p))),u=ds(u,1);for(let f of this.iconDescriptors)u=ds(u,cy(f.id)),u=ds(u,f.version),u=ds(u,f.sx),u=ds(u,f.sy);u=ds(u,1);for(let f of this.patternDescriptors)u=ds(u,cy(f.id)),u=ds(u,f.version),u=ds(u,f.sx),u=ds(u,f.sy);this.hash=u}subsetOf(e){return this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,h_)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,h_)}isSubsetArray(e,i,r){let s=0,l=0;if(e.length>i.length)return!1;for(;s<e.length&&l<i.length;){let u=r(e[s],i[l]);if(u===0)s++,l++;else{if(u<0)return!1;l++}}return s===e.length}}Qe(uy,"AtlasContentDescriptor");class Cp{static getImagePositionScale(e,i,r){if(i&&e){let{sx:s,sy:l}=e;return{x:s,y:l}}return{x:r,y:r}}constructor(e,i,r,s){this.paddedRect=e;let{pixelRatio:l,version:u,stretchX:p,stretchY:f,content:g,sdf:x,usvg:b}=i;this.pixelRatio=l,this.stretchX=p,this.stretchY=f,this.content=g,this.version=u,this.padding=r,this.sdf=x,this.usvg=b,this.scale=Cp.getImagePositionScale(s,b,l)}get tl(){return[this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return[this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return[(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function hy(n,e,i){let r=wr.parse(n),s=function(l,u,p=[1,1]){return{x:0,y:0,w:(l.data?l.data.width:l.width*p[0])+2*u,h:(l.data?l.data.height:l.height*p[1])+2*u}}(e,i,[r.sx,r.sy]);return{bin:s,imagePosition:new Cp(s,e,i,r),imageVariant:r}}function dy(n,e){let i=[];for(let[s,l]of n.entries()){let u=wr.parse(s);u&&(i.push({key:s,value:l,variant:u}),e&&e.set(s,u))}i.sort((s,l)=>{let u=s.variant.id.toString().localeCompare(l.variant.id.toString());return u!==0?u:s.variant.sx!==l.variant.sx?s.variant.sx-l.variant.sx:s.variant.sy!==l.variant.sy?s.variant.sy-l.variant.sy:0});let r=new Map;for(let s of i)r.set(s.key,s.value);return r}class Zx{constructor(e){this.sourceAtlasHash=e}}
7class Wx{constructor(e,i,r,s){let l=new Map,u=new Map;this.haveRenderCallbacks=[];let p=[],f=s!==void 0,g=f?new Map:void 0,x=f?dy(e,g):e,b=f?dy(i,g):i;this.addImages(x,l,1,p),this.addImages(b,u,2,p);let{w,h:S}=$x(p),I=new Vi({width:w||1,height:S||1});for(let[M,C]of x.entries()){let R=l.get(M).paddedRect;Vi.copy(C.data,I,{x:0,y:0},{x:R.x+1,y:R.y+1},C.data,null,C.sdf)}for(let[M,C]of b.entries()){let R=u.get(M),F=R.paddedRect,L=R.padding,j=F.x+L,H=F.y+L,$=C.data.width,ie=C.data.height;L=L>1?L-1:L,Vi.copy(C.data,I,{x:0,y:0},{x:j,y:H},C.data,r),Vi.copy(C.data,I,{x:0,y:ie-L},{x:j,y:H-L},{width:$,height:L},r),Vi.copy(C.data,I,{x:0,y:0},{x:j,y:H+ie},{width:$,height:L},r),Vi.copy(C.data,I,{x:$-L,y:0},{x:j-L,y:H},{width:L,height:ie},r),Vi.copy(C.data,I,{x:0,y:0},{x:j+$,y:H},{width:L,height:ie},r),Vi.copy(C.data,I,{x:$-L,y:ie-L},{x:j-L,y:H-L},{width:L,height:L},r),Vi.copy(C.data,I,{x:0,y:ie-L},{x:j+$,y:H-L},{width:L,height:L},r),Vi.copy(C.data,I,{x:0,y:0},{x:j+$,y:H+ie},{width:L,height:L},r),Vi.copy(C.data,I,{x:$-L,y:0},{x:j-L,y:H+ie},{width:L,height:L},r)}this.lut=r,this.image=I,this.iconPositions=l,this.patternPositions=u,f&&(this.contentDescriptor=new uy(x,b,s,r,g))}addImages(e,i,r,s){for(let[l,u]of e.entries()){let{bin:p,imagePosition:f,imageVariant:g}=hy(l,u,r);i.set(l,f),s.push(p),u.hasRenderCallback&&this.haveRenderCallbacks.push(g.id)}}patchUpdatedImages(e,i,r,s){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(l=>e.hasImage(l,r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(let l of e.getUpdatedImages(r)){for(let u of this.iconPositions.keys()){let p=wr.parse(u);if(br.isEqual(p.id,l)){let f=e.getImage(l,r);this.patchUpdatedImage(this.iconPositions.get(u),f,i,null)}}for(let u of this.patternPositions.keys()){let p=wr.parse(u);if(br.isEqual(p.id,l)){let f=e.getImage(l,r);this.patchUpdatedImage(this.patternPositions.get(u),f,i,s||this.lut)}}}}patchUpdatedImage(e,i,r,s=null){if(!e||!i||e.version===i.version)return;e.version=i.version;let[l,u]=e.tl,p=e.sdf;if(this.lut||p){let f={width:i.data.width,height:i.data.height},g=new Vi(f);Vi.copy(i.data,g,{x:0,y:0},{x:0,y:0},f,s,p),r.update(g,{position:{x:l,y:u},recreateWhenResize:!1})}else r.update(i.data,{position:{x:l,y:u},recreateWhenResize:!1})}}Qe(Cp,"ImagePosition"),Qe(Wx,"ImageAtlas",{omit:["lut"]}),Qe(Zx,"ImageAtlasReference");class Pp{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=e&&e.fontstackCompositing||"client"}loadGlyphRange(e,i,r,s,l){if(this.fontstackCompositing==="server")return void Pp.loadGlyphRange(e,i,r,s,l);let u=e.split(",").map(p=>p.trim()).filter(p=>p.length>0);u.length!==0?u.length!==1?this._loadMultipleFonts(u,i,r,s,l):this._loadFont(u[0],i,r,s,l):l(new Error("Empty fontstack"))}_loadMultipleFonts(e,i,r,s,l){let u=e.map(()=>null),p={completed:0,firstError:null,callbackCalled:!1},f=(g,x,b)=>{if(!p.callbackCalled&&(x&&!p.firstError&&(p.firstError=x),b&&(u[g]=b),p.completed++,p.completed===e.length)){p.callbackCalled=!0;let w=u.filter(I=>I!==null);if(w.length===0)return void l(p.firstError||new Error("All fonts failed to load"));let S=this._composeGlyphs(w);l(null,S)}};for(let g=0;g<e.length;g++)this._loadFont(e[g],i,r,s,(x,b)=>{f(g,x,b)})}_loadFont(e,i,r,s,l){let u=`${e}:${i}`;if(this.cachedRanges.has(u)){let f=this.cachedRanges.get(u);return void yn.frame(()=>l(null,f))}let p=this.pendingRequests.get(u);p?p.push(l):(this.pendingRequests.set(u,[l]),Pp.loadGlyphRange(e,i,r,s,(f,g)=>{f||this.cachedRanges.set(u,g||null);let x=this.pendingRequests.get(u);if(this.pendingRequests.delete(u),x)for(let b of x)b(f,g)}))}_composeGlyphs(e){let i={},r,s;for(let l of e)if(r===void 0&&l.ascender!==void 0&&(r=l.ascender),s===void 0&&l.descender!==void 0&&(s=l.descender),l.glyphs)for(let u in l.glyphs)i[u]===void 0&&(i[u]=l.glyphs[u]);return{glyphs:i,ascender:r,descender:s}}}Pp.loadGlyphRange=function(n,e,i,r,s){let l=256*e,u=l+255,p=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",n).replace("{range}",`${l}-${u}`),ws.Glyphs);nl(p,(f,g)=>{if(f)s(f);else if(g){let x={},b=function(w){return new l_(w).readFields(Cw,{})}(g);for(let w of b.glyphs)x[w.id]=w;
7s(null,{glyphs:x,ascender:b.ascender,descender:b.descender})}})};let Dp=1e20,py=new Float64Array(256);for(let n=0;n<256;n++){let e=.5-Math.pow(n/255,.45454545454545453);py[n]=e*Math.abs(e)}function Xx(n,e,i,r,s,l,u,p,f){for(let g=e;g<e+r;g++)Yx(n,i*l+g,l,s,u,p,f);for(let g=i;g<i+s;g++)Yx(n,g*l+e,1,r,u,p,f)}function Yx(n,e,i,r,s,l,u){l[0]=0,u[0]=-Dp,u[1]=Dp,s[0]=n[e];for(let p=1,f=0,g=0;p<r;p++){s[p]=n[e+p*i];let x=p*p;do{let b=l[f];g=(s[p]-s[b]+x-b*b)/(p-b)/2}while(g<=u[f]&&--f>-1);f++,l[f]=p,u[f]=g,u[f+1]=Dp}for(let p=0,f=0;p<r;p++){for(;u[f+1]<p;)f++;let g=l[f],x=p-g;n[e+p*i]=s[g]+x*x}}py[255]=-Dp;let Fw=/bold/i,Bw=/medium/i,kw=/light/i,fy={none:0,ideographs:1,all:2};class d_{constructor(e,i,r,s){this.requestManager=e,this.localGlyphMode=i,this.localFontFamily=r,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new Pp({fontstackCompositing:s})}setURL(e){this.url=e}prefetchRange(e,i){let r=this.url||di.GLYPHS_URL;if(!r)return;let s=this.entries[e];s||(s=this.entries[e]={glyphs:{},requests:{},ranges:{}}),s.ranges[i]||s.requests[i]||(s.requests[i]=[],this.glyphLoader.loadGlyphRange(e,i,r,this.requestManager,(l,u)=>{if(u){s.ascender=u.ascender,s.descender=u.descender;for(let p in u.glyphs)this._doesCharSupportLocalGlyph(+p)||(s.glyphs[+p]=u.glyphs[+p]);s.ranges[i]=!0}for(let p of s.requests[i]||[])p(l,u);delete s.requests[i]}))}getGlyphs(e,i){let r=[],s=this.url||di.GLYPHS_URL;for(let l in e)for(let u of e[l])r.push({stack:l,id:u});Oe(r,({stack:l,id:u},p)=>{let f=this.entries[l];f||(f=this.entries[l]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let g=f.glyphs[u];if(g!==void 0)return void p(null,{stack:l,id:u,glyph:g});if(g=this._tinySDF(f,l,u),g)return f.glyphs[u]=g,void p(null,{stack:l,id:u,glyph:g});let x=Math.floor(u/256);if(256*x>65535)return Bt("glyphs > 65535 not supported"),void p(null,{stack:l,id:u,glyph:g});if(f.ranges[x])return void p(null,{stack:l,id:u,glyph:g});let b=f.requests[x];b||(b=f.requests[x]=[],this.glyphLoader.loadGlyphRange(l,x,s,this.requestManager,(w,S)=>{if(S){f.ascender=S.ascender,f.descender=S.descender;for(let I in S.glyphs)this._doesCharSupportLocalGlyph(+I)||(f.glyphs[+I]=S.glyphs[+I]);f.ranges[x]=!0}for(let I of b)I(w,S);delete f.requests[x]})),b.push((w,S)=>{w?p(w):S&&p(null,{stack:l,id:u,glyph:S.glyphs[u]||null})})},(l,u)=>{if(l)i(l);else if(u){let p={};for(let{stack:f,id:g,glyph:x}of u)p[f]===void 0&&(p[f]={}),p[f].glyphs===void 0&&(p[f].glyphs={}),p[f].glyphs[g]=x&&{id:x.id,bitmap:x.bitmap.clone(),metrics:x.metrics},p[f].ascender=this.entries[f].ascender,p[f].descender=this.entries[f].descender;i(null,p)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==fy.none&&(this.localGlyphMode===fy.all?!!this.localFontFamily:!!this.localFontFamily&&(Md(e)||Gf(e)||Sd(e)||Lc(e)||La(e)||Ad(e)||(i=e)>=131072&&i<=173791||(r=>r>=66736&&r<=66815)(e)));var i}_tinySDF(e,i,r){let s=this.localFontFamily;if(!s||!this._doesCharSupportLocalGlyph(r))return;let l=e.tinySDF;if(!l){let C="400";Fw.test(i)?C="900":Bw.test(i)?C="500":kw.test(i)&&(C="200"),l=e.tinySDF=new d_.TinySDF({fontFamily:s,fontWeight:C,fontSize:48,buffer:6,radius:16}),l.fontWeight=C}let u=l.fontWeight;if(this.localGlyphs[u][r])return this.localGlyphs[u][r];let p=String.fromCodePoint(r),{data:f,width:g,height:x,glyphWidth:b,glyphHeight:w,glyphLeft:S,glyphTop:I,glyphAdvance:M}=l.draw(p);return this.localGlyphs[u][r]={id:r,bitmap:new zi({width:g,height:x},f),metrics:{width:b/2,height:w/2,left:S/2,top:I/2-27,advance:M/2,localGlyph:!0}}}}function Jx(n,e){return n+e[1]-e[0]}function my(n,e,i,r,s=1){let l=[],u=n.imagePrimary,p=u.pixelRatio,f=u.paddedRect.w-2,g=u.paddedRect.h-2,x=(n.right-n.left)*s,b=(n.bottom-n.top)*s,w=u.stretchX||[[0,f]],S=u.stretchY||[[0,g]],I=w.reduce(Jx,0),M=S.reduce(Jx,0),C=f-I,R=g-M,F=0,L=I,j=0,H=M,$=0,ie=C,W=0,Q=R;if(u.content&&r){let ee=u.content;F=p_(w,0,ee[0]),j=p_(S,0,ee[1]),L=p_(w,ee[0],ee[2]),H=p_(S,ee[1],ee[3]),$=ee[0]-F,W=ee[1]-j,ie=ee[2]-ee[0]-L,Q=ee[3]-ee[1]-H}let Y=(ee,me,ge,Te)=>{let Ae=f_(ee.stretch-F,L,x,n.left*s),Ie=m_(ee.fixed-$,ie,ee.stretch,I),Be=f_(me.stretch-j,H,b,n.top*s),xe=m_(me.fixed-W,Q,me.stretch,M),Se=f_(ge.stretch-F,L,x,n.left*s),Me=m_(ge.fixed-$,ie,ge.stretch,I),Le=f_(Te.stretch-j,H,b,n.top*s),ze=m_(Te.fixed-W,Q,Te.stretch,M),We=new ke(Ae,Be),De=new ke(Se,Be),Ge=new ke(Se,Le),$e=new ke(Ae,Le),Je=new ke(Ie/p,xe/p),tt=new ke(Me/p,ze/p
7),ct=e*Math.PI/180;if(ct){let Pt=Math.sin(ct),ji=Math.cos(ct),Qt=[ji,-Pt,Pt,ji];We._matMult(Qt),De._matMult(Qt),$e._matMult(Qt),Ge._matMult(Qt)}let rt=ee.stretch+ee.fixed,ft=ge.stretch+ge.fixed,Zt=me.stretch+me.fixed,St=Te.stretch+Te.fixed,Ut=n.imageSecondary;return{tl:We,tr:De,bl:$e,br:Ge,texPrimary:{x:u.paddedRect.x+1+rt,y:u.paddedRect.y+1+Zt,w:ft-rt,h:St-Zt},texSecondary:Ut?{x:Ut.paddedRect.x+1+rt,y:Ut.paddedRect.y+1+Zt,w:ft-rt,h:St-Zt}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Je,pixelOffsetBR:tt,minFontScaleX:ie/p/x,minFontScaleY:Q/p/b,isSDF:i}};if(u.stretchX||u.stretchY){let ee=Kx(w,C,I),me=Kx(S,R,M);for(let ge=0;ge<ee.length-1;ge++){let Te=ee[ge],Ae=ee[ge+1];for(let Ie=0;Ie<me.length-1;Ie++)l.push(Y(Te,me[Ie],Ae,me[Ie+1]))}}else l.push(Y({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:f+1},{fixed:0,stretch:g+1}));return l}function Nw(n,e){let i=n.stretchY||[[0,n.paddedRect.h-2]];return n.stretchX||n.stretchY?Qx(n.stretchX||[[0,n.paddedRect.w-2]])*Qx(i):1}function p_(n,e,i){let r=0;for(let s of n)r+=Math.max(e,Math.min(i,s[1]))-Math.max(e,Math.min(i,s[0]));return r}function Kx(n,e,i){let r=[{fixed:-1,stretch:0}];for(let[s,l]of n){let u=r.at(-1);r.push({fixed:s-u.stretch,stretch:u.stretch}),r.push({fixed:s-u.stretch,stretch:u.stretch+(l-s)})}return r.push({fixed:e+1,stretch:i}),r}function Qx(n){return 2*n.length+1}function f_(n,e,i,r){return n/e*i+r}function m_(n,e,i,r){return n-e*i/r}function Uw(n,e,i,r){let s=e+n.positionedLines[r].lineOffset;return r===0?i+s/2:i+(s+(e+n.positionedLines[r-1].lineOffset))/2}function ev(n,e,i,r,s,l,u,p,f,g=1){let x=[];if(e.positionedLines.length===0)return x;let b=(f!==void 0?f:r.layout.get("text-rotate").evaluate(l,{}))*Math.PI/180,w=function(R){let F=R[0],L=R[1],j=F*L;return j>0?[F,-L]:j<0?[-F,L]:F===0?[L,F]:[L,-F]}(i),S=Math.abs(e.top-e.bottom);for(let R of e.positionedLines)S-=R.lineOffset;let I=e.positionedLines.length,M=S/I,C=e.top-i[1];for(let R=0;R<I;++R){let F=e.positionedLines[R];C=Uw(e,M,C,R);for(let L of F.positionedGlyphs){if(!L.rect)continue;let j=L.rect||{},H=4,$=!0,ie=1,W=0;if(L.image){let Ge=u.get(L.image.toString());if(!Ge)continue;if(Ge.sdf){Bt("SDF images are not supported in formatted text and will be ignored.");continue}$=!1,ie=Ge.pixelRatio,H=1/ie,Ge.usvg||(ie/=g)}let Q=(s||p)&&L.vertical,Y=L.metrics.advance*L.scale/2,ee=L.metrics,me=L.rect;if(me===null)continue;p&&e.verticalizable&&(W=L.image?Y-L.metrics.width*L.scale/2:0);let ge=s?[L.x+Y,L.y]:[0,0],Te=[0,0],Ae=[0,0],Ie=!1;s||(Q?(Ae=[L.x+Y+w[0],L.y+w[1]-W],Ie=!0):Te=[L.x+Y+i[0],L.y+i[1]-W]);let Be=me.w*L.scale/(ie*(L.localGlyph?2:1)),xe=me.h*L.scale/(ie*(L.localGlyph?2:1)),Se,Me,Le,ze;if(Q){let Ge=L.y-C,$e=new ke(-Y,Y-Ge),Je=-Math.PI/2,tt=new ke(...Ae);Se=new ke(-Y+Te[0],Te[1]),Se._rotateAround(Je,$e)._add(tt),Se.x+=-Ge+Y,Se.y-=(ee.left-H)*L.scale;let ct=L.image?ee.advance*L.scale:wn*L.scale,rt=String.fromCodePoint(L.glyph);yw(rt)?Se.x+=(1-H)*L.scale:xw(rt)?Se.x+=ct-ee.height*L.scale+(-H-1)*L.scale:Se.x+=L.image||ee.width+2*H===me.w&&ee.height+2*H===me.h?(ct-xe)/2:(ct-(ee.height+2*H)*L.scale)/2,Me=new ke(Se.x,Se.y-Be),Le=new ke(Se.x+xe,Se.y),ze=new ke(Se.x+xe,Se.y-Be)}else{let Ge=(ee.left-H)*L.scale-Y+Te[0],$e=(-ee.top-H)*L.scale+Te[1],Je=Ge+Be,tt=$e+xe;Se=new ke(Ge,$e),Me=new ke(Je,$e),Le=new ke(Ge,tt),ze=new ke(Je,tt)}if(b){let Ge;Ge=s?new ke(0,0):Ie?new ke(w[0],w[1]):new ke(i[0],i[1]),Se._rotateAround(b,Ge),Me._rotateAround(b,Ge),Le._rotateAround(b,Ge),ze._rotateAround(b,Ge)}let We=new ke(0,0),De=new ke(0,0);x.push({tl:Se,tr:Me,bl:Le,br:ze,texPrimary:j,texSecondary:void 0,writingMode:e.writingMode,glyphOffset:ge,sectionIndex:L.sectionIndex,isSDF:$,pixelOffsetTL:We,pixelOffsetBR:De,minFontScaleX:0,minFontScaleY:0})}}return x}function Vw(n,e=1,i=!1){let r=1/0,s=1/0,l=-1/0,u=-1/0,p=n[0];for(let S=0;S<p.length;S++){let I=p[S];(!S||I.x<r)&&(r=I.x),(!S||I.y<s)&&(s=I.y),(!S||I.x>l)&&(l=I.x),(!S||I.y>u)&&(u=I.y)}let f=Math.min(l-r,u-s),g=f/2,x=new pt([],jw);if(f===0)return new ke(r,s);for(let S=r;S<l;S+=f)for(let I=s;I<u;I+=f)x.push(new Sh(S+g,I+g,g,n));let b=function(S){let I=0,M=0,C=0,R=S[0];for(let F=0,L=R.length,j=L-1;F<L;j=F++){let H=R[F],$=R[j],ie=H.x*$.y-$.x*H.y;M+=(H.x+$.x)*ie,C+=(H.y+$.y)*ie,I+=3*ie}return new Sh(M/I,C/I,0,S)}(n),w=x.length;for(;x.length;){let S=x.pop();(S.d>b.d||!b.d)&&(b=S,i&&console.log("found best %d after %d probes",Math.round(1e4*S.d)/1e4,w)),S.max-b.d<=e||(g=S.h/2,x.push(new Sh(S.p.x-g,S.p.y-g,g,n)),x.push(new Sh(S.p.x+g,S.p.y-g,g,n)),x.push(new Sh(S.p.x-g,S.p.y+g,g,n)),x.push(new Sh(S.p.x+g,S.p.y+g,g,n)),w+=4)}return i&&(console.log(`num probes: ${w}`),console.log(`best distance: ${b.d}`)),b.p}function jw(n,e){return e.max-n.max}d_.TinySDF=class{constructor({fontSize:n=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:s="sans-serif",fontWeight:l="normal",fontStyle:u="normal",lang:p=null}={}){this.buffer=e,this.radius=i,this.cutoff=r,this.lang=p;let f=this.size=n+4*e,g=this._createCanvas(f),x=this.ctx=g.getContext("2d",{willReadFrequently:!0});x.font=`${u} ${l} ${n}px ${s}`,x.textBaseline="alphabetic",x.textAlign="left",x.fillStyle="black",this.gridOuter=new Float64Array(f*f),this.gridInner=new Float64Array(f*f),this.f=new Float64Array(f),this.z=new Float64Array(f+1),this.v=new Uint16Array(f)}_createCanvas(n){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(n,n);let e=document.createElement("canvas");return e.width=e.height=n,e}draw(n){let{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:s,actualBoundingBoxRight:l}=this.ctx.measureText(n),u=Math.ceil(i),p=Math.floor(s),f=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(l)-p)),g=Math.max(0,Math.min(this.size-this.buffer,u+Math.ceil(r))),x=f+2*this.buffer,b=g+2*this.buffer,w=Math.max(x*b,0),S=new Uint8ClampedArray(w),I={data:S,width:x,height:b,glyphWidth:f,glyphHeight:g,glyphTop:u,glyphLeft:p,glyphAdvance:e};if(f===0||g===0)return I;let{ctx:M,buffer:C,gridInner:R,gridOuter:F}=this;this.lang&&(M.lang=this.lang),M.clearRect(C,C,f,g),M.fillText(n,C-p,C+u);let L=M.getImageData(C,C,f,g);F.fill(Dp,0,w),R.fill(0,0,w);let j=3;for(let ie=0;ie<g;ie++){let W=(ie+C)*x+C;for(let Q=0;Q<f;Q++,j+=4,W++){let Y=L.data[j];if(Y===0)continue;let ee=py[Y];F[W]=Math.max(0,ee),R[W]=Math.max(0,-ee)}}Xx(F,0,0,x,b,x,this.f,this.v,this.z),Xx(R,C,C,f,g,x,this.f,this.v,this.z);let H=255/this.radius,$=255*(1-this.cutoff);for(let ie=0;ie<w;ie++){let W=Math.sqrt(F[ie])-Math.sqrt(R[ie]);S[ie]=Math.round($-H*W)}return I}};
7class Sh{constructor(e,i,r,s){this.p=new ke(e,i),this.h=r,this.d=function(l,u){let p=!1,f=1/0;for(let g=0;g<u.length;g++){let x=u[g];for(let b=0,w=x.length,S=w-1;b<w;S=b++){let I=x[b],M=x[S];I.y>l.y!=M.y>l.y&&l.x<(M.x-I.x)*(l.y-I.y)/(M.y-I.y)+I.x&&(p=!p),f=Math.min(f,A(l,I,M))}}return(p?1:-1)*Math.sqrt(f)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}}let Gw=Object.keys,_y=Number.POSITIVE_INFINITY,Hw=Math.sqrt(2);function Hl(n,e,i,r,s,l){let u=sy(n)&&n.collisionPadding?n.collisionPadding:[0,0,0,0],p={top:n.top-u[1],bottom:n.bottom+u[3],left:n.left-u[0],right:n.right+u[2],scaled:!1};return r!==void 0&&function(f,g){f.top*=g,f.bottom*=g,f.left*=g,f.right*=g,f.scaled=!0}(p,r),l&&(p.left+=l[0],p.right+=l[0],p.top+=l[1],p.bottom+=l[1]),i&&function(f,g,x){if(!g)return;let b=V(g),w=new ke(x?x[0]:0,x?x[1]:0),S=new ke(f.left,f.top),I=new ke(f.right,f.top),M=new ke(f.left,f.bottom),C=new ke(f.right,f.bottom);S._rotateAround(b,w),I._rotateAround(b,w),M._rotateAround(b,w),C._rotateAround(b,w),f.left=Math.min(S.x,I.x,M.x,C.x),f.right=Math.max(S.x,I.x,M.x,C.x),f.top=Math.min(S.y,I.y,M.y,C.y),f.bottom=Math.max(S.y,I.y,M.y,C.y)}(p,i,s),e?{top:Math.min(e.top,p.top),bottom:Math.max(e.bottom,p.bottom),left:Math.min(e.left,p.left),right:Math.max(e.right,p.right),scaled:e.scaled||p.scaled}:p}function tv(n,[e,i]){let r=0,s=0;if(i===_y){e<0&&(e=0);let l=e/Hw;switch(n){case"top-right":case"top-left":s=l-7;break;case"bottom-right":case"bottom-left":s=7-l;break;case"bottom":s=7-e;break;case"top":s=e-7}switch(n){case"top-right":case"bottom-right":r=-l;break;case"top-left":case"bottom-left":r=l;break;case"left":r=e;break;case"right":r=-e}}else{switch(e=Math.abs(e),i=Math.abs(i),n){case"top-right":case"top-left":case"top":s=i-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-i}switch(n){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}}return[r,s]}function $w(n,e,i,r,s,l,u,p,f,g,x,b,w,S,I){let M=n.layers[0],C=M.appearances;if(C.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};let R={iconBBox:null,iconVerticalBBox:null},F={textBBox:null,textVerticalBBox:null},{baseIconRotate:L,baseTextRotate:j,iconScaleFactor:H}=function(ie,W,Q){let Y=ie.get("icon-rotate").evaluate(W,{},Q),ee=ie.get("text-rotate").evaluate(W,{},Q),[me,ge]=ie.get("icon-size-scale-range");return{baseIconRotate:Y,baseTextRotate:ee,iconScaleFactor:ne(1,me,ge)}}(r,s,l);e&&(R.iconBBox=Hl(e,R.iconBBox,L),i)&&(R.iconVerticalBBox=Hl(i,R.iconVerticalBBox,L+90));let $=g_(b.horizontal);$&&(F.textBBox=Hl($,F.textBBox,j,1,S)),b.vertical&&(F.textVerticalBBox=Hl(b.vertical,F.textVerticalBBox,j+90,1,S));for(let ie of C)ie.hasIconLayoutProperties()&&qw(R,n,M,ie,s,l,p,L,u,f,e,g,H,x,I),ie.hasTextLayoutProperties()&&Zw(F,M,ie,s,l,S,j,w,$,b.vertical);return{iconBBox:R.iconBBox,iconVerticalBBox:R.iconVerticalBBox,textBBox:F.textBBox,textVerticalBBox:F.textVerticalBBox}}function qw(n,e,i,r,s,l,u,p,f,g,x,b,w,S,I){let{appearanceIconOffset:M,appearanceIconRotate:C,appearanceIconSize:R}=iv(r,i,s,l,u,p,f,g.iconScaleFactor),F=null,L=null,j=null;r.hasLayoutProperty("icon-image")?j=function($,ie,W,Q,Y,ee,me,ge){let Te=null,Ae=ie.getAppearanceValueAndResolveTokens(W,"icon-image",Q,Y,ge);if(Ae){let Ie=$.getResolvedImageFromTokens(Ae),Be=W.hasLayoutProperty("icon-size")?W.getUnevaluatedLayoutProperty("icon-size"):ie._unevaluatedLayout._values["icon-size"],xe=Rp(Ie,nu($.zoom,Be,$.worldview,ge),Be,Y,$.zoom,Q,$.pixelRatio,me,$.worldview,ge);Te=ee.get(xe.iconPrimary.toString())}return Te}(e,i,r,s,l,b,w,I):x&&(j=x.imagePrimary),j&&(F=u_(j,null,M,S),e.allowVerticalPlacement&&(L=u_(j,null,M,S)));let H=f>0?R/f:1;F&&(n.iconBBox=Hl(F,n.iconBBox,C,H!==1?H:void 0)),L&&(n.iconVerticalBBox=Hl(L,n.iconVerticalBBox,C+90,H!==1?H:void 0))}function iv(n,e,i,r,s,l,u,p){let f=n.hasLayoutProperty("icon-offset")?e.getAppearanceValueAndResolveTokens(n,"icon-offset",i,r,[]):null,g=f&&Array.isArray(f)?f:s,x=n.hasLayoutProperty("icon-rotate")?e.getAppearanceValueAndResolveTokens(n,"icon-rotate",i,r,[]):null,b=typeof x=="number"?x:l,w=n.hasLayoutProperty("icon-size")?e.getAppearanceValueAndResolveTokens(n,"icon-size",i,r,[]):null;return{appearanceIconOffset:g,appearanceIconRotate:b,appearanceIconSize:typeof w=="number"?w*p:u}}function Zw(n,e,i,r,s,l,u,p,f,g){let{appearanceTextOffset:x,appearanceTextRotate:b,appearanceTextSize:w}=nv(i,e,r,s,l,u,p),S=w/p,I=[(x[0]-l[0])*S,(x[1]-l[1])*S],M=I[0]!==0||I[1]!==0;f&&(n.textBBox=Hl(f,n.textBBox,b,S,x,M?I:void 0)),g&&(n.textVerticalBBox=Hl(g,n.textVerticalBBox,b+90,S,x,M?I:void 0))}function nv(n,e,i,r,s,l,u){let p=n.hasLayoutProperty("text-offset")?e.getAppearanceValueAndResolveTokens(n,"text-offset",i,r,[]):null,f=p&&Array.isArray(p)?[p[0]*wn,p[1]*wn]:s,g=n.hasLayoutProperty("text-rotate")?e.getAppearanceValueAndResolveTokens(n,"text-rotate",i,r,[]):null,x=typeof g=="number"?g:l,b=n.hasLayoutProperty("text-size")?e.getAppearanceValueAndResolveTokens(n,"text-size",i,r,[]):null;return{appearanceTextOffset:f,appearanceTextRotate:x,appearanceTextSize:typeof b=="number"?b:u}}function __(n,e,i,r,s,l,u,p,f){if(!e||!e.usvg)return;let g=Nx(r),x=Nx(s),b=l!=="both"&&l!=="width"||!Bx(r)?1:x.width/g.width,w=l!=="both"&&l!=="height"||!kx(r)?1:x.height/g.height;i.scaleSelf(b,w);let S=i.toString();u.set(S,i),p.set(S,e);let{imagePosition:I}=hy(S,e,1);f.set(S,I)}function rv(n,e,i,r,s,l,u,p,f,g){if(!n)return;let x=function(b,w,S,I,M,C,R){if(b.kind==="camera")return b.maxSize;if(b.kind==="composite"){let F=w.possiblyEvaluate(new Jt(b.maxZoom,{worldview:C}),S,R).evaluate(M,{},S,R),L=w.possiblyEvaluate(new Jt(b.minZoom,{worldview:C}),S,R).evaluate(M,{},S,R);return Math.max(F,L)}return w.possiblyEvaluate(new Jt(I,{worldview:C}),S,R).evaluate(M,{},S,R)}(e,i,r,s,l,f,g);
7return n.scaleSelf(x*p*u)}function Rp(n,e,i,r,s,l,u,p,f,g){return{iconPrimary:rv(n.getPrimary(),e,i,r,s,l,u,p,f,g),iconSecondary:rv(n.getSecondary(),e,i,r,s,l,u,p,f,g)}}function Ww(n,e,i){if(!e)return;let r=i.get(n.toString()),s=i.get(e.toString());r&&s&&(r.paddedRect.w===s.paddedRect.w&&r.paddedRect.h===s.paddedRect.h||Bt(`Mismatch in icon variant sizes: ${n.toString()} and ${e.toString()}`),r.usvg!==s.usvg&&Bt(`Mismatch in icon variant image types: ${n.id} and ${e.id}`))}function ov(n,e,i,r){if(!n)return;let s=e.get(i.toString());if(s&&(n.imagePrimary=s),r){let l=e.get(r.toString());n.imageSecondary=l}}function Xw(n,e){for(let i in n.horizontal)sv(n.horizontal[i],e);sv(n.vertical,e)}function sv(n,e){if(n){for(let i of n.positionedLines)for(let r of i.positionedGlyphs)if(r.image!==null){let s=r.image.toString();r.rect=e.get(s).paddedRect}}}function gy(n){switch(n){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Yw(n,e,i,r,s,l,u,p,f){let g=g_(l.horizontal)||l.vertical,x=i.get("icon-text-fit-padding").evaluate(r,{},s),b,w=e;return e&&f!=="none"&&(n.allowVerticalPlacement&&l.vertical&&(b=ay(e,l.vertical,f,x,p,u)),g&&(w=ay(e,g,f,x,p,u))),{defaultShapedIcon:w,verticallyShapedIcon:b}}function av(n,e){return n*e/24}function Jw(n,e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F,L,j,H,$,ie){let W=u.textMaxSize.evaluate(e,{},w);W===void 0?W=p*u.textScaleFactor:W*=u.textScaleFactor;let Q=n.layers[0].layout,Y=av(p,u.textScaleFactor),ee=g_(i.horizontal)||i.vertical,me=n.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),ge=n.getAppearanceFeatureData(e.index);(C!=="none"||me)&&ge&&(ge.textShaping=ee,ge.iconTextFitPadding=Q.get("icon-text-fit-padding").evaluate(e,{},w),ge.fontScale=Y,ge.textScaleFactor=u.textScaleFactor);let Te=S.name==="globe",Ae=n.tilePixelRatio*W/24,Ie=(ze=n.overscaling,n.zoom>18&&ze>2&&(ze>>=1),Math.max(Xe/(512*ze),1)*Q.get("symbol-spacing")),Be=Q.get("text-padding")*n.tilePixelRatio,xe=Q.get("icon-padding")*n.tilePixelRatio,Se=V(Q.get("text-max-angle")),Me=Q.get("icon-rotation-alignment")==="map"&&L!=="point",Le=Ie/2;var ze;n.hasAnyIconTextFit===!1&&C!=="none"&&(n.hasAnyIconTextFit=!0);let We=e.properties?+e.properties[qs]:null,De=We&&n.elevationFeatureIdToIndex?n.elevationFeatureIdToIndex.get(We):65535,Ge=($e,Je,tt)=>{if(Je.x<0||Je.x>=Xe||Je.y<0||Je.y>=Xe)return;let ct=null;if(Te){let{x:rt,y:ft,z:Zt}=S.projectTilePoint(Je.x,Je.y,tt);ct={anchor:new $a(rt,ft,Zt,0,void 0),up:S.upVector(tt,Je.x,Je.y)}}(function(rt,ft,Zt,St,Ut,Pt,ji,Qt,$t,ui,Pi,Tn,_i,Gi,un,tn,hn,Lt,jn,hr,Qi,Mn,ir,Gn,Oi,mn,Dr,Ph,_r,ky,$p,qp){let qa=rt.addToLineVertexArray(ft,St),co,Mo,Xl,Yl,zt,Cn,Hi,_n=0,Co=0,Jr=0,uo=0,Kr=-1,Zp=-1,jo={},Dh=pc(""),Qs=Zt?Zt.anchor:ft,Rh=Ph!=="none",dn=0,On=0;if($t._unevaluatedLayout.getValue("text-radial-offset")===void 0){let Hn=$t.layout.get("text-offset").evaluate(Qi,{},Oi);dn=Hn[0]*wn,On=Hn[1]*wn}else dn=$t.layout.get("text-radial-offset").evaluate(Qi,{},Oi)*wn,On=_y;if(rt.allowVerticalPlacement&&Ut.vertical){let Hn=Ut.vertical;if(un)Cn=vy(Hn),Qt&&(Hi=vy(Qt));else{let nr=$t.layout.get("text-rotate").evaluate(Qi,{},Oi)+90;Xl=y_(ui,Qs,ft,Pi,Tn,_i,Hn,Gi,nr,tn,qp),Qt&&(Yl=y_(ui,Qs,ft,Pi,Tn,_i,Qt,Lt,nr,null,$p))}}if(Pt){let Hn=$t.layout.get("icon-rotate").evaluate(Qi,{},Oi),nr=my(Pt,Hn,ir,Rh,Mn.iconScaleFactor),po=Qt?my(Qt,Hn,ir,Rh,Mn.iconScaleFactor):void 0;Mo=y_(ui,Qs,ft,Pi,Tn,_i,Pt,Lt,Hn,null,ky);let ea=function(ms,Wp,g1,ZT,WT,y1,x1,XT,p2,Vy){let v1=ms.layers[0],b1=v1.appearances,zh=Wp.length;if(g1&&(zh=Math.max(zh,g1.length)),b1.length===0)return zh;let[YT,JT]=ZT.get("icon-size-scale-range"),KT=ne(1,YT,JT);for(let L_ of b1)if(L_.hasLayoutProperty("icon-image")){let w1=v1.getAppearanceValueAndResolveTokens(L_,"icon-image",y1,x1,Vy);if(w1){let T1=ms.getResolvedImageFromTokens(w1);if(T1){let S1=L_.hasLayoutProperty("icon-size")?L_.getUnevaluatedLayoutProperty("icon-size"):WT._values["icon-size"],QT=
7Rp(T1,nu(ms.zoom,S1,ms.worldview,Vy),S1,x1,ms.zoom,y1,ms.pixelRatio,KT,ms.worldview,Vy),E1=XT.get(QT.iconPrimary.toString());E1&&(zh=Math.max(zh,Nw(E1)))}}}return zh}(rt,nr,po,$t.layout,$t._unevaluatedLayout,Qi,Oi,rt.iconAtlasPositions,0,Gn);_n=4*ea;let R_=$t.layout.get("icon-size").evaluate(Qi,{},Oi,Gn),Ny=Mn.compositeIconSizes?Mn.compositeIconSizes[0].evaluate(Qi,{},Oi,Gn):0,Uy=Mn.compositeIconSizes?Mn.compositeIconSizes[1].evaluate(Qi,{},Oi,Gn):0,Lh=xy(rt.layerIds[0],rt.iconSizeData,R_,Pt.imagePrimary.usvg?1:Mn.iconScaleFactor,Ny,Uy);rt.addSymbols(rt.icon,nr,Lh,hr,jn,Qi,void 0,Zt,ft,qa.lineStartIndex,qa.lineLength,-1,Gn,Oi,mn,Dr,rt.symbolInstances.length,ea),Kr=rt.icon.placedSymbolArray.length-1,po&&(Co=4*ea,rt.addSymbols(rt.icon,po,Lh,hr,jn,Qi,Yr.vertical,Zt,ft,qa.lineStartIndex,qa.lineLength,-1,Gn,Oi,mn,Dr,rt.symbolInstances.length,ea),Zp=rt.icon.placedSymbolArray.length-1)}for(let Hn in Ut.horizontal){let nr=Hn,po=Ut.horizontal[nr];co||(Dh=pc(po.text),un?zt=vy(po):co=y_(ui,Qs,ft,Pi,Tn,_i,po,Gi,$t.layout.get("text-rotate").evaluate(Qi,{},Oi),tn,qp));let ea=po.positionedLines.length===1;if(Jr+=lv(rt,Zt,ft,po,ji,$t,un,Qi,tn,qa,Ut.vertical?Yr.horizontal:Yr.horizontalOnly,ea?Gw(Ut.horizontal):[nr],jo,Kr,Mn,Gn,Oi,rt.symbolInstances.length,mn),ea)break}Ut.vertical&&(uo+=lv(rt,Zt,ft,Ut.vertical,ji,$t,un,Qi,tn,qa,Yr.vertical,["vertical"],jo,Zp,Mn,Gn,Oi,rt.symbolInstances.length,mn));let Wi=-1,ho=(Hn,nr)=>Hn?Math.max(Hn,nr):nr;Wi=ho(zt,Wi),Wi=ho(Cn,Wi),Wi=ho(Hi,Wi);let gr=Wi>-1?1:0;rt.glyphOffsetArray.length>=65535&&Bt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Qi.sortKey!==void 0&&rt.addToSortKeyRanges(rt.symbolInstances.length,Qi.sortKey),rt.symbolInstances.emplaceBack(ft.x,ft.y,Qs.x,Qs.y,Qs.z,jo.right>=0?jo.right:-1,jo.center>=0?jo.center:-1,jo.left>=0?jo.left:-1,jo.vertical>=0?jo.vertical:-1,Kr,Zp,Dh,co!==void 0?co:rt.collisionBoxArray.length,co!==void 0?co+1:rt.collisionBoxArray.length,Xl!==void 0?Xl:rt.collisionBoxArray.length,Xl!==void 0?Xl+1:rt.collisionBoxArray.length,Mo!==void 0?Mo:rt.collisionBoxArray.length,Mo!==void 0?Mo+1:rt.collisionBoxArray.length,Yl||rt.collisionBoxArray.length,Yl?Yl+1:rt.collisionBoxArray.length,Pi,Jr,uo,_n,Co,gr,0,dn,On,Wi,0,Rh?1:0,_r)})(n,Je,ct,$e,i,r,l,s,n.layers[0],n.collisionBoxArray,e.index,e.sourceLayerIndex,n.index,Be,F,g,0,xe,Me,R,e,u,x,b,w,I,M,C,De,j,H,$)};if(L==="line")for(let $e of Ym(e.geometry,0,0,Xe,Xe)){let Je=Ow($e,Ie,Se,i.vertical||ee,r,24,Ae,n.overscaling,Xe);for(let tt of Je)ee&&Kw(n,ee.text,Le,tt)||Ge($e,tt,w)}else if(L==="line-center"){for(let $e of e.geometry)if($e.length>1){let Je=zw($e,Se,i.vertical||ee,r,24,Ae);Je&&Ge($e,Je,w)}}else if(e.type==="Polygon")for(let $e of mp(e.geometry,0)){let Je=Vw($e,16);Ge($e[0],new $a(Je.x,Je.y,0,0,void 0),w)}else if(e.type==="LineString")for(let $e of e.geometry)Ge($e,new $a($e[0].x,$e[0].y,0,0,void 0),w);else if(e.type==="Point")for(let $e of e.geometry)for(let Je of $e)Ge([Je],new $a(Je.x,Je.y,0,0,void 0),w)}let yy=255,ru=yy*Ha;function lv(n,e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F){let L=ev(0,r,f,l,u,p,s,n.allowVerticalPlacement,void 0,I.textScaleFactor),j=l.layout.get("text-size").evaluate(p,{},C),H=I.compositeTextSizes?I.compositeTextSizes[0].evaluate(p,{},C):0,$=I.compositeTextSizes?I.compositeTextSizes[1].evaluate(p,{},C):0,ie=xy(n.layerIds[0],n.textSizeData,j,I.textScaleFactor,H,$);n.addSymbols(n.text,L,ie,f,u,p,x,e,i,g.lineStartIndex,g.lineLength,S,M,C,F,!1,R,L.length);for(let W of b)w[W]=n.text.placedSymbolArray.length-1;return 4*L.length}function xy(n,e,i,r,s,l){let u=e,p=null;return u.kind==="source"?(p=[Ha*i*r],p[0]>ru&&Bt(`${n}: Value for "text-size" or "icon-size" is >= ${yy}. Reduce your "text-size" or "icon-size".`)):u.kind==="composite"&&(p=[Ha*s*r,Ha*l*r],(p[0]>ru||p[1]>ru)&&Bt(`${n}: Value for "text-size" or "icon-size" is >= ${yy}. Reduce your "text-size" or "icon-size".`)),p}function g_(n){for(let e in n)return n[e];return null}function y_(n,e,i,r,s,l,u,p,f,g,x){let b,w,S,I;if(b=x?x.top:u.top,w=x?x.bottom:u.bottom,S=x?x.left:u.left,I=x?x.right:u.right,sy(u)&&u.collisionPadding){let M=u.collisionPadding;S-=M[0],b-=M[1],I+=M[2],w+=M[3]}if(f){let M=new ke(S,b),C=new ke(I,b),R=new ke(S,w),F=new ke(I,w),L=V(f),j=new ke(0,0);
7g&&(j=new ke(g[0],g[1])),M._rotateAround(L,j),C._rotateAround(L,j),R._rotateAround(L,j),F._rotateAround(L,j),S=Math.min(M.x,C.x,R.x,F.x),I=Math.max(M.x,C.x,R.x,F.x),b=Math.min(M.y,C.y,R.y,F.y),w=Math.max(M.y,C.y,R.y,F.y)}return n.emplaceBack(e.x,e.y,e.z,i.x,i.y,S,b,I,w,p,r,s,l),n.length-1}function vy(n){sy(n)&&n.collisionPadding&&(n.top-=n.collisionPadding[1],n.bottom+=n.collisionPadding[3]);let e=n.bottom-n.top;return e>0?Math.max(10,e):null}function Kw(n,e,i,r){let s=n.compareText;if(e in s){let l=s[e];for(let u=l.length-1;u>=0;u--)if(r.dist(l[u])<i)return!0}else s[e]=[];return s[e].push(r),!1}function cv(n,e){let i=n.fovAboveCenter,r=n.elevation?n.elevation.getMinElevationBelowMSL()*e:0,s=Math.min(r,n.isOrthographic?-10*e:0),l=(n._camera.position[2]*n.worldSize-s)/Math.cos(n._pitch),u=Math.sin(i)*l/Math.sin(Math.max(Math.PI/2-n._pitch-i,.01)),p=Math.sin(n._pitch)*u+l,f=l*(1/n._horizonShift);if(!n.elevation||n.elevation.exaggeration()===0){let g=Math.max(n.zoom-17,0);n.isOrthographic&&(g/=10),p*=1+g}return Math.min(1.01*p,f)}function ou(n,e){if(!e.isReprojectedInTileSpace)return{scale:1<<n.z,x:n.x,y:n.y,x2:n.x+1,y2:n.y+1,projection:e};let i=Math.pow(2,-n.z),r=n.x*i,s=(n.x+1)*i,l=n.y*i,u=(n.y+1)*i,p=Mr(r),f=Mr(s),g=zn(l),x=zn(u),b=e.project(p,g),w=e.project(f,g),S=e.project(f,x),I=e.project(p,x),M=Math.min(b.x,w.x,S.x,I.x),C=Math.min(b.y,w.y,S.y,I.y),R=Math.max(b.x,w.x,S.x,I.x),F=Math.max(b.y,w.y,S.y,I.y),L=i/16;function j($,ie,W,Q,Y,ee){let me=(W+Y)/2,ge=(Q+ee)/2,Te=e.project(Mr(me),zn(ge)),Ae=Math.max(0,M-Te.x,C-Te.y,Te.x-R,Te.y-F);M=Math.min(M,Te.x),R=Math.max(R,Te.x),C=Math.min(C,Te.y),F=Math.max(F,Te.y),Ae>L&&(j($,Te,W,Q,me,ge),j(Te,ie,me,ge,Y,ee))}j(b,w,r,l,s,l),j(w,S,s,l,s,u),j(S,I,s,u,r,u),j(I,b,r,u,r,l),M-=L,C-=L,R+=L,F+=L;let H=1/Math.max(R-M,F-C);return{scale:H,x:M*H,y:C*H,x2:R*H,y2:F*H,projection:e}}function uv(n,{x:e,y:i},r=0){return new ke(((e-r)*n.scale-n.x)*Xe,(i*n.scale-n.y)*Xe)}let Qw=Mt(new Float32Array(16));class $l{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,i){return{x:0,y:0,z:0}}unproject(e,i){return new Kt(0,0)}projectTilePoint(e,i,r){return{x:e,y:i,z:0}}locationPoint(e,i,r,s=!0){return e._coordinatePoint(e.locationCoordinate(i,r),s)}pixelsPerMeter(e,i){return lr(1,e)*i}pixelSpaceConversion(e,i,r){return 1}farthestPixelDistance(e){return cv(e,e.pixelsPerMeter)}pointCoordinate(e,i,r,s){let l=e.horizonLineFromTop(!1),u=new ke(i,Math.max(l,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(u,s))}pointCoordinate3D(e,i,r){let s=new ke(i,r);if(e.elevation)return e.elevation.pointCoordinate(s);{let l=this.pointCoordinate(e,s.x,s.y,0);return[l.x,l.y,l.z]}}isPointAboveHorizon(e,i){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,i.x,i.y);let r=e.horizonLineFromTop();return i.y<r}createInversionMatrix(e,i){return Qw}createTileMatrix(e,i,r){let s,l,u,p=r.canonical,f=Mt(new Float64Array(16));if(this.isReprojectedInTileSpace){let g=ou(p,this);s=1,l=g.x+r.wrap*g.scale,u=g.y,Yn(f,f,[s/g.scale,s/g.scale,e.pixelsPerMeter/i])}else s=i/e.zoomScale(p.z),l=(p.x+Math.pow(2,p.z)*r.wrap)*s,u=p.y*s;return $n(f,f,[l,u,0]),Yn(f,f,[s/Xe,s/Xe,1]),f}upVector(e,i,r){return[0,0,1]}upVectorScale(e,i,r){return{metersToTile:1}}}class eT extends $l{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];let[i,r]=this.parallels=e.parallels||[29.5,45.5],s=Math.sin(V(i));this.n=(s+Math.sin(V(r)))/2,this.c=1+s*(2*this.n-s),this.r0=Math.sqrt(this.c)/this.n}project(e,i){let{n:r,c:s,r0:l}=this,u=V(e-this.center[0]),p=V(i),f=Math.sqrt(s-2*r*Math.sin(p))/r;return{x:f*Math.sin(u*r),y:f*Math.cos(u*r)-l,z:0}}unproject(e,i){let{n:r,c:s,r0:l}=this,u=l+i,p=Math.atan2(e,Math.abs(u))*Math.sign(u);u*r<0&&(p-=Math.PI*Math.sign(e)*Math.sign(u));let f=V(this.center[0])*r;p=Ne(p,-Math.PI-f,Math.PI-f);let g=ne(X(p/r)+this.center[0],-180,180),x=Math.asin(ne((s-(e*e+u*u)*r*r)/(2*r),-1,1)),b=ne(X(x),-85.051129,Cr);return new Kt(g,b)}}let Lp=1.340264,zp=-.081106,Op=893e-6,Fp=.003796,x_=Math.sqrt(3)/2;class tT extends $l{project(e,i){i=i/180*Math.PI,e=e/180*Math.PI;let r=Math.asin(x_*Math.sin(i)),s=r*r,l=s*s*s;return{x:.5*(e*Math.cos(r)/(x_*(Lp+3*zp*s+l*(7*Op+9*Fp*s)))/Math.PI+.5),y:1-.5*(r*(Lp+zp*s+l*(Op+Fp*s))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,s=r*r,l=s*s*s;for(let x,b,w,S=0;S<12&&(b=r*(Lp+zp*s+l*(Op+Fp*s))-i,w=Lp+3*zp*s+l*(7*Op+9*Fp*s),x=b/w,r=ne(r-x,-Math.PI/3,Math.PI/3),s=r*r,l=s*s*s,!(Math.abs(x)<1e-12));++S);
7let u=x_*e*(Lp+3*zp*s+l*(7*Op+9*Fp*s))/Math.cos(r),p=Math.asin(Math.sin(r)/x_),f=ne(180*u/Math.PI,-180,180),g=ne(180*p/Math.PI,-85.051129,Cr);return new Kt(f,g)}}class iT extends $l{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){return{x:.5+e/360,y:.5-i/360,z:0}}unproject(e,i){let r=360*(e-.5),s=ne(360*(.5-i),-85.051129,Cr);return new Kt(r,s)}}let Eh=Math.PI/2;function v_(n){return Math.tan((Eh+n)/2)}class nT extends $l{constructor(e){super(e),this.center=e.center||[0,30];let[i,r]=this.parallels=e.parallels||[30,30],s=V(i),l=V(r);this.southernCenter=s+l<0,this.southernCenter&&(s=-s,l=-l);let u=Math.cos(s),p=v_(s);this.n=s===l?Math.sin(s):Math.log(u/Math.cos(l))/Math.log(v_(l)/p),this.f=u*Math.pow(v_(s),this.n)/this.n}project(e,i){i=V(i),this.southernCenter&&(i=-i),e=V(e-this.center[0]);let r=1e-6,{n:s,f:l}=this;l>0?i<-Eh+r&&(i=-Eh+r):i>Eh-r&&(i=Eh-r);let u=l/Math.pow(v_(i),s),p=u*Math.sin(s*e),f=l-u*Math.cos(s*e);return p=.5*(p/Math.PI+.5),f=.5*(f/Math.PI+.5),{x:p,y:this.southernCenter?f:1-f,z:0}}unproject(e,i){e=(2*e-.5)*Math.PI,this.southernCenter&&(i=1-i),i=(2*(1-i)-.5)*Math.PI;let{n:r,f:s}=this,l=s-i,u=Math.sign(l),p=Math.sign(r)*Math.sqrt(e*e+l*l),f=Math.atan2(e,Math.abs(l))*u;l*r<0&&(f-=Math.PI*Math.sign(e)*u);let g=ne(X(f/r)+this.center[0],-180,180),x=ne(X(2*Math.atan(Math.pow(s/p,1/r))-Eh),-85.051129,Cr);return new Kt(g,this.southernCenter?-x:x)}}class hv extends $l{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,i){return{x:So(e),y:ko(i),z:0}}unproject(e,i){let r=Mr(e),s=zn(i);return new Kt(r,s)}}let dv=V(Cr);class rT extends $l{project(e,i){let r=(i=V(i))*i,s=r*r;return{x:.5*((e=V(e))*(.8707-.131979*r+s*(s*(.003971*r-.001529*s)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+r*(.015085+s*(.028874*r-.044475-.005916*s)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,s=25,l=0,u=r*r;do{u=r*r;let g=u*u;l=(r*(1.007226+u*(.015085+g*(.028874*u-.044475-.005916*g)))-i)/(1.007226+u*(.045255+g*(.259866*u-.311325-.005916*11*g))),r=ne(r-l,-dv,dv)}while(Math.abs(l)>1e-6&&--s>0);u=r*r;let p=ne(X(e/(.8707+u*(u*(u*u*u*(.003971-.001529*u)-.013791)-.131979))),-180,180),f=X(r);return new Kt(p,f)}}let pv=V(Cr);class oT extends $l{project(e,i){i=V(i),e=V(e);let r=Math.cos(i),s=2/Math.PI,l=Math.acos(r*Math.cos(e/2)),u=Math.sin(l)/l,p=.5*(e*s+2*r*Math.sin(e/2)/u)||0,f=.5*(i+Math.sin(i)/u)||0;return{x:.5*(p/Math.PI+.5),y:1-.5*(f/Math.PI+1),z:0}}unproject(e,i){let r=e=(2*e-.5)*Math.PI,s=i=(2*(1-i)-1)*Math.PI,l=25,u=1e-6,p=0,f=0;do{let g=Math.cos(s),x=Math.sin(s),b=2*x*g,w=x*x,S=g*g,I=Math.cos(r/2),M=Math.sin(r/2),C=2*I*M,R=M*M,F=1-S*I*I,L=F?1/F:0,j=F?Math.acos(g*I)*Math.sqrt(1/F):0,H=.5*(2*j*g*M+2*r/Math.PI)-e,$=.5*(j*x+s)-i,ie=.5*L*(S*R+j*g*I*w)+1/Math.PI,W=L*(C*b/4-j*x*M),Q=.125*L*(b*M-j*x*S*C),Y=.5*L*(w*I+j*R*g)+.5,ee=W*Q-Y*ie;p=($*W-H*Y)/ee,f=(H*Q-$*ie)/ee,r=ne(r-p,-Math.PI,Math.PI),s=ne(s-f,-pv,pv)}while((Math.abs(p)>u||Math.abs(f)>u)&&--l>0);return new Kt(X(r),X(s))}}class fv extends $l{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(V(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){let{scale:r,cosPhi:s}=this;return{x:V(e)*s*r+.5,y:-Math.sin(V(i))/s*r+.5,z:0}}unproject(e,i){let{scale:r,cosPhi:s}=this,l=-(i-.5)/r,u=ne(X((e-.5)/r)/s,-180,180),p=Math.asin(ne(l*s,-1,1)),f=ne(X(p),-85.051129,Cr);return new Kt(u,f)}}class sT extends hv{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,r){let s=ht(e,i,r);return Bi(s,s,Et(He(r))),{x:s[0],y:s[1],z:s[2]}}locationPoint(e,i,r){let s=os(i.lat,i.lng),l=hi([],s),u=r?e._centerAltitude+r:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude;zr(s,s,l,lr(1,0)*Xe*u);let p=Mt(new Float64Array(16));return xi(p,e.pixelMatrix,e.globeMatrix),Bi(s,s,p),new ke(s[0],s[1])}pixelsPerMeter(e,i){return lr(1,0)*i}pixelSpaceConversion(e,i,r){let s=lr(1,e)*i,l=mt(lr(1,45)*i,s,r);return this.pixelsPerMeter(e,i)/l}createTileMatrix(e,i,r){let s=xt(He(r.canonical));return xi(new Float64Array(16),e.globeMatrix,s)}createInversionMatrix(e,i){let{center:r}=e,s=Et(He(i));return Ho(s,s,V(r.lng)),Go(s,s,V(r.lat)),Yn(s,s,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(s)}
7pointCoordinate(e,i,r,s){return Ce(e,i,r,!0)||new Wn(0,0)}pointCoordinate3D(e,i,r){let s=this.pointCoordinate(e,i,r,0);return[s.x,s.y,s.z]}isPointAboveHorizon(e,i){return!Ce(e,i.x,i.y,!1)}farthestPixelDistance(e){let i=function(s,l){let u=s.cameraToCenterDistance,p=s._centerAltitude*l,f=s._camera,g=s._camera.forward(),x=nn([],Fi([],g,-u),[0,0,p]),b=s.worldSize/(2*Math.PI),w=[0,0,-b],S=s.width/s.height,I=Math.tan(s.fovAboveCenter),M=Fi([],f.up(),I),C=Fi([],f.right(),I*S),R=hi([],nn([],nn([],g,M),C)),F=[],L;if(new Yc(x,R).closestPointOnSphere(w,b,F)){let j=nn([],F,w),H=$i([],j,x);L=Math.cos(s.fovAboveCenter)*Dn(H)}else{let j=$i([],x,w),H=$i([],w,x);hi(H,H);let $=Dn(j)-b;L=Math.sqrt($*($+2*b));let ie=Math.acos(L/(b+$))-Math.acos(en(g,H));L*=Math.cos(ie)}return 1.01*L}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=qt(e.zoom);if(r>0){let s=cv(e,lr(1,e.center.lat)*e.worldSize),l=e.worldSize/(2*Math.PI),u=Math.max(e.width,e.height)/e.worldSize*Math.PI;return mt(i,s+l*(1-Math.cos(u)),Math.pow(r,10))}return i}upVector(e,i,r){return ht(i,r,e,1)}upVectorScale(e){return{metersToTile:fe(vt(He(e)))}}}function mv(n){let e=n.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(n.name){case"mercator":return new hv(n);case"equirectangular":return new iT(n);case"naturalEarth":return new rT(n);case"equalEarth":return new tT(n);case"winkelTripel":return new oT(n);case"albers":return i?new fv(n):new eT(n);case"lambertConformalConic":return i?new fv(n):new nT(n);case"globe":return new sT(n)}throw new Error(`Invalid projection name: ${n.name}`)}class aT{constructor(e,i){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=i,this.appearances=e;let r=e.map(s=>function(l){if(!l.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};let u=l.condition.expression;return{featureDependent:!Ma(u),stateDependent:!fl(u),zoomDependent:!rr(u,["zoom"]),pitchDependent:!rr(u,["pitch"]),brightnessDependent:!rr(u,["brightness","measure-light"]),worldviewDependent:!rr(u,["worldview"])}}(s));this.anyFeatureDependent=r.some(s=>s.featureDependent),this.anyStateDependent=r.some(s=>s.stateDependent)}update(e,i){let r=this.lastParams,s=!r||r.zoom!==e.zoom||r.pitch!==(e.pitch||0)||r.brightness!==(e.brightness||0)||r.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};let l=i&&this.anyStateDependent;if(!s&&!l&&this.lastAllFeaturesIndex!==-2)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!l){let u=this.evaluateAllFeatures(e);return u===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=u,{kind:"all-features",appearanceIndex:u})}return{kind:"per-feature"}}evaluateAllFeatures(e){for(let i=0;i<this.appearances.length;i++){let r=this.appearances[i];if(r.condition&&r.condition.evaluate(e,void 0,void 0,void 0))return i}return-1}}let lT=$s.types,cT=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Bp(n,e,i,r,s,l,u,p,f,g,x,b,w){let S=p?Math.min(ru,Math.round(p[0])):0,I=p?Math.min(ru,Math.round(p[1])):0;n.emplaceBack(e,i,Math.round(32*r),Math.round(32*s),l,u,(S<<1)+(f?1:0),0+(I<<1),16*g,16*x,256*b,256*w)}function kp(n,e,i){n.emplaceBack(e,i)}function Np(n,e,i,r,s,l,u){n.emplaceBack(e,i,r,s,l,u)}let b_=(n,e,i,r)=>{for(let s=0;s<e;s++)n.emplaceBack(i[0],i[1],i[2],r[0],r[1],r[2])};function Ih(n,e,i,r,s){n.emplaceBack(e,i,r,s),n.emplaceBack(e,i,r,s),n.emplaceBack(e,i,r,s),n.emplaceBack(e,i,r,s)}function uT(n){for(let e of n.sections)if(Fs(e.text))return!0;return!1}let Ah=12;class by{constructor(e){this.layoutVertexArray=new Vd,this.indexArray=new Yi,this.programConfigurations=e,this.segments=new pi,this.dynamicLayoutVertexArray=new js,this.opacityVertexArray=new rh,this.placedSymbolArray=new Xd,this.iconTransitioningVertexArray=new Vr,this.globeExtVertexArray=new jd,this.zOffsetVertexArray=new Lo,this.orientationVertexArray=new $d,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new Lo,this.featureIdBuffer=null,this.cachedBatchIndices=null,this.cachedBatchSegments=null}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0&&this.iconTransitioningVertexArray.length===0}getBatchGrouping(e){let i=e.get().length===this.segments.get().length;if(i&&this.cachedBatchIndices&&this.cachedBatchSegments)return{batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};let r=new Map;for(let u of e.get()){let p=u.batchIndex!==void 0?u.batchIndex:0;r.has(p)||r.set(p,[]),r.get(p).push(u)}let s=Array.from(r.keys()).sort((u,p)=>u-p),l=new Map;for(let u of s){let p=r.get(u);l.set(u,new pi(p))}return i&&(this.cachedBatchIndices=s,this.cachedBatchSegments=l),{batchIndices:s,batchSegments:l}}snapshotSymbolVertexData(e,i){let r=e*Ah;return this.layoutVertexArray.uint16.slice(r,r+i*Ah)}restoreSymbolVertexData(e,i){this.layoutVertexArray.uint16.set(i,e*Ah)}updateSymbolVertexData(e,i,r,s,l,u,p,f,g,x,b,w,S){let I=this.layoutVertexArray.uint16,M=e*Ah;I[M]=i,I[M+1]=r,I[M+2]=s,I[M+3]=l,I[M+4]=u,I[M+5]=p,I[M+6]=f,I[M+7]=g,I[M+8]=x,I[M+9]=b,I[M+10]=w,I[M+11]=S}upload(e,i,r,s,l,u){this.isEmpty()||(r&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,aw.members,!!u),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,cw.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,cT,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,pw.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,lw.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||l)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,uw.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,dw.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,hw.members,!1))),(r||s)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.upload(e)))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy())}}Qe(by,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class wy{constructor(e,i,r){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new r,this.segments=new pi,this.collisionVertexArray=new zo,this.collisionVertexArrayExt=new js}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,fw.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,mw.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.de
7stroy())}}Qe(wy,"CollisionBuffers");class No{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(u=>u.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Mt([]),this.placementViewportMatrix=Mt([]);let i=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.disableSymbolUBO=e.disableSymbolUBO,this.textSizeData=nu(this.zoom,i["text-size"],this.worldview,e.availableImages),this.iconSizeData=nu(this.zoom,i["icon-size"],this.worldview,e.availableImages);let r=this.layers[0].layout,s=r.get("symbol-sort-key"),l=r.get("symbol-z-order");this.lut=e.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey=l!=="viewport-y"&&s.constantOr(1)!==void 0,this.sortFeaturesByY=(l==="viewport-y"||l==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(u=>Yr[u]),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(e){let i=this.layers[0].getAppearances();if(!i||i.length===0)return!1;let r=Array.isArray(e)?e:[e];return i.some(s=>r.some(l=>s.hasLayoutProperty(l)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new by(new To(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new by(new To(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new iy(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new iy(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new Yd,this.lineVertexArray=new um,this.symbolInstances=new cm}calculateGlyphDependencies(e,i,r,s,l){for(let u of e){let p=u.codePointAt(0);if(p===void 0)break;if(i[p]=!0,s&&l&&p<=65535){let f=Ap[u];f&&(i[f.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,i,r,s,l,u,p){if(!e.hasLayoutProperty("icon-size"))return p*u;let f=1,g=e.getUnevaluatedLayoutProperty("icon-size"),x=nu(this.zoom,g,this.worldview,l),b=Th(x,i);if(x.kind!=="constant"&&x.kind!=="camera"||(f=b.uSize),x.kind==="composite"){let{minZoom:w,maxZoom:S}=x,I=g.possiblyEvaluate(new Jt(w,{worldview:this.worldview}),s),M=g.possiblyEvaluate(new Jt(S,{worldview:this.worldview}),s),C=I.evaluate(r,{},s,l);f=C+(M.evaluate(r,{},s,l)-C)*b.uSizeT}return x.kind==="source"&&(f=g.possiblyEvaluate(new Jt(this.zoom,{worldview:this.worldview}),s).evaluate(r,{},s,l)),f*u}updateFootprints(e,i){}updateReplacement(e,i){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;let r=i.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!Vm(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(e){return typeof e=="string"?dr.build(e):e}populate(e,i,r,s){let l=this.layers[0],u=l.layout,p=this.projection.name==="globe",f=u.get("text-font"),g=u.get("text-field"),x=u.get("icon-image"),[b,w]=u.get("icon-size-scale-range"),S=ne(i.scaleFactor||1,b,w),[I,M]=u.get("text-size-scale-range"),C=ne(i.scaleFactor||1,I,M),R=(g.value.kind!=="constant"||g.value.value instanceof Un&&!g.value.value.isEmpty()||g.value.value.toString().length>0)&&(f.value.kind!=="constant"||f.value.value.length>0),F=x.value.kind!=="constant"||!!x.value.value||Object.keys(x.parameters).length>0,L=this.hasAnyAppearanceLayoutProperty("icon-image"),j=u.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!R&&!F&&!L)return;let H=i.iconDependencies,$=i.glyphDependencies,ie=i.availableImages,W=new Jt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),Q=Y=>{let ee=Y.id.toString();H.has(ee)?H.get(ee).push(Y):H.set(ee,[Y])};for(let Y of e){let{feature:ee,id:me,index:ge,sourceLayerIndex:Te}=Y,Ae=l._featureFilter.needGeometry,Ie=qr(ee,Ae);if(!l._featureFilter.filter(W,Ie,r))continue;if(Ae||(Ie.geometry=$r(ee,r,s)),p&&ee.type!==1&&r.z<=5){let De=Ie.geometry,Ge=.98078528056,$e=(Je,tt)=>en(ht(Je.x,Je.y,r,1),ht(tt.x,tt.y,r,1))<Ge;
7for(let Je=0;Je<De.length;Je++)De[Je]=hh(De[Je],$e)}let Be,xe;if(R){let De=l.getValueAndResolveTokens("text-field",Ie,r,ie),Ge=Un.factory(De);uT(Ge)&&(this.hasRTLText=!0),(!this.hasRTLText||Qu()==="unavailable"||this.hasRTLText&&ts.isParsed())&&(Be=gw(Ge,l,Ie))}if(F){let De=l.getValueAndResolveTokens("icon-image",Ie,r,ie);xe=this.getResolvedImageFromTokens(De)}let Se=this.layers[0],Me=!1;if(!xe&&L){let De=Se.getAppearances();for(let Ge of De)if(Ge.getLayoutProperty("icon-image")){let $e=Se.getAppearanceValueAndResolveTokens(Ge,"icon-image",Ie,r,ie);if($e){xe=this.getResolvedImageFromTokens($e),Me=!0;break}}}if(!Be&&!xe)continue;let Le=this.sortFeaturesByKey?j.evaluate(Ie,{},r):void 0,ze={id:me,text:Be,icon:xe,index:ge,sourceLayerIndex:Te,geometry:Ie.geometry,properties:ee.properties,type:lT[ee.type],sortKey:Le};if(this.features.push(ze),this.featureAppearanceData.set(ge,{id:me,properties:ee.properties,usesAppearanceIconAsPlaceholder:Me}),xe){let De=Se._unevaluatedLayout._values,{iconPrimary:Ge,iconSecondary:$e}=Rp(xe,this.iconSizeData,De["icon-size"],r,this.zoom,ze,this.pixelRatio,S,this.worldview,ie);Q(Ge),$e&&(this.hasAnySecondaryIcon=!0,Q($e))}let We=Se.getAppearances();if(We.length!==0&&We.forEach(De=>{if(!De.getLayoutProperty("icon-image"))return;let Ge=this.getCombinedIconPrimary(De,Se,Ie,r,ie,ze,S);Ge&&Q(Ge)}),Be){let De=f.evaluate(Ie,{},r).join(","),Ge=u.get("text-rotation-alignment")==="map"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(Yr.vertical);for(let $e of Be.sections)if($e.image){let Je=$e.image.getPrimary().scaleSelf(this.pixelRatio*C),tt=Je.id.toString(),ct=H.get(tt)||[];ct.push(Je),H.set(tt,ct)}else{let Je=Xu(Be.toString()),tt=$e.fontStack||De,ct=$[tt]=$[tt]||{};this.calculateGlyphDependencies($e.text,ct,Ge,this.allowVerticalPlacement,Je)}}}if(u.get("symbol-placement")==="line"&&(this.features=function(Y){let ee={},me={},ge=[],Te=0;function Ae(Se){ge.push(Y[Se]),Te++}function Ie(Se,Me,Le){let ze=me[Se];return delete me[Se],me[Me]=ze,ge[ze].geometry[0].pop(),ge[ze].geometry[0]=ge[ze].geometry[0].concat(Le[0]),ze}function Be(Se,Me,Le){let ze=ee[Me];return delete ee[Me],ee[Se]=ze,ge[ze].geometry[0].shift(),ge[ze].geometry[0]=Le[0].concat(ge[ze].geometry[0]),ze}function xe(Se,Me,Le){let ze=Le?Me[0].at(-1):Me[0][0];return`${Se}:${ze.x}:${ze.y}`}for(let Se=0;Se<Y.length;Se++){let Me=Y[Se],Le=Me.geometry,ze=Me.text?Me.text.toString():null;if(!ze){Ae(Se);continue}let We=xe(ze,Le),De=xe(ze,Le,!0);if(We in me&&De in ee&&me[We]!==ee[De]){let Ge=Be(We,De,Le),$e=Ie(We,De,ge[Ge].geometry);delete ee[We],delete me[De],me[xe(ze,ge[$e].geometry,!0)]=$e,ge[Ge].geometry=null}else We in me?Ie(We,De,Le):De in ee?Be(We,De,Le):(Ae(Se),ee[We]=Te-1,me[De]=Te-1)}return ge.filter(Se=>Se.geometry)}(this.features)),u.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",i.elevationFeatures){!this.elevationFeatures&&i.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(let Y of i.elevationFeatures)this.elevationFeatureIdToIndex.set(Y.id,this.elevationFeatures.length),this.elevationFeatures.push(Y)}}else u.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((Y,ee)=>Y.sortKey-ee.sortKey)}getCombinedIconPrimary(e,i,r,s,l,u,p){let f,g;if(e.hasLayoutProperty("icon-image")){let x=i.getAppearanceValueAndResolveTokens(e,"icon-image",r,s,l);f=this.getResolvedImageFromTokens(x)}else{let x=i.getValueAndResolveTokens("icon-image",r,s,l);f=this.getResolvedImageFromTokens(x)}if(f){let x=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):i._unevaluatedLayout._values["icon-size"];g=Rp(f,nu(this.zoom,x,this.worldview,l),x,s,this.zoom,u,this.pixelRatio,p,this.worldview,l).iconPrimary}return g}updateSymbolInstanceIconVertices(e,i,r,s,l,u){let{canonical:p,availableImages:f,globalProperties:g,layer:x,iconScaleFactor:b,featureState:w,layoutIconOffset:S,layoutIconSize:I,layoutIconRotate:M}=u;if(e.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(i.activeAppearanceIndex===r)return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1};let C=r>=0?x.appearances[r]:null;if(C){let R=this.getCombinedIconPrimary(C,x,s,p,f,{sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:i.properties,type:"Point",id:i.id},b);if(!R)return{vertexOffsetDelta:0,hasChanges:!1};let F=R.toString(),L=this.iconAtlasPositions&&this.iconAtlasPositions.get(F);if(L){let{appearanceIconOffset:j,appearanceIconRotate:H}=iv(C,x,s,p,S,M,I,b),$=u_(L,void 0,j,x.layout.get("icon-anchor").evaluate(s,w,p)),ie=L.sdf,W=x.layout.get("icon-text-fit").constantOr("none");W!=="none"&&i.textShaping&&i.iconTextFitPadding&&i.fontScale&&($=ay($,i.textShaping,W,i.iconTextFitPadding,j,i.fontScale));
7let Q=this.calculateEffectiveAppearanceIconSize(C,g.zoom,s,p,f,b,I),Y=0,ee=1+(Math.min(ru,Math.round(Q*Ha))<<1),me=my($,H,ie,W!=="none",b);i.isUsingAppearanceIconVertexData||(i.isUsingAppearanceIconVertexData=!0,i.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(l,e.numIconVertices));let ge=Math.floor(e.numIconVertices/4),Te=Math.min(me.length,ge),Ae=l;for(let Be=0;Be<Te;++Be){let xe=me[Be],Se=i.layoutBasedIconVertexData[0]||e.tileAnchorX,Me=i.layoutBasedIconVertexData[1]||e.tileAnchorY,Le=16*xe.pixelOffsetTL.x,ze=16*xe.pixelOffsetTL.y,We=16*xe.pixelOffsetBR.x,De=16*xe.pixelOffsetBR.y,Ge=16*xe.minFontScaleX,$e=16*xe.minFontScaleY;this.icon.updateSymbolVertexData(Ae,Se,Me,Math.round(32*xe.tl.x),Math.round(32*xe.tl.y),xe.texPrimary.x,xe.texPrimary.y,Y,ee,Le,ze,Ge,$e),this.icon.updateSymbolVertexData(Ae+1,Se,Me,Math.round(32*xe.tr.x),Math.round(32*xe.tr.y),xe.texPrimary.x+xe.texPrimary.w,xe.texPrimary.y,Y,ee,We,ze,Ge,$e),this.icon.updateSymbolVertexData(Ae+2,Se,Me,Math.round(32*xe.bl.x),Math.round(32*xe.bl.y),xe.texPrimary.x,xe.texPrimary.y+xe.texPrimary.h,Y,ee,Le,De,Ge,$e),this.icon.updateSymbolVertexData(Ae+3,Se,Me,Math.round(32*xe.br.x),Math.round(32*xe.br.y),xe.texPrimary.x+xe.texPrimary.w,xe.texPrimary.y+xe.texPrimary.h,Y,ee,We,De,Ge,$e),Ae+=4}let Ie=e.numIconVertices-4*Te;for(let Be=0;Be<Ie;++Be)this.icon.updateSymbolVertexData(Ae+Be,0,0,0,0,0,0,0,0,0,0,0,0);return{vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}}else{if(i.usesAppearanceIconAsPlaceholder)return this.icon.updateSymbolVertexData(l,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(l+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(l+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(l+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:e.numIconVertices,hasChanges:!0};if(i.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(l,i.layoutBasedIconVertexData),i.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:i.layoutBasedIconVertexData.length/Ah,hasChanges:!0}}return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(e,i,r,s,l,u){let{canonical:p,layer:f,textScaleFactor:g,imageMap:x,featureState:b,layoutTextOffset:w,layoutTextSize:S,layoutTextRotate:I,layoutMinZoomSize:M,layoutMaxZoomSize:C,layoutTextSizeMinZoom:R,layoutTextSizeMaxZoom:F,availableImages:L}=u,j=e.numHorizontalGlyphVertices>0||e.numVerticalGlyphVertices>0;if(!j)return{vertexOffsetDelta:j?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(i.activeAppearanceIndex===r)return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};let H=r>=0?f.appearances[r]:null;if(H&&i.textShaping){let{appearanceTextOffset:$,appearanceTextRotate:ie,appearanceTextSize:W}=nv(H,f,s,p,w,I,S);i.fontScale=av(W,i.textScaleFactor);let Q=H.getUnevaluatedLayoutProperty("text-size"),Y=this.textSizeData,ee=R,me=F;H.hasLayoutProperty("text-size")&&(Y=nu(this.zoom,Q,this.worldview,L),ee=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,me=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);let ge=i.textShaping.bottom-w[1],Te=i.textShaping.left-w[0],Ae=i.textShaping.right-w[0];i.textShaping.top=$[1]+(i.textShaping.top-w[1]),i.textShaping.bottom=$[1]+ge,i.textShaping.left=$[0]+Te,i.textShaping.right=$[0]+Ae;let Ie=ev(0,i.textShaping,$,f,!1,s,x,this.allowVerticalPlacement,ie),Be=W&&Y.kind==="composite"?Q.possiblyEvaluate(new Jt(ee,{}),p).evaluate(s,b,p):M,xe=W&&Y.kind==="composite"?Q.possiblyEvaluate(new Jt(me,{}),p).evaluate(s,b,p):C,Se=xy(H.name,Y,W,g,Be,xe),Me=Array.isArray(Se)?Se[1]:W,Le=0,ze=1+(Math.min(ru,Math.round(Me*Ha))<<1);i.isUsingAppearanceTextVertexData||(i.isUsingAppearanceTextVertexData=!0,i.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(l,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let We=0;We<Ie.length&&We<(e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices)/4;++We){let De=Ie[We],Ge=De.glyphOffset[1],$e=e.tileAnchorX,Je=e.tileAnchorY,tt=l+4*We;this.text.updateSymbolVertexData(tt,$e,Je,Math.round(32*De.tl.x),Math.round(32*(Ge+De.tl.y)),De.texPrimary.x,De.texPrimary.y,Le,ze,De.pixelOffsetTL.x,De.pixelOffsetTL.y,De.minFontScaleX,De.minFontScaleY),this.text.updateSymbolVertexData(tt+1,$e,Je,Math.round(32*De.tr.x),Math.round(32*(Ge+De.tr.y)),De.texPrimary.x+De.texPrimary.w,De.texPrimary.y,Le,ze,De.pixelOffsetBR.x,De.pixelOffsetTL.y,De.minFontScaleX,De.minFontScaleY),this.text.updateSymbolVertexData(tt+2,$e,Je,Math.round(32*De.bl.x),Math.round(32*(Ge+De.bl.y)),De.texPrimary.x,De.texPrimary.y+De.texPrimary.h,Le,ze,De.pixelOffsetTL.x,De.pixelOffsetBR.y,De.minFontScaleX,De.minFontScaleY),this.text.updateSymbolVertexData(tt+3,$e,Je,Math.round(32*De.br.x),Math.round(32*(Ge+De.br.y)),De.texPrimary.x+De.texPrimary.w,De.texPrimary.y+De.texPrimary.h,Le,ze,De.pixelOffsetBR.x,De.pixelOffsetBR.y,De.minFontScaleX,De.minFontScaleY)}return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!0}}return i.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(l,i.layoutBasedTextVertexData),i.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:i.layoutBasedTextVertexData.length/Ah,hasChanges:!0}):{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1}}updateExpressions(e){this.text&&this.text.programConfigurations.updateExpressions(e),this.icon&&this.icon.programConfigurations.updateExpressions(e)}update(e,i,r,s,l,u,p,f){if(this.text.uboBinder||this.text.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,this.worldview),this.icon.uboBinder||this.icon.programConfigurations.updatePaintArrays(e,i,l,r,s,u,p,this.worldview),f){if(u)this.text.uboBinder&&!this.text.uboBinder.isLightConstant&&this.text.uboBinder.updateDynamicExpressions(l[0],i,f,r,e,p),this.icon.uboBinder&&!this.icon.uboBinder.isLightConstant&&this.icon.uboBinder.updateDynamicExpressions(l[0],i,f,r,e,p);else if(Object.keys(e).length>0){let g=new Set(Object.keys(e).map(x=>{let b=Number(x);return!isNaN(b)&&Number.isSafeInteger(b)&&String(b)===x?b:x}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(g,l[0],i,f,r,e,p),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(g,l[0],i,f,r,e,p)}}}updateRoadElevation(e){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let i=!1,r=Hr(e),s=1/r,l=!1,u=!1;for(let p=0;p<this.symbolInstances.length;p++){let f=this.symbolInstances.get(p),g=kn(1,0,0),x=kn(0,1,0),{numHorizontalGlyphVertices:b,numVerticalGlyphVertices:w,numIconVertices:S,numVerticalIconVertices:I}=f,M=b>0||w>0,C=S>0,R=this.elevationFeatures[f.elevationFeatureIndex];if(R){let F=new ke(f.tileAnchorX,f.tileAnchorY),L=.075+R.pointElevation(F);f.zOffset!==L&&(i=!0,f.zOffset=L),L!==0&&(this.hasAnyZOffset=!0);let j=R.computeSlopeNormal(F,s),H=oc(ys(),kn(0,0,1),j);Za(g,g,H),Za(x,x,H),g[2]*=r,x[2]*=r,g[0]===1&&g[1]===0&&g[2]===0&&x[0]===0&&x[1]===1&&x[2]===0||(l=l||M,u=u||C)}if(M&&(b_(this.text.orientationVertexArray,b,g,x),b_(this.text.orientationVertexArray,w,g,x)),C){let{placedIconSymbolIndex:F,verticalPlacedIconSymbolIndex:L}=f;F>=0&&b_(this.icon.orientationVertexArray,S,g,x),L>=0&&b_(this.icon.orientationVertexArray,I,g,x)}}l||(this.text.orientationVertexArray=void 0),u||(this.icon.orientationVertexArray=void 0),i&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){let e=(l,u,p)=>{r+=u,r>l.length&&l.resize(r);for(let f=-u;f<0;f++)l.emplace(f+r,p)},i=(l,u,p)=>{s+=u,s>l.length&&l.resize(s);for(let f=-u;f<0;f++)l.emplace(f+s,p)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,s=0;for(let l=0;l<this.symbolInstances.length;l++){let u=this.symbolInstances.get(l),{numHorizontalGlyphVertices:p,numVerticalGlyphVertices:f,numIconVertices:g}=u,x=u.zOffset,b=g>0;if((p>0||f>0)&&(e(this.text.zOffsetVertexArray,p,x),e(this.text.zOffsetVertexArray,f,x)),b){let{placedIconSymbolIndex:w,verticalPlacedIconSymbolIndex:S}=u;w>=0&&i(this.icon.zOffsetVertexArray,g,x),S>=0&&i(this.icon.zOffsetVertexArray,u.numVerticalIconVertices,x)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,i,r,s,l){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(u=>u.appearances&&u.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(e,i,r,s,l,u=!1){let p={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!r||!this.featureAppearanceData)return p;let f=i||{},g=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,x=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!g&&!x)return p;let b=this.layers[0],w=b.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===b.appearancesVersion||(this.featureAppearances=new aT(b.appearances,b.appearancesVersion));let S=this.featureAppearances.update(s,u);if(S.kind==="no-changes")return p;let I=1,M=0,C=!1,R=!1;if(g){let[$,ie]=w.get("icon-size-scale-range");I=ne(1,$,ie)}let F=1,L=0,j=!1;if(x){let[$,ie]=w.get("text-size-scale-range");F=ne(1,$,ie)}let H=new Map;if(l&&r)for(let $ of r){let ie=l.getImage($,b.scope);if(ie){let W=new wr($.toString());H.set(W.toString(),ie)}}for(let $=0;$<this.symbolInstances.length;$++){let ie=this.symbolInstances.get($),W=this.getAppearanceFeatureData(ie.featureIndex);if(!W)continue;let Q=W.id,Y=Q!==void 0?f[String(Q)]:void 0,ee={type:"Point",id:W.id,properties:W.properties,geometry:[]},me;if(S.kind==="all-features")me=S.appearanceIndex;else{let Te=b.appearances?b.appearances.findIndex(Ae=>Ae.isActive({globals:s,feature:ee,canonical:e,featureState:Y})):-1;me=Te>=0?Te:-1}let ge=W.activeAppearanceIndex!==me;if(x){let Te=w.get("text-size"),Ae=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,Ie=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,Be={canonical:e,layer:b,featureState:Y,availableImages:r,textScaleFactor:F,imageMap:H,layoutTextOffset:w.get("text-offset").evaluate(ee,Y,e).map(Se=>Se*wn),layoutTextSize:Te.evaluate(ee,Y,e),layoutTextRotate:w.get("text-rotate").evaluate(ee,Y,e),layoutMinZoomSize:Te.evaluate(ee,{zoom:Ae},e),layoutMaxZoomSize:Te.evaluate(ee,{zoom:Ie},e),layoutTextSizeMinZoom:Ae,layoutTextSizeMaxZoom:Ie},xe=this.updateSymbolInstanceTextVertices(ie,W,me,ee,L,Be);L+=xe.vertexOffsetDelta,j=j||xe.hasChanges}if(g){let Te={canonical:e,layer:b,featureState:Y,availableImages:r,globalProperties:s,iconScaleFactor:I,layoutIconOffset:w.get("icon-offset").evaluate(ee,Y,e),layoutIconSize:w.get("icon-size").evaluate(ee,Y,e,r),layoutIconRotate:w.get("icon-rotate").evaluate(ee,Y,e)},Ae=this.updateSymbolInstanceIconVertices(ie,W,me,ee,M,Te);M+=Ae.vertexOffsetDelta,C=C||Ae.hasChanges}if(ge){let Te=ie.featureIndex,Ae=s?s.brightness:null,Ie=Y||{},Be=me>=0?b.appearances[me]:null;this.text.uboBinder&&(this.text.uboBinder.layer=b,R=this.text.uboBinder.updateFeaturePaintForAppearance(Te,ee,Ie,e,r,Ae,Be)||R),this.icon.uboBinder&&(this.icon.uboBinder.layer=b,R=this.icon.uboBinder.updateFeaturePaintForAppearance(Te,ee,Ie,e,r,Ae,Be)||R)}W.activeAppearanceIndex=me}return C&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),j&&this.text.layoutVertexBuffer&&this.text.layoutVertexArray.arrayBuffer!==null&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:C||j,hasUboChanges:R}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=mv(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){let r=this.lineVertexArray.length;if(e.segment!==void 0)for(let{x:s,y:l}of i)this.lineVertexArray.emplaceBack(s,l);return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,i,r,s,l,u,p,f,g,x,b,w,S,I,M,C,R,F){let L=e.indexArray,j=e.layoutVertexArray,H=e.globeExtVertexArray,$=F,ie=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,W=e.segments.prepareSegment(4*$,j,L,this.canOverlap?u.sortKey:void 0,ie),Q=this.glyphOffsetArray.length,Y=W.vertexLength,ee=this.allowVerticalPlacement&&p===Yr.vertical?Math.PI/2:0,me=u.text&&u.text.sections,ge=j.length,Te=-1;for(let Be=0;Be<i.length;Be++){let{tl:xe,tr:Se,bl:Me,br:Le,texPrimary:ze,texSecondary:We,pixelOffsetTL:De,pixelOffsetBR:Ge,minFontScaleX:$e,minFontScaleY:Je,glyphOffset:tt,isSDF:ct,sectionIndex:rt}=i[Be],ft=W.vertexLength,Zt=tt[1];if(Bp(j,g.x,g.y,xe.x,Zt+xe.y,ze.x,ze.y,r,ct,De.x,De.y,$e,Je),Bp(j,g.x,g.y,Se.x,Zt+Se.y,ze.x+ze.w,ze.y,r,ct,Ge.x,De.y,$e,Je),Bp(j,g.x,g.y,Me.x,Zt+Me.y,ze.x,ze.y+ze.h,r,ct,De.x,Ge.y,$e,Je),Bp(j,g.x,g.y,Le.x,Zt+Le.y,ze.x+ze.w,ze.y+ze.h,r,ct,Ge.x,Ge.y,$e,Je),f){let{x:St,y:Ut,z:Pt}=f.anchor,[ji,Qt,$t]=f.up;Np(H,St,Ut,Pt,ji,Qt,$t),Np(H,St,Ut,Pt,ji,Qt,$t),Np(H,St,Ut,Pt,ji,Qt,$t),Np(H,St,Ut,Pt,ji,Qt,$t),Ih(e.dynamicLayoutVertexArray,St,Ut,Pt,ee)}else Ih(e.dynamicLayoutVertexArray,g.x,g.y,g.z,ee);if(C){let St=We||ze;kp(e.iconTransitioningVertexArray,St.x,St.y),kp(e.iconTransitioningVertexArray,St.x+St.w,St.y),kp(e.iconTransitioningVertexArray,St.x,St.y+St.h),kp(e.iconTransitioningVertexArray,St.x+St.w,St.y+St.h)}if(L.emplaceBack(ft,ft+1,ft+2),L.emplaceBack(ft+1,ft+2,ft+3),W.vertexLength+=4,W.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(tt[0]),(Be===i.length-1||rt!==i[Be+1].sectionIndex)&&(e.uboBinder||e.programConfigurations.populatePaintArrays(j.length,u,u.index,{},S,I,M,me&&me[rt],this.worldview),e.uboBinder&&e.featureIdArray)){let St=e.uboBinder.populateUBO(u,u.index,I,S,M,me&&me[rt],void 0);Te=St;let Ut=j.length-ge;for(let Pt=0;Pt<Ut;Pt++)e.featureIdArray.emplaceBack(St);ge=j.length}}let Ae=F-i.length;if(Ae!==0&&(this._addNullVertices(Ae,j,r,f,H,e,C,W,L),e.uboBinder&&e.featureIdArray&&Te>=0)){let Be=4*Ae;for(let xe=0;xe<Be;xe++)e.featureIdArray.emplaceBack(Te)}let Ie=f?f.anchor:g;e.placedSymbolArray.emplaceBack(Ie.x,Ie.y,Ie.z,g.x,g.y,Q,this.glyphOffsetArray.length-Q,Y,x,b,g.segment,r?r[0]:0,r?r[1]:0,s[0],s[1],p,0,0,0,w,0),e.symbolInstanceIndices.push(R)}_addNullVertices(e,i,r,s,l,u,p,f,g){for(let x=0;x<e;x++){for(let w=0;w<4;w++)Bp(i,0,0,0,0,0,0,r,!1,0,0,0,0),s&&Np(l,0,0,0,0,0,0),Ih(u.dynamicLayoutVertexArray,0,0,0,0),p&&kp(u.iconTransitioningVertexArray,0,0);let b=f.vertexLength;g.emplaceBack(b,b+1,b+2),g.emplaceBack(b+1,b+2,b+3),f.vertexLength+=4,f.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(e,i,r,s,l,u,p){e.emplaceBack(i,r,s,l,u,Math.round(p.x),Math.round(p.y))}_addCollisionDebugVertices(e,i,r,s,l,u,p){let f=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),g=f.vertexLength,x=p.tileAnchorX,b=p.tileAnchorY;for(let S=0;S<4;S++)r.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(r.collisionVertexArrayExt,i,e.padding,p.zOffset),this._commitLayoutVertex(r.layoutVertexArray,s,l,u,x,b,new ke(e.x1,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,s,l,u,x,b,new ke(e.x2,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,s,l,u,x,b,new ke(e.x2,e.y2)),this._commitLayoutVertex(r.layoutVertexArray,s,l,u,x,b,new ke(e.x1,e.y2)),f.vertexLength+=4;let w=r.indexArray;w.emplaceBack(g,g+1),w.emplaceBack(g+1,g+2),w.emplaceBack(g+2,g+3),w.emplaceBack(g+3,g),f.primitiveLength+=4}_addTextDebugCollisionBoxes(e,i,r,s,l,u){for(let p
7=s;p<l;p++){let f=r.get(p),g=this.getSymbolInstanceTextSize(e,u,i,p);this._addCollisionDebugVertices(f,g,this.textCollisionBox,f.projectedAnchorX,f.projectedAnchorY,f.projectedAnchorZ,u)}}_addIconDebugCollisionBoxes(e,i,r,s,l,u){for(let p=s;p<l;p++){let f=r.get(p),g=this.getSymbolInstanceIconSize(e,i,u.placedIconSymbolIndex);this._addCollisionDebugVertices(f,g,this.iconCollisionBox,f.projectedAnchorX,f.projectedAnchorY,f.projectedAnchorZ,u)}}generateCollisionDebugBuffers(e,i,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new wy(oh,Ax.members,Vr),this.iconCollisionBox=new wy(oh,Ax.members,Vr);let s=Th(this.iconSizeData,e),l=Th(this.textSizeData,e,r);for(let u=0;u<this.symbolInstances.length;u++){let p=this.symbolInstances.get(u);this._addTextDebugCollisionBoxes(l,e,i,p.textBoxStartIndex,p.textBoxEndIndex,p),this._addTextDebugCollisionBoxes(l,e,i,p.verticalTextBoxStartIndex,p.verticalTextBoxEndIndex,p),this._addIconDebugCollisionBoxes(s,e,i,p.iconBoxStartIndex,p.iconBoxEndIndex,p),this._addIconDebugCollisionBoxes(s,e,i,p.verticalIconBoxStartIndex,p.verticalIconBoxEndIndex,p)}}getSymbolInstanceTextSize(e,i,r,s){let l=this.text.placedSymbolArray.get(i.rightJustifiedTextSymbolIndex>=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:s),u=ly(this.textSizeData,e,l)/wn;return this.tilePixelRatio*u}getSymbolInstanceIconSize(e,i,r){let s=this.icon.placedSymbolArray.get(r),l=ly(this.iconSizeData,e,s);return this.tilePixelRatio*l}
7_commitDebugCollisionVertexUpdate(e,i,r,s){e.emplaceBack(i,-r,-r,s),e.emplaceBack(i,r,-r,s),e.emplaceBack(i,r,r,s),e.emplaceBack(i,-r,r,s)}_updateTextDebugCollisionBoxes(e,i,r,s,l,u,p){for(let f=s;f<l;f++){let g=r.get(f),x=this.getSymbolInstanceTextSize(e,u,i,f);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,x,g.padding,u.zOffset)}}_updateIconDebugCollisionBoxes(e,i,r,s,l,u,p){for(let f=s;f<l;f++){let g=r.get(f),x=this.getSymbolInstanceIconSize(e,i,u.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,x,g.padding,u.zOffset)}}updateCollisionDebugBuffers(e,i,r,s){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();let l=Th(this.iconSizeData,e,s),u=Th(this.textSizeData,e,r);for(let p=0;p<this.symbolInstances.length;p++){let f=this.symbolInstances.get(p);this._updateTextDebugCollisionBoxes(u,e,i,f.textBoxStartIndex,f.textBoxEndIndex,f,r),this._updateTextDebugCollisionBoxes(u,e,i,f.verticalTextBoxStartIndex,f.verticalTextBoxEndIndex,f,r),this._updateIconDebugCollisionBoxes(l,e,i,f.iconBoxStartIndex,f.iconBoxEndIndex,f,s),this._updateIconDebugCollisionBoxes(l,e,i,f.verticalIconBoxStartIndex,f.verticalIconBoxEndIndex,f,s)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,i,r,s,l,u,p,f,g){let x={};if(i<r){let{x1:b,y1:w,x2:S,y2:I,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:L,tileAnchorY:j,featureIndex:H}=e.get(i);x.textBox={x1:b,y1:w,x2:S,y2:I,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:L,tileAnchorY:j},x.textFeatureIndex=H}if(s<l){let{x1:b,y1:w,x2:S,y2:I,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:L,tileAnchorY:j,featureIndex:H}=e.get(s);x.verticalTextBox={x1:b,y1:w,x2:S,y2:I,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:L,tileAnchorY:j},x.verticalTextFeatureIndex=H}if(u<p){let{x1:b,y1:w,x2:S,y2:I,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:L,tileAnchorY:j,featureIndex:H}=e.get(u);x.iconBox={x1:b,y1:w,x2:S,y2:I,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:L,tileAnchorY:j},x.iconFeatureIndex=H}if(f<g){let{x1:b,y1:w,x2:S,y2:I,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:L,tileAnchorY:j,featureIndex:H}=e.get(f);x.verticalIconBox={x1:b,y1:w,x2:S,y2:I,padding:M,projectedAnchorX:C,projectedAnchorY:R,projectedAnchorZ:F,tileAnchorX:L,tileAnchorY:j},x.verticalIconFeatureIndex=H}return x}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){let r=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,i){let r=e.placedSymbolArray.get(i),s=r.vertexStartIndex+4*r.numGlyphs;for(let l=r.vertexStartIndex;l<s;l+=4)e.indexArray.emplaceBack(l,l+1,l+2),e.indexArray.emplaceBack(l+1,l+2,l+3)}
7getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;let i=Math.sin(e),r=Math.cos(e),s=[],l=[],u=[];for(let p=0;p<this.symbolInstances.length;++p){u.push(p);let f=this.symbolInstances.get(p);s.push(0|Math.round(i*f.tileAnchorX+r*f.tileAnchorY)),l.push(f.featureIndex)}return u.sort((p,f)=>s[p]-s[f]||l[f]-l[p]),u}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e)}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort((e,i)=>this.symbolInstances.get(i).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,i){let r=this.sortKeyRanges.at(-1);r&&r.sortKey===i?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(let i of this.symbolInstanceIndexes){let r=this.symbolInstances.get(i);this.featureSortOrder.push(r.featureIndex);let{rightJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:l,leftJustifiedTextSymbolIndex:u,verticalPlacedTextSymbolIndex:p,placedIconSymbolIndex:f,verticalPlacedIconSymbolIndex:g}=r;s>=0&&this.addIndicesForPlacedSymbol(this.text,s),l>=0&&l!==s&&this.addIndicesForPlacedSymbol(this.text,l),u>=0&&u!==l&&u!==s&&this.addIndicesForPlacedSymbol(this.text,u),p>=0&&this.addIndicesForPlacedSymbol(this.text,p),f>=0&&this.addIndicesForPlacedSymbol(this.icon,f),g>=0&&this.addIndicesForPlacedSymbol(this.icon,g)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getOrCreateSortedSymbolsByBatch(e,i){let r=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(let s of this.symbolsByBatch.values())for(let l of s){let u=this.symbolInstances.get(l.index);l.rotatedY=0|Math.round(e*u.tileAnchorX+i*u.tileAnchorY)}else{this.symbolsByBatch=new Map;for(let s=0;s<this.symbolInstances.length;s++){let l=this.symbolInstances.get(s),u=Math.floor(s/r),p=0|Math.round(e*l.tileAnchorX+i*l.tileAnchorY);this.symbolsByBatch.has(u)||this.symbolsByBatch.set(u,[]),this.symbolsByBatch.get(u).push({index:s,rotatedY:p,featureIndex:l.featureIndex})}}for(let s of this.symbolsByBatch.values())s.sort((l,u)=>l.rotatedY-u.rotatedY||u.featureIndex-l.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(e,i){for(let r of e){let s=r.batchIndex;if(s===void 0)continue;let l=i.get(s);if(!l){r.primitiveOffset=this.text.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.text.indexArray.length;let u=this.text.indexArray.length;for(let{index:p}of l){let f=this.symbolInstances.get(p),{rightJustifiedTextSymbolIndex:g,centerJustifiedTextSymbolIndex:x,leftJustifiedTextSymbolIndex:b,verticalPlacedTextSymbolIndex:w}=f;g>=0&&this.addIndicesForPlacedSymbol(this.text,g),x>=0&&x!==g&&this.addIndicesForPlacedSymbol(this.text,x),b>=0&&b!==x&&b!==g&&this.addIndicesForPlacedSymbol(this.text,b),w>=0&&this.addIndicesForPlacedSymbol(this.text,w)}r.primitiveLength=this.text.indexArray.length-u}}rebuildIconSegmentIndices(e,i){for(let r of e){let s=r.batchIndex;if(s===void 0)continue;let l=i.get(s);if(!l){r.primitiveOffset=this.icon.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.icon.indexArray.length;let u=this.icon.indexArray.length;for(let{index:p}of l){let f=this.symbolInstances.get(p),{placedIconSymbolIndex:g,verticalPlacedIconSymbolIndex:x}=f;g>=0&&this.addIndicesForPlacedSymbol(this.icon,g),x>=0&&this.addIndicesForPlacedSymbol(this.icon,x)}r.primitiveLength=this.icon.indexArray.length-u}}sortFeaturesWithinSegments(){this.featureSortOrder=[];let e=Math.sin(this.sortedAngle),i=Math.cos(this.sortedAngle),r=this.getOrCreateSortedSymbolsByBatch(e,i),s=Array.from(r.keys()).sort((l,u)=>l-u);for(let l of s){let u=r.get(l);for(let{index:p}of u){let f=this.symbolInstances.get(p);this.featureSortOrder.push(f.featureIndex)}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),r),this.rebuildIconSegmentIndices(this.icon.segments.get(),r),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}getElevationFeatureForText(e){let i=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex,r;return this.elevationFeatures&&i<this.elevationFeatures.length&&(r=this.elevationFeatures[i]),r}}function _v(n,e){return e.replace(/{([^{}]+)}/g,(i,r)=>r in n?String(n[r]):"")}let gv,yv,Ty;Qe(No,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),No.addDynamicAttributes=Ih;class xv{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:ya,this.defaultValue=e}evaluate(e){if(e.formattedSection){let i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Qe(xv,"FormatSectionOverride",{omit:["defaultValue"]});let Sy=()=>Ty||(Ty={layout:gv||(gv=new Ti({"symbol-placement":new qe(he.layout_symbol["symbol-placement"]),"symbol-spacing":new qe(he.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new qe(he.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ze(he.layout_symbol["symbol-sort-key"]),"symbol-z-order":new qe(he.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new qe(he.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new qe(he.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new qe(he.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new qe(he.layout_symbol["icon-ignore-placement"]),"icon-optional":new qe(he.layout_symbol["icon-optional"]),"icon-rotation-alignment":new qe(he.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ze(he.layout_symbol["icon-size"]),"icon-size-scale-range":new qe(he.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Ze(he.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ze(he.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ze(he.layout_symbol["icon-image"]),"icon-image-use-theme":new qe({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Ze(he.layout_symbol["icon-rotate"]),"icon-padding":new qe(he.layout_symbol["icon-padding"]),"icon-keep-upright":new qe(he.layout_symbol["icon-keep-upright"]),"icon-offset":new Ze(he.layout_symbol["icon-offset"]),"icon-anchor":new Ze(he.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new qe(he.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new qe(he.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new qe(he.layout_symbol["text-rotation-alignment"]),"text-field":new Ze(he.layout_symbol["text-field"]),"text-font":new Ze(he.layout_symbol["text-font"]),"text-size":new Ze(he.layout_symbol["text-size"]),"text-size-scale-range":new qe(he.layout_symbol["text-size-scale-range"]),"text-max-width":new Ze(he.layout_symbol["text-max-width"]),"text-line-height":new Ze(he.layout_symbol["text-line-height"]),"text-letter-spacing":new Ze(he.layout_symbol["text-letter-spacing"]),"text-justify":new Ze(he.layout_symbol["text-justify"]),"text-radial-offset":new Ze(he.layout_symbol["text-radial-offset"]),"text-variable-anchor":new qe(he.layout_symbol["text-variable-anchor"]),"text-anchor":new Ze(he.layout_symbol["text-anchor"]),"text-max-angle":new qe(he.layout_symbol["text-max-angle"]),"text-writing-mode":new qe(he.layout_symbol["text-writing-mode"]),"text-rotate":new Ze(he.layout_symbol["text-rotate"]),"text-padding":new qe(he.layout_symbol["text-padding"]),"text-keep-upright":new qe(he.layout_symbol["text-keep-upright"]),"text-transform":new Ze(he.layout_symbol["text-transform"]),"text-offset":new Ze(he.layout_symbol["text-offset"]),"text-allow-overlap":new qe(he.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new qe(he.layout_symbol["text-ignore-placement"]),"text-optional":new qe(he.layout_symbol["text-optional"]),visibility:new qe(he.layout_symbol.visibility)})),paint:yv||(yv=new Ti({"icon-opacity":new Ze(he.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Ze(he.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Ze(he.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ze(he.paint_symbol["text-emissive-strength"]),"icon-color":new Ze(he.paint_symbol["icon-color"]),"icon-halo-color":new Ze(he.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ze(he.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ze(he.paint_symbol["icon-halo-blur"]),"icon-translate":new qe(he.paint_symbol["icon-translate"]),"icon-translate-anchor":new qe(he.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new qe(he.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Ze(he.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Ze(he.paint_symbol["text-occlusion-opacity"]),"text-color":new Ze(he.paint_symbol["text-color"],{runtimeType:on,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new Ze(he.paint_symbol["text-halo-color"]),"text-halo-width":new Ze(he.paint_symbol["text-halo-width"]),"text-halo-blur":new Ze(he.paint_symbol["text-halo-blur"]),"text-translate":new qe(he.paint_symbol["text-translate"]),"text-translate-anchor":new qe(he.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new qe(he.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new qe(he.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new qe(he.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new qe(he.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Ze(he.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},Ty);
7class w_ extends or{constructor(e,i,r,s){super(e,Sy(),i,r,s,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=Mt([]),this.hasOcclusionOpacityProperties=e.paint!==void 0&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}_handleSpecialPaintPropertyUpdate(e){e!=="icon-occlusion-opacity"&&e!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(e,i){super.recalculate(e,i),this.appearances&&this.appearances.forEach(s=>{s.recalculate(e,i,this.iconImageUseTheme)}),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")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));let r=this.layout.get("text-writing-mode");if(r){let s=[];for(let l of r)s.includes(l)||s.push(l);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(e,i,r,s){return this._saturation===e&&this._contrast===i&&this._brightnessMin===r&&this._brightnessMax===s||(this._colorAdjustmentMatrix=function(l,u,p,f){l=Fr(l),u=Ln(u);let g=eo(),x=l/3,b=1-2*x,w=[b,x,x,0,x,b,x,0,x,x,b,0,0,0,0,1],S=.5-.5*u,I=f-p;return xi(g,[I,0,0,0,0,I,0,0,0,0,I,0,p,p,p,1],[u,0,0,0,0,u,0,0,0,0,u,0,S,S,S,1]),xi(g,g,w),g}(e,i,r,s),this._saturation=e,this._contrast=i,this._brightnessMin=r,this._brightnessMax=s),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,i,r,s){let l=this.layout.get(e).evaluate(i,{},r,s),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||qu(u.value)||!l?l:_v(i.properties,l)}getAppearanceValueAndResolveTokens(e,i,r,s,l){let u=e.getLayoutProperty(i);if(!u)return;let p=u.evaluate(r,{},s,l),f=e.getUnevaluatedLayoutProperties()._values[i];return f.isDataDriven()||qu(f.value)||!p||typeof p!="string"?p:_v(r.properties,p)}createBucket(e){return new No(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(let e of Sy().paint.overridableProperties){if(!w_.hasPaintOverride(this.layout,e))continue;let i=this.paint.get(e),r=new xv(i),s=new vd(r,i.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme")),l=null;l=i.value.kind==="constant"||i.value.kind==="source"?new Dc("source",s):new bl("composite",s,i.value.zoomStops,i.value.interpolationType),this.paint._values[e]=new ks(i.property,l,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&w_.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){let r=e.get("text-field"),s=Sy().paint.properties[i],l=!1,u=p=>{for(let f of p)if(s.overrides&&s.overrides.hasOverride(f))return void(l=!0)};if(r.value.kind==="constant"&&r.value.value instanceof Un)u(r.value.value.sections);else if(r.value.kind==="source"){let p=g=>{l||(g instanceof bo&&xn(g.value)===Ko?u(g.value.sections):g instanceof _c?u(g.sections):g.eachChild(p))},f=r.value;f._styleExpression&&p(f._styleExpression.expression)}return l}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,i,r){return{config:new rs(this,{zoom:i,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let vv,bv,wv,Tv;var T_=Rt([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function S_(n,e,i,r,s,l,u,p){let f=[n,e,1,i,r,1,s,l,1],g=[u,p,1],x=Qr([],f),[b,w,S]=gs(g,g,x);return Xn(f,f,[b,0,0,0,w,0,0,0,S])}function Sv(n,e,i,r,s,l,u,p){let f=function(g,x,b,w,S,I,M,C){let R=S_(0,0,1,0,1,1,0,1),F=S_(g,x,b,w,S,I,M,C);return Xn(F,F,Qr([],R))}(n,e,i,r,s,l,u,p);return[f[2]/f[8]/Xe,f[5]/f[8]/Xe]}function E_(n){return[n[0],Math.min(Math.max(n[1],-85.051129),Cr)]}
7class Ev extends ol{constructor(e,i,r,s){super(),this.id=e,this.dispatcher=r,this.coordinates=i.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(s),this.options=i,this._dirty=!1}load(e,i){if(this._loaded=i||!1,this.fire(new Jo("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=to(this.map._requestManager.transformRequest(this.url,ws.Image),(r,s)=>{this._imageRequest=null,this._loaded=!0,r?this.fire(new rl(r)):s&&(this.image=s,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Sp(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Jo("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Sp||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let i=e[0][1],r=e[0][1];for(let l of e)l[1]>r&&(r=l[1]),l[1]<i&&(i=l[1]);let s=(r+i)/2;if(s>Cr?this.onNorthPole=!0:s<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){let l=e.map(Wn.fromLngLat);this.tileID=function(u){let p=1/0,f=1/0,g=-1/0,x=-1/0;for(let M of u)p=Math.min(p,M.x),f=Math.min(f,M.y),g=Math.max(g,M.x),x=Math.max(x,M.y);let b=Math.max(g-p,x-f),w=Math.max(0,Math.floor(-Math.log2(b))),S=Math.pow(2,w),I=Math.floor((p+g)/2*S);return I>1&&(I-=1),new J(w,I,Math.floor((f+x)/2*S))}(l),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Jo("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Sp||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(let C in this.tiles){let R=this.tiles[C];R.state!=="loaded"&&(R.state="loaded",R.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;let i=ou(new J(0,0,0),this.map.transform.projection),r=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(C){let R=C[1].x-C[0].x,F=C[1].y-C[0].y,L=C[2].x-C[1].x,j=C[2].y-C[1].y,H=C[3].x-C[2].x,$=C[3].y-C[2].y,ie=C[0].x-C[3].x,W=C[0].y-C[3].y,Q=R*j-L*F,Y=L*$-H*j,ee=H*W-ie*$,me=ie*F-R*W;return Q>0&&Y>0&&ee>0&&me>0||Q<0&&Y<0&&ee<0&&me<0}(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);let s=ou(this.tileID,this.map.transform.projection),[l,u,p,f]=this.coordinates.map(C=>{let R=s.projection.project(C[0],C[1]);return uv(s,R)._round()});this.perspectiveTransform=Sv(l.x,l.y,u.x,u.y,p.x,p.y,f.x,f.y);let g=this._boundsArray=new Ba;g.emplaceBack(l.x,l.y,0,0),g.emplaceBack(u.x,u.y,Xe,0),g.emplaceBack(f.x,f.y,0,Xe),g.emplaceBack(p.x,p.y,Xe,Xe),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(g,T_.members),this.boundsSegments=pi.simpleSegment(0,0,4,2);let x=[],b=function(C){return[E_(C[0]),E_(C[1]),E_(C[2]),E_(C[3])]}(this.coordinates),[w,S,I,M]=function(C){let R=C[0][0],F=R,L=C[0][1],j=L;for(let H=1;H<C.length;H++)C[H][0]<R?R=C[H][0]:C[H][0]>F&&(F=C[H][0]),C[H][1]<L?L=C[H][1]:C[H][1]>j&&(j=C[H][1]);return[R,L,F-R,j-L]}(b);{let C=new Ba,[R,F,L,j]=function(Ie){let Be=Ie[0].x,xe=Be,Se=Ie[0].y,Me=Se;for(let Le=1;Le<Ie.length;
7Le++)Ie[Le].x<Be?Be=Ie[Le].x:Ie[Le].x>xe&&(xe=Ie[Le].x),Ie[Le].y<Se?Se=Ie[Le].y:Ie[Le].y>Me&&(Me=Ie[Le].y);return[Be,Se,xe-Be,Me-Se]}(r),H=Ie=>[(Ie.x-R)/L,(Ie.y-F)/j],[$,ie,W,Q]=r.map(H),Y=function(Ie,Be,xe,Se,Me,Le,ze,We){let De=S_(0,0,1,0,1,1,0,1);return Xn(De,De,Qr([],S_(Ie,Be,xe,Se,Me,Le,ze,We)))}($[0],$[1],ie[0],ie[1],W[0],W[1],Q[0],Q[1]);this.elevatedGlobePerspectiveTransform=Sv($[0],$[1],ie[0],ie[1],W[0],W[1],Q[0],Q[1]);let ee=(Ie,Be)=>{x.push(Ie.lng);let xe=Math.round((Ie.lng-w)/I*Xe),Se=Math.round((Ie.lat-S)/M*Xe),Me=H(Be),Le=gs([],[Me[0],Me[1],1],Y),ze=Math.round(Le[0]/Le[2]*Xe),We=Math.round(Le[1]/Le[2]*Xe);C.emplaceBack(xe,Se,ze,We)},me=r[3].x-r[0].x,ge=r[3].y-r[0].y,Te=r[2].x-r[1].x,Ae=r[2].y-r[1].y;for(let Ie=0;Ie<65;Ie++){let Be=Ie/64,xe=[r[0].x+Be*me,r[0].y+Be*ge],Se=[r[1].x+Be*Te,r[1].y+Be*Ae],Me=Se[0]-xe[0],Le=Se[1]-xe[1];for(let ze=0;ze<65;ze++){let We=ze/64,De={x:xe[0]+Me*We,y:xe[1]+Le*We};ee(i.projection.unproject(De.x,De.y),De)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(C,T_.members)}{this.maxLongitudeTriangleSize=0;let C=[],R=new Yi,F=(L,j,H)=>{R.emplaceBack(L,j,H);let $=x[L],ie=x[j],W=x[H],Q=Math.min(Math.min($,ie),W),Y=Math.max(Math.max($,ie),W)-Q;Y>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Y),C.push(Q+Y/2)};for(let L=0;L<64;L++)for(let j=0;j<64;j++){let H=65*L+j,$=H+1,ie=H+65,W=ie+1;F(H,ie,$),F($,ie,W)}[C,R]=function(L,j){let H=Array.from({length:L.length},(W,Q)=>Q);H.sort((W,Q)=>L[W]-L[Q]);let $=[],ie=new Yi;for(let W=0;W<H.length;W++){let Q=H[W];$.push(L[Q]);let Y=3*Q,ee=Y+1;ie.emplaceBack(j.uint16[Y],j.uint16[ee],j.uint16[ee+1])}return[$,ie]}(C,R),this.elevatedGlobeTrianglesCenterLongitudes=C,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(R)}this.elevatedGlobeSegments=pi.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,I/Xe,0,M/Xe,0,0,S,w,0])}prepare(){let e=Object.keys(this.tiles).length!==0;if(this.tileID&&!e)return;let i=this.map.painter.context,r=i.gl;!this._dirty||this.texture instanceof Sp||(this.texture?this.texture.update(this.image):(this.texture=new Ys(i,this.image,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(i)}loadTile(e,i){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},i(null)):(e.state="errored",i(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(e){let i=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!i)return null;let r=this.elevatedGlobeTrianglesCenterLongitudes,s=(l=e+180)+360*Math.round((r[0]-l)/360);var l;let u=new pi,p=(b,w)=>{u.segments.push({vertexOffset:0,primitiveOffset:b,vertexLength:i.segments[0].vertexLength,primitiveLength:w,sortKey:void 0,vaos:{}})},f=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-s)<=f){let b=gn(r,0,r.length,s+f);return b===r.length||p(b,Nn(r,b+1,r.length,s+360-f)-b),u}s<r[0]&&(s+=360);let g=Nn(r,0,r.length,s-f);if(g===r.length)return p(0,r.length),u;p(0,g-0);let x=gn(r,g+1,r.length,s+f);return x!==r.length&&p(x,r.length-x),u}}let Ey=1024,hT=(Math.pow(Ey,2)-1)/268170240;class Iv extends or{constructor(e,i,r,s){super(e,{layout:wv||(wv=new Ti({visibility:new qe(he.layout_raster.visibility)})),paint:Tv||(Tv=new Ti({"raster-opacity":new qe(he.paint_raster["raster-opacity"]),"raster-color":new za(he.paint_raster["raster-color"]),"raster-color-mix":new qe(he.paint_raster["raster-color-mix"]),"raster-color-range":new qe(he.paint_raster["raster-color-range"]),"raster-hue-rotate":new qe(he.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new qe(he.paint_raster["raster-brightness-min"]),"raster-brightness-max":new qe(he.paint_raster["raster-brightness-max"]),"raster-saturation":new qe(he.paint_raster["raster-saturation"]),"raster-contrast":new qe(he.paint_raster["raster-contrast"]),"raster-resampling":new qe(he.paint_raster["raster-resampling"]),"raster-fade-duration":new qe(he.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new qe(he.paint_raster["raster-emissive-strength"]),"raster-array-band":new qe(he.paint_raster["raster-array-band"]),"raster-elevation":new qe(he.paint_raster["raster-elevation"]),"raster-elevation-reference":new qe(he.paint_raster["raster-elevation-reference"]),"raster-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},i,r,s),this.updateColorRamp(),this._curRampRange=[NaN,NaN]}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(e){return!(e&&e._source instanceof Ev&&(e._source.onNorthPole||e._source.onSouthPole))&&this.paint.get("raster-elevation")===0}_handleSpecialPaintPropertyUpdate(e){e!=="raster-color"&&e!=="raster-color-range"||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}
7updateColorRamp(e){if(!this.hasColorMap()||!this._curRampRange)return;let i=this._transitionablePaint._values["raster-color"].value.expression,[r,s]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(s)||r===this._curRampRange[0]&&s===this._curRampRange[1]||(this.colorRamp=ii({expression:i,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:s}],resolution:Ey}),this.colorRampTexture=null,this._curRampRange=[r,s])}is3D(e){return this.paint.get("raster-elevation")>0}}let Av,Mv,Cv,Pv,Dv,Rv,Lv;class zv extends or{constructor(e,i,r,s){super(e,{layout:Av||(Av=new Ti({visibility:new qe(he["layout_raster-particle"].visibility)})),paint:Mv||(Mv=new Ti({"raster-particle-array-band":new qe(he["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new qe(he["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new za(he["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new qe(he["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new qe(he["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new qe(he["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new qe(he["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new qe(he["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},i,r,s),this._updateColorRamp(),this.lastInvalidatedAt=yn.now()}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null)}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return this.visibility!=="none"}isDraped(e){return!1}_handleSpecialPaintPropertyUpdate(e){e!=="raster-particle-color"&&e!=="raster-particle-max-speed"||(this._updateColorRamp(),this._invalidateAnimationState()),e==="raster-particle-count"&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;let e=this._transitionablePaint._values["raster-particle-color"].value.expression,i=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=ii({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:i}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=yn.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class dT extends or{constructor(e,i){super(e,{},i,null),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(e){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isDraped(e){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}function Iy(n,e,i){let r=[0,0,1],s=xs([]);return sa(s,s,i?-V(n)+Math.PI:V(n)),Ja(s,s,-V(e)),Za(r,r,s),hi(r,r)}class Ov{constructor(e,i){this.feature=e,this.instancedDataOffset=i,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Fv{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new Pl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(e){let i=16*e,r=this.instancedDataArray.float32,s=Math.floor(r[i+2]),l=1.05*(r[i+2]-s);return s/=100,[r[i]%1*1.05,r[i+1]%1*1.05,l,s]}tileCoordinatesForInstance(e){let i=16*e,r=this.instancedDataArray.float32,s=r[i+0];return s=s>Xe?s-Xe:s,new ke(Math.trunc(s),Math.trunc(r[i+1]))}translationForInstance(e){let i=16*e,r=this.instancedDataArray.float32;return[r[i+4],r[i+5],r[i+6]]}rotationScaleForInstance(e){let i=16*e,r=this.instancedDataArray.float32;
7return[r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]]}transformForInstance(e){let i=16*e,r=this.instancedDataArray.float32;return[r[i+7],r[i+8],r[i+9],r[i+4],r[i+10],r[i+11],r[i+12],r[i+5],r[i+13],r[i+14],r[i+15],r[i+6],0,0,0,1]}}class Ay{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(e,i){}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,i,r,s){this.tileToMeter=Hr(r);let l=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);let u=this.layers[0].paint.get("model-elevation-reference")==="hd-road-markup"?i.elevationFeatures:void 0;for(let{feature:p,id:f,index:g,sourceLayerIndex:x}of e){let b=f??(p.properties&&Object.hasOwn(p.properties,"id")?p.properties.id:void 0),w=qr(p,l);if(!this.layers[0]._featureFilter.filter(new Jt(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),w,r))continue;let S={id:b,sourceLayerIndex:x,index:g,geometry:l?w.geometry:$r(p,r,s),properties:p.properties,type:p.type,patterns:{}},I=this.addFeature(S,S.geometry,w,u,r);I&&i.featureIndex.insert(p,S.geometry,g,x,this.index,this.instancesPerModel[I].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){let e=this.layers[0].modelManager,i=this.layers[0].scope,r=0;for(let s of this.modelUris){let l=e.getModel(s,i);if(!l)continue;let u=this.instancesPerModel[s];if(u){let p=.5*ia(l.aabb.max,l.aabb.min)*u.maxScale+u.maxXYTranslationDistance,f=Math.min(Xe,Math.max(p/this.tileToMeter,256));r=Math.max(f,r)}}return r}
7update(e,i,r,s){for(let l in this.instancesPerModel){let u=this.instancesPerModel[l];for(let p in e)Object.hasOwn(u.idToFeaturesIndex,p)&&(this.evaluate(u.features[u.idToFeaturesIndex[p]],e[p],u,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(let i in this.instancesPerModel){let r=this.instancesPerModel[i];for(let s of r.features){let l=this.layers[0],u=s.feature,p=this.canonical,f=l.paint.get("model-rotation").evaluate(u,{},p),g=l.paint.get("model-scale").evaluate(u,{},p),x=l.paint.get("model-translation").evaluate(u,{},p);Po(s.rotation,f)&&Po(s.scale,g)&&Po(s.translation,x)||(this.evaluate(s,s.featureStates,r,!0),e=!0)}}return e}updateReplacement(e,i,r,s){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;let l=i.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(Vm(this.activeReplacements,l))return!1;this.activeReplacements=l;let u=!1;for(let p in this.instancesPerModel){let f=this.instancesPerModel[p],g=f.instancedDataArray;for(let x of f.features){let b=x.instancedDataOffset,w=x.instancedDataCount;for(let S=0;S<w;S++){let I=16*(S+b),M=g.float32[I+0],C=M>Xe;M=C?M-Xe:M;let R=Math.floor(M),F=Math.floor(g.float32[I+1]),L=!1;for(let j of this.activeReplacements)if(!d0(j,r,jm.Model,s)&&!(j.min.x>R||R>j.max.x||j.min.y>F||F>j.max.y)&&(L=g0(_0(R,F,e.canonical,j.footprintTileId.canonical),j.footprint),L))break;g.float32[I]=L?M+Xe:M,u=u||L!==C}}}return u}isEmpty(){for(let e in this.instancesPerModel)if(this.instancesPerModel[e].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(let i in this.instancesPerModel){let r=this.instancesPerModel[i];r.instancedDataArray.length<0||r.instancedDataArray.length===0||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,Eb.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(e){for(let r in this.instancesPerModel){let s=this.instancesPerModel[r];s.instancedDataArray.length!==0&&s.instancedDataBuffer&&s.instancedDataBuffer.destroy()}let i=this.layers[0].modelManager;if(e&&i&&this.modelUris&&this.modelsRequested)for(let r of this.modelUris)i.removeModel(r,"",!0)}addFeature(e,i,r,s,l){let u=this.layers[0],p=u.layout.get("model-id"),f=u.layout.get("model-allow-density-reduction"),g=p.evaluate(r,{},this.canonical);if(!g)return Bt(`modelId is not evaluated for layer ${u.id} and it is not going to get rendered.`),g;!g.includes("://")&&!this.styleDefinedModelURLs[g]||this.modelUris.includes(g)||this.modelUris.push(g),this.instancesPerModel[g]||(this.instancesPerModel[g]=new Fv);let x=this.instancesPerModel[g],b=x.instancedDataArray,w=new Ov(r,b.length),S;s&&(S=mh.getElevationFeature(e,s));for(let I of i)for(let M of I){if(M.x<0||M.x>=Xe||M.y<0||M.y>=Xe)continue;if(this.lookupDim!==0&&f){let R=(this.lookupDim-1)/Xe,F=this.lookupDim*(M.y*R|0)+M.x*R|0;if(this.lookup){if(this.lookup[F]!==0)continue;this.lookup[F]=1}}this.instanceCount++;let C=b.length;if(b.resize(C+1),s){x.instancesRoadElevation||(x.instancesRoadElevation=[]);let R=S?S.pointElevation(new ke(M.x,M.y)):0;x.instancesRoadElevation.push(R)}x.instancesEvaluatedElevation.push(0),b.float32[16*C]=M.x,b.float32[16*C+1]=M.y}return w.instancedDataCount=x.instancedDataArray.length-w.instancedDataOffset,w.instancedDataCount>0&&(e.id&&(x.idToFeaturesIndex[e.id]=x.features.length),x.features.push(w),this.evaluate(w,{},x,!1)),g}getModelUris(){return this.modelUris}evaluate(e,i,r,s){let l=this.layers[0],u=e.feature,p=this.canonical,f=e.rotation=l.paint.get("model-rotation").evaluate(u,i,p),g=e.scale=l.paint.get("model-scale").evaluate(u,i,p),x=e.translation=l.paint.get("model-translation").evaluate(u,i,p),b=Object.assign({},l.paint.get("model-color").evaluate(u,i,p));b.a=l.paint.get("model-color-mix-intensity").evaluate(u,i,p);let w=[];this.maxVerticalOffset<x[2]&&(this.maxVerticalOffset=x[2]);let S=x[0]*x[0]+x[1]*x[1],I=S>0?Math.sqrt(S):0;r.maxScale=Math.max(Math.max(r.maxScale,g[0]),Math.max(g[1],g[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,I),this.maxScale=Math.max(Math.max(this.maxScale,g[0]),Math.max(g[1],g[2])),ix(w,f,g);let M=Math.round(100*b.a)+b.b/1.05;for(let C=0;C<e.instancedDataCount;++C){let R=e.instancedDataOffset+C,F=16*R,L=r.instancedDataArray.float32,j=0;s&&(j=L[F+6]-r.instancesEvaluatedElevation[R]);let H=0|L[F+1];L[F]=(0|L[F])+b.r/1.05,L[F+1]=H+b.g/1.05,L[F+2]=M,L[F+3]=1/(p.z>10?this.tileToMeter:Hr(p,H)),L[F+4]=x[0],L[F+5]=x[1],L[F+6]=x[2]+(r.instancesRoadElevation?r.instancesRoadElevation[R]:0)+j,L[F+7]=w[0],L[F+8]=w[1],L[F+9]=w[2],L[F+10]=w[4],L[F+11]=w[5],L[F+12]=w[6],L[F+13]=w[8],L[F+14]=w[9],L[F+15]=w[10],r.instancesEvaluatedElevation[R]=x[2]}}}Qe(Ay,"ModelBucket",{omit:["layers"]}),Qe(Fv,"PerModelAttributes"),Qe(Ov,"ModelFeature");class Mh{constructor(e,i,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=i,this._offset=r}static create(e,i,r){let s=r||e.findDEMTileFor(i);if(!s||!s.dem)return;let l=s.dem,u=s.tileID,p=1<<i.canonical.z-u.canonical.z;return new Mh(s,l.dim/Xe/p,[(i.canonical.x/p-u.canonical.x)*l.dim,(i.canonical.y/p-u.canonical.y)*l.dim])}tileCoordToPixel(e,i){let r=i*this._scale+this._offset[1];return new ke(Math.floor(e*this._scale+this._offset[0]),Math.floor(r))}
7getElevationAt(e,i,r,s){let l=e*this._scale+this._offset[0],u=i*this._scale+this._offset[1],p=Math.floor(l),f=Math.floor(u),g=this._dem;return s=!!s,r?mt(mt(g.get(p,f,s),g.get(p,f+1,s),u-f),mt(g.get(p+1,f,s),g.get(p+1,f+1,s),u-f),l-p):g.get(p,f,s)}getElevationAtPixel(e,i,r){return this._dem.get(e,i,!!r)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*lr(1,e)*this._dem.stride}}let My=new Float32Array(262144),su=new Uint8Array(262144),I_=[0,0,0],A_=[0,0,0];function Bv(n){let e=0;if(n.meshes)for(let i of n.meshes)e=Math.max(e,i.aabb.max[2]);if(n.children)for(let i of n.children)e=Math.max(e,Bv(i));return e}function kv(n,e,i){if(n.meshes)for(let r of n.meshes){if(r.aabb.min[0]===1/0)continue;let s=Ei.applyTransform(r.aabb,n.globalMatrix);i.insert(e,s.min[0],s.min[1],s.max[0],s.max[1])}if(n.children)for(let r of n.children)kv(r,e,i)}let Nv=["","wall","door","roof","window","lamp","logo"];class Uv{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedTranslation=[0,0,0],this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.targetLod=-1,this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Bv(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new Ei([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0,i=new Ei([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(let r of this.node.meshes)this.node.lightMeshIndex!==e&&(r.transformedAabb=Ei.applyTransformFast(r.aabb,this.node.globalMatrix),i.encapsulate(r.transformedAabb)),e++;this.aabb=i}return this.aabb}}class M_{constructor(e,i,r,s,l,u,p,f){this.id=r,this.layers=e,this.layerIds=this.layers.map(g=>g.fqid),this.stateDependentLayerIds=this.layers.filter(g=>g.isStateDependent()).map(g=>g.id),this.modelTraits|=xh.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,s&&(this.modelTraits|=xh.HasMapboxMeshFeatures),l&&(this.modelTraits|=xh.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=u,this.worldview=f,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(let g of i)this.nodesInfo.push(new Uv(g)),kv(g,p.featureIndexArray.length,p.grid),p.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,p.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,i){for(let r of this.getNodesInfo()){let s=r.node;s.footprint&&i.push({footprint:s.footprint,id:e})}}updateAppearances(e,i,r,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(e){let i=Object.keys(e).length!==0;if(i&&!this.stateDependentLayers.length)return;let r=i?this.stateDependentLayers:this.layers;if(!Xo(e,this.states))for(let s of r)this.evaluate(s,e);this.states=structuredClone(e)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;let i=this.getNodesInfo();for(let r of i){let s=r.node;this.uploaded?this.updatePbrBuffer(s):$g(s,e,!0)}for(let r of i)o_(r.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let i=!1;if(!e.meshes)return i;for(let r of e.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),i=!0);if(e.lodMeshes)for(let r of e.lodMeshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),i=!0);return i}needsReEvaluation(e,i,r){let s=e.transform.projectionOptions,l=e.style.getBrightness(),u=this.brightness!==l;if(!this.uploaded||this.dirty||s.name!==this.projection.name||Up(r.paint.get("model-color").value,u)||Up(r.paint.get("model-color-mix-intensity").value,u)||Up(r.paint.get("model-roughness").value,u)||Up(r.paint.get("model-emissive-strength").value,u)||Up(r.paint.get("model-height-based-emissive-strength-multiplier").value,u)){this.projection=s,this.brightness=l;let p=this.getNodesInfo();for(let f of p)f.state=null;return!0}return!1}evaluateTransform(e,i){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;let r=this.getNodesInfo(),s=this.id.canonical;for(let l of r){let u=l.feature;l.evaluatedTranslation=i.paint.get("model-translation").evaluate(u,{},s),l.evaluatedScale=i.paint.get("model-scale").evaluate(u,{},s)}}evaluate(e,i){let r=this.getNodesInfo();for(let s of r){if(!s.node.meshes)continue;let l=s.feature,u=i&&i[l.id];if(Xo(u,s.state))continue;s.state=structuredClone(u);let p=s.node.meshes&&s.node.meshes[0].featureData,f=s.evaluatedColor[2],g=s.evaluatedRMEA[2],x=this.id.canonical;if(s.hasTranslucentParts=!1,p){for(let b=0;b<Nv.length;b++){let w=Nv[b];w.length&&(l.properties.part=w);let S=e.paint.get("model-color").evaluate(l,u,x).toPremultipliedRenderColor(null),I=e.paint.get("model-color-mix-intensity").evaluate(l,u,x);s.evaluatedColor[b]=[S.r,S.g,S.b,I],s.evaluatedRMEA[b][0]=e.paint.get("model-roughness").evaluate(l,u,x),s.evaluatedRMEA[b][2]=e.paint.get("model-emissive-strength").evaluate(l,u,x),s.evaluatedRMEA[b][3]=S.a,s.emissionHeightBasedParams[b]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(l,u,x),!s.hasTranslucentParts&&S.a<1&&(s.hasTranslucentParts=!0)}delete l.properties.part,pT(s,f!==s.evaluatedColor[2]||g!==s.evaluatedRMEA[2],this.modelTraits)}else s.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(l,u,x);s.evaluatedTranslation=e.paint.get("model-translation").evaluate(l,u,x),s.evaluatedScale=e.paint.get("model-scale").evaluate(l,u,x),this.updatePbrBuffer(s.node)||(this.needsUpload=!0)}this.dirty=!1}
7elevationUpdate(e,i,r,s){let l=e.findDEMTileFor(r);if(l&&(l.tileID.canonical!==this.terrainTile||i!==this.terrainExaggeration)){if(l.dem&&l.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=l.tileID.overscaledZ;let u=Mh.create(e,r,l);if(!u)return;this.modelTraits&xh.HasMapboxMeshFeatures&&this.updateDEM(e,u,r,s);for(let p of this.getNodesInfo()){let f=p.node;if(!f.footprint||!f.footprint.vertices||!f.footprint.vertices.length)continue;let g=f.footprint.vertices,x=u.getElevationAt(g[0].x,g[0].y,!0,!0);for(let b=1;b<g.length;b++)x=Math.min(x,u.getElevationAt(g[b].x,g[b].y,!0,!0));f.elevation=x}}this.terrainTile=l.tileID.canonical,this.terrainExaggeration=i}}updateDEM(e,i,r,s){let l=i._dem._modifiedForSources[s];if(l===void 0&&(i._dem._modifiedForSources[s]=[],l=i._dem._modifiedForSources[s]),l.includes(r.canonical))return;let u=i._dem.dim;l.push(r.canonical);let p=!1;for(let f of this.getNodesInfo()){let g=f.node;if(!g.footprint||!g.footprint.grid)continue;let x=g.footprint.grid,b=i.tileCoordToPixel(x.min.x,x.min.y),w=i.tileCoordToPixel(x.max.x,x.max.y),S=Math.min(Math.min(u-w.y,b.x),Math.min(b.y,u-w.x));if(S<0)continue;let I=ne(S,2,5),M=Math.max(0,b.x-I),C=Math.max(0,b.y-I),R=Math.min(w.x+I,u-1),F=Math.min(w.y+I,u-1);for(let $=C;$<=F;++$)for(let ie=M;ie<=R;++ie)su[$*u+ie]=255;let L=0,j=0;for(let $=0;$<x.cellsY;++$)for(let ie=0;ie<x.cellsX;++ie){if(!x.cells[$*x.cellsX+ie])continue;let W=i.tileCoordToPixel(x.min.x+ie/x.xScale,x.min.y+$/x.yScale),Q=i.tileCoordToPixel(x.min.x+(ie+1)/x.xScale,x.min.y+($+1)/x.yScale);for(let Y=W.y;Y<=Math.min(Q.y+1,u-1);++Y)for(let ee=W.x;ee<=Math.min(Q.x+1,u-1);++ee)su[Y*u+ee]===255&&(su[Y*u+ee]=0,L+=i.getElevationAtPixel(ee,Y),j++)}let H=L/j;M=Math.max(1,b.x-I),C=Math.max(1,b.y-I),R=Math.min(w.x+I,u-2),F=Math.min(w.y+I,u-2),p=!0;for(let $=C;$<=F;++$)for(let ie=M;ie<=R;++ie)su[$*u+ie]===0&&(My[$*u+ie]=i._dem.set(ie,$,H));for(let $=1;$<I;++$){M=Math.max(1,b.x-$),C=Math.max(1,b.y-$),R=Math.min(w.x+$,u-2),F=Math.min(w.y+$,u-2);for(let ie=C;ie<=F;++ie)for(let W=M;W<=R;++W){let Q=ie*u+W;if(su[Q]===255){let Y=0,ee=0,me=-1,ge=-1;for(let Te=-1;Te<=1;++Te)for(let Ae=-1;Ae<=1;++Ae){let Ie=(ie+Te)*u+W+Ae;if(su[Ie]>=$)continue;let Be=My[Ie],xe=Math.abs(Be);xe>ee&&(Y=Be,ee=xe,me=Ae,ge=Te)}if(ee>.1){let Te=1-($+.5*Math.abs(me*ge))/I,Ae=i._dem.get(W,ie)+Y*Te,Ie=i._dem.get(W+me,ie+ge),Be=i._dem.get(W-me,ie-ge,!0);(Ae-Ie)*(Ae-Be)>0&&(Ae=(Ie+Be)/2),My[Q]=i._dem.set(W,ie,Ae),su[Q]=$}}}}}p&&(i._demTile.needsDEMTextureUpload=!0,i._dem._timestamp=yn.now())}setFilter(e){this.filter=e?oo(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Jt(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){let e=this.getNodesInfo();for(let i of e)o_(i.node),qg(i.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,i){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let r=i.getReplacementRegionsForTile(e.toUnwrapped());for(let s of this.getNodesInfo()){let l=s.node.footprint;s.hiddenByReplacement=!!l&&!r.some(u=>u.footprint===l)}}getHeightAtTileCoord(e,i){let r=[0,0,0],s=Mt([]);for(let l of this.getNodesInfo()){let u=l.node.meshes[0],p=u.transformedAabb;if(e<p.min[0]||i<p.min[1]||e>p.max[0]||i>p.max[1])continue;if(l.node.hidden===!0)return{height:1/0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};if(Bn(s,l.node.globalMatrix),r[0]=e,r[1]=i,r[2]=0,Bi(r,r,s),l.node.meshBVH){let b=r[0],w=r[1];I_[0]=b-1,I_[1]=w-1,I_[2]=-1e3,A_[0]=b+1,A_[1]=w+1,A_[2]=1e3;let S=l.node.meshBVH.findHighestPoint(I_,A_);if(S!==null)return{height:S,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]};continue}let f=(r[0]-u.aabb.min[0])/(u.aabb.max[0]-u.aabb.min[0])*eu|0,g=Math.min(63,(r[1]-u.aabb.min[1])/(u.aabb.max[1]-u.aabb.min[1])*eu|0)*eu+Math.min(63,f),x=u.heightmap[g];if(x<0&&l.node.footprint){let b=[];if(l.node.footprint.grid.query(new ke(e,i),new ke(e,i),b),b.length>0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]};continue}return l.hiddenByReplacement?void 0:{height:x,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]}}}}function Up(n,e){return n instanceof Dc&&!n.isLightConstant&&e}function Vv(n,e,i,r,s,l,u,p){let f=(61440&e|(61440&e)>>4)>>8,g=(3840&e|(3840&e)>>4)>>4,x=240&e|(240&e)>>4,b=15&e|(15&e)<<4;i[3]>0&&(f=mt(f,255*i[0],i[3]),g=mt(g,255*i[1],i[3]),x=mt(x,255*i[2],i[3]));let w=b/255;f*=w,g*=w,x*=w;let S=f<<8|g,I=x<<8|Math.floor(255*r[3]),M=function(W){let Q=ne(W,0,2);return Math.min(Math.round(.5*Q*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],C=ne(s[0],0,1),R=ne(s[1],0,1),F=ne(s[2],0,1),L=ne(s[3],0,1),j,H,$,ie;if(C!==R&&u!==l&&R!==C){let W=u-l;H=1/(W*(R-C)),$=-(l+W*C)/(W*(R-C));let Q=ne(s[4],-1,1);ie=Math.pow(10,Q),j=255*F<<8|255*L}else j=65535,H=0,$=1,ie=1;if(n.emplaceBack(S,I,M,j,H,$,ie),p){let W=p.length;p.clear();for(let Q=0;Q<W;Q++)p.emplaceBack(S,I,M,j,H,$,ie)}}function pT(n,e,i){let r=n.node,s=0,l=i&xh.HasMeshoptCompression;for(let u of r.meshes){if(r.lights&&r.lightMeshIndex===s||!u.featureData)continue;u.featureArray=new Dl,u.featureArray.reserve(u.featureData.length);let p=e;for(let f of u.featureData){let g=l?65535&f:f>>16&65535,x=l?f>>16&65535:65535&f,b=(15&x)<8?15&x:0,w=n.evaluatedRMEA[b],S=n.evaluatedColor[b],I=n.emissionHeightBasedParams[b],M;if(p&&b===2&&r.lights&&(M=new Dl,M.resize(10*r.lights.length)),Vv(u.featureArray,g,S,w,I,u.aabb.min[2],u.aabb.max[2],M),M&&p){p=!1;let C=r.meshes[r.lightMeshIndex];C.featureArray=M,C.featureArray._trim()}}u.featureArray._trim(),s++}if(r.lodMeshes){for(let u of r.lodMeshes)if(u.featureData){u.featureArray=new Dl,u.featureArray.reserve(u.featureData.length);for(let p of u.featureData){let f=l?p>>16&65535:65535&p,g=(15&f)<8?15&f:0;Vv(u.featureArray,l?65535&p:p>>16&65535,n.evaluatedColor[g],n.evaluatedRMEA[g],n.emissionHeightBasedParams[g],u.aabb.min[2],u.aabb.max[2],null)}u.featureArray._trim()}}}Qe(M_,"Tiled3dModelBucket",{omit:["layers"]}),Qe(Uv,"Tiled3dModelFeature");let fT=["id","tile","layer","source","sourceLayer","state"];class au{constructor(e,i,r,s,l){this.type="Feature",this._vectorTileFeature=e,this._z=i,this._x=r,this._y=s,this.properties=e?e.properties:{},this.id=l}clone(){let e=new au(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},this.layer)),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){let e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(let i of fT)this[i]!==void 0&&(e[i]=this[i]);return e}}
7class lu extends ol{constructor(e,i,r,s){super(),this.id=e,this.type="model",this.models=[],this._options=i,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}loadGLTFFromURI(e,i){return K0(this.map._requestManager.transformRequest(e,ws.Model).url,i)}async loadModel(e,i,r){try{let s=await this.loadGLTFFromURI(i.uri,r);if(r.aborted)return;let l=this._modelsInfo.get(e);if(!l)return;let u=Yg(s),p=l.modelSpec,f=new nx(e,p.uri,p.position,p.orientation,u);lu.applyModelSpecification(f,p),f.computeBoundsAndApplyParent(),this.models.push(f),l.model=f}catch(s){if(s instanceof Error&&s.name==="AbortError")return;let l=s instanceof Error?s.message:"Unknown error";this.fire(new rl(new Error(`Could not load model ${e} from ${i.uri}: ${l}`)))}}async load(){this._abortController||(this._abortController=new AbortController);let e=this._abortController.signal,i=[];for(let r in this._options.models){let s=this._options.models[r],l=this._modelsInfo.get(r);if(l&&l.model){l.modelSpec=s;let u=l.model;u.position=s.position!=null?new Kt(s.position[0],s.position[1]):new Kt(0,0),u.orientation=s.orientation!=null?s.orientation:[0,0,0],lu.applyModelSpecification(u,s),u.computeBoundsAndApplyParent(),this.models.push(u)}else l?l.modelSpec=s:(this._modelsInfo.set(r,{modelSpec:s,model:null}),i.push(this.loadModel(r,s,e)))}i.length!==0?(await Promise.allSettled(i),e.aborted||this.fire(new Jo("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new Jo("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(e,i){i.nodeOverrides&&lu.convertNodeOverrides(e,i.nodeOverrides),i.materialOverrides&&lu.convertMaterialOverrides(e,i.materialOverrides),i.nodeOverrideNames&&(e.nodeOverrideNames=[...i.nodeOverrideNames]),i.materialOverrideNames&&(e.materialOverrideNames=[...i.materialOverrideNames]),i.featureProperties&&(e.featureProperties=i.featureProperties)}static convertNodeOverrides(e,i){if(Array.isArray(i)&&i.every(r=>typeof r=="string")){e.nodeOverrideNames=[];for(let r of i)e.nodeOverrideNames.push(r)}else Object.entries(i).forEach(([r,s])=>{let l={orientation:[0,0,0]};if(Object.hasOwn(s,"orientation")){let u=s.orientation;u&&(l.orientation=u)}e.nodeOverrides.set(r,l)})}static convertMaterialOverrides(e,i){if(Array.isArray(i)&&i.every(r=>typeof r=="string")){e.materialOverrideNames=[];for(let r of i)e.materialOverrideNames.push(r)}else Object.entries(i).forEach(([r,s])=>{let l={color:new Ht(1,1,1),colorMix:0,emissionStrength:0,opacity:1},u=s["model-color"];u!==void 0&&(l.color.r=u[0],l.color.g=u[1],l.color.b=u[2]);let p=s["model-color-mix-intensity"];p!==void 0&&(l.colorMix=p);let f=s["model-emissive-strength"];f!==void 0&&(l.emissionStrength=f);let g=s["model-opacity"];g!==void 0&&(l.opacity=g),e.materialOverrides.set(r,l)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){if(this._modelsInfo.size===0)return!0;for(let e of this._modelsInfo.values())if(e.model==null)return!1;return!0}getModels(){return this.models}loadTile(e,i){}serialize(){return this._options}setProperty(e,i){return!1}reload(){this.cancelModelRequests();let e=Ns(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(e){this.cancelModelRequests()}setModels(e){this.models=[];let i=new Map;for(let r in e){let s=e[r],l=this._modelsInfo.get(r);l&&l.modelSpec.uri===s.uri&&i.set(r,l)}if(this._modelsInfo.size!==i.size){this.cancelModelRequests();for(let[r,s]of i)s.model||i.delete(r)}this._modelsInfo=i,this._options.models=e,this.load()}}function Cy(n,e,i,r){let s=1<<n.z;e.lat=zn((r/Xe+n.y)/s),e.lng=Mr((i/Xe+n.x)/s)}function mT(n,e,i,r){let s=n.getNodesInfo()[e];if(!s||s.hiddenByReplacement||!s.node.meshes)return;let l=Number.MAX_VALUE,u=s.node,p=i.tile,f=r.calculatePosMatrix(p.tileID.toUnwrapped(),r.worldSize),g=s.evaluatedScale,x=0;r.elevation&&u.elevation&&(x=u.elevation*r.elevation.exaggeration()),$n(f,f,[(u.anchor?u.anchor[0]:0)*(g[0]-1),(u.anchor?u.anchor[1]:0)*(g[1]-1),x]),Yn(f,f,g);let b=i.queryGeometry,w=b.isPointQuery()?b.screenBounds:b.screenGeometry,S=function(M){let C=xi([],f,M.globalMatrix);xi(C,r.expandedFarZProjMatrix,C);for(let R=0;R<M.meshes.length;++R){let F=M.meshes[R];if(R===M.lightMeshIndex)continue;let L=Hg(w,r,C,F.aabb);L!=null&&(l=Math.min(L,l))}if(M.children)for(let R of M.children)S(R)};if(S(u),l===Number.MAX_VALUE)return;let I=new Kt(0,0);return Cy(p.tileID.canonical,I,s.node.anchor[0],s.node.anchor[1]),{intersectionZ:l,position:I,feature:s.feature}}let _T={circle:class extends or{constructor(n,e,i,r){super(n,{layout:se||(se=new Ti({"circle-sort-key":new Ze(he.layout_circle["circle-sort-key"]),"circle-elevation-reference":new qe(he.layout_circle["circle-elevation-reference"]),visibility:new qe(he.layout_circle.visibility)})),paint:K||(K=new Ti({"circle-radius":new Ze(he.paint_circle["circle-radius"]),"circle-color":new Ze(he.paint_circle["circle-color"]),"circle-blur":new Ze(he.paint_circle["circle-blur"]),"circle-opacity":new Ze(he.paint_circle["circle-opacity"]),"circle-translate":new qe(he.paint_circle["circle-translate"]),"circle-translate-anchor":new qe(he.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new qe(he.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new qe(he.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ze(he.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ze(he.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ze(he.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new qe(he.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r)}createBucket(n){return new o(n)}queryRadius(n){let e=n;return Z("circle-radius",this,e)+Z("circle-stroke-width",this,e)+G(this.paint.get("circle-translate"))}queryIntersectsFeature(n,e,i,r,s,l,u,p){let f=te(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),l.angle,n.pixelToTileUnitsFactor),g=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return ti(n,r,l,u,p,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",f,g)}getProgramIds(){return["circle"]}getDefaultProgramParams(n,e,i){let r=Li(this);return{config:new rs(this,{zoom:e,lut:i}
vendor: 15,209 bytes, line 7
7),defines:r,overrideFog:!1}}is3D(n){return!n&&!!this.layout&&this.layout.get("circle-elevation-reference")!=="none"}hasElevation(){return this.layout&&this.layout.get("circle-elevation-reference")!=="none"}},heatmap:class extends or{createBucket(n){return new Nt(n)}constructor(n,e,i,r){super(n,{layout:Ji||(Ji=new Ti({visibility:new qe(he.layout_heatmap.visibility)})),paint:Vn||(Vn=new Ti({"heatmap-radius":new Ze(he.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ze(he.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new qe(he.paint_heatmap["heatmap-intensity"]),"heatmap-color":new za(he.paint_heatmap["heatmap-color"]),"heatmap-opacity":new qe(he.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(n){n==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ii({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}queryRadius(n){return Z("heatmap-radius",this,n)}queryIntersectsFeature(n,e,i,r,s,l,u,p){let f=this.paint.get("heatmap-radius").evaluate(e,i);return ti(n,r,l,u,p,!0,!0,new ke(0,0),f)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(n,e,i){return n==="heatmap"?{config:new rs(this,{zoom:e,lut:i}),overrideFog:!1}:{}}},hillshade:class extends or{constructor(n,e,i,r){super(n,{layout:pn||(pn=new Ti({visibility:new qe(he.layout_hillshade.visibility)})),paint:In||(In=new Ti({"hillshade-illumination-direction":new qe(he.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new qe(he.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new qe(he.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new qe(he.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new qe(he.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new qe(he.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new qe(he.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r)}shouldRedrape(){return this.hasOffscreenPass()&&this.paint.get("hillshade-illumination-anchor")==="viewport"}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(n,e,i){return{overrideFog:!1}}},fill:class extends or{constructor(n,e,i,r){super(n,{layout:a0||(a0=new Ti({"fill-sort-key":new Ze(he.layout_fill["fill-sort-key"]),visibility:new qe(he.layout_fill.visibility),"fill-elevation-reference":new qe(he.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new Ze(he.layout_fill["fill-construct-bridge-guard-rail"])})),paint:l0||(l0=new Ti({"fill-antialias":new qe(he.paint_fill["fill-antialias"]),"fill-opacity":new Ze(he.paint_fill["fill-opacity"]),"fill-color":new Ze(he.paint_fill["fill-color"]),"fill-outline-color":new Ze(he.paint_fill["fill-outline-color"]),"fill-translate":new qe(he.paint_fill["fill-translate"]),"fill-translate-anchor":new qe(he.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ze(he.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new qe(he.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new qe(he.paint_fill["fill-emissive-strength"]),"fill-z-offset":new Ze(he.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new Ze(he.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new Ze(he.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r)}getProgramIds(){let n=this.paint.get("fill-pattern"),e=n&&n.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(n,e,i){return{config:new rs(this,{zoom:e,lut:i}),overrideFog:!1}}recalculate(n,e){super.recalculate(n,e);let i=this.paint._values["fill-outline-color"];i.value.kind==="constant"&&i.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(n){return new km(n)}queryRadius(){return G(this.paint.get("fill-translate"))}queryIntersectsFeature(n,e,i,r,s,l){return!n.queryGeometry.isAboveHorizon&&m(re(n.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),l.angle,n.pixelToTileUnitsFactor),r)}isTileClipped(){return this.paint.get("fill-z-offset").constantOr(1)===0}is3D(n){if(this.paint.get("fill-z-offset").constantOr(1)!==0)return!0;let e=this.layout&&this.layout.get("fill-elevation-reference")!=="none";return n!=null?e&&!n:e}hasElevation(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}hasShadowPass(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}},"fill-extrusion":class extends or{constructor(n,e,i,r){super(n,{layout:M0||(M0=new Ti({visibility:new qe(he["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new qe(he["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new qe(he["layout_fill-extrusion"]["source-max-zoom"])})),paint:C0||(C0=new Ti({"fill-extrusion-opacity":new qe(he["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ze(he["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new qe(he["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new qe(he["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ze(he["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new qe(he["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new Ze(he["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ze(he["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new qe(he["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new qe(he["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new qe(he["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new qe(he["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new qe(he["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new qe(he["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new Ze(he["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new Ze(he["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new qe(he["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new qe(he["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new qe(he["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new qe(he["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new qe(he["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new Ze(he["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new Ze(he["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new qe(he["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(n){return new Xm(n)}queryRadius(){return G(this.paint.get("fill-extrusion-translate"))}is3D(n){return!0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(n,e,i,r,s,l,u,p,f){let g=te(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),l.angle,n.pixelToTileUnitsFactor),x=this.paint.get("fill-extrusion-height").evaluate(e,i),b=this.paint.get("fill-extrusion-base").evaluate(e,i),w=[0,0],S=p&&l.elevation,I=l.elevation?l.elevation.exaggeration():1,M=n.tile.getBucket(this);if(M instanceof Xm){let j=M.centroidData.find(H=>f>=H.vertexArrayOffset&&f<H.vertexArrayOffset+H.vertexCount);if(j&&j.flags&Hm)return!1;if(S){let H=M.centroidVertexArray,$=f+1;$<H.length&&(w[0]=H.geta_centroid_pos0($),w[1]=H.geta_centroid_pos1($))}}if(w[0]===0&&w[1]===1)return!1;l.projection.name==="globe"&&(r=A0([r],[new ke(0,0),new ke(Xe,Xe)],n.tileID.canonical).map(j=>j.polygon).flat());let C=S?p:null,[R,F]=k0(l,r,b,x,g,u,C,w,I,l.center.lat,n.tileID.canonical),L=n.queryGeometry;return B0(R,F,L.isPointQuery()?L.screenBounds:L.screenGeometry)}},building:class extends or{constructor(n,e,i,r){super(n,{layout:P0||(P0=new Ti({visibility:new qe(he.layout_building.visibility),"building-facade":new Ze(he.layout_building["building-facade"]),"building-facade-floors":new Ze(he.layout_building["building-facade-floors"]),"building-facade-unit-width":new Ze(he.layout_building["building-facade-unit-width"]),"building-facade-window":new Ze(he.layout_building["building-facade-window"]),"building-roof-shape":new Ze(he.layout_building["building-roof-shape"]),"building-height":new Ze(he.layout_building["building-height"]),"building-base":new Ze(he.layout_building["building-base"]),"building-flood-light-wall-radius":new Ze(he.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Ze(he.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Ze(he.layout_building["building-flip-roof-orientation"])})),paint:D0||(D0=new Ti({"building-opacity":new qe(he.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new qe(he.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new qe(he.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new qe(he.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new qe(he.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new qe(he.paint_building["building-vertical-scale"]),"building-cast-shadows":new qe(he.paint_building["building-cast-shadows"]),"building-color":new Ze(he.paint_building["building-color"]),"building-emissive-strength":new Ze(he.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new qe(he.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new qe(he.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new qe(he.paint_building["building-front-cutoff"]),"building-flood-light-color":new qe(he.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new qe(he.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new qe(he.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}prepare(){return mx()}createBucket(n){return new fx(n)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(n){return!0}queryRadius(n){return 0}queryIntersectsFeature(n,e,i,r,s,l,u,p,f,g){let x=this.layout.get("building-height").evaluate(e,i),b=this.layout.get("building-base").evaluate(e,i),w=n.tile.getBucket(this).getFootprint(e);if(w){if(w.hiddenFlags!==0)return!1;x=w.height}let[S,I]=k0(l,r,b,x,new ke(0,0),u,null,[0,0],1,l.center.lat,n.tileID.canonical),M=n.queryGeometry;return B0(S,I,M.isPointQuery()?M.screenBounds:M.screenGeometry)}},line:class extends or{constructor(n,e,i,r){let s=Ex();super(n,s,e,i,r),s.layout&&(this.layout=new is(s.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null}_handleSpecialPaintPropertyUpdate(n){if(n==="line-gradient"){let e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof gl,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(n,e){super.recalculate(n,e),this.paint._values["line-floorwidth"]=(()=>
7{if(Ip)return Ip;let i=Ex();return Ip=new sw(i.paint.properties["line-width"].specification),Ip.useIntegerZoom=!0,Ip})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,n)}createBucket(n){return new a_(n)}getProgramIds(){let n=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&n.push("lineBlendComposite"),n}getDefaultProgramParams(n,e,i){if(n==="lineBlendComposite")return{};let r=Tx(this);return{config:new rs(this,{zoom:e,lut:i}),defines:r,overrideFog:!1}}queryRadius(n){let e=n,i=Ix(Z("line-width",this,e),Z("line-gap-width",this,e)),r=Z("line-offset",this,e);return i/2+Math.abs(r)+G(this.paint.get("line-translate"))}queryIntersectsFeature(n,e,i,r,s,l){if(n.queryGeometry.isAboveHorizon)return!1;let u=re(n.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),l.angle,n.pixelToTileUnitsFactor),p=n.pixelToTileUnitsFactor/2*Ix(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),f=this.paint.get("line-offset").evaluate(e,i);return f&&(r=function(g,x){let b=[],w=new ke(0,0);for(let S=0;S<g.length;S++){let I=g[S],M=[];for(let C=0;C<I.length;C++){let R=I[C],F=I[C+1],L=C===0?w:R.sub(I[C-1])._unit()._perp(),j=C===I.length-1?w:F.sub(R)._unit()._perp(),H=L._add(j)._unit();H._mult(1/(H.x*j.x+H.y*j.y)),M.push(H._mult(x)._add(R))}b.push(M)}return b}(r,f*n.pixelToTileUnitsFactor)),function(g,x,b){for(let w=0;w<x.length;w++){let S=x[w];if(g.length>=3){for(let I=0;I<S.length;I++)if(z(g,S[I]))return!0}if(_(g,S,b))return!0}return!1}(u,r,p)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(n){return!this.hasElevatedBuckets||this.layout&&this.layout.get("line-elevation-reference")==="hd-road-markup"}hasElevation(){return this.layout&&this.layout.get("line-elevation-reference")!=="none"}hasOffscreenPass(){return this.paint.get("line-blend-mode")!=="default"&&this.paint.get("line-opacity").constantOr(1)!==0&&this.paint.get("line-width").constantOr(1)!==0&&this.visibility!=="none"}resize(){this._destroyLineBlendFbo()}onRemove(n){this._destroyLineBlendFbo(n.painter&&n.painter.context&&n.painter.context.gl||void 0)}_clear(){this._destroyLineBlendFbo()}_destroyLineBlendFbo(n){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),n&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(n),this.lineBlendDensityReadback=null}},symbol:w_,background:class extends or{constructor(n,e,i,r){super(n,{layout:vv||(vv=new Ti({visibility:new qe(he.layout_background.visibility)})),paint:bv||(bv=new Ti({"background-pitch-alignment":new qe(he.paint_background["background-pitch-alignment"]),"background-color":new qe(he.paint_background["background-color"]),"background-pattern":new qe(he.paint_background["background-pattern"]),"background-opacity":new qe(he.paint_background["background-opacity"]),"background-emissive-strength":new qe(he.paint_background["background-emissive-strength"]),"background-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(n,e,i){return{overrideFog:!1}}is3D(n){return this.paint.get("background-pitch-alignment")==="viewport"}},raster:Iv,"raster-particle":zv,sky:class extends or{constructor(n,e,i,r){super(n,{layout:Cv||(Cv=new Ti({visibility:new qe(he.layout_sky.visibility)})),paint:Pv||(Pv=new Ti({"sky-type":new qe(he.paint_sky["sky-type"]),"sky-atmosphere-sun":new qe(he.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new qe(he.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new qe(he.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new qe(he.paint_sky["sky-gradient-radius"]),"sky-gradient":new za(he.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new qe(he.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new qe(he.paint_sky["sky-atmosphere-color"]),"sky-opacity":new qe(he.paint_sky["sky-opacity"]),"sky-gradient-use
7-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this._updateColorRamp()}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0}_handleSpecialPaintPropertyUpdate(n){n==="sky-gradient"?this._updateColorRamp():n!=="sky-atmosphere-sun"&&n!=="sky-atmosphere-halo-color"&&n!=="sky-atmosphere-color"&&n!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=ii({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(n){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){let e=n.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(n,e){if(this.paint.get("sky-type")==="atmosphere"){let r=this.paint.get("sky-atmosphere-sun"),s=!r,l=n.style.light,u=l.properties.get("position");return s&&l.properties.get("anchor")==="viewport"&&Bt("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),s?Iy(u.azimuthal,90-u.polar,e):Iy(r[0],90-r[1],e)}let i=this.paint.get("sky-gradient-center");return Iy(i[0],90-i[1],e)}isSky(){return!0}markSkyboxValid(n){this._skyboxInvalidated=!1,this._lightPosition=n.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){let n=this.paint.get("sky-type");return n==="atmosphere"?["skyboxCapture","skybox"]:n==="gradient"?["skyboxGradient"]:null}},slot:class extends or{constructor(n,e,i,r){super(n,{paint:Dv||(Dv=new Ti({}))},e,null)}},model:class extends or{constructor(n,e,i,r){super(n,{layout:Rv||(Rv=new Ti({visibility:new qe(he.layout_model.visibility),"model-id":new Ze(he.layout_model["model-id"]),"model-allow-density-reduction":new qe(he.layout_model["model-allow-density-reduction"])})),paint:Lv||(Lv=new Ti({"model-opacity":new Ze(he.paint_model["model-opacity"]),"model-rotation":new Ze(he.paint_model["model-rotation"]),"model-scale":new Ze(he.paint_model["model-scale"]),"model-translation":new Ze(he.paint_model["model-translation"]),"model-color":new Ze(he.paint_model["model-color"]),"model-color-mix-intensity":new Ze(he.paint_model["model-color-mix-intensity"]),"model-type":new qe(he.paint_model["model-type"]),"model-cast-shadows":new qe(he.paint_model["model-cast-shadows"]),"model-receive-shadows":new qe(he.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new qe(he.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Ze(he.paint_model["model-emissive-strength"]),"model-roughness":new Ze(he.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Ze(he.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new qe(he.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new qe(he.paint_model["model-front-cutoff"]),"model-elevation-reference":new qe(he.paint_model["model-elevation-reference"]),"model-ignore-line-cutout":new qe(he.paint_model["model-ignore-line-cutout"]),"model-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,i,r),this.layer=n,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(n){return new Ay(n)}getProgramIds(){return["model"]}is3D(n){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(n){return n instanceof M_?8191:0}queryRenderedFeatures(n,e,i){let r=e.getSource();if(!(r&&r instanceof lu))return{};let s=r,l={};l[this.id]=[];let u=l[this.id],p=0;for(let f of s.models){let g=e.getFeatureState(this.sourceLayer,f.id),x={type:"Unknown",id:f.id,properties:f.featureProperties},b=this.paint.get("model-rotation").evaluate(x,g),w=this.paint.get("model-scale").evaluate(x,g),S=this.paint.get("model-translation").evaluate(x,g),I=this.paint.get("model-elevation-reference"),M=[];r_(M,f,i,f.position,b,w,S,I==="ground",I==="ground",!1),i.projection.name==="globe"&&(M=n_(M,i));let C=xi([],i.projMatrix,M),R=Hg(n.isPointQuery()?n.screenBounds:n.screenGeometry,i,C,f.aabb);if(R!=null){let F=new au(void 0,0,0,0,f.id);F.layer=this.layer,F.properties=structuredClone(f.featureProperties),F.properties.layer=this.id,F.properties.uri=f.uri,F.properties.orientation=f.orientation,F.sourceLayer=this.sourceLayer,F.geometry={type:"Point",coordinates:[f.position.lng,f.position.lat]},F.state=g,F.source=this.source,u.push({featureIndex:p,feature:F,intersectionZ:R})}++p}return l}queryIntersectsFeature(n,e,i,r,s,l,u,p,f,g){if(!this.modelManager)return!1;let x=this.modelManager,b=n.tile.getBucket(this);if(!(b&&b instanceof Ay))return!1;for(let w in b.instancesPerModel){let S=b.instancesPerModel[w],I=e.id!==void 0?e.id:e.properties&&Object.hasOwn(e.properties,"id")?e.properties.id:void 0;if(Object.hasOwn(S.idToFeaturesIndex,I)){let M=S.features[S.idToFeaturesIndex[I]],C=x.getModel(w,g||this.scope);if(!C)return!1;let R=[],F=new Kt(0,0),L=b.canonical,j=Number.MAX_VALUE;for(let H=0;H<M.instancedDataCount;++H){let $=16*(M.instancedDataOffset+H),ie=S.instancedDataArray.float32,W=[ie[$+4],ie[$+5],ie[$+6]];Cy(L,F,Math.floor(ie[$]),Math.floor(ie[$+1])),r_(R,C,l,F,M.rotation,M.scale,W,!1,!1,!1),l.projection.name==="globe"&&(R=n_(R,l));let Q=xi([],l.projMatrix,R),Y=n.queryGeometry,ee=Hg(Y.isPointQuery()?Y.screenBounds:Y.screenGeometry,l,Q,C.aabb);ee!=null&&(j=Math.min(ee,j))}return j!==Number.MAX_VALUE&&j}}return!1}_handleOverridablePaintPropertyUpdate(n,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven()||n!=="model-color"&&n!=="model-color-mix-intensity"&&n!=="model-rotation"&&n!=="model-scale"&&n!=="model-translation"&&n!=="model-emissive-strength")}_isPropertyZoomDependent(n){let e=this._transitionablePaint._values[n];return e!=null&&e.value!=null&&e.value.expression!=null&&e.value.expression instanceof bl}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends or{constructor(n,e,i,r){super(n,{layout:c0||(c0=new Ti({"clip-layer-types":ne
7w qe(he.layout_clip["clip-layer-types"]),"clip-layer-scope":new qe(he.layout_clip["clip-layer-scope"]),visibility:new qe(he.layout_clip.visibility)})),paint:u0||(u0=new Ti({}))},e,i,r)}recalculate(n,e){super.recalculate(n,e)}createBucket(n){return new h0(n)}is3D(n){return!0}}};class Py{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;let i=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,i),i}put(e,i){this.cache.has(e)?this.cache.delete(e):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(e,i)}delete(e){this.cache.delete(e)}}Qe(Py,"LRUCache");class gT{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class jv{constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i<e.length;i++){let r=e[i];this._stringToNumber[r]=i,this._numberToString[i]=r}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}class Gv{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Ra(Xe,Xe,512),this.featureIndexArray=new hm,this.promoteId=i,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,i,r,s,l,u=0,p=0){let f=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,s,l,u);let g=this.grid;for(let x=0;x<i.length;x++){let b=i[x],w=[1/0,1/0,-1/0,-1/0];for(let S=0;S<b.length;S++){let I=b[S];w[0]=Math.min(w[0],I.x),w[1]=Math.min(w[1],I.y),w[2]=Math.max(w[2],I.x),w[3]=Math.max(w[3],I.y)}p!==0&&(w[0]-=p,w[1]-=p,w[2]+=p,w[3]+=p),w[0]<Xe&&w[1]<Xe&&w[2]>=0&&w[3]>=0&&g.insert(f,w[0],w[1],w[2],w[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new lp(new l_(this.rawTileData)).layers,this.sourceLayerCoder=new jv(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(let e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,i){let{tilespaceGeometry:r,transform:s,tileTransform:l,pixelPosMatrix:u,availableImages:p,worldview:f}=i;this.loadVTLayers(),this.serializedLayersCache.clear();let g=i.queryRadius?i.queryRadius:0,x=r.bufferedTilespaceBounds,b=this.grid.queryKeys(x.min.x,x.min.y,x.max.x,x.max.y,(M,C,R,F)=>O(r.bufferedTilespaceGeometry,M-g,C-g,R+g,F+g));b.sort(yT);let w=null;s.elevation&&b.length>0&&(w=Mh.create(s.elevation,this.tileID));let S={},I;for(let M=0;M<b.length;M++){let C=b[M];if(C===I)continue;I=C;let R=this.featureIndexArray.get(C),F=null;this.is3DTile?this.loadMatchingModelFeature(S,R,e,r,s,f):this.loadMatchingFeature(S,R,e,p,f,(L,j,H,$=0)=>(F||(F=$r(L,this.tileID.canonical,l)),j.queryIntersectsFeature(r,L,H,F,this.z,s,u,w,$,i.scope)))}return S}loadMatchingFeature(e,i,r,s,l,u){let{featureIndex:p,bucketIndex:f,sourceLayerIndex:g,layoutVertexArrayOffset:x}=i,b=this.bucketLayerIDs[f],w=r.layers,S=Object.keys(w);if(S.length&&!qi(S,b))return;let I=r.sourceCache,M=this.sourceLayerCoder.decode(g),C=this.vtLayers[M].feature(p),R=this.getId(C,M);for(let F=0;F<b.length;F++){let L=b[F];if(!w[L])continue;let{styleLayer:j,targets:H}=w[L],$={};R!==void 0&&($=I.getFeatureState(j.sourceLayer,R));let ie=!u||u(C,j,$,x);if(!ie)continue;let W=new au(C,this.z,this.x,this.y,R);W.tile=this.tileID.canonical,W.state=$;let Q=this.serializedLayersCache.get(L);Q||(Q=j.serialize(),Q.id=L,this.serializedLayersCache.set(L,Q)),W.source=Q.source,W.sourceLayer=Q["source-layer"],W.layer=Object.assign({},Q),W.layer.paint=Hv(Q.paint,j.paint,C,$,s),W.layer.layout=Hv(Q.layout,j.layout,C,$,s);let Y=!1;for(let ee of H){this.updateFeatureProperties(W,ee);let{filter:me}=ee;if(me){if(C.properties=W.properties,me.needGeometry){let ge=qr(C,!0);if(!me.filter(new Jt(this.tileID.overscaledZ,{worldview:l}),ge,this.tileID.canonical))continue}else if(!me.filter(new Jt(this.tileID.overscaledZ,{worldview:l}),C))continue}Y=!0,ee.targetId&&this.addFeatureVariant(W,ee)}Y&&this.appendToResult(e,L,p,W,ie)}}
7loadMatchingModelFeature(e,i,r,s,l,u){let{featureIndex:p,bucketIndex:f}=i,g=this.bucketLayerIDs[f],x=r.layers,b=Object.keys(x);if(!b.length||qi(b,g))for(let w=0;w<g.length;w++){let S=g[w],{styleLayer:I,targets:M}=x[S];if(I.type!=="model")continue;let C=s.tile,R=C.getBucket(I);if(!(R&&R instanceof M_))continue;let F=mT(R,p,s,l);if(!F)continue;let{z:L,x:j,y:H}=C.tileID.canonical,{feature:$,intersectionZ:ie,position:W}=F,Q={};$.id!==void 0&&(Q=r.sourceCache.getFeatureState(I.sourceLayer,$.id));let Y=new au({},L,j,H,$.id);Y.tile=this.tileID.canonical,Y.state=Q,Y.properties=$.properties,Y.geometry={type:"Point",coordinates:[W.lng,W.lat]};let ee=this.serializedLayersCache.get(S);ee||(ee=I.serialize(),ee.id=S,this.serializedLayersCache.set(S,ee)),Y.source=ee.source,Y.sourceLayer=ee["source-layer"],Y.layer=Object.assign({},ee);let me=!1;for(let ge of M){this.updateFeatureProperties(Y,ge);let{filter:Te}=ge;if(Te){if($.properties=Y.properties,Te.needGeometry){if(!Te.filter(new Jt(this.tileID.overscaledZ,{worldview:u}),$,this.tileID.canonical))continue}else if(!Te.filter(new Jt(this.tileID.overscaledZ,{worldview:u}),$))continue}me=!0,ge.targetId&&this.addFeatureVariant(Y,ge)}me&&this.appendToResult(e,S,p,Y,ie)}}updateFeatureProperties(e,i,r){if(i.properties){let s={};for(let l in i.properties){let u=i.properties[l].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,r);u!=null&&(s[l]=u)}e.properties=s}}addFeatureVariant(e,i,r){let s={target:i.target,namespace:i.namespace,uniqueFeatureID:i.uniqueFeatureID};i.properties&&(s.properties=e.properties),e.variants=e.variants||{},e.variants[i.targetId]=e.variants[i.targetId]||[],e.variants[i.targetId].push(s)}appendToResult(e,i,r,s,l){let u=e[i];u===void 0&&(u=e[i]=[]),u.push({featureIndex:r,feature:s,intersectionZ:l})}lookupSymbolFeatures(e,i,r,s,l,u){let p={};this.loadVTLayers();for(let f of e)this.loadMatchingFeature(p,{bucketIndex:i,sourceLayerIndex:r,featureIndex:f,layoutVertexArrayOffset:0},s,l,u);return p}loadFeature(e){let{featureIndex:i,sourceLayerIndex:r}=e;this.loadVTLayers();let s=this.sourceLayerCoder.decode(r),l=this.vtFeatures[s];if(l[i])return l[i];let u=this.vtLayers[s].feature(i);return l[i]=u,u}hasLayer(e){for(let i of this.bucketLayerIDs)for(let r of i)if(e===r)return!0;return!1}getId(e,i){let r=e.id;if(this.promoteId){let s=Array.isArray(this.promoteId)||typeof this.promoteId!="object"?this.promoteId:this.promoteId[i];if(s!=null)if(Array.isArray(s)){if(!this.promoteIdExpression){let l=Pa(s);if(l.result!=="success"){let u=l.value.map(p=>`${p.key}: ${p.message}`).join(", ");return void Bt(`Failed to create expression for promoteId: ${u}`)}this.promoteIdExpression=l.value}r=this.promoteIdExpression.evaluate({zoom:0},e)}else r=e.properties[s];typeof r=="boolean"&&(r=Number(r))}return r}}function Hv(n,e,i,r,s){return Dt(n,(l,u)=>{let p=e instanceof is?e.get(u):null;return p&&p.evaluate?p.evaluate(i,r,void 0,s):p})}function yT(n,e){return e-n}function $v(n,e){let i={};if(!e)return i;for(let r of n){let s=r.layerIds.map(l=>e.getLayer(l)).filter(Boolean);if(s.length!==0){r.layers=s,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(l=>s.filter(u=>u.id===l)[0])),r.updateExpressions&&r.updateExpressions(s);for(let l of s)i[l.fqid]=r}}return i}Qe(Gv,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});let Uo=32,Js=33,ql=new Uint16Array(8184);for(let n=0;n<2046;n++){let e=n+2,i=0,r=0,s=0,l=0,u=0,p=0;for(1&e?s=l=u=Uo:i=r=p=Uo;(e>>=1)>1;){let g=i+s>>1,x=r+l>>1;1&e?(s=i,l=r,i=u,r=p):(i=s,r=l,s=u,l=p),u=g,p=x}let f=4*n;ql[f+0]=i,ql[f+1]=r,ql[f+2]=s,ql[f+3]=l}
7let Ks=new Uint16Array(2178),Zl=new Uint8Array(1089),C_=new Uint16Array(1089);function qv(n){return n===0?-.03125:n===32?.03125:0}let Zv={Other:0,Symbol:1,FillExtrusion:2},Wv={type:2,extent:Xe,loadGeometry:()=>[[new ke(0,0),new ke(8193,0),new ke(8193,8193),new ke(0,8193),new ke(0,0)]]};class xT{constructor(){this.tasks={},this.taskQueue=[],It(["process"],this),this.invoker=new gT(this.process),this.nextId=0}add(e,i){let r=this.nextId++,s=function({type:l,renderSourceType:u,zoom:p}){p=p||0;let f=u===Zv.Symbol;return l==="message"?0:l!=="maybePrepare"||f?l!=="parseTile"||f?l==="parseTile"&&f?300-p:l==="maybePrepare"&&f?400-p:500:200-p:100-p}(i);if(s===0){try{e()}finally{}return null}return this.tasks[r]={fn:e,metadata:i,priority:s,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(r=>!!this.tasks[r]),!this.taskQueue.length)return;let e=this.pick();if(e===null)return;let i=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!i)return;i.fn()}finally{}}pick(){let e=null,i=1/0;for(let s=0;s<this.taskQueue.length;s++){let l=this.tasks[this.taskQueue[s]];l.priority<i&&(i=l.priority,e=s)}if(e===null)return null;let r=this.taskQueue[e];return this.taskQueue.splice(e,1),r}remove(){this.invoker.remove()}}function Xv(n,e,i){try{e=function(s){if(!s.variants)return s;if(!Array.isArray(s.variants))throw new Error("variants must be an array");for(let l of s.variants){if(l==null||typeof l!="object"||l.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(l.capabilities))throw new Error("capabilities must be an array");if(l.capabilities.length===1&&l.capabilities[0]==="meshopt")return Object.assign(s,l)}return s}(e)}catch(s){return new Error("Failed to process TileJSON variants",{cause:s})}let r=Ke(Object.assign({},e,n),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return n.url&&e.tiles&&n.tiles&&(r.tiles=e.tiles),r.tiles=i.canonicalizeTileset(r,n.url),r}let Dy=new Map,Yv=new Map;class Jv{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,i){let r=this.toIdx(e,i);return{min:this.minimums[r],max:this.maximums[r]}}isLeaf(e,i){return this.leaves[this.toIdx(e,i)]}toIdx(e,i){return i*this.size+e}}function Kv(n,e,i,r){let s=0,l=Number.MAX_VALUE;for(let u=0;u<3;u++)if(Math.abs(r[u])<1e-15){if(i[u]<n[u]||i[u]>e[u])return null}else{let p=1/r[u],f=(n[u]-i[u])*p,g=(e[u]-i[u])*p;if(f>g){let x=f;f=g,g=x}if(f>s&&(s=f),g<l&&(l=g),s>l)return null}return s}function Qv(n,e,i,r,s,l,u,p,f,g,x){let b=r-n,w=s-e,S=l-i,I=u-n,M=p-e,C=f-i,R=x[1]*C-x[2]*M,F=x[2]*I-x[0]*C,L=x[0]*M-x[1]*I,j=b*R+w*F+S*L;if(Math.abs(j)<1e-15)return null;let H=1/j,$=g[0]-n,ie=g[1]-e,W=g[2]-i,Q=($*R+ie*F+W*L)*H;if(Q<0||Q>1)return null;let Y=ie*S-W*w,ee=W*b-$*S,me=$*w-ie*b,ge=(x[0]*Y+x[1]*ee+x[2]*me)*H;return ge<0||Q+ge>1?null:(I*Y+M*ee+C*me)*H}function e1(n,e,i){return(n-e)/(i-e)}function t1(n,e,i,r,s,l,u,p,f){let g=1<<i,x=l-r,b=u-s,w=(n+1)/g*x+r,S=(e+0)/g*b+s,I=(e+1)/g*b+s;p[0]=(n+0)/g*x+r,p[1]=S,f[0]=w,f[1]=I}class i1{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;let i=function(l){let u=Math.ceil(Math.log2(l.dim/8)),p=[],f=Math.ceil(Math.pow(2,u)),g=1/f,x=(S,I,M,C,R)=>{let F=C?1:0,L=(S+1)*M-F,j=I*M,H=(I+1)*M-F;R[0]=S*M,R[1]=j,R[2]=L,R[3]=H},b=new Jv(f),w=[];for(let S=0;S<f*f;S++){x(S%f,Math.floor(S/f),g,!1,w);let I=Wl(w[0],w[1],l),M=Wl(w[2],w[1],l),C=Wl(w[2],w[3],l),R=Wl(w[0],w[3],l);b.minimums.push(Math.min(I,M,C,R)),b.maximums.push(Math.max(I,M,C,R)),b.leaves.push(1)}for(p.push(b),f/=2;f>=1;f/=2){let S=p.at(-1);b=new Jv(f);for(let I=0;I<f*f;I++){x(I%f,Math.floor(I/f),2,!0,w);let M=S.getElevation(w[0],w[1]),C=S.getElevation(w[2],w[1]),R=S.getElevation(w[2],w[3]),F=S.getElevation(w[0],w[3]),L=S.isLeaf(w[0],w[1]),j=S.isLeaf(w[2],w[1]),H=S.isLeaf(w[2],w[3]),$=S.isLeaf(w[0],w[3]),ie=Math.min(M.min,C.min,R.min,F.min),W=Math.max(M.max,C.max,R.max,F.max),Q=L&&j&&H&&$;b.maximums.push(W),b.minimums.push(ie),b.leaves.push(W-ie<=5&&Q?1:0)}p.push(b)}return p}(this.dem),r=i.length-1,s=i[r];this._addNode(s.minimums[0],s.maximums[0],s.leaves[0]),this._construct(i,
70,0,r,0)}raycastRoot(e,i,r,s,l,u,p=1){return Kv([e,i,-100],[r,s,this.maximums[0]*p],l,u)}raycast(e,i,r,s,l,u,p=1){if(!this.nodeCount)return null;let f=this.raycastRoot(e,i,r,s,l,u,p);if(f==null)return null;let g=[],x=[],b=[],w=[],S=[{idx:0,t:f,nodex:0,nodey:0,depth:0}];for(;S.length>0;){let{idx:I,t:M,nodex:C,nodey:R,depth:F}=S.pop();if(this.leaves[I]){t1(C,R,F,e,i,r,s,b,w);let j=1<<F,H=(C+0)/j,$=(C+1)/j,ie=(R+0)/j,W=(R+1)/j,Q=Wl(H,ie,this.dem)*p,Y=Wl($,ie,this.dem)*p,ee=Wl($,W,this.dem)*p,me=Wl(H,W,this.dem)*p,ge=Qv(b[0],b[1],Q,w[0],b[1],Y,w[0],w[1],ee,l,u),Te=Qv(w[0],w[1],ee,b[0],w[1],me,b[0],b[1],Q,l,u),Ae=Math.min(ge!==null?ge:Number.MAX_VALUE,Te!==null?Te:Number.MAX_VALUE);if(Ae!==Number.MAX_VALUE)return Ae;{let Ie=zr([],l,u,M);if(n1(Q,Y,me,ee,e1(Ie[0],b[0],w[0]),e1(Ie[1],b[1],w[1]))>=Ie[2])return M}continue}let L=0;for(let j=0;j<this._siblingOffset.length;j++){t1((C<<1)+this._siblingOffset[j][0],(R<<1)+this._siblingOffset[j][1],F+1,e,i,r,s,b,w),b[2]=-100,w[2]=this.maximums[this.childOffsets[I]+j]*p;let H=Kv(b,w,l,u);if(H!=null){let $=H;g[j]=$;let ie=!1;for(let W=0;W<L&&!ie;W++)$>=g[x[W]]&&(x.splice(W,0,j),ie=!0);ie||(x[L]=j),L++}}for(let j=0;j<L;j++){let H=x[j];S.push({idx:this.childOffsets[I]+H,t:g[H],nodex:(C<<1)+this._siblingOffset[H][0],nodey:(R<<1)+this._siblingOffset[H][1],depth:F+1})}}return null}_addNode(e,i,r){return this.minimums.push(e),this.maximums.push(i),this.leaves.push(r),this.childOffsets.push(0),this.nodeCount++}_construct(e,i,r,s,l){if(e[s].isLeaf(i,r)===1)return;this.childOffsets[l]||(this.childOffsets[l]=this.nodeCount);let u=s-1,p=e[u],f=0,g=0;for(let x=0;x<this._siblingOffset.length;x++){let b=2*i+this._siblingOffset[x][0],w=2*r+this._siblingOffset[x][1],S=p.getElevation(b,w),I=p.isLeaf(b,w),M=this._addNode(S.min,S.max,I);I&&(f|=1<<x),g||(g=M)}for(let x=0;x<this._siblingOffset.length;x++)f&1<<x||this._construct(e,2*i+this._siblingOffset[x][0],2*r+this._siblingOffset[x][1],u,g+x)}}function n1(n,e,i,r,s,l){return mt(mt(n,i,l),mt(e,r,l),s)}function Wl(n,e,i){let r=i.dim,s=ne(n*r-.5,0,r-1),l=ne(e*r-.5,0,r-1),u=Math.floor(s),p=Math.floor(l),f=Math.min(u+1,r-1),g=Math.min(p+1,r-1);return n1(i.get(u,p),i.get(f,p),i.get(u,g),i.get(f,g),s-u,l-p)}let vT={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function bT(n,e,i){return(256*n*256+256*e+i)/10-1e4}function wT(n,e,i){return 256*n+e+i/256-32768}class P_{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,i,r,s=!1){if(this.uid=e,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(r&&r!=="mapbox"&&r!=="terrarium")return void Bt(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=i.height;let l=this.dim=i.height-2,u=new Uint32Array(i.data.buffer);if(this.pixels=new Uint8Array(i.data.buffer),this.floatView=new Float32Array(i.data.buffer),this.borderReady=s,this._modifiedForSources={},!s){for(let f=0;f<l;f++)u[this._idx(-1,f)]=u[this._idx(0,f)],u[this._idx(l,f)]=u[this._idx(l-1,f)],u[this._idx(f,-1)]=u[this._idx(f,0)],u[this._idx(f,l)]=u[this._idx(f,l-1)];u[this._idx(-1,-1)]=u[this._idx(0,0)],u[this._idx(l,-1)]=u[this._idx(l-1,0)],u[this._idx(-1,l)]=u[this._idx(0,l-1)],u[this._idx(l,l)]=u[this._idx(l-1,l-1)]}let p=r==="terrarium"?wT:bT;
7for(let f=0;f<u.length;++f){let g=4*f;this.floatView[f]=p(this.pixels[g],this.pixels[g+1],this.pixels[g+2])}this._timestamp=yn.now()}_buildQuadTree(){this._tree=new i1(this)}get(e,i,r=!1){r&&(e=ne(e,-1,this.dim),i=ne(i,-1,this.dim));let s=this._idx(e,i);return this.floatView[s]}set(e,i,r){let s=this._idx(e,i),l=this.floatView[s];return this.floatView[s]=r,r-l}static getUnpackVector(e){return vT[e]}_idx(e,i){if(e<-1||e>=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+(e+1)}static pack(e,i){let r=[0,0,0,0],s=P_.getUnpackVector(i),l=Math.floor((e+s[3])/s[2]);return r[2]=l%256,l=Math.floor(l/256),r[1]=l%256,l=Math.floor(l/256),r[0]=l,r}getPixels(){return new Ii({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let s=i*this.dim,l=i*this.dim+this.dim,u=r*this.dim,p=r*this.dim+this.dim;switch(i){case-1:s=l-1;break;case 1:l=s+1}switch(r){case-1:u=p-1;break;case 1:p=u+1}let f=-i*this.dim,g=-r*this.dim;for(let x=u;x<p;x++)for(let b=s;b<l;b++){let w=4*this._idx(b,x),S=4*this._idx(b+f,x+g);this.pixels[w+0]=e.pixels[S+0],this.pixels[w+1]=e.pixels[S+1],this.pixels[w+2]=e.pixels[S+2],this.pixels[w+3]=e.pixels[S+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function TT(n,e,i){n===1?e.headerLength=i.readFixed32():n===2?e.x=i.readVarint():n===3?e.y=i.readVarint():n===4?e.z=i.readVarint():n===5&&e.layers.push(function(r,s){return r.readFields(MT,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},s)}(i,i.readVarint()+i.pos))}function ST(n,e,i){n===1?(e.delta_filter=function(r,s){return r.readFields(ET,{blockSize:0},s)}(i,i.readVarint()+i.pos),e.filter="delta_filter"):n===2?(i.readVarint(),e.filter="zigzag_filter"):n===3?(i.readVarint(),e.filter="bitshuffle_filter"):n===4&&(i.readVarint(),e.filter="byteshuffle_filter")}function ET(n,e,i){n===1&&(e.blockSize=i.readVarint())}function IT(n,e,i){n===1?(i.readVarint(),e.codec="gzip_data"):n===2?(i.readVarint(),e.codec="jpeg_image"):n===3?(i.readVarint(),e.codec="webp_image"):n===4&&(i.readVarint(),e.codec="png_image")}function AT(n,e,i){let r=0,s=0;n===1?e.firstByte=i.readFixed64():n===2?e.lastByte=i.readFixed64():n===3?e.filters.push(function(l,u){return l.readFields(ST,{},u)}(i,i.readVarint()+i.pos)):n===4?e.codec=function(l,u){return l.readFields(IT,{},u)}(i,i.readVarint()+i.pos):n===5?s=i.readFloat():n===6?r=i.readFloat():n===7?e.bands.push(i.readString()):n===8?e.offset=i.readDouble():n===9&&(e.scale=i.readDouble()),e.offset===0&&(e.offset=s),e.scale===0&&(e.scale=r)}function MT(n,e,i){n===1?e.version=i.readVarint():n===2?e.name=i.readString():n===3?e.units=i.readString():n===4?e.tileSize=i.readVarint():n===5?e.buffer=i.readVarint():n===6?e.pixelFormat=i.readVarint():n===7&&e.dataIndex.push(function(r,s){return r.readFields(AT,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},s)}(i,i.readVarint()+i.pos))}function CT(n,e,i){if(n===2)(function(r,s,l){r.readFields(PT,l,s)})(i,i.readVarint()+i.pos,e);else if(n===3)throw new Error("Not implemented")}function PT(n,e,i){if(n===1){let r=0,s=i.readVarint()+i.pos;for(;i.pos<s;)e[r++]=i.readVarint()}}function DT(n,e){if(e.length!==4)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let i=e[3];for(let r=2;r>=1;r--){let s=r===1?1:0,l=r===2?1:0;for(let u=0;u<e[0];u++){let p=e[1]*u;for(let f=s;f<e[1];f++){let g=e[2]*(f+p);for(let x=l;x<e[2];x++){let b=e[3]*(x+g);for(let w=0;w<e[3];w++){let S=b+w;n[S]+=n[S-i]}}}}i*=e[r]}return n}function RT(n){for(let e=0,i=n.length;e<i;e++)n[e]=n[e]>>>1^-(1&n[e]);return n}function LT(n,e){switch(e){case"uint32":return n;case"uint16":for(let i=0;i<n.length;i+=2){let r=n[i],s=n[i+1];n[i]=(240&r)>>4|(61440&r)>>8|(240&s)<<4|61440&s,n[i+1]=15&r|(3840&r)>>4|(15&s)<<8|(3840&s)<<4}return n;case"uint8":for(let i=0;i<n.length;i+=4){let r=n[i],s=n[i+1],l=n[i+2],u=n[i+3];n[i+0]=(192&r)>>6|(192&s)>>4|(192&l)>>2|192&u,n[i+1]=(48&r)>>4|(48&s)>>2|48&l|(48&u)<<2,n[i+2]=(12&r)>>2|12&s|(12&l)<<2|(12&u)<<4,n[i+3]=3&r|(3&s)<<2|(3&l)<<4|(3&u)<<6}return n;default:throw new Error(`Invalid pixel format, "${e}"`)}}Qe(P_,"DEMData"),Qe(i1,"DemMinMaxQuadTree",{omit:["dem"]});var Ao=Uint8Array,Vp=Uint16Array,zT=Int32Array,r1=new Ao([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),o1=new Ao([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),OT=new Ao([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s1=function(n,e){for(var i=new Vp(31),r=0;r<31;++r)i[r]=e+=1<<n[r-1];var s=new zT(i[30]);for(r=1;r<30;++r)for(var l=i[r];l<i[r+1];++l)s[l]=l-i[r]<<5|r;return{b:i,r:s}
7},a1=s1(r1,2),l1=a1.b,FT=a1.r;l1[28]=258,FT[258]=28;for(var BT=s1(o1,0).b,c1=new Vp(32768),fn=0;fn<32768;++fn){var Ch=(43690&fn)>>1|(21845&fn)<<1;c1[fn]=((65280&(Ch=(61680&(Ch=(52428&Ch)>>2|(13107&Ch)<<2))>>4|(3855&Ch)<<4))>>8|(255&Ch)<<8)>>1}var jp=function(n,e,i){for(var r=n.length,s=0,l=new Vp(e);s<r;++s)n[s]&&++l[n[s]-1];var u,p=new Vp(e);for(s=1;s<e;++s)p[s]=p[s-1]+l[s-1]<<1;u=new Vp(1<<e);var f=15-e;for(s=0;s<r;++s)if(n[s])for(var g=s<<4|n[s],x=e-n[s],b=p[n[s]-1]++<<x,w=b|(1<<x)-1;b<=w;++b)u[c1[b]>>f]=g;return u},Gp=new Ao(288);for(fn=0;fn<144;++fn)Gp[fn]=8;for(fn=144;fn<256;++fn)Gp[fn]=9;for(fn=256;fn<280;++fn)Gp[fn]=7;for(fn=280;fn<288;++fn)Gp[fn]=8;var u1=new Ao(32);for(fn=0;fn<32;++fn)u1[fn]=5;var kT=jp(Gp,9),NT=jp(u1,5),Ry=function(n){for(var e=n[0],i=1;i<n.length;++i)n[i]>e&&(e=n[i]);return e},ps=function(n,e,i){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(7&e)&i},Ly=function(n,e){var i=e/8|0;return(n[i]|n[i+1]<<8|n[i+2]<<16)>>(7&e)},UT=function(n){return(n+7)/8|0},VT=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],fs=function(n,e,i){var r=new Error(e||VT[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,fs),!i)throw r;return r},jT=new Ao(0),GT=typeof TextDecoder<"u"&&new TextDecoder;try{GT.decode(jT,{stream:!0})}catch{}let HT={gzip_data:"gzip"};class Vo extends Error{constructor(e){super(e),this.name="MRTError"}}let $T={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},h1={uint32:1,uint16:2,uint8:4},qT={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array},zy;class D_{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){let i=this.layers[e];if(!i)throw new Vo(`Layer '${e}' not found`);return i}getHeaderLength(e){let i=new Uint8Array(e),r=new DataView(e);if(i[0]!==13)throw new Vo("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(e){let i=new Uint8Array(e),r=this.getHeaderLength(e);if(i.length<r)throw new Vo(`Expected header with length >= ${r} but got buffer of length ${i.length}`);let s=new zy(i.subarray(0,r)).readFields(TT,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==s.x||this.y!==s.y||this.z!==s.z))throw new Vo(`Invalid attempt to parse header ${s.z}/${s.x}/${s.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=s.x,this.y=s.y,this.z=s.z;for(let l of s.layers)this.layers[l.name]=new d1(l,{cacheSize:this._cacheSize});return this}createDecodingTask(e){let i=[],r=this.getLayer(e.layerName);for(let s of e.blockIndices){let l=r.dataIndex[s],u=l.firstByte-e.firstByte,p=l.lastByte-e.firstByte;if(r._blocksInProgress.has(s))continue;let f={layerName:r.name,firstByte:u,lastByte:p,pixelFormat:r.pixelFormat,blockIndex:s,blockShape:[l.bands.length].concat(r.bandShape),buffer:r.buffer,codec:l.codec.codec,filters:l.filters.map(g=>g.filter)};r._blocksInProgress.add(s),i.push(f)}return new p1(i,()=>{i.forEach(s=>r._blocksInProgress.delete(s.blockIndex))},(s,l)=>{if(i.forEach(u=>r._blocksInProgress.delete(u.blockIndex)),s)throw s;l.forEach(u=>{this.getLayer(u.layerName).processDecodedData(u)})})}}class d1{constructor({version:e,name:i,units:r,tileSize:s,pixelFormat:l,buffer:u,dataIndex:p},f){if(this.version=e,this.version!==1)throw new Vo(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=i,this.units=r,this.tileSize=s,this.buffer=u,this.pixelFormat=$T[l],this.dataIndex=p,this.bandShape=[s+2*u,s+2*u,h1[this.pixelFormat]],this._decodedBlocks=new Py(f?f.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return h1[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){let i=e.blockIndex.toString();this._decodedBlocks.get(i)||this._decodedBlocks.put(i,e.data)}getBlockForBand(e){let i=0;switch(typeof e){case"string":for(let[r,s]of this.dataIndex.entries()){for(let[l,u]of s.bands.entries())if(u===e)return{bandIndex:i+l,blockIndex:r,blockBandIndex:l};i+=s.bands.length}break;case"number":for(let[r,s]of this.dataIndex.entries()){if(e>=i&&e<i+s.bands.length)return{bandIndex:e,blockIndex:r,blockBandIndex:e-i};i+=s.bands.length}break;default:throw new Vo(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let i=1/0,r=-1/0,s=[],l=new Set;for(let u of e){let{blockIndex:p}=this.getBlockForBand(u);if(p<0)throw new Vo(`Invalid band: ${JSON.stringify(u)}`);let f=this.dataIndex[p];s.includes(p)||s.push(p),l.add(p),i=Math.min(i,f.firstByte),r=Math.max(r,f.lastByte)}if(l.size>this.cacheSize)throw new Vo(`Number of blocks to decode (${l.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:i,lastByte:r,blockIndices:s}}hasBand(e){let{blockIndex:i}=this.getBlockForBand(e);return i>=0}hasDataForBand(e){let{blockIndex:i}=this.getBlockForBand(e);return i>=0&&!!this._decodedBlocks.get(i.toString())}getBandView(e){let{blockIndex:i,blockBandIndex:r}=this.getBlockForBand(e);if(i<0)throw new Vo(`Band not found: ${JSON.stringify(e)}`);let s=this._decodedBlocks.get(i.toString());if(!s)throw new Vo(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);let l=this.dataIndex[i],u=this.bandShape.reduce((g,x)=>g*x,1),p=r*u,f=s.subarray(p,p+u);return{data:f,bytes:new Uint8Array(f.buffer).subarray(f.byteOffset,f.byteOffset+f.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:l.offset,scale:l.scale}}}D_.setPbf=function(n){zy=n};class p1{constructor(e,i,r){this.tasks=e,this._onCancel=i,this._onComplete=r,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,i){this._finalized||(this._onComplete(e,i),this._finalized=!0)}}D_.performDecoding=function(n,e){let i=new Uint8Array(n);return Promise.all(e.tasks.map(r=>
7{let{layerName:s,firstByte:l,lastByte:u,pixelFormat:p,blockShape:f,blockIndex:g,filters:x,codec:b}=r,w=i.subarray(l,u+1),S=new Uint32Array(f[0]*f[1]*f[2]),I;if(b!=="gzip_data")throw new Vo(`Unhandled codec: ${b}`);return I=function(M,C){if(!globalThis.DecompressionStream&&C==="gzip_data")return Promise.resolve((H=function(W){W[0]==31&&W[1]==139&&W[2]==8||fs(6,"invalid gzip data");var Q=W[3],Y=10;4&Q&&(Y+=2+(W[10]|W[11]<<8));for(var ee=(Q>>3&1)+(Q>>4&1);ee>0;ee-=!W[Y++]);return Y+(2&Q)}(R=M),H+8>R.length&&fs(6,"invalid gzip data"),function(W,Q,Y,ee){var me=W.length;if(!me||Q.f&&!Q.l)return Y||new Ao(0);var ge=!Y,Te=ge||Q.i!=2,Ae=Q.i;ge&&(Y=new Ao(3*me));var Ie=function(Oi){var mn=Y.length;if(Oi>mn){var Dr=new Ao(Math.max(2*mn,Oi));Dr.set(Y),Y=Dr}},Be=Q.f||0,xe=Q.p||0,Se=Q.b||0,Me=Q.l,Le=Q.d,ze=Q.m,We=Q.n,De=8*me;do{if(!Me){Be=ps(W,xe,1);var Ge=ps(W,xe+1,3);if(xe+=3,!Ge){var $e=W[(Qt=UT(xe)+4)-4]|W[Qt-3]<<8,Je=Qt+$e;if(Je>me){Ae&&fs(0);break}Te&&Ie(Se+$e),Y.set(W.subarray(Qt,Je),Se),Q.b=Se+=$e,Q.p=xe=8*Je,Q.f=Be;continue}if(Ge==1)Me=kT,Le=NT,ze=9,We=5;else if(Ge==2){var tt=ps(W,xe,31)+257,ct=ps(W,xe+10,15)+4,rt=tt+ps(W,xe+5,31)+1;xe+=14;for(var ft=new Ao(rt),Zt=new Ao(19),St=0;St<ct;++St)Zt[OT[St]]=ps(W,xe+3*St,7);xe+=3*ct;var Ut=Ry(Zt),Pt=(1<<Ut)-1,ji=jp(Zt,Ut);for(St=0;St<rt;){var Qt,$t=ji[ps(W,xe,Pt)];if(xe+=15&$t,(Qt=$t>>4)<16)ft[St++]=Qt;else{var ui=0,Pi=0;for(Qt==16?(Pi=3+ps(W,xe,3),xe+=2,ui=ft[St-1]):Qt==17?(Pi=3+ps(W,xe,7),xe+=3):Qt==18&&(Pi=11+ps(W,xe,127),xe+=7);Pi--;)ft[St++]=ui}}var Tn=ft.subarray(0,tt),_i=ft.subarray(tt);ze=Ry(Tn),We=Ry(_i),Me=jp(Tn,ze),Le=jp(_i,We)}else fs(1);if(xe>De){Ae&&fs(0);break}}Te&&Ie(Se+131072);for(var Gi=(1<<ze)-1,un=(1<<We)-1,tn=xe;;tn=xe){var hn=(ui=Me[Ly(W,xe)&Gi])>>4;if((xe+=15&ui)>De){Ae&&fs(0);break}if(ui||fs(2),hn<256)Y[Se++]=hn;else{if(hn==256){tn=xe,Me=null;break}var Lt=hn-254;hn>264&&(Lt=ps(W,xe,(1<<(Qi=r1[St=hn-257]))-1)+l1[St],xe+=Qi);var jn=Le[Ly(W,xe)&un],hr=jn>>4;if(jn||fs(3),xe+=15&jn,_i=BT[hr],hr>3){var Qi=o1[hr];_i+=Ly(W,xe)&(1<<Qi)-1,xe+=Qi}if(xe>De){Ae&&fs(0);break}Te&&Ie(Se+131072);var Mn=Se+Lt;if(Se<_i){var ir=0-_i,Gn=Math.min(_i,Mn);for(ir+Se<0&&fs(3);Se<Gn;++Se)Y[Se]=ee[ir+Se]}for(;Se<Mn;++Se)Y[Se]=Y[Se-_i]}}Q.l=Me,Q.p=tn,Q.b=Se,Q.f=Be,Me&&(Be=1,Q.m=ze,Q.d=Le,Q.n=We)}while(!Be);return Se!=Y.length&&ge?function(Oi,mn,Dr){return(Dr==null||Dr>Oi.length)&&(Dr=Oi.length),new Ao(Oi.subarray(0,Dr))}(Y,0,Se):Y.subarray(0,Se)}(R.subarray(H,-8),{i:2},new Ao(((L=R)[(j=L.length)-4]|L[j-3]<<8|L[j-2]<<16|L[j-1]<<24)>>>0),F)));var R,F,L,j,H;let $=HT[C];if(!$)throw new Error(`Unhandled codec: ${C}`);let ie=new globalThis.DecompressionStream($);return new Response(new Blob([M]).stream().pipeThrough(ie)).arrayBuffer().then(W=>new Uint8Array(W))}(w,b).then(M=>(function(C,R){C.readFields(CT,R)}(new zy(M),S),new qT[p](S.buffer))),I.then(M=>{for(let C=x.length-1;C>=0;C--)switch(x[C]){case"delta_filter":DT(M,f);break;case"zigzag_filter":RT(M);break;case"bitshuffle_filter":LT(M,p);break;default:throw new Vo(`Unhandled filter "${x[C]}"`)}return{layerName:s,blockIndex:g,data:M}}).catch(M=>{throw M})}))},Qe(p1,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),Qe(D_,"MapboxRasterTile"),Qe(d1,"MapboxRasterLayer",{omit:["_blocksInProgress"]});let f1=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Oy{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");let[i,r]=new Uint8Array(e,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");let s=r>>4;if(s!==1)throw new Error(`Got v${s} data when expected v1.`);let l=f1[15&r];if(!l)throw new Error("Unrecognized array type.");let[u]=new Uint16Array(e,2,1),[p]=new Uint32Array(e,4,1);return new Oy(p,u,l,e)}constructor(e,i=64,r=Float64Array,s){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let l=f1.indexOf(this.ArrayType),u=2*e*this.ArrayType.BYTES_PER_ELEMENT,p=e*this.IndexArrayType.BYTES_PER_ELEMENT,f=(8-p%8)%8;if(l<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+f,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+u+p+f),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+f,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+l]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=e)}add(e,i){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=i,r}finish(){let e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Fy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}
7range(e,i,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:l,coords:u,nodeSize:p}=this,f=[0,l.length-1,0],g=[];for(;f.length;){let x=f.pop()||0,b=f.pop()||0,w=f.pop()||0;if(b-w<=p){for(let C=w;C<=b;C++){let R=u[2*C],F=u[2*C+1];R>=e&&R<=r&&F>=i&&F<=s&&g.push(l[C])}continue}let S=w+b>>1,I=u[2*S],M=u[2*S+1];I>=e&&I<=r&&M>=i&&M<=s&&g.push(l[S]),(x===0?e<=I:i<=M)&&(f.push(w),f.push(S-1),f.push(1-x)),(x===0?r>=I:s>=M)&&(f.push(S+1),f.push(b),f.push(1-x))}return g}within(e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:s,coords:l,nodeSize:u}=this,p=[0,s.length-1,0],f=[],g=r*r;for(;p.length;){let x=p.pop()||0,b=p.pop()||0,w=p.pop()||0;if(b-w<=u){for(let C=w;C<=b;C++)_1(l[2*C],l[2*C+1],e,i)<=g&&f.push(s[C]);continue}let S=w+b>>1,I=l[2*S],M=l[2*S+1];_1(I,M,e,i)<=g&&f.push(s[S]),(x===0?e-r<=I:i-r<=M)&&(p.push(w),p.push(S-1),p.push(1-x)),(x===0?e+r>=I:i+r>=M)&&(p.push(S+1),p.push(b),p.push(1-x))}return f}}function Fy(n,e,i,r,s,l){if(s-r<=i)return;let u=r+s>>1;m1(n,e,u,r,s,l),Fy(n,e,i,r,u-1,1-l),Fy(n,e,i,u+1,s,1-l)}function m1(n,e,i,r,s,l){for(;s>r;){if(s-r>600){let g=s-r+1,x=i-r+1,b=Math.log(g),w=.5*Math.exp(2*b/3),S=.5*Math.sqrt(b*w*(g-w)/g)*(x-g/2<0?-1:1);m1(n,e,i,Math.max(r,Math.floor(i-x*w/g+S)),Math.min(s,Math.floor(i+(g-x)*w/g+S)),l)}let u=e[2*i+l],p=r,f=s;for(Hp(n,e,r,i),e[2*s+l]>u&&Hp(n,e,r,s);p<f;){for(Hp(n,e,p,f),p++,f--;e[2*p+l]<u;)p++;for(;e[2*f+l]>u;)f--}e[2*r+l]===u?Hp(n,e,r,f):(f++,Hp(n,e,f,s)),f<=i&&(r=f+1),i<=f&&(s=f-1)}}function Hp(n,e,i,r){By(n,i,r),By(e,2*i,2*r),By(e,2*i+1,2*r+1)}function By(n,e,i){let r=n[e];n[e]=n[i],n[i]=r}function _1(n,e,i,r){let s=n-i,l=e-r;return s*s+l*l}U.$=Xh,U.A=wr,U.B=2,U.C=Ht,U.D=Cp,U.E=ol,U.F=$x,U.G=Wh,U.H=Uc,U.I=br,U.J=Su,U.K=yc,U.L=Py,U.M=gd,U.N=$u,U.O=Df,U.P=ke,U.Q=qu,U.R=ws,U.S=Vc,U.T=Ys,U.U=Pa,U.V=Da,U.W=rr,U.X=Ma,U.Y=fl,U.Z=pr,U._=Yh,U.a=function(n){return di.API_CDN_URL_REGEX.test(n)},U.a$=lu,U.a0=fc,U.a1=jc,U.a2=/^(.*)-use-theme$/,U.a3=/^(.*)-transition$/,U.a4=yd,U.a5=Pf,U.a6=he,U.a7=Yf,U.a8=Ti,U.a9=qe,U.aA=function(n){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(let l of n)e=Math.min(e,l.x),i=Math.min(i,l.y),r=Math.max(r,l.x),s=Math.max(s,l.y);return{min:new ke(e,i),max:new ke(r,s)}},U.aB=ne,U.aC=xi,U.aD=xr,U.aE=er,U.aF=z,U.aG=So,U.aH=ym,U.aI=as,U.aJ=ko,U.aK=Ke,U.aL=class{constructor(n){this.entries={},this.scheduler=n}request(n,e,i,r){let s=this.entries[n]=this.entries[n]||{callbacks:[]};if(s.result){let[l,u]=s.result;return this.scheduler?this.scheduler.add(()=>{r(l,u)},e):r(l,u),()=>{}}return s.callbacks.push(r),s.cancel||(s.cancel=i((l,u)=>{s.result=[l,u];for(let p of s.callbacks)this.scheduler?this.scheduler.add(()=>{p(l,u)},e):p(l,u);setTimeout(()=>delete this.entries[n],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(l=>l!==r),s.callbacks.length||(s.cancel(),delete this.entries[n]))}}},U.aM=function(n){if("provider"in n&&!n.provider)return null;let e=n.provider;if(!e&&"url"in n&&n.url&&(e=function(s){try{let l=new URL(s).pathname.split("/").pop()||"",u=l.lastIndexOf(".");return u>=0?l.slice(u+1):""}catch{return""}}(n.url)),!e)return null;let i=di.TILE_PROVIDER_URLS[e];if(!i)return null;let r;try{r=new URL(i,di.API_URL).href}catch{return new Error(`TileProvider "${e}" has an invalid URL: "${i}"`)}return{name:e,url:r}},U.aN=function(n,e,i,r,s){let l=function(p,f){if(p)return s(p);if(f){n.url&&f.tiles&&n.tiles&&delete n.tiles;let g=Xv(n,f,e);if(g instanceof Error)return s(g);s(null,g)}},u=function(p,f,g){if(!p)return null;if(!f&&!g)return p;g=g||p.worldview_default;let x=Object.values(p.language||{});if(x.length===0)return null;let b=Object.values(p.worldview||{});if(b.length===0)return null;let w=x.every(I=>I===f),S=b.every(I=>I===g);return w&&S?p:f in(p.language_options||{})||g in(p.worldview_options||{})?null:p.language_options&&p.worldview_options?p:null}(n.data,i,r);return u?yn.frame(()=>l(null,u)):n.url?of(e.transformRequest(e.normalizeSourceURL(n.url,null,i,r),ws.Source),l):yn.frame(()=>{let{data:p,...f}=n;l(null,f)})},U.aO=function(n,e){let i=n.url&&!n.tiles?e.transformRequest(n.url,ws.Source):void 0;return{request:i,options:i?Object.assign({},n,{url:i.url}):n}},U.aP=function(n,e,i){return e?Xv(n,e,i):n.tiles&&n.tiles.length>0?{tiles:n.tiles}:new Error('TileJSON is missing required "tiles" property')},U.aQ=function(n,e,i){let r=JSON.stringify(n.request);
7return n.data&&(this.deduped.entries[r]={result:[null,n.data]}),this.deduped.request(r,{type:"parseTile",renderSourceType:n.renderSourceType,zoom:n.tileZoom},s=>{let l=nl(n.request,(u,p,f)=>{u?Ts(u)?s(null,null):s(u):p&&s(null,{rawData:p,vectorTile:i?void 0:new lp(new l_(p)),responseHeaders:new Map(f.entries())})});return()=>{l.cancel(),s(null,null)}},e)},U.aR=function(n){return n?{cacheControl:n.get("cache-control"),expires:n.get("expires")}:{cacheControl:void 0,expires:void 0}},U.aS=function(n){kh++,kh>Qp&&(n.getActor().send("enforceCacheSizeLimit",Kp),kh=0)},U.aT=async function(n,e){let i=Yv.get(n);if(i)return i;let r=Dy.get(n);if(r!==void 0)return r;let s=import(e).catch(l=>{throw new Error(`TileProvider "${n}" failed to load: ${l instanceof Error?l.message:String(l)}`)}).then(l=>{let u=l.default;if(typeof u!="function")throw new Error(`TileProvider "${n}" module must default-export a class`);if(typeof u.prototype.loadTile!="function")throw new Error(`TileProvider "${n}" class must have a loadTile method`);return Yv.set(n,u),u}).finally(()=>{Dy.delete(n)});return Dy.set(n,s),s},U.aU=ue,U.aV=Iv,U.aW=zv,U.aX=Kt,U.aY=Ev,U.aZ=function(n,e){let i=document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let r=0;r<n.length;r++){let s=document.createElement("source");sf(n[r])||(i.crossOrigin="Anonymous"),s.src=n[r],i.appendChild(s)}return{cancel:()=>{}}},U.a_=Sp,U.aa=class{constructor(n){this.specification=n}possiblyEvaluate(n,e){return rn(n.expression.evaluate(e))}interpolate(n,e,i){return{x:mt(n.x,e.x,i),y:mt(n.y,e.y,i),z:mt(n.z,e.z,i),azimuthal:mt(n.azimuthal,e.azimuthal,i),polar:mt(n.polar,e.polar,i)}}},U.ab=Jt,U.ac=bl,U.ad=Wn,U.ae=Bi,U.af=Dn,U.ag=ye,U.ah=is,U.ai=qt,U.aj=mt,U.ak=Xe,U.al=qh,U.am=V,U.an=dt,U.ao=Oe,U.ap=class{constructor(n,e,i){this.target=n,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},It(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new xT}send(n,e,i,r,s=!1,l){let u=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=l,this.callbacks[u]=i);let p=new Set;return this.target.postMessage({id:u,type:n,hasCallback:!!i,targetMapId:r,mustQueue:s,sourceMapId:this.mapId,data:Os(e,p)},p),{cancel:()=>{i&&delete this.callbacks[u],this.target.postMessage({id:u,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(n){let e=n.data;if(!e)return;let i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){let r=this.cancelCallbacks[i];delete this.cancelCallbacks[i],r&&r.cancel()}else if(e.mustQueue||ri(self)){let r=this.callbacks[i],s=this.scheduler.add(()=>this.processTask(i,e),r&&r.metadata||{type:"message"});s&&(this.cancelCallbacks[i]=s)}else this.processTask(i,e)}processTask(n,e){if(delete this.cancelCallbacks[n],e.type==="<response>"){let i=this.callbacks[n];delete this.callbacks[n],i&&(e.error?i(es(e.error)):i(null,es(e.data)))}else{let i=new Set,r=e.hasCallback?(l,u)=>{this.target.postMessage({id:n,type:"<response>",sourceMapId:this.mapId,error:l?Os(l):null,data:Os(u,i)},i)}:()=>{},s=es(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,s,r);else if(this.parent.getWorkerSource){let l=e.type.split("."),{source:u,scope:p}=s;this.parent.getWorkerSource(e.sourceMapId,{type:l[0],source:u,scope:p,uid:0})[l[1]](s,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},U.aq=class{constructor(n){this.specification=n}possiblyEvaluate(n,e){return function([i,r]){let s=rn([1,i,r]);return{x:s.x,y:s.y,z:s.z}}(n.expression.evaluate(e))}interpolate(n,e,i){return{x:mt(n.x,e.x,i),y:mt(n.y,e.y,i),z:mt(n.z,e.z,i)}}},U.ar=function(n,e,i=0,r=!0){let s=new ke(i,i),l=n.sub(s),u=e.add(s),p=[l,new ke(u.x,l.y),u,new ke(l.x,u.y)];return r&&p.push(l.clone()),p},U.as=function(n,e){let i=[];for(let r=0;r<n.length;r++){let s=Ne(r-1,-1,n.length-1),l=Ne(r+1,-1,n.length-1),u=n[r],p=n[l],f=n[s].sub(u).unit(),g=p.sub(u).unit(),x=g.angleWithSep(f.x,f.y),b=f.add(g).unit().mult(-1*e/Math.sin(x/2));i.push(u.add(b))}return i},U.at=uv,U.au=O,U.av=function(n,e,i=0){return kn(((e.x-i)*n.scale-n.x)*Xe,(e.y*n.scale-n.y)*Xe,uh(e.z,e.y
7))},U.aw=$i,U.ax=hi,U.ay=Yc,U.az=xx,U.b=function(n){return di.API_FONTS_REGEX.test(n)},U.b$=lh,U.b0=It,U.b1=D_,U.b2=l_,U.b3=class{constructor(n,e,i,r,s,l){this.tileID=n,this.uid=dt(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=s,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=l,this._hasAppearances=null}registerFadeDuration(n){let e=n+this.timeAdded;e<yn.now()||this.fadeEndTime!==void 0&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=ou(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(n,e,i){if(this.unloadVectorData(),this.state="loaded",n){n.featureIndex&&(this.latestFeatureIndex=n.featureIndex,n.rawTileData?(this.latestRawTileData=n.rawTileData,this.latestFeatureIndex.rawTileData=n.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=n.collisionBoxArray,this.buckets=$v(n.buckets,e.style),this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!n.hasTunnelGeometry;for(let r in this.buckets){let s=this.buckets[r];if(s instanceof No){if(this.hasSymbolBuckets=!0,!i)break;s.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let r in this.buckets){let s=this.buckets[r];if(s instanceof No&&s.hasRTLText){this.hasRTLText=!0,Od();break}}this.queryPadding=0;for(let r in this.buckets){let s=this.buckets[r],l=e.style.getOwnLayer(r);if(!l)continue;let u=l.queryRadius(s)||0;this.queryPadding=Math.max(this.queryPadding,u)}n.imageAtlas&&(this.imageAtlas=e.style.imageManager.imageAtlasCache.getOrCache(n.imageAtlas)),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage),n.lineAtlas&&(this.lineAtlas=n.lineAtlas),this._lastUpdatedBrightness=n.brightness}else this.collisionBoxArray=new $c}unloadVectorData(){if(this.hasData()){for(let n in this.buckets)this.buckets[n].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}loadModelData(n,e,i){n&&(n.resourceTiming&&(this.resourceTiming=n.resourceTiming),this.buckets=Object.assign({},this.buckets,$v(n.buckets,e.style)),n.featureIndex&&(this.latestFeatureIndex=n.featureIndex))}getBucket(n){return this.buckets[n.fqid]}upload(n,e){for(let s in this.buckets){let l=this.buckets[s];if(l.uploadPending()){let u={},p=[],f={zoom:0,pitch:0,brightness:0,worldview:""};if(e){if(e.style){p=e.style.listImages();let g=l.layers[0],x=g.sourceLayer||"_geojsonTileLayer",b=e.style.getLayerSourceCache(g);b&&(u=b._state.getState(x,void 0))}f={zoom:e.transform.zoom||0,pitch:e.transform.pitch||0,brightness:e.style.getBrightness()||0,worldview:e.worldview||""}}l.upload(n,this.tileID.canonical,u,p,f)}}let i=n.gl,r=this.imageAtlas;!r||this.imageAtlasTexture&&r.uploaded||(this.imageAtlasTexture=null,this.imageAtlasTexture=e.style.imageManager.imageAtlasCache.getTextureForAtlas(r,n,i.RGBA8),r.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ys(n,this.glyphAtlasImage,i.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Ys(n,this.lineAtlas.image,i.R8),this.lineAtlas.uploaded=!0)}prepare(n,e,i){if(this.imageAtlas&&this.imageAtlasTexture&&e){let b=e.style.getLut(i);this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture,i,b)}if(!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;let r=e.style.getBrightness(),s=e.style.listImages(),l=s.length,u=e.style._changes.getUpd
7atedPaintProperties(),p=Object.keys(this.buckets).some(b=>this.buckets[b].layers.some(w=>u.has(w.fqid))),f=Object.keys(this.buckets).some(b=>this.buckets[b].layers.some(w=>w.hasTransition&&w.hasTransition())),g=this._firstPrepareComplete&&l!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(e));let x=this._lastUpdatedBrightness!==r;this._lastAvailableImagesCount=l,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||r||this._hasAppearances||p||f||g)&&(!(this._hasAppearances||p||f||g)&&this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this.updateBuckets(e,x,void 0,g||p||f,u,s),this._lastUpdatedBrightness=r))}evaluateQueryRenderedFeaturePadding(){let n=0;for(let e in this.buckets){let i=this.buckets[e];i.evaluateQueryRenderedFeaturePadding&&(n=Math.max(n,i.evaluateQueryRenderedFeaturePadding()))}return n}queryRenderedFeatures(n,e,i,r,s,l,u){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};let p=this.evaluateQueryRenderedFeaturePadding(),f=function(g,x){let b=$o([],[.5*g.width,.5*-g.height,1]);return $n(b,b,[1,-1,0]),xi(b,b,g.calculateProjMatrix(x.toUnwrapped())),Float32Array.from(b)}(s,this.tileID);return this.latestFeatureIndex.query(n,{tilespaceGeometry:e,pixelPosMatrix:f,transform:r,availableImages:i,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:p,scope:u})}querySourceFeatures(n,e){let i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;let r=i.loadVTLayers(),s=e?e.sourceLayer:"",l=r._geojsonTileLayer||r[s];if(!l)return;let u=oo(e&&e.filter),{z:p,x:f,y:g}=this.tileID.canonical,x={z:p,x:f,y:g};for(let b=0;b<l.length;b++){let w=l.feature(b);if(u.needGeometry){let M=qr(w,!0);if(!u.filter(new Jt(this.tileID.overscaledZ,{worldview:this.worldview}),M,this.tileID.canonical))continue}else if(!u.filter(new Jt(this.tileID.overscaledZ,{worldview:this.worldview}
7),w))continue;let S=i.getId(w,s),I=new au(w,p,f,g,S);I.tile=x,n.push(I)}}loaded(){return this.state==="loaded"||this.state==="errored"}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!this.imageAtlas.patternPositions.size}setExpiryData(n){let e=this.expirationTime;if(n.cacheControl){let i=Ci(n.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else n.expires&&(this.expirationTime=new Date(n.expires).getTime());if(this.expirationTime){let i=Date.now(),r=!1;if(this.expirationTime>i)r=!1;else if(e)if(this.expirationTime<e)r=!0;else{let s=this.expirationTime-e;s?this.expirationTime=i+Math.max(s,3e4):r=!0}else r=!0;r?(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-Date.now(),Math.pow(2,31)-1)}refreshFeatureState(n,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!n)return;let i=n.style.listImages();this.updateBuckets(n,!1,e,void 0,void 0,i)}hasAppearances(n){for(let e in this.buckets)if(n.style.hasLayer(e)&&this.buckets[e].layers.some(i=>i.appearances&&i.appearances.length>0))return!0;return!1}updateBuckets(n,e,i,r,s,l){if(!this.latestFeatureIndex||!n.style)return;let u=l||n.style.listImages(),p=n.style.getBrightness(),f=s||new Set;for(let g in this.buckets){if(!n.style.hasLayer(g))continue;let x=this.buckets[g],b=x.layers[0],w=b.sourceLayer||"_geojsonTileLayer",S=n.style.getLayerSourceCache(b),I=x.layers.some(H=>f.has(H.fqid)),M=(r||I)&&x instanceof No?n.style.getOwnLayer(g):void 0,C=i&&i[w]||{};S&&!i&&(C=S._state.getState(w,void 0));let R=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},F=Object.keys(C).length>0&&!e;x.hasAppearances=x.layers.some(H=>H.appearances&&H.appearances.length>0);let L=F?x.stateDependentLayers:x.layers;if(F&&x.stateDependentLayers.length!==0||e||I||r){let H=this.latestFeatureIndex.loadVTLayers()[w];if(x.update(C,H,u,R,L,e,p,this.tileID.canonical),(r||I)&&(!e||e&&x instanceof No&&(!x.text.uboBinder||x.text.uboBinder.isLightConstant||!x.icon.uboBinder||x.icon.uboBinder.isLightConstant))&&x instanceof No&&M&&M.type==="symbol"){let $=x;$.text&&$.text.uboBinder&&$.text.uboBinder.updateDynamicExpressions(M,H,this.tileID.canonical,u,C,p),$.icon&&$.icon.uboBinder&&$.icon.uboBinder.updateDynamicExpressions(M,H,this.tileID.canonical,u,C,p)}if(x instanceof No){let $=x,ie=n.context;$.text&&$.text.uboBinder&&$.text.uboBinder.upload(ie),$.icon&&$.icon.uboBinder&&$.icon.uboBinder.upload(ie)}}if(F&&x.stateDependentLayers.length!==0||e||x.hasAppearances){let H={zoom:n.transform.zoom,pitch:n.transform.pitch,brightness:n.style.getBrightness()||0,worldview:n.worldview},$=x.updateAppearances(this.tileID.canonical,C,u,H,n.imageManager,F&&x.stateDependentLayers.length!==0);if($&&$.hasUboChanges){let ie=n.context;x instanceof No&&x.text&&x.text.uboBinder&&x.text.uboBinder.upload(ie),x instanceof No&&x.icon&&x.icon.uboBinder&&x.icon.uboBinder.upload(ie)}}(x instanceof a_||x instanceof km)&&n._terrain&&n._terrain.enabled&&S&&x.uploadPending()&&n._terrain._clearRenderCacheForTile(S.id,this.tileID);let j=n&&n.style&&n.style.getOwnLayer(g);j&&(this.queryPadding=Math.max(this.queryPadding,j.queryRadius(x)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<yn.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(n){this.symbolFadeHoldUntil=yn.now()+n}setTexture(n,e){let i=e.context,r=i.gl;this.texture=this.texture||e.getTileTexture(n.width),this.texture&&this.texture instanceof Ys?this.texture.update(n):(this.texture=new Ys(i,n,r.RGBA8,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE))}setDependencies(n,e){let i={};for(let r of e)i[r]=!0;this.dependencies[n]=i}hasDependency(n,e){for(let i of n){let r=this.dependencies[i];if(r){for(let s of e)if(r[s])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(n,e){if(!e||e.name==="mercator"||this._tileDebugBuffer)return;let i=$r(Wv,this.tileID.canonical,this.tileTransform)[0],r=new Zn,s=new Cl;for(let l=0;l<i.length;l++){let{x:u,y:p}=i[l];r.emplaceBack(u,p),s.emplaceBack(l)}s.emplaceBack(0),this._tileDebugIndexBuffer=n.createIndexBuffer(s),this._tileDebugBuffer=n.createVertexBuffer(r,Ee.members),this._tileDebugSegments=pi.simpleSegment(0,0,r.length,s.length)}_makeTileBoundsBuffers(n,e){if(this._tileBoundsBuffer||!e||e.name==="mercator")return;let i=$r(Wv,this.tileID.canonical,this.tileTransform)[0],r,s;if(this.isRaster){let l=function(u,p){let f=ou(u,p),g=Math.pow(2,u.z);for(let M=0;M<Js;M++)for(let C=0;C<Js;C++){let R=Mr((u.x+(C+qv(C))/Uo)/g),F=zn((u.y+(M+qv(M))/Uo)/g),L=p.project(R,F),j=M*Js+C;Ks[2*j+0]=Math.round((L.x*f.scale-f.x)*Xe),Ks[2*j+1]=Math.round((L.y*f.scale-f.y)*Xe)}Zl.fill(0),C_.fill(0);for(let M=2045;M>=0;M--){let C=4*M,R=ql[C+0],F=ql[C+1],L=ql[C+2],j=ql[C+3],H=R+L>>1,$=F+j>>1,ie=H+$-F,W=$+R-H,Q=F*Js+R,Y=j*Js+L,ee=$*Js+H,me=Math.hypot((Ks[2*Q+0]+Ks[2*Y+0])/2-Ks[2*ee+0],(Ks[2*Q+1]+Ks[2*Y+1])/2-Ks[2*ee+1])>=16;Zl[ee]=Zl[ee]||(me?1:0),M<1022&&(Zl[ee]=Zl[ee]||Zl[(F+W>>1)*Js+(R+ie>>1)]||Zl[(j+W>>1)*Js+(L+ie>>1)])}let x=new Ba,b=new Yi,w=0;function S(M,C){let R=C*Js+M;return C_[R]===0&&(x.emplaceBack(Ks[2*R+0],Ks[2*R+1],M*Xe/Uo,C*Xe/Uo),C_[R]=++w),C_[R]-1}function I(M,C,R,F,L,j){let H=M+R>>1,$=C+F>>1;if(Math.abs(M-L)+Math.abs(C-j)>1&&Zl[$*Js+H])I(L,j,M,C,H,$),I(R,F,L,j,H,$);else{let ie=S(M,C),W=S(R,F),Q=S(L,j);b.emplaceBack(ie,W,Q)}}return I(0,0,Uo,Uo,Uo,0),I(Uo,Uo,0,0,0,Uo),{vertices:x,indices:b}}(this.tileID.canonical,e);r=l.vertices,s=l.indices}else{r=new Ba,s=new Yi;for(let{x:u,y:p}of i)r.emplaceBack(u,p,0,0);let l=bn(r.int16.subarray(0,4*r.length),void 0,4);for(let u=0;u<l.length;u+=3)s.emplaceBack(l[u],l[u+1],l[u+2])}this._tileBoundsBuffer=n.createVertexBuffer(r,T_.members),this._tileBoundsIndexBuffer=n.createIndexBuffer(s),this._tileBoundsSegments=pi.simpleSegment(0,0,r.length,s.length)}_makeGlobeTileDebugBuffers(n,e){let i=e.projection;if(!i||i.name!=="globe"||e.freezeTileCoverage)return;let r=this.tileID.canonical,s=Et(Ue(r,e)),l=qt(e.zoom),u;l>0&&(u=Bn(new Float64Array(16),e.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(n,r,e,s,u,l),this._makeGlobeTileDebugTextBuffer(n,r,e,s,u,l)}_globePoint(n,e,i,r,s,l,u){let p=ht(n,e,i);if(l){let f=1<<i.z,g=So(r.center.lng),x=ko(r.center.lat),b=(i.x+.5)/f-g,w=0;b>.5?w=-1:b<-.5&&(w=1);let S=(n/Xe+i.x)/f+w,I=(e/Xe+i.y)/f;S=(S-g)*r._pixelsPerMercatorPixel+g,I=(I-x)*r._pixelsPerMercatorPixel+x;let M=[S*r.worldSize,I*r.worldSize,0];Bi(M,M,l),p=je(p,M,u)}return Bi(p,p,s)}_makeGlobeTileDebugBorderBuffer(n,e,i,r,s,l){let u=new Zn,p=new Cl,f=new Us,g=(b,w,S,I,M)=>{let C=(S-b)/(M-1),R=(I-w)/(M-1),F=u.length;for(let L=0;L<M;L++){let j=b+L*C,H=w+L*R;u.emplaceBack(j,H);let $=this._globePoint(j,H,e,i,r,s,l);f.emplaceBack($[0],$[1],$[2]),p.emplaceBack(F+L)}},x=Xe;
7g(0,0,x,0,16),g(x,0,x,x,16),g(x,x,0,x,16),g(0,x,0,0,16),this._tileDebugIndexBuffer=n.createIndexBuffer(p),this._tileDebugBuffer=n.createVertexBuffer(u,Ee.members),this._globeTileDebugBorderBuffer=n.createVertexBuffer(f,pe.members),this._tileDebugSegments=pi.simpleSegment(0,0,u.length,p.length)}_makeGlobeTileDebugTextBuffer(n,e,i,r,s,l){let u=new Zn,p=new Yi,f=new Us,g=25;p.reserve(32),u.reserve(g),f.reserve(g);let x=(b,w)=>g*b+w;for(let b=0;b<g;b++){let w=2048*b;for(let S=0;S<g;S++){let I=2048*S;u.emplaceBack(I,w);let M=this._globePoint(I,w,e,i,r,s,l);f.emplaceBack(M[0],M[1],M[2])}}for(let b=0;b<4;b++)for(let w=0;w<4;w++){let S=x(b,w),I=x(b,w+1),M=x(b+1,w),C=x(b+1,w+1);p.emplaceBack(S,I,M),p.emplaceBack(M,I,C)}this._tileDebugTextIndexBuffer=n.createIndexBuffer(p),this._tileDebugTextBuffer=n.createVertexBuffer(u,Ee.members),this._globeTileDebugTextBuffer=n.createVertexBuffer(f,pe.members),this._tileDebugTextSegments=pi.simpleSegment(0,0,g,32)}destroy(n=!0){for(let e in this.buckets)this.buckets[e].destroy(n);this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&delete this.imageAtlasTexture,this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),n&&this.texture&&this.texture instanceof Ys&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof Ys&&(this.emissiveTexture.destroy(),delete this.emissiveTexture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}},U.b4=nl,U.b5=Ts,U.b6=function(n,e){let i=[];for(let r in n)r in e||i.push(r);return i},U.b7=Zv,U.b8=["type","source","source-layer","minzoom","maxzoom","filter","layout"],U.b9=Xo,U.bA=Mt,U.bB=$n,U.bC=wn,U.bD=d0,U.bE=jm,U.bF=_0,U.bG=g0,U.bH=qr,U.bI=Ya,U.bJ=oy,U.bK=tv,U.bL=gy,U.bM=Oy,U.bN=Fi,U.bO=ra,U.bP=xs,U.bQ=function(n,e,i){i*=.5;var r=e[0],s=e[1],l=e[2],u=e[3],p=Math.sin(i),f=Math.cos(i);return n[0]=r*f+s*p,n[1]=s*f-r*p,n[2]=l*f+u*p,n[3]=u*f-l*p,n},U.bR=Ja,U.bS=Xi,U.bT=$o,U.bU=function(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n},U.bV=Ql,U.bW=function(n,e,i,r,s){var l=1/Math.tan(e/2);if(n[0]=l/i,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=l,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,s!=null&&s!==1/0){var u=1/(r-s);n[10]=(s+r)*u,n[14]=2*s*r*u}else n[10]=-1,n[14]=-2*r;return n},U.bX=function(n,e,i,r,s,l,u){var p=1/(e-i),f=1/(r-s),g=1/(l-u);return n[0]=-2*p,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*f,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*g,n[11]=0,n[12]=(e+i)*p,n[13]=(s+r)*f,n[14]=(u+l)*g,n[15]=1,n},U.bY=lr,U.bZ=zn,U.b_=function(n,e,i){n[4*e+0]=i[0],n[4*e+1]=i[1],n[4*e+2]=i[2],n[4*e+3]=i[3]},U.ba=Bn,U.bb=Rr,U.bc=fo,U.bd=eo,U.be=function(n,e){let{x:i,y:r}=n.point,s=Vt(i,r,n.worldSize/n._pixelsPerMercatorPixel,0,0);return xi(s,s,xt(He(e)))},U.bf=Fn,U.bg=Wa,U.bh=ia,U.bi=zr,U.bj=Jn,U.bk=en,U.bl=Th,U.bm=Yr,U.bn=ly,U.bo=function(n,e,i,r,s){let l=5*e+2;n.float32[l+0]=i,n.float32[l+1]=r,n.float32[l+2]=s},U.bp=Ih,U.bq=Ra,U.br=go,U.bs=la,U.bt=aa,U.bu=Ka,U.bv=Ne,U.bw=function(n,e,i,r){var s=new wi(4);return s[0]=n,s[1]=e,s[2]=i,s[3]=r,s},U.bx=class{isDataAvailableAtPoint(n){let e=this._source();if(this.isUsingMockSource()||!e||n.y<0||n.y>1)return!1;let i=e.getSource().maxzoom,r=1<<i,s=Math.floor(n.x),l=Math.floor((n.x-s)*r),u=Math.floor(n.y*r),p=this.findDEMTileFor(new ue(i,s,i,l,u));return!(!p||!p.dem)}getAtPointOrZero(n,e=0){return this.getAtPoint(n,e)||0}getAtPoint(n,e,i=!0){if(this.isUsingMockSource())return null;e==null&&(e=null);let r=this._source();if(!r||n.y<0||n.y>1)return e;let s=r.getSource().maxzoom,l=1<<s,u=Math.floor(n.x),p=n.x-u,f=new ue(s,u,s,Math.floor(p*l),Math.floor(n.y*l)),g=this.findDEMTileFor(f);if(!g||!g.dem)return e;let x=g.dem,b=1<<g.tileID.canonical.z,w=(p*b-g.tileID.canonical.x)*x.dim,S=(n.y*b-g.tileID.canonical.y)*x.dim,I=Math.floor(w),M=Math.floor(S);return(i?this.exaggeration():1)*mt(mt(x.get(I,M),x.get(I,M+1),S-M),mt(x.get(I+1,M),x.get(I+1,M+1),S-M),w-I)}static getAtTileOffset(n,e,i,r){let s=1<<n.canonical.z;return r?r.pointElevation(e):i?i.getAtPointOrZero(new Wn(n.wrap+(n.canonical.x+e.x/Xe)/s,(n.canonical.y+e.
7y/Xe)/s)):0}static getAtTileOffsetFunc(n,e,i,r){return(s,l,u)=>{let p=this.getAtTileOffset(n,s,l,u),f=r.upVector(n.canonical,s.x,s.y);return Fi(f,f,p*r.upVectorScale(n.canonical,e,i).metersToTile),f}}getForTilePoints(n,e,i,r){if(this.isUsingMockSource())return!1;let s=Mh.create(this,n,r);return!!s&&(e.forEach(l=>{l[2]=this.exaggeration()*s.getElevationAt(l[0],l[1],i,!0)}),!0)}getMinMaxForTile(n){if(this.isUsingMockSource())return null;let e=this.findDEMTileFor(n);if(!e||!e.dem)return null;let i=e.dem.tree,r=e.tileID,s=1<<n.canonical.z-r.canonical.z,l=n.canonical.x/s-r.canonical.x,u=n.canonical.y/s-r.canonical.y,p=0;for(let f=0;f<n.canonical.z-r.canonical.z&&!i.leaves[p];f++){l*=2,u*=2;let g=2*Math.floor(u)+Math.floor(l);p=i.childOffsets[p]+g,l%=1,u%=1}return{min:this.exaggeration()*i.minimums[p],max:this.exaggeration()*i.maximums[p]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(n,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(n){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(n){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){let n=this.visibleDemTiles;if(n.length===0)return null;let e=!1,i=Number.MAX_VALUE,r=Number.MIN_VALUE;for(let s of n){let l=this.getMinMaxForTile(s.tileID);l&&(i=Math.min(i,l.min),r=Math.max(r,l.max),e=!0)}return e?{min:i,max:r}:null}},U.by=Ym,U.bz=c,U.c=tl,U.c$=K0,U.c0=Zc,U.c1=ln,U.c2=mr,U.c3=Wc,U.c4=mv,U.c5=function(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]},U.c6=Po,U.c7=function(n){var e=n[0],i=n[1],r=n[2],s=n[3];return Math.sqrt(e*e+i*i+r*r+s*s)},U.c8=cu,U.c9=Za,U.cA=t_,U.cB=ec,U.cC=Q0,U.cD=function(n){let e=Q0(n,!0);return Fn([],[e[0],e[1],e[4],e[5]])},U.cE=Yn,U.cF=cp,U.cG=Go,U.cH=function(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n},U.cI=function(n){let{x:e,y:i}=n.point,{lng:r,lat:s}=n._center;return Vt(e,i,n.worldSize,r,s)},U.cJ=ic,U.cK=_s,U.cL=X,U.cM=k,U.cN=5,U.cO=function(n,e,i){let r=0;for(let s=0;s<2;++s)n[s]>0&&(r+=(n[s]-0)*(n[s]-0)),e[s]<0&&(r+=(0-e[s])*(0-e[s]));return r},U.cP=function(n){return n*n*n*n*n},U.cQ=rp,U.cR=45,U.cS=tp,U.cT=function(n,e,i){let r=Math.sqrt(n*n+e*e+i*i),s=r>0?Math.acos(i/r)*ua:0,l=n!==0||e!==0?Math.atan2(-e,-n)*ua+90:0;return l<0&&(l+=360),[r,l,s]},U.cU=kn,U.cV=rn,U.cW=Hr,U.cX=nn,U.cY=Ei,U.cZ=mo,U.c_=function(n){return[Math.pow(n[0],1/2.2),Math.pow(n[1],1/2.2),Math.pow(n[2],1/2.2)]},U.ca=oe,U.cb=3,U.cc=2,U.cd=7,U.ce=6,U.cf=na,U.cg=ai,U.ch=tc,U.ci=0,U.cj=1,U.ck=4,U.cl=5,U.cm=de,U.cn=up,U.co=ex,U.cp=J,U.cq=st,U.cr=function(n,e,i,r,s,l,u,p,f){if(f.name==="globe")return st(n,e,new J(i,r,s),!1);let g=ou({z:i,x:r,y:s},f);return new Ei([(l+g.x/g.scale)*e,e*(g.y/g.scale),u],[(l+g.x2/g.scale)*e,e*(g.y2/g.scale),p])},U.cs=function(n,e,i){return n[0]=Math.min(e[0],i[0]),n[1]=Math.min(e[1],i[1]),n[2]=Math.min(e[2],i[2]),n[3]=Math.min(e[3],i[3]),n},U.ct=function(n,e,i){return n[0]=Math.max(e[0],i[0]),n[1]=Math.max(e[1],i[1]),n[2]=Math.max(e[2],i[2]),n[3]=Math.max(e[3],i[3]),n},U.cu=function(n){let e=Math.round((n+45+360)%360/90)%4;return ae[e]},U.cv=Cr,U.cw=oa,U.cx=6,U.cy=function(n){let e=Mt(new Float64Array(16));xi(e,n.pixelMatrix,n.globeMatrix);let i=[0,jr,0],r=[0,Gr,0];return Bi(i,i,e),Bi(r,r,e),[i[0]>0&&i[0]<=n.width&&i[1]>0&&i[1]<=n.height&&!li(n,new Kt(n.center.lat,90)),r[0]>0&&r[0]<=n.width&&r[1]>0&&r[1]<=n.height&&!li(n,new Kt(n.center.lat,-90))]},U.cz=function(n,e){let{scale:i}=n.tileTransform,r=i*Xe/(n.tileSize*Math.pow(2,e.zoom-n.tileID.overscaledZ+n.tileID.canonical.z)),s=e.inverseAdjustmentMatrix;return new Float32Array([s[0]*r,s[1]*r,s[2]*r,s[3]*r])},U.d=function(n){return di.API_TILEJSON_REGEX.test(n)},U.d$=Ft,U.d0=Yg,U.d1=nx,U.d2=m,U.d3=class{static calculate(n,e,i){let r=new Set,s=new Map,l=new Set,u=new Set;for(let f of Object.values(n))for(let[g,x]of Object.entries(f.floors)){l.add(g),x.isDefault&&u.add(g),x.conflicts&&s.set(g,x.conflicts);let b=g===e,w=x.connections&&e&&x.connections.has(e);(b||w)&&r.add(g)}let p=f=>{let g=s.get(f)||new Set;for(let x of r)if((s.get(x)||new Set).has(f)||g.has(x))return!0;return!1};if(i)for(let f of i)l.has(f)&&(p(f)||r.add(f));for(let f of u)r.has(f)||p(f)||r.add(f);return r}},U.d4=d_,U.d5=fy,U.d6=il,U.d7=function(){return{API_URL:di.API_URL,DRACO_URL:di.DRACO_URL,MESHOPT_URL:di.MESHOPT_URL,MESHOPT_SIMD_URL:di.MESHOPT_SIMD_URL,BUILDING_GEN_URL:di.BUILDING_GEN_URL}},U.d8=Fc,U.d9=Bh,U.dA=Ee,U.dB=pi,U.dC=Ii,U.dD=fe,U.dE=Zn,U.dF=Yi,U.dG=function(n,e){return[Math.pow(n[0],2.2)*e,Math.pow(n[1],2.2)*e,Math.pow(n[2],2.2)*e]},U.dH=yr,U.dI=function(n,e){var i=Math.sin(e),r=Math.cos(e);return n[0]=r,n[1]=i,n[2]=0,n[3]=-i,n[4]=r,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n},U.dJ=gs,U.dK=Tt,U.dL=Ln,U.dM=Fr,U.dN=Ey,U.dO=function(n,e){let i=[0,0,0];return Bi(i,i,Et(He(e.canonical))),Bi(i,i,n),i},U.dP=n=>({u_matrix:new Wc(n),u_texsize:new mr(n),u_pixels_to_tile_units:new Bl(n),u_device_pixel_ratio:new ln(n),u_width_scale:new ln(n),u_floor_width_scale:new ln(n),u_image:new lh(n),u_units_to_pixels:new mr(n),u_tile_units_to_pixels:new ln(n),u_alph
7a_discard_threshold:new ln(n),u_trim_offset:new mr(n),u_trim_fade_range:new mr(n),u_trim_gradient_mix_range:new mr(n),u_trim_color:new tp(n),u_zbias_factor:new ln(n),u_tile_to_meter:new ln(n),u_ground_shadow_factor:new Zc(n),u_pattern_transition:new ln(n)}),U.dQ=n=>({u_matrix:new Wc(n),u_pixels_to_tile_units:new Bl(n),u_device_pixel_ratio:new ln(n),u_width_scale:new ln(n),u_floor_width_scale:new ln(n),u_units_to_pixels:new mr(n),u_dash_image:new lh(n),u_gradient_image:new lh(n),u_image_height:new ln(n),u_texsize:new mr(n),u_tile_units_to_pixels:new ln(n),u_alpha_discard_threshold:new ln(n),u_trim_offset:new mr(n),u_trim_fade_range:new mr(n),u_trim_gradient_mix_range:new mr(n),u_trim_color:new tp(n),u_zbias_factor:new ln(n),u_tile_to_meter:new ln(n),u_ground_shadow_factor:new Zc(n)}),U.dR=n=>({u_camera_to_center_distance:new ln(n),u_extrude_scale:new Bl(n),u_device_pixel_ratio:new ln(n),u_matrix:new Wc(n),u_inv_rot_matrix:new Wc(n),u_merc_center:new mr(n),u_tile_id:new Zc(n),u_zoom_transition:new ln(n),u_up_dir:new Zc(n),u_emissive_strength:new ln(n)}),U.dS=Gd,U.dT=_w,U.dU=class{constructor(n,e,i,r){this.context=n,this.format=r,this.size=i,this.texture=n.gl.createTexture();let[s,l,u]=this.size,{gl:p}=n;p.bindTexture(p.TEXTURE_3D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in e&&e.data&&p.texImage3D(p.TEXTURE_3D,0,this.format,s,l,u,0,Vg(this.format),jg(this.format),e.data)}bind(n,e){let{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_3D,this.texture),n!==this.minFilter&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MAG_FILTER,n),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MIN_FILTER,n),this.minFilter=n),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){let{gl:n}=this.context;n.deleteTexture(this.texture),this.texture=null}},U.dV=Li,U.dW=(n,e,i,r,s,l)=>{let u=n.transform,p=u.projection.name==="globe",f;if(l.paint.get("circle-pitch-alignment")==="map")if(p){let x=Tt(u.zoom,e.canonical)*u._pixelsPerMercatorPixel;f=Float32Array.from([x,0,0,x])}else f=u.calculatePixelsToTileUnitsMatrix(i);else f=new Float32Array([u.pixelsToGLUnits[0],0,0,u.pixelsToGLUnits[1]]);let g={u_camera_to_center_distance:n.transform.getCameraToCenterDistance(u.projection),u_matrix:n.translatePosMatrix(e.projMatrix,i,l.paint.get("circle-translate"),l.paint.get("circle-translate-anchor")),u_device_pixel_ratio:yn.devicePixelRatio,u_extrude_scale:f,u_inv_rot_matrix:ci,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:l.paint.get("circle-emissive-strength")};if(p){g.u_inv_rot_matrix=r,g.u_merc_center=s,g.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],g.u_zoom_transition=qt(u.zoom);let x=s[0]*Xe,b=s[1]*Xe;g.u_up_dir=u.projection.upVector(new J(0,0,0),x,b)}return g},U.dX=Tx,U.dY=dr,U.dZ=(n,e,i,r,s,l,u,p,f,g)=>{let x=n.transform,b=x.pitch<15?vx(.07,.7,ne((14-x.zoom)/5,0,1)):.07,w=i.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:wx(n,e,i,r),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:x.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:s,u_width_scale:l,u_floor_width_scale:u,u_image:0,u_tile_units_to_pixels:bx(e,x),u_units_to_pixels:[1/x.pixelsToGLUnits[0],1/x.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:p,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(w?null:i.lut).toArray01(),u_zbias_factor:b,u_tile_to_meter:Hr(e.tileID.canonical,0),u_ground_shadow_factor:f,u_pattern_transition:g}},U.d_=(n,e,i,r,s,l,u,p,f,g)=>{let x=n.transform,b=x.calculatePixelsToTileUnitsMatrix(e),w=i.paint.get("line-trim-color-use-theme").constantOr("default")==="none",S=x.pitch<15?vx(.07,.7,ne((14-x.zoom)/5,0,1)):.07;return{u_matrix:wx(n,e,i,r),u_pixels_to_tile_units:b,u_device_pixel_ratio:l,u_width_scale:u,u_floor_width_scale:p,u_units_to_pixels:[1/x.pixelsToGLUnits[0],1/x.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:s,u_texsize:Sx(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:bx(e,n.transform),u_alpha_discard_threshold:0,u_trim_offset:f,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(w?null:i.lut).toArray01(),u_zbias_factor:S,u_tile_to_meter:Hr(e.tileID.canonical,0),u_ground_shadow_factor:g}},U.da=pc,U.db=Gt,U.dc=function(n){let e=n.indexOf(Il);return e>=0?n.slice(0,e):n},U.dd=mx,U.de=function(n){return n.includes(Il)},U.df=function(n){let e=n.lastIndexOf(Il);return e>=0?n.slice(e+1):""},U.dg=function(n){let e=[],i=n.id;return i===void 0&&e.push({message:`layers.${i}: missing required property "id"`}),n.render===void 0&&e.push({message:`layers.${i}: missing required method "render"`}),n.renderingMode&&n.renderingMode!=="2d"&&n.renderingMode!=="3d"&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},U.dh=function(n,e,i,r){return n.type==="custom"?new dT(n,e):new _T[n.type](n,e,i,r)},U.di=Ve,U.dj=oo,U.dk=tm,U.dl=class extends au{constructor(n,e){super(n._vectorTileFeature,n._z,n._x,n._y,n.id),n.state&&(this.state=Object.assign({},n.state)),this.target=e.target,this.namespace=e.namespace,e.properties&&(this.properties=e.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=n.source,this.sourceLayer=n.sourceLayer,this.layer=n.layer)}toJSON(){let n=super.toJSON();return n.target=this.target,n.namespace=this.namespace,n}},U.dm=Tl,U.dn=function(n){return n({pluginStatus:En,pluginURL:Bs}),Tl.on("pluginStateChange",n),n},U.dp=fm,U.dq=class extends Oo{constructor(n){super(n),this.current=ne
7w Float32Array(9)}set(n,e,i){if(!this.fetchUniformLocation(n,e))return;let r=this.current;for(let s=0;s<9;s++)if(i[s]!==r[s]){r.set(i),this.gl.uniformMatrix3fv(this.location,!1,r);break}}},U.dr=le,U.ds=function(n,e,i){let r=qt(i.zoom),s=n.style.map._antialias,l=n.terrain&&n.terrain.exaggeration()>0;return r===0&&!s&&!l},U.dt=function(n){let e=n.pixelsPerMeter,i=e/lr(1,n.center.lat),r=Mt(new Float64Array(16));return $n(r,r,[n.point.x,n.point.y,0]),Yn(r,r,[i,i,e]),Float32Array.from(r)},U.du=et,U.dv=function(n){let e=80.051129;n=ne(n,-80.051129,e)/e*90;let i=Math.pow(Math.abs(Math.sin(V(n))),3);return Math.round(i*(np.length-1))},U.dw=function(n,e,i,r){let s=e.getNorth(),l=e.getSouth(),u=e.getWest(),p=e.getEast(),f=1<<n.z,g=p-u,x=s-l,b=g/Hs,w=-x/np[i],S=[0,b,0,w,0,0,s,u,0];if(n.z>0){let I=180/r;Xn(S,S,[I/g+1,0,0,0,I/x+1,0,-.5*I/b,.5*I/w,1])}return S[2]=f,S[5]=n.x,S[8]=n.y,S},U.dx=Et,U.dy=He,U.dz=function(n,e,i){let r=Mt(new Float64Array(16)),s=(e/(1<<n)-.5)*Math.PI*2;return Ho(r,i.globeMatrix,s),Float32Array.from(r)},U.e=function(n){return n.indexOf("mapbox:")===0},U.e$=Gg,U.e0=ii,U.e1=uh,U.e2=be,U.e3=Xm,U.e4=I0,U.e5=Ga,U.e6=450,U.e7=7,U.e8=Ua,U.e9=function(n,e){if(n===e){var i=e[1],r=e[2],s=e[3],l=e[6],u=e[7],p=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=i,n[6]=e[9],n[7]=e[13],n[8]=r,n[9]=l,n[11]=e[14],n[12]=s,n[13]=u,n[14]=p}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n},U.eA=function(n,e){var i=2*Math.acos(e[3]),r=Math.sin(i/2);return r>Pn?(n[0]=e[0]/r,n[1]=e[1]/r,n[2]=e[2]/r):(n[0]=1,n[1]=0,n[2]=0),i},U.eB=Cy,U.eC=r_,U.eD=n_,U.eE=[1,1,1],U.eF=Mh,U.eG=function(n,e,i,r){var s=e[0],l=e[1],u=e[2],p=e[3];return n[0]=s+r*(i[0]-s),n[1]=l+r*(i[1]-l),n[2]=u+r*(i[2]-u),n[3]=p+r*(i[3]-p),n},U.eH=xh,U.eI=Vr,U.eJ=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new ke(1/0,1/0),max:new ke(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(n,e=!1){let i=f0(new ke(0,0),new ke(Xe,Xe),n),r=[];if(e&&!Rg(i,this._globalClipBounds))return r;for(let s of this._activeRegions){if(s.hiddenByOverlap||!Rg(i,s))continue;let l=rb(s.min,s.max,n);r.push({min:l.min,max:l.max,sourceId:this._sourceIds[s.priority],footprint:s.footprint,footprintTileId:s.tileId,order:s.order,clipMask:s.clipMask,clipScope:s.clipScope})}return r}setSources(n){this._setSources(n.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{let i=[];for(let r of e.cache.getVisibleCoordinates()){let s=e.cache.getTile(r).buckets[e.layer];s&&s.updateFootprints(r.toUnwrapped(),i)}return i},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(n){let e=n.getFootprints();if(e.length===0)return;let i=n.getOrder(),r=n.getClipMask(),s=n.getClipScope();for(let l of e){if(!l.footprint)continue;let u=f0(l.footprint.min,l.footprint.max,l.id);this._activeRegions.push({min:u.min,max:u.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:l.id,footprint:l.footprint,order:i,clipMask:r,clipScope:s})}this._sourceIds.push(n.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,i)=>e.priority-i.priority||Um(e.min,i.min)||Um(e.max,i.max)||e.order-i.order||e.clipMask-i.clipMask||function(r,s){let l=(u,p)=>u+p;return r.length-s.length||r.reduce(l,"").localeCompare(s.reduce(l,""))}(e.clipScope,i.clipScope));let n=this._activeRegions.length!==this._prevRegions.length;if(!n){let e=0;for(;!n&&e!==this._activeRegions.length;){let i=this._activeRegions[e],r=this._prevRegions[e];n=i.priority!==r.priority||!p0(i,r)||i.order!==r.order||i.clipMask!==r.clipMask||!Xo(i.clipScope,r.clipScope),this._activeRegions[e].hiddenByOverlap=r.hiddenByOverlap,++e}}if(n){++this._updateTime;for(let i of this._activeRegions)i.order!==yp&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,i.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,i.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,i.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,i.max.y));let e=i=>{let r=this._activeRegions;if(i>=r.length)return i;let s=r[i].priority;for(;i<r.length&&r[i].priority===s;)++i;return i};if(this._sourceIds.length>1){let i=0,r=e(i);for(;i!==r;){let s=i,l=i;for(;s!==r;){let u=this._activeRegions[s];u.hiddenByOverlap=!1;for(let p=0;p<l;p++){let f=this._activeRegions[p];if(!f.hiddenByOverlap&&u.order===yp&&Rg(u,f)&&(u.hiddenByOverlap=m0(u.footprint,u.tileId,f.footprint,f.tileId),u.hiddenByOverlap))break}++s}i=r,r=e(i)}}}}_setSources(n){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let e=n.length-1;e>=0;e--)this._addSource(n[e]);this._computeReplacement()}},U.eK=Ba,U.eL=T_,U.eM=Cl,U.eN=yp,U.eO=class{constructor(n){this._createGrid(n),this._createPoles(n)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(let n of this._poleSegments)n.destroy();for(let n of this._gridSegments)n.withSkirts.destroy(),n.withoutSkirts.destroy()}_fillGridMeshWithLods(n,e){let i=new Zn,r=new Yi,s=[],l=n+1+2,u=e[0]+1,p=e[0]+1+(1+e.length),f=(g,x,b)=>{let w=g===l-1?g-2:g===0?g:g-1;return w+=b?24575:0,[w,x]};for(let g=0;g<l;++g)i.emplaceBack(...f(g,0,!0));for(let g=0;g<u;++g)for(let x=0;x<l;++x)i.emplaceBack(...f(x,g,(x===0||x===l-1)&&!0));for(let g=0;g<e.length;++g){let x=e[g];for(let b=0;b<l;++b)i.emplaceBack(...f(b,x,!0))}for(let g=0;g<e.length;++g){let x=r.length,b=e[g]+1+2,w=new Yi;for(let M=0;M<b-1;M++){let C=M===b-2,R=C?l*(p-e.length+g-M):l;for(let F=0;F<l-1;F++){let L=M*l+F;M===0||C||F===0||F===l-2?(w.emplaceBack(L+1,L,L+R),w.emplaceBack(L+R,L+R+1,L+1)):(r.emplaceBack(L+1,L,L+R),r.emplaceBack(L+R,L+R+1,L+1))}}let S=pi.simpleSegment(0,x,i.length,r.length-x);for(let M=0;M<w.uint16.length;M+=3)r.emplaceBack(w.uint16[M],w.uint16[M+1],w.uint16[M+2]);let I=pi.simpleSegment(0,x,i.length,r.length-x);s.push({withoutSkirts:S,withSkirts:I})}return{vertices:i,indices:r,segments:s}}_createGrid(n){let e=this._fillGridMeshWithLods(Hs,np);this._gridSegments=e.segments,this._gridBuffer=n.createVertexBuffer(e.vertices,Ee.members),this._gridIndexBuffer=n.createIndexBuffer(e.indices,!0)}_createPoles(n){let e=new Yi;for(let u=0;u<=Hs;u++)e.emplaceBack(0,u+1,u+2);this._poleIndexBuffer=n.createIndexBuffer(e,!0);let i=new ka,r=new ka,s=new ka,l=new ka;this._poleSegments=[];for(let u=0,p=0;u<6;u++){let f=360/(1<<u);i.emplaceBack(0,-er,0,.5,0),r.emplaceBack(0,-er,0,.5,1),s.emplaceBack(0,-er,0,.5,.5),l.emplaceBack(0,-er,0,.5,.5);for(let g=0;g<=Hs;g++){let x=g/Hs,b=0,w=mt(0,f,x),[S,I,M]=Nl(At,Ct,w,er);i.emplaceBack(S,I,M,x,b),r.emplaceBack(S,I,M,x,1-b);let C=V(w);x=.5+.5*Math.sin(C),b=.5+.5*Math.cos(C),s.emplaceBack(S,I,M,x,b),l.emplaceBack(S,I,M,x,1-b)}this._poleSegments.push(pi.simpleSegment(p,0,66,64)),p+=66}this._poleNorthVertexBuffer=n.createVertexBuffer(i,Fe,!1),this._poleSouthVertexBuffer=n.createVertexBuffer(r,Fe,!1),this._texturedPoleNorthVertexBuffer=n.createVertexBuffer(s,Fe,!1),this._texturedPoleSouthVertexBuffer=n.createVertexBuffer(l,Fe,!1)}getGridBuffers(n,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[n].withSkirts:this._gridSegments[n].withoutSkirts]}getPoleBuffers(n,e){return[e?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,e?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[n]]}},U.eP=nb,U.eQ=ce,U.eR=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},U.eS=we,U.eT=gm,U.eU=function(n,e,i){return n[0]=e[0]/i[0],n[1]=e[1]/i[1],n[2]=e[2]/i[2],n},U.eV=Xa,U.eW=os,U.eX=nc,U.eY=Mi,U.eZ=function([n,e,i]){let r=Math.hypot(n,e,i),s=Math.atan2(n,i),l=.5*Math.PI-Math.acos(-e/r);return new Kt(X(s),X(l))},U.e_=Zo,U.ea=Rt,U.eb=Rl,U.ec=256,U.ed=function(n){return n>>>=0,n=Math.imul(2747636419^n,2654435769)>>>0,n=Math.imul(n^n>>>16,2654435769)>>>0,(n=Math.imul(n^n>>>16,2654435769)>>>0)/4294967296},U.ee=sr,U.ef=fd,U.eg=ss,U.eh=fr,U.ei=Zd,U.ej=hT,U.ek=Ue,U.el=xt,U.em=Ur,U.en=function(n,e){var i=Math.sin(e),r=Math.cos(e);return n[0]=r,n[1]=0,n[2]=-i,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=i,n[9]=0,n[10]=r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},U.eo=function(n,e){var i=Math.sin(e),r=Math.cos(e);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=r,n[6]=i,n[7]=0,n[8]=0,n[9]=-i,n[10]=r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},U.ep=function(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[4],n[4]=e[5],n[5]=e[6],n[6]=e[8],n[7]=e[9],n[8]=e[10],n},U.eq=ka,U.er=qd,U.es=function(n,e,i,r,s){return ne((n-e)/(i-e)*(s-r)+r,r,s)},U.et=sa,U.eu=function(n,e){var i=e[0],r=e[1],s=e[2],l=e[3],u=e[4],p=e[5],f=e[6],g=e[7],x=e[8],b=x*u-p*g,w=-x*l+p*f,S=g*l-u*f,I=i*b+r*w+s*S;return I?(n[0]=b*(I=1/I),n[1]=(-x*r+s*g)*I,n[2]=(p*r-s*u)*I,n[3]=w*I,n[4]=(x*i-s*f)*I,n[5]=(-p*i+s*l)*I,n[6]=S*I,n[7]=(-g*i+r*f)*I,n[8]=(u*i-r*l)*I,n):null},U.ev=2,U.ew=_o,U.ex=ys,U.ey=Kl,U.ez=function(n,e){var i=new wi(3);Kl(i,e);var r=1/i[0],s=1/i[1],l=1/i[2],u=e[0]*r,p=e[1]*s,f=e[2]*l,g=e[4]*r,x=e[5]*s,b=e[6]*l,w=e[8]*r,S=e[9]*s,I=e[10]*l,M=u+x+I,C=0;return M>0?(C=2*Math.sqrt(M+1),n[3]=.25*C,n[0]=(b-S)/C,n[1]=(w-f)/C,n[2]=(p-g)/C):u>x&&u>I?(C=2*Math.sqrt(1+u-x-I),n[3]=(b-S)/C,n[0]=.25*C,n[1]=(p+g)/C,n[2]=(w+f)/C):x>I?(C=2*Math.sqrt(1+x-u-I),n[3]=(w-f)/C,n[0]=(p+g)/C,n[1]=.25*C,n[2]=(b+S)/C):(C=2*Math.sqrt(1+I-u-x),n[3]=(p-g)/C,n[0]=(w+f)/C,n[1]=(b+S)/C,n[2]=.25*C),n},U.f=bs,U.f0=function(n){let e=n.navigator?n.navigator.userAgent:null;return!!function(i){if(vi==null){let r=i.navigator?i.navigator.userAgent:null;vi=!!i.safari||!(!r||!(_e.test(r)||r.match("Safari")&&!r.match("Chrome")))}return vi}(n)&&!(!e||!(e.match("Version/15.4")||e.match("Version/15.5")||e.match(B)))},U.f1=function(n,e){Kp=n,Qp=e}
7,U.f2=li,U.f3=bi,U.f4=function(n){let e=[0,0,0],i=Mt(new Float64Array(16));return xi(i,n.pixelMatrix,n.globeMatrix),Bi(e,e,i),new ke(e[0],e[1])},U.f5=function(n,e){if(!n||!e)throw new Error("TileProvider name and URL are required");di.TILE_PROVIDER_URLS[n]=yn.resolveURL(e)},U.f6=Qu,U.f7=function(n,e,i=!1){if(En===Ar.deferred||En===Ar.loading||En===Ar.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Bs=yn.resolveURL(n),En=Ar.deferred,zd=e,Ku(),i||Xf()},U.f8=pa,U.f9=da,U.fA=a_,U.fB=lp,U.fC=function(n){return n<=1?1:Math.pow(2,Math.floor(Math.log2(n)))},U.fD=P_,U.fE=$s,U.fF=function(n){let e=0;if(new Uint32Array(n,0,1)[0]!==Z0){let i=new Uint32Array(n,0,7),[,,r,s,l,u]=i;e=i.byteLength+s+l+u+l,(r!==n.byteLength||e>=n.byteLength)&&Bt("Invalid b3dm header information.")}return J0(n,e)},U.fG=function(n,e){let i=n.json.extensionsUsed&&n.json.extensionsUsed.includes("mbx_bvh"),r=Yg(n);for(let s of r){if(!i)for(let l of s.meshes)zb(l);s.lights&&(s.lightMeshIndex=s.meshes.length,s.meshes.push(Ob(s.lights,e)))}return r},U.fH=M_,U.fI=ri,U.fJ=ts,U.fK=Ar,U.fL=function(n){fa(),Yo?.then(e=>{e.keys().then(i=>{for(let r=0;r<i.length-n;r++)e.delete(i[r]).catch(s=>Bt(s.message))}).catch(i=>Bt(i.message))}).catch(e=>Bt(e.message))},U.fa=ha,U.fb=function(n){let e=tf();if(!e)return;let i=e.delete(Jp);n&&i.then(()=>n()).catch(n)},U.fc=Qe,U.fd=zi,U.fe=2,U.ff=Tc,U.fg=ou,U.fh=$c,U.fi=jv,U.fj=Gv,U.fk=_x,U.fl=qs,U.fm="hd_road_elevation",U.fn=mh,U.fo=Dt,U.fp=km,U.fq=ja,U.fr=hy,U.fs=1,U.ft=No,U.fu=function(n,e,i,r,s,l,u,p=1,f,g,x,b){n.createArrays(),n.tilePixelRatio=Xe/(512*n.overscaling),n.compareText={},n.iconsNeedLinear=!1;let w=n.layers[0].layout,S=n.layers[0]._unevaluatedLayout._values,I={};I.scaleFactor=p,I.textSizeScaleRange=w.get("text-size-scale-range"),I.iconSizeScaleRange=w.get("icon-size-scale-range");let[M,C]=I.textSizeScaleRange,[R,F]=I.iconSizeScaleRange;I.textScaleFactor=ne(I.scaleFactor,M,C),I.iconScaleFactor=ne(I.scaleFactor,R,F);let L=S["text-size"],j=S["icon-size"];if(n.textSizeData.kind==="composite"){let{minZoom:Y,maxZoom:ee}=n.textSizeData;I.compositeTextSizes=[L.possiblyEvaluate(new Jt(Y,{worldview:x}),l),L.possiblyEvaluate(new Jt(ee,{worldview:x}),l)]}if(n.iconSizeData.kind==="composite"){let{minZoom:Y,maxZoom:ee}=n.iconSizeData;I.compositeIconSizes=[j.possiblyEvaluate(new Jt(Y,{worldview:x}),l,b),j.possiblyEvaluate(new Jt(ee,{worldview:x}),l,b)]}I.layoutTextSize=L.possiblyEvaluate(new Jt(u+1,{worldview:x}),l),I.layoutIconSize=j.possiblyEvaluate(new Jt(u+1,{worldview:x}),l,b),I.textMaxSize=L.possiblyEvaluate(new Jt(18,{worldview:x}),l);let H=w.get("symbol-placement"),$=w.get("text-rotation-alignment")==="map"&&H!=="point",ie=w.get("text-size"),W=!1,Q=[];for(let Y of n.features){let ee=w.get("text-font").evaluate(Y,{},l).join(","),me=ie.evaluate(Y,{},l)*I.textScaleFactor,ge=I.layoutTextSize.evaluate(Y,{},l)*I.textScaleFactor,Te=I.layoutIconSize.evaluate(Y,{},l,b)*I.iconScaleFactor,Ae={horizontal:{},vertical:void 0},Ie=Y.text,Be,xe=[0,0];if(Ie){let Pt=Ie.toString(),ji=w.get("text-letter-spacing").evaluate(Y,{},l)*wn,Qt=w.get("text-line-height").evaluate(Y,{},l)*wn,$t=tg(Pt)?ji:0,ui=w.get("text-anchor").evaluate(Y,{},l),Pi=w.get("text-variable-anchor");if(!Pi){let tn=w.get("text-radial-offset").evaluate(Y,{},l);if(tn)xe=tv(ui,[tn*wn,_y]);else{let hn=w.get("text-offset").evaluate(Y,{},l);xe=[hn[0]*wn,hn[1]*wn]}}let Tn=$?"center":w.get("text-justify").evaluate(Y,{},l),_i=H==="point",Gi=_i?w.get("text-max-width").evaluate(Y,{},l)*wn:1/0,un=tn=>{n.allowVerticalPlacement&&Xu(Pt)&&(Ae.vertical=ry(Ie,e,i,s,ee,Gi,Qt,ui,tn,$t,xe,Yr.vertical,!0,ge,me,f,I.textScaleFactor))};if(!$&&Pi){let tn=Tn==="auto"?Pi.map(Lt=>gy(Lt)):[Tn],hn=!1;for(let Lt=0;Lt<tn.length;Lt++){let jn=tn[Lt];if(!Ae.horizontal[jn])if(hn)Ae.horizontal[jn]=Ae.horizontal[0];else{let hr=ry(Ie,e,i,s,ee,Gi,Qt,"center",jn,$t,xe,Yr.horizontal,!1,ge,me,f,I.textScaleFactor);hr&&(Ae.horizontal[jn]=hr,hn=hr.positionedLines.length===1)}}un("left")}else{if(Tn==="auto"&&(Tn=gy(ui)),_i||w.get("text-writing-mode").includes("horizontal")||!Xu(Pt)){let tn=ry(Ie,e,i,s,ee,Gi,Qt,ui,Tn,$t,xe,Yr.horizontal,!1,ge,me,f,I.textScaleFactor);tn&&(Ae.horizontal[Tn]=tn)}un(_i?"left":Tn)}}let Se,Me,Le,ze,We,De,Ge=!1,$e=w.get("icon-text-fit").evaluate(Y,{},l);if(Y.icon&&Y.icon.hasPrimary()){let Pt=Rp(Y.icon,n.iconSizeData,S["icon-size"],l,n.zoom,Y,f,I.iconScaleFactor,x,b);Se=Pt.iconPrimary,Le=Pt.iconSecondary;let ji=Se.toString();if(Me=r.get(ji),Me&&(We=w.get("icon-offset").evaluate(Y,{},l),De=w.get("icon-anchor").evaluate(Y,{},l),Be=u_(s.get(ji),Le?s.get(Le.toString()):void 0,We,De),Ge=Me.sdf,n.sdfIcons===void 0?n.sdfIcons=Me.sdf:n.sdfIcons!==Me.sdf&&Bt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Me.pixelRatio!==n.pixelRatio||w.get("icon-rotate").constantOr(1)!==0)&&(n.iconsNeedLinear=!0)),Le){let Qt=Le.toString();ze=r.get(Qt)}}W=W||!(!Y.icon||!Y.icon.hasSecondary());let Je=g_(Ae.horizontal)||Ae.vertical;n.iconsInText||(n.iconsInText=!!Je&&Je.iconsInText);let tt=ge*I.textScaleFactor/wn,{defaultShapedIcon:ct,verticallyShapedIcon:rt}=Yw(n,Be,w,Y,l,Ae,tt,We,$e);$e!=="none"&&Be&&(Bx(Be)||kx(Be))&&(__(0,Me,Se,Be,ct,$e,g,r,s),__(0,ze,Le,Be,ct,$e,g,r,s),rt&&(__(0,Me,Se,Be,rt,$e,g,r,s),__(0,ze,Le,Be,rt,$e,g,r,s))),Be=ct;let{iconBBox:ft,iconVerticalBBox:Zt,textBBox:St,textVerticalBBox:Ut}=$w(n,Be,rt,w,Y,l,Te,We,I,s,De,Ae,ge,xe,b);Q.push({feature:Y,shapedTextOrientations:Ae,shapedText:Je,shapedIcon:Be,iconPrimary:Se,iconSecondary:Le,iconOffset:We,iconAnchor:De,verticallyShapedIcon:rt,layoutTextSize:ge,layoutIconSize:Te,textOffset:xe,isSDFIcon:Ge,iconTextFit:$e,iconCollisionBounds:ft,iconVerticalCollisionBounds:Zt,textCollisionBounds:St,textVerticalCollisionBounds:Ut})}return{featureData:Q,sizes:I,hasAnySecondaryIcon:W,textAlongLine:$,symbolPlacement:H}},U.fv=dy,U.fw=uy,U.fx=Zx,U.fy=Wx,U.fz=function(n,e,i,r,s,l,u,p,f,g){n.iconAtlasPositions=g.iconPositions;let{featureData:x,hasAnySecondaryIcon:b,sizes:w,textAlongLine:S,symbolPlacement:I}=e;for(let M of x){let{shapedIcon:C,verticallyShapedIcon:R,feature:F,shapedTextOrientations:L,shapedText:j,layoutTextSize:H,textOffset:$,isSDFIcon:ie,iconPrimary:W,iconSecondary:Q,iconTextFit:Y,iconOffset:ee,iconCollisionBounds:me,iconVerticalCollisionBounds:ge,textCollisionBounds:Te}=M;ov(C,g.iconPositions,W,Q),ov(R,g.iconPositions,W,Q),Xw(L,g.iconPositions),Ww(W,Q,g.iconPositions),(j||C)&&Jw(n,F,L,C,R,f,w,H,0,$,ie,r,s,u,p,b,Y,ee,S,I,me,ge,Te)}i&&n.generateCollisionDebugBuffers(l,n.collisionBoxArray,w.textScaleFactor)},U.g=di,U.h=function(n,e){return Br(Object.assign(n,{method:"GET"}),e)},U.i=function(n){return di.API_STYLE_REGEX.test(n)&&!tl(n)},U.j=function(n){return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,i)=>String.fromCharCode(+("0x"+i))))},U.k=Nh,U.l=function(n){return decodeURIComponent(atob(n).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},U.m=of,U.n=to,U.o=yn,U.p=function(n,e){return Br(Object.assign(n,{method:"POST"}),e)},U.q=Vi,U.r=Fh,U.s=function(n){try{let e=self[n];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}},U.t=Ns,U.u=function(){return function n(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,n)}()},U.v=function(n){return!!n&&el.test(n)},U.w=Bt,U.x=class{constructor(n){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(n&&n.maxTextureMemoryMB?n.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures()})}calculateTextureMemory(n){return n.image?Math.ceil(n.image.width*n.image.height*4*(n.patternPositions.size>0?1.33:1)):0}evictTexture(n){let e=this.textures.get(n);if(e){let i=this.calculateTextureMemory(n);e.destroy(),this.textures.delete(n),this.textureAccessTimes.delete(n),this.textureMemoryUsed-=i,n.uploaded=!1}}evictTexturesIfNeeded(n){for(;this.textureMemoryUsed+n>this.maxTextureMemory&&this.textures.size>0;){let e=null,i=1/0;for(let[r]of this.textures.entries()){let s=this.textureAccessTimes.get(r)||0;s<i&&(i=s,e=r)}if(!e)break;this.evictTexture(e)}}findCachedAtlas(n){let e=this.cache.get(n.hash);if(e){let i=e.deref();if(i&&i.contentDescriptor&&this.isMipmapCompatible(n,i.contentDescriptor))return i}for(let[,i]of this.cache.entries()){let r=i.deref();if(r&&r.contentDescriptor){let s=n.subsetOf(r.contentDescriptor),l=this.isMipmapCompatible(n,r.contentDescriptor);if(s&&l)return r}}}getTextureForAtlas(n,e,i){this.textureAccessTimes.set(n,performance.now());let r=this.textures.get(n);if(r)return r;if(n.image){let s=this.calculateTextureMemory(n);return this.evictTexturesIfNeeded(s),r=new Ys(e,n.image,i,{useMipmap:!!n.patternPositions.size}),this.textures.set(n,r),this.textureMemoryUsed+=s,r}return null}clearExpiredTextures(){for(let[n]of this.textures.entries())if(!this.isAtlasCached(n)){let e=this.textures.get(n);if(e){let i=this.calculateTextureMemory(n);e.destroy(),this.textureMemoryUsed-=i}this.textures.delete(n),this.textureAccessTimes.delete(n)}}isAtlasCached(n){if(!n.contentDescriptor)return!1;let e=this.cache.get(n.contentDescriptor.hash);return!!e&&e.deref()===n}getOrCache(n){if(!("image"in n)){let s=this.cache.get(n.sourceAtlasHash);if(s){let l=s.deref();if(l)return l}return Bt("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!n.contentDescriptor)return n;
7let e=n.contentDescriptor,i=e.hash,r=this.cache.get(i);if(r){let s=r.deref();if(s&&s.contentDescriptor&&this.isMipmapCompatible(e,s.contentDescriptor))return s}return this.cache.set(i,new WeakRef(n)),this.finalizationRegistry.register(n,i,n),n}isMipmapCompatible(n,e){return!n.requiresMipMaps||e.requiresMipMaps}destroyTextures(){for(let n of this.textures.values())n&&n.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}clear(){for(let n of this.textures.values())n&&n.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}},U.y=rl,U.z=Jo}),Ai(["require","./shared"],function(h,U){function Pn(_e){let B=_e?_e.url.toString():void 0;return B?performance.getEntriesByName(B):[]}function wi(_e){if(typeof _e=="number"||typeof _e=="boolean"||typeof _e=="string"||_e==null)return JSON.stringify(_e);if(Array.isArray(_e)){let V="[";for(let X of _e)V+=`${wi(X)},`;return`${V}]`}let B="{";for(let V of Object.keys(_e).sort())B+=`${V}:${wi(_e[V])},`;return`${B}}`}function Fn(_e){let B="";for(let V of U.b8)B+=`/${wi(_e[V])}`;return B}function yr(_e,B){return function V(X){return typeof X=="string"&&X===B||(Array.isArray(X)?X.some(V):!(!X||typeof X!="object")&&Object.values(X).some(V))}(_e)}class Qr{constructor(B){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),B&&this.replace(B)}replace(B,V){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(B,[],V)}update(B,V,X){this._options=X;for(let le of B)this._layerConfigs[le.id]=le,(this._layers[le.id]=U.dh(le,this.scope,null,this._options)).compileFilter(X),this.keyCache[le.id]&&delete this.keyCache[le.id];for(let le of V)delete this.keyCache[le],delete this._layerConfigs[le],delete this._layers[le];this.familiesBySource=Object.create(null);let ae=function(le,ce){let we=Object.create(null);for(let ye=0;ye<le.length;ye++){let Ne=le[ye],Oe=ce&&ce[Ne.id];Oe||(Ne.type==="symbol"?Oe=Ne.id:(Oe=Fn(Ne),Ne.type==="line"&&Ne.paint&&yr(Ne.paint["line-width"],"line-progress")&&(Oe+=`/${wi(Ne.paint["line-width"])}`))),ce&&(ce[Ne.id]=Oe);let Ke=we[Oe];Ke||(Ke=we[Oe]=[]),Ke.push(Ne)}let ne=[];for(let ye in we)ne.push(we[ye]);return ne}(Object.values(this._layerConfigs),this.keyCache);for(let le of ae){let ce=le.map(Ke=>this._layers[Ke.id]),we=ce[0];if(we.visibility==="none")continue;let ne=we.source||"",ye=this.familiesBySource[ne];ye||(ye=this.familiesBySource[ne]=Object.create(null));let Ne=we.sourceLayer||"_geojsonTileLayer",Oe=ye[Ne];Oe||(Oe=ye[Ne]=[]),Oe.push(ce)}}}let Xn=1*U.fe;class eo{constructor(B){let V={},X=[];for(let we in B){let ne=B[we],ye=V[we]={};for(let Ne in ne.glyphs){let Oe=ne.glyphs[+Ne];if(!Oe||Oe.bitmap.width===0||Oe.bitmap.height===0)continue;let Ke=Oe.metrics.localGlyph?Xn:1,ut={x:0,y:0,w:Oe.bitmap.width+2*Ke,h:Oe.bitmap.height+2*Ke};X.push(ut),ye[Ne]=ut}}let{w:ae,h:le}=U.F(X),ce=new U.fd({width:ae||1,height:le||1});for(let we in B){let ne=B[we];for(let ye in ne.glyphs){let Ne=ne.glyphs[+ye];if(!Ne||Ne.bitmap.width===0||Ne.bitmap.height===0)continue;let Oe=V[we][ye],Ke=Ne.metrics.localGlyph?Xn:1;U.fd.copy(Ne.bitmap,ce,{x:0,y:0},{x:Oe.x+Ke,y:Oe.y+Ke},Ne.bitmap)}}this.image=ce,this.positions=V}}function Rr(_e,B,V){_e[B]?V&&(_e[B].center=V):_e[B]={floorIds:new Set,center:V||[0,0],floors:{}}}function Mt(_e,B,V,X){for(let ae of B)Rr(_e,ae),_e[ae].floors[V]=X,_e[ae].floorIds.add(V)}function Bn(_e){return{id:_e.properties.id.toString(),center:[_e.properties.center_lon||0,_e.properties.center_lat||0]}}function xi(_e,B){let V=_e.properties.id.toString(),X=!!_e.properties.is_default&&_e.properties.is_default,ae=_e.properties.connected_floor_ids?new Set(_e.properties.connected_floor_ids.toString().split(";")):new Set,le=_e.properties.conflicted_floor_ids?new Set(_e.properties.conflicted_floor_ids.toString().split(";")):new Set,ce=_e.properties.structure_ids?new Set(_e.properties.structure_ids.toString().split(";")):new Set,we=_e.properties.name.toString(),ne=_e.properties.z_index,ye=function(Ne,Oe){let Ke=Ne.loadGeometry();if(!Ke||Ke.length===0)return;let ut=Ke.map(dt=>dt.map(Ft=>U.ff(Ft,Oe,Ne.extent)));return ut.length===0?void 0:{type:"Polygon",coordinates:[ut[0]]}}(_e,B);return{id:V,isDefault:X,connections:ae,conflicts:le,buildings:ce,name:we,zIndex:ne,geometry:ye}}function $n(_e,B){return B.every(V=>_e.properties&&_e.properties[V]!=null)}function Yn(_e){return $n(_e,["type","id","name"])&&_e.properties.type==="structure"}function Go(_e){return $n(_e,["type","id","name","z_index"])&&_e.properties.type==="floor"}U.fc(eo,"GlyphAtlas");class Ho{constructor(B){this.tileID=new U.aU(B.tileID.overscaledZ,B.tileID.wrap,B.tileID.canonical.z,B.tileID.canonical.x,B.tileID.canonical.y),this.tileZoom=B.tileZoom,this.uid=B.uid,this.zoom=B.zoom,this.lut=B.lut,this.canonical=B.tileID.canonical,this.pixelRatio=B.pixelRatio,this.tileSize=B.tileSize,this.source=B.source,this.scope=B.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=B.showCollisionBoxes,this.showElevationIdDebug=B.showElevationIdDebug,this.collectResourceTiming=!!B.request&&B.request.collectResourceTiming,this.promoteId=B.promoteId,this.renderSourceType=B.renderSourceType,this.tileTransform=U.fg(B.tileID.canonical,B.projection),this.projection=B.projection,this.worldview=B.worldview,this.localizableLayerIds=B.localizableLayerIds,this.brightness=B.brightness,this.extraShadowCaster=!!B.extraShadowCaster,this.tessellationStep=B.tessellationStep,this.scaleFactor=B.scaleFactor,this.worldview=B.worldview,this.indoor=B.indoor}parse(B,V,X,ae,le,ce){this.status="parsing",this.data=B,this.collisionBoxArray=new U.fh;let we=new U.fi(Object.keys(B.layers).sort()),ne=new U.fj(this.tileID,this.promoteId);ne.bucketLayerIDs=[];let ye={},Ne=new U.fk(256,256),Oe={featureIndex:ne,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ne,availableImages:X,brightness:this.brightness,scaleFactor:this.scaleFactor,showElevationIdDebug:this.showElevationIdDebug,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(Oe.activeFloors=function(Ft,It,Dt,Ve){let Gt=It.indoorState.activeFloorsVisible;if(!It.sourceLayers)return Gt?It.indoorState.activeFloors:void 0;let qi=function(ni,Di){if(!ni)return U.w("No source layers defined in indoor specification"),Di;if(ni.size===0)return Di;let rn=ni.difference(Di);for(let ri of rn)U.w(`Missing source layer required in indoor specification: ${ri}`);return Di.intersection(Di)}(It.sourceLayers,new Set(Object.keys(Ft.layers))),Zi=It.indoorState,Bt=function(ni,Di,rn,ri,Ci){let Ni={};for(let vi of Di){let Xi=ni.layers[vi];if(Xi)for(let Nn=0;Nn<Xi.length;Nn++){let gn=Xi.feature(Nn);if(Yn(gn)){let{id:Ln,center:Fr}=Bn(gn);
7Rr(Ni,Ln,Fr);continue}if(Go(gn)){let Ln=xi(gn,Ci);Mt(Ni,Ln.buildings,Ln.id,Ln)}}else U.w(`indoor source layer not found: ${vi}`)}return{buildings:Ni,activeFloors:U.d3.calculate(Ni,ri,rn)}}(Ft,qi,Zi.activeFloors,Zi.selectedFloorId,Ve);return Dt.send("setIndoorData",Bt),Gt?Bt.activeFloors:void 0}(B,this.indoor,le,this.canonical));let Ke=[],ut=V.familiesBySource[this.source];for(let Ft in ut){let It=B.layers[Ft];if(!It)continue;let Dt=!1,Ve=!1,Gt=!1,qi=!1;for(let rn of ut[Ft])rn[0].type==="symbol"?Dt=!0:rn[0].type==="fill-extrusion"?Ve=!0:Gt=!0,rn[0].is3D()&&rn[0].type!=="model"&&(qi=!0);if(this.extraShadowCaster&&!qi||this.renderSourceType===U.b7.Symbol&&!Dt||this.renderSourceType===U.b7.FillExtrusion&&!Ve||this.renderSourceType===U.b7.Other&&!Gt)continue;It.version===1&&U.w(`Vector tile source "${this.source}" layer "${Ft}" does not use vector tile spec v2 and therefore may have some rendering errors.`);let Zi=we.encode(Ft),Bt=[],ni=this.localizableLayerIds&&this.localizableLayerIds.has(Ft),Di=!1;for(let rn=0,ri=0;rn<It.length;rn++){let Ci=It.feature(rn),Ni=ne.getId(Ci,Ft),vi=Ci.properties?Ci.properties.worldview:null;if(ni&&this.worldview&&typeof vi=="string")if(vi==="all")Ci.properties.$localized=!0;else{if(!vi.split(",").includes(this.worldview))continue;Ci.properties.$localized=!0,Ci.properties.worldview=this.worldview}!Di&&Ci.properties&&Object.hasOwn(Ci.properties,U.fl)&&(Di=!0),Bt.push({feature:Ci,id:Ni,index:ri,sourceLayerIndex:Zi}),ri++}Di&&!Oe.elevationFeatures&&Object.hasOwn(B.layers,U.fm)&&(Oe.elevationFeatures=U.fn.parseFrom(B.layers[U.fm],this.canonical));for(let rn of ut[Ft]){let ri=rn[0];if(this.extraShadowCaster&&(!ri.is3D()||ri.type==="model")||this.renderSourceType===U.b7.Symbol&&ri.type!=="symbol"||this.renderSourceType===U.b7.FillExtrusion&&ri.type!=="fill-extrusion"||this.renderSourceType===U.b7.Other&&(ri.type==="symbol"||ri.type==="fill-extrusion")||ri.minzoom&&this.zoom<Math.floor(ri.minzoom)||ri.maxzoom&&this.zoom>=ri.maxzoom||ri.visibility==="none")continue;fo(rn,this.zoom,Oe.brightness,X,this.worldview,Oe.activeFloors);let Ci=()=>{let Ni=ye[ri.id]=ri.createBucket({index:ne.bucketLayerIDs.length,layers:rn,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Zi,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:ae,worldview:this.worldview,localizable:ni,availableImages:X,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});ne.bucketLayerIDs.push(rn.map(vi=>U.t(vi.id,vi.scope))),Ni.populate(Bt,Oe,this.tileID.canonical,this.tileTransform)};if("prepare"in ri){let Ni=ri.prepare().then(()=>Ci());Ke.push(Ni)}else Ci()}}let dt=()=>{Ne.trim();let Ft=!(!Oe.elevationFeatures||!Oe.elevationFeatures.some(ri=>ri.heightRange.min<0)),It,Dt,Ve,Gt,qi,Zi,Bt,ni={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},Di=()=>{if(It)return this.status="done",ce(It);if(this.extraShadowCaster)this.status="done",ce(null,{buckets:Object.values(ye).filter(ri=>!ri.isEmpty()),featureIndex:ne,collisionBoxArray:null,hasTunnelGeometry:Ft,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Oe.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Dt&&Ve&&Gt&&Bt){let Ci=new eo(Dt),Ni=new Map;for(let[Xi,Nn]of Ve.entries()){let{imagePosition:gn}=U.fr(Xi,Nn,U.fs);Ni.set(Xi,gn)}let vi={};for(let Xi in ye){let Nn=ye[Xi];Nn instanceof U.ft&&(fo(Nn.layers,this.zoom,Oe.brightness,X,this.worldview,Oe.activeFloors),vi[Xi]=U.fu(Nn,Dt,Ci.positions,Ve,Ni,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,qi,this.worldview,X))}qi.size||Zi.size?this.rasterizeTask=le.send("rasterizeImages",{scope:this.scope,iconTasks:qi,patternTasks:Zi},(Xi,Nn)=>{if(!Xi)for(let[gn,Ln]of Nn.entries())Ve.has(gn)&&Ve.set(gn,Object.assign(Ve.get(gn),{data:Ln})),Gt.has(gn)&&Gt.set(gn,Object.assign(Gt.get(gn),{data:Ln}));rn(vi,Ci,void 0,Bt)}):rn(vi,Ci,void 0,Bt)}},rn=(ri,Ci,Ni,vi)=>{let Xi=Ve.size>0||Gt.size>0,Nn=Object.keys(ri).length>0;if(!Xi&&!Nn)return this.status="done",void ce(null,{buckets:Object.values(ye).filter(Ln=>!Ln.isEmpty()),featureIndex:ne,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:Ft,glyphAtlasImage:Ci.image,lineAtlas:Ne,imageAtlas:null,brightness:Oe.brightness});let gn=(Ln,Fr)=>{for(let xo in ye){let di=ye[xo];if(xo in ri)U.fz(di,ri[xo],this.showCollisionBoxes,X,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,Ve,Fr);else if(di.hasPattern&&(di instanceof U.fA||di instanceof U.fp||di instanceof U.e3)){fo(di.layers,this.zoom,Oe.brightness,X,this.worldview,Oe.activeFloors);let ha=Object.fromEntries(Fr.patternPositions);di.addFeatures(Oe,this.tileID.canonical,ha,X,this.tileTransform,this.brightness)}}this.status="done",ce(null,{buckets:Object.values(ye).filter(xo=>!xo.isEmpty()),featureIndex:ne,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:Ft,glyphAtlasImage:Ci.image,lineAtlas:Ne,imageAtlas:Ln,brightness:Oe.brightness})};if(Xi){let Ln=new Map,Fr=U.fv(Ve,Ln),xo=U.fv(Gt,Ln),di=new U.fw(Fr,xo,vi,this.lut,Ln);le.send("checkAtlasCache",{descriptor:di,scope:this.scope},(ha,da)=>{let pa,bs;if(ha&&U.w(`[Worker] Error checking atlas cache: ${ha.message}`),da)pa=new U.fx(da.sourceHash),bs=da;else{let tl=new U.fy(Ve,Gt,this.lut,vi);pa=tl,bs=tl}gn(pa,bs)})}else gn(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){let ri=U.fo(Oe.glyphDependencies,vi=>Object.keys(vi).map(Number));Object.keys(ri).length?le.send("getGlyphs",{uid:this.uid,stacks:ri},(vi,Xi)=>{It||(It=vi,Dt=Xi,Di())},void 0,!1,ni):Dt={},Bt=new Map;let Ci=Array.from(Oe.iconDependencies.keys()).map(vi=>U.I.parse(vi)),Ni=Array.from(Oe.patternDependencies.keys()).map(vi=>U.I.parse(vi));Ci.length||Ni.length?le.send("getImages",{icons:Ci,patterns:Ni,source:this.source,scope:this.scope,tileID:this.tileID},(vi,Xi)=>
7{if(!It){It=vi,Ve=new Map,Gt=new Map,qi=this.updateImageMapAndGetImageTaskQueue(Ve,Xi.images,Oe.iconDependencies),Zi=this.updateImageMapAndGetImageTaskQueue(Gt,Xi.images,Oe.patternDependencies);for(let[Nn,gn]of Xi.versions.entries())Bt.set(Nn,gn);Di()}},void 0,!1,ni):(Ve=new Map,Gt=new Map,qi=new Map,Zi=new Map)}if(Oe.elevationFeatures&&Oe.elevationFeatures.length>0){let ri=[];for(let Ni of Object.values(ye))if(Ni instanceof U.fp){let vi=Ni.getUnevaluatedPortalGraph();vi&&ri.push(vi)}let Ci=U.fq.evaluate(ri);for(let Ni of Object.values(ye))if(Ni instanceof U.fp){let vi=B.layers[we.decode(Ni.sourceLayerIndex)];Ni.setEvaluatedPortalGraph(Ci,vi,this.tileID.canonical,Oe.availableImages,Oe.brightness)}}Di()};Ke.length>0?Promise.allSettled(Ke).then(dt).catch(ce):dt()}updateParameters(B){this.scaleFactor=B.scaleFactor,this.showCollisionBoxes=B.showCollisionBoxes,this.showElevationIdDebug=B.showElevationIdDebug,this.projection=B.projection,this.brightness=B.brightness,this.tileTransform=U.fg(B.tileID.canonical,B.projection),this.extraShadowCaster=B.extraShadowCaster,this.lut=B.lut,this.worldview=B.worldview,this.indoor=B.indoor}updateImageMapAndGetImageTaskQueue(B,V,X){let ae=new Map;for(let le of V.keys()){let ce=X.get(le)||[];for(let we of ce){let ne=we.toString(),ye=V.get(we.id.toString());ye.usvg?ae.has(ne)||(ae.set(ne,we),B.set(ne,Object.assign({},ye))):B.set(ne,ye)}}return ae}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function fo(_e,B,V,X,ae,le){let ce=new U.ab(B,{brightness:V,worldview:ae,activeFloors:le});for(let we of _e)we.recalculate(ce,X)}class _s extends U.E{constructor({actor:B,layerIndex:V,availableImages:X,availableModels:ae,isSpriteLoaded:le,tileProvider:ce,brightness:we,maxUniformBufferBindings:ne,maxUniformBlockSizeDwords:ye,disableSymbolUBO:Ne}){super(),this.actor=B,this.layerIndex=V,this.availableImages=X,this.availableModels=ae,this.loadVectorData=U.aQ,this.tileProvider=ce,this.loading={},this.loaded={},this.deduped=new U.aL(B.scheduler),this.isSpriteLoaded=le,this.scheduler=B.scheduler,this.brightness=we,this.maxUniformBufferBindings=ne,this.maxUniformBlockSizeDwords=ye,this.disableSymbolUBO=Ne}loadTileData(B,V){if(!this.tileProvider)return this.loadVectorData(B,V);let X=new AbortController;return this.loadTileWithProvider(this.tileProvider,B,X,V),()=>X.abort()}async loadTileWithProvider(B,V,X,ae){let{z:le,x:ce,y:we}=V.tileID.canonical;try{let ne=await B.loadTile({z:le,x:ce,y:we},{request:V.request,signal:X.signal});if(X.signal.aborted)return;if(ne==null){let Ne=new Error("Tile not found");return Ne.status=404,ae(Ne)}if(ne.data==null)return ae(null,null);let ye=new Map;ne.expires&&ye.set("expires",ne.expires),ne.cacheControl&&ye.set("cache-control",ne.cacheControl),ae(null,{rawData:ne.data,responseHeaders:ye})}catch(ne){if(X.signal.aborted)return;ae(ne instanceof Error?ne:new Error(String(ne)))}}loadTile(B,V){let X=B.uid,ae=B&&B.request,le=ae&&ae.collectResourceTiming,ce=this.loading[X]=new Ho(B);ce.maxUniformBufferBindings=this.maxUniformBufferBindings,ce.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,ce.disableSymbolUBO=this.disableSymbolUBO,ce.abort=this.loadTileData(B,(we,ne)=>{let ye=!this.loading[X];if(delete this.loading[X],ce.cancelRasterize(),ye||we||!ne)return ce.status="done",ye||(this.loaded[X]=ce),V(we);let Ne=ne.rawData,Oe={},Ke=U.aR(ne.responseHeaders);Ke&&Ke.expires&&(Oe.expires=Ke.expires),Ke&&Ke.cacheControl&&(Oe.cacheControl=Ke.cacheControl),ce.vectorTile=ne.vectorTile||new U.fB(new U.b2(Ne));let ut=()=>{ce.parse(ce.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(dt,Ft)=>{if(dt||!Ft)return V(dt);let It={};if(le){let Dt=Pn(ae);Dt.length>0&&(It.resourceTiming=JSON.parse(JSON.stringify(Dt)))}V(null,Object.assign({rawTileData:Ne.slice(0),responseHeaders:ne.responseHeaders},Ft,Oe,It))})};this.isSpriteLoaded?ut():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(ut,{type:"parseTile",renderSourceType:B.renderSourceType,zoom:B.tileZoom}):ut()}),this.loaded=this.loaded||{},this.loaded[X]=ce})}reloadTile(B,V){let X=this.loaded,ae=B.uid;if(X&&X[ae]){let le=X[ae];le.updateParameters(B);let ce=(we,ne)=>{let ye=le.reloadCallback;ye&&(delete le.reloadCallback,le.parse(le.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ye)),V(we,ne)};le.status==="parsing"?le.reloadCallback=ce:le.status==="done"&&(le.vectorTile?le.parse(le.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ce):ce())}else V(null,void 0)}abortTile(B,V){let X=B.uid,ae=this.loading[X];ae&&(ae.abort&&ae.abort(),delete this.loading[X]),V()}removeTile(B,V){let X=this.loaded,ae=B.uid;X&&X[ae]&&delete X[ae],V()}}class $o{constructor(B){this.tileProvider=B.tileProvider,this.loading={}}loadTile(B,V){let X=B.uid;if(this.tileProvider){let le=new AbortController;return this.loading[X]={cancel:()=>le.abort()},void this.loadTileWithProvider(this.tileProvider,X,B,le,V)}let{cancel:ae}=U.b4(B.request,(le,ce,we)=>{let ne=!this.loading[X];if(delete this.loading[X],ne||le||!ce)return V(le);this.decodeTile(X,ce,B.encoding).then(ye=>{let{expires:Ne,cacheControl:Oe}=U.aR(we);V(null,Object.assign(ye,{expires:Ne,cacheControl:Oe}))}).catch(ye=>V(ye))});this.loading[X]={cancel:ae}}
7async decodeTile(B,V,X){let ae=await createImageBitmap(new Blob([new Uint8Array(V)],{type:"image/png"})),le=1-(ae.width-U.fC(ae.width))/2,ce=le<1,we=this.getImageData(ae,le);return ae.close(),{dem:new U.fD(B,we,X,ce),borderReady:ce}}async loadTileWithProvider(B,V,X,ae,le){let{z:ce,x:we,y:ne}=X.tileID.canonical;try{let ye=await B.loadTile({z:ce,x:we,y:ne},{request:X.request,signal:ae.signal});if(ae.signal.aborted)return le(null,null);if(ye==null){let Oe=new Error("Tile not found");return Oe.status=404,le(Oe)}if(ye.data==null)return le(null,null);let Ne=await this.decodeTile(V,ye.data,X.encoding);if(ae.signal.aborted)return le(null,null);le(null,Object.assign(Ne,{expires:ye.expires,cacheControl:ye.cacheControl}))}catch(ye){if(ae.signal.aborted||ye instanceof DOMException&&ye.name==="AbortError")return le(null,null);le(ye instanceof Error?ye:new Error(String(ye)))}finally{delete this.loading[V]}}reloadTile(B,V){V(null,null)}abortTile(B,V){let X=B.uid,ae=this.loading[X];ae&&(ae.cancel(),delete this.loading[X]),V()}removeTile(B,V){V()}getImageData(B,V){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(B.width,B.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=B.width,this.offscreenCanvas.height=B.height,this.offscreenCanvasContext.drawImage(B,0,0,B.width,B.height);let X=this.offscreenCanvasContext.getImageData(-V,-V,B.width+2*V,B.height+2*V);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),X}}U.b1.setPbf(U.b2);class ta{constructor(B){this._mrt=new U.b1(B.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=B.uid,this.tileID=B.tileID,this.source=B.source}parse(B,V){let X=this._mrt;this.status="parsing",this._entireBuffer=B;try{X.parseHeader(B),this._isHeaderLoaded=!0;let ae=[];for(let le in X.layers){let ce=X.getLayer(le),we=ce.getDataRange(ce.getBandList()),ne=X.createDecodingTask(we),ye=B.slice(we.firstByte,we.lastByte+1),Ne=U.b1.performDecoding(ye,ne).then(Oe=>ne.complete(null,Oe)).catch(Oe=>ne.complete(Oe,null));ae.push(Ne)}Promise.allSettled(ae).then(()=>V(null,X)).catch(le=>V(le))}catch(ae){V(ae)}}}class Kl{constructor({actor:B}){this.actor=B,this.loading={},this.loaded={}}loadTile(B,V){let X=B.uid,ae=B.request,le=this.loading[X]=new ta(B),{cancel:ce}=U.b4(ae,(we,ne,ye)=>{let Ne=!this.loading[X];if(delete this.loading[X],Ne||we||!ne)return le.status="done",Ne||(this.loaded[X]=le),V(we);le.parse(ne,(Oe,Ke)=>{if(Oe||!Ke)return V(Oe);V(null,Ke,ye)}),this.loaded[X]=le});le.abort=ce}reloadTile(B,V){V(null,void 0)}abortTile(B,V){let X=B.uid,ae=this.loading[X];ae&&(ae.abort&&ae.abort(),delete this.loading[X]),V()}removeTile(B,V){let X=B.uid;this.loaded[X]&&delete this.loaded[X],V()}decodeRasterArray(B,V){U.b1.performDecoding(B.buffer,B.task).then(X=>V(null,X)).catch(X=>V(X))}}let Ql=U.fE.prototype.toGeoJSON;class ec{constructor(B){this._feature=B,this.extent=U.ak,this.type=B.type,this.properties=B.tags,"id"in B&&!isNaN(B.id)&&(this.id=parseInt(B.id,10))}loadGeometry(){if(this._feature.type===1){let B=[];for(let V of this._feature.geometry)B.push([new U.P(V[0],V[1])]);return B}{let B=[];for(let V of this._feature.geometry){let X=[];for(let ae of V)X.push(new U.P(ae[0],ae[1]));B.push(X)}return B}}toGeoJSON(B,V,X){return Ql.call(this,B,V,X)}}class ai{constructor(B,V){this.name=B,this.extent=U.ak,this.length=V.length,this._jsonFeatures=V}feature(B){return new ec(this._jsonFeatures[B])}}class tc{constructor(B){this.layers={},this.extent=U.ak;for(let V of Object.keys(B))this.layers[V]=new ai(V,B[V])}}let Dn=64/4096;class kn{constructor(){this.features=new Map}clear(){this.features.clear()}load(B=[],V){for(let X of B){let ae=X.id;if(ae==null)continue;let le=this.features.get(ae);le&&this.updateCache(le,V),X.geometry?(le=nn(X),this.updateCache(le,V),this.features.set(ae,le)):this.features.delete(ae),this.updateCache(le,V)}}updateCache(B,V){for(let{canonical:X,uid:ae}of Object.values(V)){let{z:le,x:ce,y:we}=X;Mi(B,Math.pow(2,le),ce,we)&&delete V[ae]}}getTile(B,V,X){let ae=Math.pow(2,B),le=[];for(let ce of this.features.values())Mi(ce,ae,V,X)&&le.push(Lr(ce,ae,V,X));return{features:le}}getFeatures(){return[...this.features.values()]}}function Mi({minX:_e,minY:B,maxX:V,maxY:X},ae,le,ce){return _e<(le+1+Dn)/ae&&B<(ce+1+Dn)/ae&&V>(le-Dn)/ae&&X>(ce-Dn)/ae}function nn(_e){let{id:B,geometry:V,properties:X}=_e;if(!V)return;
7if(V.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");let{type:ae,coordinates:le}=V,ce={id:B,type:1,geometry:[],tags:X,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},we=ce.geometry;if(ae==="Point")mo(le,we,ce);else if(ae==="MultiPoint")for(let ne of le)mo(ne,we,ce);else if(ae==="LineString")ce.type=2,ic(le,we,ce);else if(ae==="MultiLineString")ce.type=2,Rn(le,we,ce);else if(ae==="Polygon")ce.type=3,Rn(le,we,ce,!0);else{if(ae!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");ce.type=3;for(let ne of le)Rn(ne,we,ce,!0)}return ce}function mo([_e,B],V,X){let ae=U.aG(_e),le=U.aJ(B);le=le<0?0:le>1?1:le,V.push(ae,le),X.minX=Math.min(X.minX,ae),X.minY=Math.min(X.minY,le),X.maxX=Math.max(X.maxX,ae),X.maxY=Math.max(X.maxY,le)}function ic(_e,B,V,X=!1,ae=!1){let le=[];for(let ce of _e)mo(ce,le,V);B.push(le),X&&function(ce,we){let ne=0;for(let ye=0,Ne=ce.length,Oe=Ne-2;ye<Ne;Oe=ye,ye+=2)ne+=(ce[ye]-ce[Oe])*(ce[ye+1]+ce[Oe+1]);if(ne>0===we)for(let ye=0,Ne=ce.length;ye<Ne/2;ye+=2){let Oe=ce[ye],Ke=ce[ye+1];ce[ye]=ce[Ne-2-ye],ce[ye+1]=ce[Ne-1-ye],ce[Ne-2-ye]=Oe,ce[Ne-1-ye]=Ke}}(le,ae)}function Rn(_e,B,V,X=!1){for(let ae=0;ae<_e.length;ae++)ic(_e[ae],B,V,X,ae===0)}function Lr(_e,B,V,X){let{id:ae,type:le,geometry:ce,tags:we}=_e,ne=[];if(le===1)(function(ye,Ne,Oe,Ke,ut){for(let dt=0;dt<ye.length;dt+=2){let Ft=Math.round(U.ak*(ye[dt+0]*Ne-Oe)),It=Math.round(U.ak*(ye[dt+1]*Ne-Ke));ut.push([Ft,It])}})(ce,B,V,X,ne);else if(le===2)for(let ye of ce)Fi(ye,B,V,X,ne);else if(le===3)for(let ye of ce)zr(ye,B,V,X,ne);return{id:ae,type:le,geometry:ne,tags:we}}function Fi(_e,B,V,X,ae){let ce=U.ak+128,we;for(let ne=0;ne<_e.length-2;ne+=2){let ye=Math.round(U.ak*(_e[ne+0]*B-V)),Ne=Math.round(U.ak*(_e[ne+1]*B-X)),Oe=Math.round(U.ak*(_e[ne+2]*B-V)),Ke=Math.round(U.ak*(_e[ne+3]*B-X)),ut=Oe-ye,dt=Ke-Ne;ye<-128&&Oe<-128||(ye<-128?(Ne+=Math.round(dt*((-128-ye)/ut)),ye=-128):Oe<-128&&(Ke=Ne+Math.round(dt*((-128-ye)/ut)),Oe=-128),Ne<-128&&Ke<-128||(Ne<-128?(ye+=Math.round(ut*((-128-Ne)/dt)),Ne=-128):Ke<-128&&(Oe=ye+Math.round(ut*((-128-Ne)/dt)),Ke=-128),ye>=ce&&Oe>=ce||(ye>=ce?(Ne+=Math.round(dt*((ce-ye)/ut)),ye=ce):Oe>=ce&&(Ke=Ne+Math.round(dt*((ce-ye)/ut)),Oe=ce),Ne>=ce&&Ke>=ce||(Ne>=ce?(ye+=Math.round(ut*((ce-Ne)/dt)),Ne=ce):Ke>=ce&&(Oe=ye+Math.round(ut*((ce-Ne)/dt)),Ke=ce),we&&ye===we.at(-1)[0]&&Ne===we.at(-1)[1]||(we=[[ye,Ne]],ae.push(we)),we.push([Oe,Ke])))))}}function zr(_e,B,V,X,ae){let le=(V-Dn)/B,ce=(X-Dn)/B,we=(V+1+Dn)/B,ne=(X+1+Dn)/B;function ye(Ke,ut){let dt=0;return Ke<le?dt|=1:Ke>we&&(dt|=2),ut<ce?dt|=4:ut>ne&&(dt|=8),dt}let Ne=[];for(let Ke=1;Ke<=8;Ke*=2){let ut=_e[_e.length-2],dt=_e.at(-1),Ft=!(ye(ut,dt)&Ke);for(let It=0;It<_e.length;It+=2){let Dt=_e[It],Ve=_e[It+1],Gt=!(ye(Dt,Ve)&Ke);Gt!==Ft&&(8&Ke?Ne.push(ut+(Dt-ut)*(ne-dt)/(Ve-dt),ne):4&Ke?Ne.push(ut+(Dt-ut)*(ce-dt)/(Ve-dt),ce):2&Ke?Ne.push(we,dt+(Ve-dt)*(we-ut)/(Dt-ut)):1&Ke&&Ne.push(le,dt+(Ve-dt)*(le-ut)/(Dt-ut))),Gt&&Ne.push(Dt,Ve),ut=Dt,dt=Ve,Ft=Gt}if(!(_e=Ne).length||Ke===8)break;Ne=[]}let Oe=[];for(let Ke=0;Ke<Ne.length;Ke+=2)Oe.push([Math.round(U.ak*(Ne[Ke]*B-V)),Math.round(U.ak*(Ne[Ke+1]*B-X))]);Oe.length&&ae.push(Oe)}function ia({name:_e,features:B},V){V.writeStringField(1,_e),V.writeVarintField(5,U.ak);let X=new Map,ae=new Map,le={keys:X,values:ae,feature:null};for(let ce of B)le.feature=ce,V.writeMessage(2,qo,le);for(let ce of X.keys())V.writeStringField(3,ce);for(let ce of ae.keys())V.writeMessage(4,Jn,ce)}function qo(_e,B){let V=_e.feature;V.id!==void 0&&Number.isSafeInteger(+V.id)&&B.writeVarintField(1,+V.id),V.tags&&B.writeMessage(2,nc,_e),B.writeVarintField(3,V.type),B.writeMessage(4,en,V)}function nc({keys:_e,values:B,feature:V},X){for(let ae of Object.keys(V.tags)){let le=V.tags[ae];if(le===null)continue;let ce=_e.get(ae);ce===void 0&&(ce=_e.size,_e.set(ae,ce)),X.writeVarint(ce);let we=typeof le;we!=="string"&&we!=="boolean"&&we!=="number"&&(le=JSON.stringify(le));let ne=B.get(le);ne===void 0&&(ne=B.size,B.set(le,ne)),X.writeVarint(ne)}}function _o(_e,B){return(B<<3)+(7&_e)}function hi(_e){return _e<<1^_e>>31}function en(_e,B){let{geometry:V,type:X}=_e,ae=0,le=0;if(X===1){B.writeVarint(_o(1,V.length));for(let ce of V){let we=ce[0]-ae,ne=ce[1]-le;B.writeVarint(hi(we)),B.writeVarint(hi(ne)),ae+=we,le+=ne}}else for(let ce of V){if(ce.length===0)continue;B.writeVarint(_o(1,1));let we=ce.length-(X===3?1:0);for(let ne=0;ne<we;ne++){ne===1&&B.writeVarint(_o(2,we-1));let ye=ce[ne][0]-ae,Ne=ce[ne][1]-le;B.writeVarint(hi(ye)),B.writeVarint(hi(Ne)),ae+=ye,le+=Ne}X===3&&B.writeVarint(_o(7,1))}}function Jn(_e,B){let V=typeof _e;
7V==="string"?B.writeStringField(1,_e):V==="boolean"?B.writeBooleanField(7,_e):V==="number"&&(_e%1!=0?B.writeDoubleField(3,_e):_e<0?B.writeSVarintField(6,_e):B.writeVarintField(5,_e))}let na={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:_e=>_e},Bi=Math.fround||(gs=new Float32Array(1),_e=>(gs[0]=+_e,gs[0]));var gs;class Za{constructor(B){this.options=Object.assign(Object.create(na),B),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(B){let{log:V,minZoom:X,maxZoom:ae}=this.options;V&&console.time("total time");let le=`prepare ${B.length} points`;V&&console.time(le),this.points=B;let ce=[];for(let ne=0;ne<B.length;ne++){let ye=B[ne];if(!ye.geometry)continue;let[Ne,Oe]=ye.geometry.coordinates,Ke=Bi($i(Ne)),ut=Bi(Xa(Oe));ce.push(Ke,ut,1/0,ne,-1,1),this.options.reduce&&ce.push(0)}let we=this.trees[ae+1]=this._createTree(ce);V&&console.timeEnd(le);for(let ne=ae;ne>=X;ne--){let ye=+Date.now();we=this.trees[ne]=this._createTree(this._cluster(we,ne)),V&&console.log("z%d: %d clusters in %dms",ne,we.numItems,+Date.now()-ye)}return V&&console.timeEnd("total time"),this}getClusters(B,V){let X=((B[0]+180)%360+360)%360-180,ae=Math.max(-90,Math.min(90,B[1])),le=B[2]===180?180:((B[2]+180)%360+360)%360-180,ce=Math.max(-90,Math.min(90,B[3]));if(B[2]-B[0]>=360)X=-180,le=180;else if(X>le){let Oe=this.getClusters([X,ae,180,ce],V),Ke=this.getClusters([-180,ae,le,ce],V);return Oe.concat(Ke)}let we=this.trees[this._limitZoom(V)],ne=we.range($i(X),Xa(ce),$i(le),Xa(ae)),ye=we.data,Ne=[];for(let Oe of ne){let Ke=this.stride*Oe;Ne.push(ye[Ke+5]>1?Wa(ye,Ke,this.clusterProps):this.points[ye[Ke+3]])}return Ne}getChildren(B){let V=this._getOriginId(B),X=this._getOriginZoom(B),ae="No cluster with the specified id.",le=this.trees[X];if(!le)throw new Error(ae);let ce=le.data;if(V*this.stride>=ce.length)throw new Error(ae);let we=this.options.radius/(this.options.extent*Math.pow(2,X-1)),ne=le.within(ce[V*this.stride],ce[V*this.stride+1],we),ye=[];for(let Ne of ne){let Oe=Ne*this.stride;ce[Oe+4]===B&&ye.push(ce[Oe+5]>1?Wa(ce,Oe,this.clusterProps):this.points[ce[Oe+3]])}if(ye.length===0)throw new Error(ae);return ye}getLeaves(B,V,X){let ae=[];return this._appendLeaves(ae,B,V=V||10,X=X||0,0),ae}getTile(B,V,X){let ae=this.trees[this._limitZoom(B)],le=Math.pow(2,B),{extent:ce,radius:we}=this.options,ne=we/ce,ye=(X-ne)/le,Ne=(X+1+ne)/le,Oe={features:[]};return this._addTileFeatures(ae.range((V-ne)/le,ye,(V+1+ne)/le,Ne),ae.data,V,X,le,Oe),V===0&&this._addTileFeatures(ae.range(1-ne/le,ye,1,Ne),ae.data,le,X,le,Oe),V===le-1&&this._addTileFeatures(ae.range(0,ye,ne/le,Ne),ae.data,-1,X,le,Oe),Oe.features.length?Oe:null}getClusterExpansionZoom(B){let V=this._getOriginZoom(B)-1;for(;V<=this.options.maxZoom;){let X=this.getChildren(B);if(V++,X.length!==1)break;B=X[0].properties.cluster_id}return V}_appendLeaves(B,V,X,ae,le){let ce=this.getChildren(V);for(let we of ce){let ne=we.properties;if(ne&&ne.cluster?le+ne.point_count<=ae?le+=ne.point_count:le=this._appendLeaves(B,ne.cluster_id,X,ae,le):le<ae?le++:B.push(we),B.length===X)break}return le}_createTree(B){let V=new U.bM(B.length/this.stride|0,this.options.nodeSize,Float32Array);for(let X=0;X<B.length;X+=this.stride)V.add(B[X],B[X+1]);return V.finish(),V.data=B,V}_addTileFeatures(B,V,X,ae,le,ce){for(let we of B){let ne=we*this.stride,ye=V[ne+5]>1,Ne,Oe,Ke;if(ye)Ne=Po(V,ne,this.clusterProps),Oe=V[ne],Ke=V[ne+1];else{let Ft=this.points[V[ne+3]];Ne=Ft.properties;let[It,Dt]=Ft.geometry.coordinates;Oe=$i(It),Ke=Xa(Dt)}let ut={type:1,geometry:[[Math.round(this.options.extent*(Oe*le-X)),Math.round(this.options.extent*(Ke*le-ae))]],tags:Ne},dt;dt=ye||this.options.generateId?V[ne+3]:this.points[V[ne+3]].id,dt!==void 0&&(ut.id=dt),ce.features.push(ut)}}_limitZoom(B){return Math.max(this.options.minZoom,Math.min(Math.floor(+B),this.options.maxZoom+1))}_cluster(B,V){let{radius:X,extent:ae,reduce:le,minPoints:ce}=this.options,we=X/(ae*Math.pow(2,V)),ne=B.data,ye=[],Ne=this.stride;for(let Oe=0;Oe<ne.length;Oe+=Ne){if(ne[Oe+2]<=V)continue;ne[Oe+2]=V;let Ke=ne[Oe],ut=ne[Oe+1],dt=B.within(ne[Oe],ne[Oe+1],we),Ft=ne[Oe+5],It=Ft;for(let Dt of dt){let Ve=Dt*Ne;ne[Ve+2]>V&&(It+=ne[Ve+5])}if(It>Ft&&It>=ce){let Dt,Ve=Ke*Ft,Gt=ut*Ft,qi=-1,Zi=(Oe/Ne<<5)+(V+1)+this.points.length;for(let Bt of dt){let ni=Bt*Ne;if(ne[ni+2]<=V)continue;ne[ni+2]=V;let Di=ne[ni+5];Ve+=ne[ni]*Di,Gt+=ne[ni+1]*Di,ne[ni+4]=Zi,le&&(Dt||(Dt=this._map(ne,Oe,!0),qi=this.clusterProps.length,this.clusterProps.push(Dt)),le(Dt,this._map(ne,ni)))}ne[Oe+4]=Zi,ye.push(Ve/It,Gt/It,1/0,Zi,-1,It),le&&ye.push(qi)}else{for(let Dt=0;Dt<Ne;Dt++)ye.push(ne[Oe+Dt]);if(It>1)for(let Dt of dt){let Ve=Dt*Ne;if(!(ne[Ve+2]<=V)){ne[Ve+2]=V;for(let Gt=0;Gt<Ne;Gt++)ye.push(ne[Ve+Gt])}}}}return ye}_getOriginId(B){return B-this.points.length>>5}_getOriginZoom(B){return(B-this.points.length)%32}_map(B,V,X){if(B[V+5]>1){let ce=this.clusterProps[B[V+6]];return X?Object.assign({},ce):ce}let ae=this.points[B[V+3]].properties,le=this.options.map(ae);return X&&le===ae?Object.assign({},le):le}}function Wa(_e,B,V){return{type:"Feature",id:_e[B+3],properties:Po(_e,B,V),geometry:{type:"Point",coordinates:[(X=_e[B],360*(X-.5)),ra(_e[B+1])]}};var X}function Po(_e,B,V){let X=_e[B+5],ae=X>=1e4?`${Math.round(X/1e3)}
7k`:X>=1e3?Math.round(X/100)/10+"k":X,le=_e[B+6],ce=le===-1?{}:Object.assign({},V[le]);return Object.assign(ce,{cluster:!0,cluster_id:_e[B+3],point_count:X,point_count_abbreviated:ae})}function $i(_e){return _e/360+.5}function Xa(_e){let B=Math.sin(_e*Math.PI/180),V=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return V<0?0:V>1?1:V}function ra(_e){let B=(180-360*_e)*Math.PI/180;return 360*Math.atan(Math.exp(B))/Math.PI-90}function Ya(_e,B,V,X){let ae=X,le=B+(V-B>>1),ce,we=V-B,ne=_e[B],ye=_e[B+1],Ne=_e[V],Oe=_e[V+1];for(let Ke=B+3;Ke<V;Ke+=3){let ut=oa(_e[Ke],_e[Ke+1],ne,ye,Ne,Oe);if(ut>ae)ce=Ke,ae=ut;else if(ut===ae){let dt=Math.abs(Ke-le);dt<we&&(ce=Ke,we=dt)}}ae>X&&(ce-B>3&&Ya(_e,B,ce,X),_e[ce+2]=ae,V-ce>3&&Ya(_e,ce,V,X))}function oa(_e,B,V,X,ae,le){let ce=ae-V,we=le-X;if(ce!==0||we!==0){let ne=((_e-V)*ce+(B-X)*we)/(ce*ce+we*we);ne>1?(V=ae,X=le):ne>0&&(V+=ce*ne,X+=we*ne)}return ce=_e-V,we=B-X,ce*ce+we*we}function Zo(_e,B,V,X){let ae={id:_e??null,type:B,geometry:V,tags:X,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(B==="Point"||B==="MultiPoint"||B==="LineString")xr(ae,V);else if(B==="Polygon")xr(ae,V[0]);else if(B==="MultiLineString")for(let le of V)xr(ae,le);else if(B==="MultiPolygon")for(let le of V)xr(ae,le[0]);return ae}function xr(_e,B){for(let V=0;V<B.length;V+=3)_e.minX=Math.min(_e.minX,B[V]),_e.minY=Math.min(_e.minY,B[V+1]),_e.maxX=Math.max(_e.maxX,B[V]),_e.maxY=Math.max(_e.maxY,B[V+1])}function ys(_e,B,V,X){if(!B.geometry)return;let ae=B.geometry.coordinates;if(ae&&ae.length===0)return;let le=B.geometry.type,ce=Math.pow(V.tolerance/((1<<V.maxZoom)*V.extent),2),we=[],ne=B.id;if(V.promoteId?ne=B.properties[V.promoteId]:V.generateId&&(ne=X||0),le==="Point")xs(ae,we);else if(le==="MultiPoint")for(let ye of ae)xs(ye,we);else if(le==="LineString")Ja(ae,we,ce,!1);else if(le==="MultiLineString"){if(V.lineMetrics){for(let ye of ae)we=[],Ja(ye,we,ce,!1),_e.push(Zo(ne,"LineString",we,B.properties));return}sa(ae,we,ce,!1)}else if(le==="Polygon")sa(ae,we,ce,!0);else{if(le!=="MultiPolygon"){if(le==="GeometryCollection"){for(let ye of B.geometry.geometries)ys(_e,{id:ne,geometry:ye,properties:B.properties},V,X);return}throw new Error("Input data is not a valid GeoJSON object.")}for(let ye of ae){let Ne=[];sa(ye,Ne,ce,!0),we.push(Ne)}}_e.push(Zo(ne,le,we,B.properties))}function xs(_e,B){B.push(vr(_e[0]),rc(_e[1]),0)}function Ja(_e,B,V,X){let ae,le,ce=0;for(let ne=0;ne<_e.length;ne++){let ye=vr(_e[ne][0]),Ne=rc(_e[ne][1]);B.push(ye,Ne,0),ne>0&&(ce+=X?(ae*Ne-ye*le)/2:Math.sqrt(Math.pow(ye-ae,2)+Math.pow(Ne-le,2))),ae=ye,le=Ne}let we=B.length-3;B[2]=1,Ya(B,0,we,V),B[we+2]=1,B.size=Math.abs(ce),B.start=0,B.end=B.size}function sa(_e,B,V,X){for(let ae=0;ae<_e.length;ae++){let le=[];Ja(_e[ae],le,V,X),B.push(le)}}function vr(_e){return _e/360+.5}function rc(_e){let B=Math.sin(_e*Math.PI/180),V=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return V<0?0:V>1?1:V}function Or(_e,B,V,X,ae,le,ce,we){if(X/=B,le>=(V/=B)&&ce<X)return _e;if(ce<V||le>=X)return null;let ne=[];for(let ye of _e){let Ne=ye.geometry,Oe=ye.type,Ke=ae===0?ye.minX:ye.minY,ut=ae===0?ye.maxX:ye.maxY;if(Ke>=V&&ut<X){ne.push(ye);continue}if(ut<V||Ke>=X)continue;let dt=[];if(Oe==="Point"||Oe==="MultiPoint")cu(Ne,dt,V,X,ae);else if(Oe==="LineString")oc(Ne,dt,V,X,ae,!1,we.lineMetrics);else if(Oe==="MultiLineString")go(Ne,dt,V,X,ae,!1);else if(Oe==="Polygon")go(Ne,dt,V,X,ae,!0);else if(Oe==="MultiPolygon")for(let Ft of Ne){let It=[];go(Ft,It,V,X,ae,!0),It.length&&dt.push(It)}if(dt.length){if(we.lineMetrics&&Oe==="LineString"){for(let Ft of dt)ne.push(Zo(ye.id,Oe,Ft,ye.tags));continue}Oe!=="LineString"&&Oe!=="MultiLineString"||(dt.length===1?(Oe="LineString",dt=dt[0]):Oe="MultiLineString"),Oe!=="Point"&&Oe!=="MultiPoint"||(Oe=dt.length===3?"Point":"MultiPoint"),ne.pu
7sh(Zo(ye.id,Oe,dt,ye.tags))}}return ne.length?ne:null}function cu(_e,B,V,X,ae){for(let le=0;le<_e.length;le+=3){let ce=_e[le+ae];ce>=V&&ce<=X&&Wo(B,_e[le],_e[le+1],_e[le+2])}}function oc(_e,B,V,X,ae,le,ce){let we=Kn(_e),ne=ae===0?aa:yo,ye,Ne,Oe=_e.start;for(let It=0;It<_e.length-3;It+=3){let Dt=_e[It],Ve=_e[It+1],Gt=_e[It+2],qi=_e[It+3],Zi=_e[It+4],Bt=ae===0?Dt:Ve,ni=ae===0?qi:Zi,Di=!1;ce&&(ye=Math.sqrt(Math.pow(Dt-qi,2)+Math.pow(Ve-Zi,2))),Bt<V?ni>V&&(Ne=ne(we,Dt,Ve,qi,Zi,V),ce&&(we.start=Oe+ye*Ne)):Bt>X?ni<X&&(Ne=ne(we,Dt,Ve,qi,Zi,X),ce&&(we.start=Oe+ye*Ne)):Wo(we,Dt,Ve,Gt),ni<V&&Bt>=V&&(Ne=ne(we,Dt,Ve,qi,Zi,V),Di=!0),ni>X&&Bt<=X&&(Ne=ne(we,Dt,Ve,qi,Zi,X),Di=!0),!le&&Di&&(ce&&(we.end=Oe+ye*Ne),B.push(we),we=Kn(_e)),ce&&(Oe+=ye)}let Ke=_e.length-3,ut=_e[Ke],dt=_e[Ke+1],Ft=ae===0?ut:dt;Ft>=V&&Ft<=X&&Wo(we,ut,dt,_e[Ke+2]),Ke=we.length-3,le&&Ke>=3&&(we[Ke]!==we[0]||we[Ke+1]!==we[1])&&Wo(we,we[0],we[1],we[2]),we.length&&B.push(we)}function Kn(_e){let B=[];return B.size=_e.size,B.start=_e.start,B.end=_e.end,B}function go(_e,B,V,X,ae,le){for(let ce of _e)oc(ce,B,V,X,ae,le,!1)}function Wo(_e,B,V,X){_e.push(B,V,X)}function aa(_e,B,V,X,ae,le){let ce=(le-B)/(X-B);return Wo(_e,le,V+(ae-V)*ce,1),ce}function yo(_e,B,V,X,ae,le){let ce=(le-V)/(ae-V);return Wo(_e,B+(X-B)*ce,le,1),ce}function la(_e,B){let V=[];for(let X=0;X<_e.length;X++){let ae=_e[X],le=ae.type,ce;if(le==="Point"||le==="MultiPoint"||le==="LineString")ce=ca(ae.geometry,B);else if(le==="MultiLineString"||le==="Polygon"){ce=[];for(let we of ae.geometry)ce.push(ca(we,B))}else if(le==="MultiPolygon"){ce=[];for(let we of ae.geometry){let ne=[];for(let ye of we)ne.push(ca(ye,B));ce.push(ne)}}V.push(Zo(ae.id,le,ce,ae.tags))}return V}function ca(_e,B){let V=[];V.size=_e.size,_e.start!==void 0&&(V.start=_e.start,V.end=_e.end);for(let X=0;X<_e.length;X+=3)V.push(_e[X]+B,_e[X+1],_e[X+2]);return V}function sc(_e,B){if(_e.transformed)return _e;let V=1<<_e.z,X=_e.x,ae=_e.y;for(let le of _e.features){let ce=le.geometry,we=le.type;if(le.geometry=[],we===1)for(let ne=0;ne<ce.length;ne+=2)le.geometry.push(Do(ce[ne],ce[ne+1],B,V,X,ae));else for(let ne=0;ne<ce.length;ne++){let ye=[];for(let Ne=0;Ne<ce[ne].length;Ne+=2)ye.push(Do(ce[ne][Ne],ce[ne][Ne+1],B,V,X,ae));le.geometry.push(ye)}}return _e.transformed=!0,_e}function Do(_e,B,V,X,ae,le){return[Math.round(V*(_e*X-ae)),Math.round(V*(B*X-le))]}function ac(_e,B,V,X,ae){let le=B===ae.maxZoom?0:ae.tolerance/((1<<B)*ae.extent),ce={features:[],numPoints:0,numSimplified:0,numFeatures:_e.length,source:null,x:V,y:X,z:B,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(let we of _e)uu(ce,we,le,ae);return ce}function uu(_e,B,V,X){let ae=B.geometry,le=B.type,ce=[];if(_e.minX=Math.min(_e.minX,B.minX),_e.minY=Math.min(_e.minY,B.minY),_e.maxX=Math.max(_e.maxX,B.maxX),_e.maxY=Math.max(_e.maxY,B.maxY),le==="Point"||le==="MultiPoint")for(let we=0;we<ae.length;we+=3)ce.push(ae[we],ae[we+1]),_e.numPoints++,_e.numSimplified++;else if(le==="LineString")Ka(ce,ae,_e,V,!1,!1);else if(le==="MultiLineString"||le==="Polygon")for(let we=0;we<ae.length;we++)Ka(ce,ae[we],_e,V,le==="Polygon",we===0);else if(le==="MultiPolygon")for(let we=0;we<ae.length;we++){let ne=ae[we];for(let ye=0;ye<ne.length;ye++)Ka(ce,ne[ye],_e,V,!0,ye===0)}if(ce.length){let we=B.tags||null;if(le==="LineString"&&X.lineMetrics){we={};for(let ye in B.tags)we[ye]=B.tags[ye];we.mapbox_clip_start=ae.start/ae.size,we.mapbox_clip_end=ae.end/ae.size}let ne={geometry:ce,type:le==="Polygon"||le==="MultiPolygon"?3:le==="LineString"||le==="MultiLineString"?2:1,tags:we};B.id!==null&&(ne.id=B.id),_e.features.push(ne)}}function Ka(_e,B,V,X,ae,le){let ce=X*X;if(X>0&&B.size<(ae?ce:X))return void(V.numPoints+=B.length/3);let we=[];for(let ne=0;ne<B.length;ne+=3)(X===0||B[ne+2]>ce)&&(V.numSimplified++,we.push(B[ne],B[ne+1])),V.numPoints++;ae&&function(ne,ye){let Ne=0;for(let Oe=0,Ke=ne.length,ut=Ke-2;Oe<Ke;ut=Oe,Oe+=2)Ne+=(ne[Oe]-ne[ut])*(ne[Oe+1]+ne[ut+1]);if(Ne>0===ye)for(let Oe=0,Ke=ne.length;Oe<Ke/2;Oe+=2){let ut=ne[Oe],dt=ne[Oe+1];ne[Oe]=ne[Ke-2-Oe],ne[Oe+1]=ne[Ke-1-Oe],ne[Ke-2-Oe]=ut,ne[Ke-1-Oe]=dt}}(we,le),_e.push(we)}let hu={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Oh{constructor(B,V){let X=(V=this.options=function(le,ce){for(let we in ce)le[we]=ce[we];return le}(Object.create(hu),V)).debug;if(X&&console.time("preprocess data"),V.maxZoom<0||V.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(V.promoteId&&V.generateId)throw new Error("promoteId and generateId cannot be used together.");let ae=function(le,ce){let we=[];if(le.type==="FeatureCollection")for(let ne=0;ne<le.features.length;ne++)ys(we,le.features[ne],ce,ne);else ys(we,le.type==="Feature"?le:{geometry:le},ce);return we}(B,V);this.tiles={}
7,this.tileCoords=[],X&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",V.indexMaxZoom,V.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),ae=function(le,ce){let we=ce.buffer/ce.extent,ne=le,ye=Or(le,1,-1-we,we,0,-1,2,ce),Ne=Or(le,1,1-we,2+we,0,-1,2,ce);return(ye||Ne)&&(ne=Or(le,1,-we,1+we,0,-1,2,ce)||[],ye&&(ne=la(ye,1).concat(ne)),Ne&&(ne=ne.concat(la(Ne,-1)))),ne}(ae,V),ae.length&&this.splitTile(ae,0,0,0),X&&(ae.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,V,X,ae,le,ce,we){let ne=[B,V,X,ae],ye=this.options,Ne=ye.debug;for(;ne.length;){ae=ne.pop(),X=ne.pop(),V=ne.pop(),B=ne.pop();let Oe=1<<V,Ke=Qa(V,X,ae),ut=this.tiles[Ke];if(!ut&&(Ne>1&&console.time("creation"),ut=this.tiles[Ke]=ac(B,V,X,ae,ye),this.tileCoords.push({z:V,x:X,y:ae}),Ne)){Ne>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",V,X,ae,ut.numFeatures,ut.numPoints,ut.numSimplified),console.timeEnd("creation"));let Di=`z${V}`;this.stats[Di]=(this.stats[Di]||0)+1,this.total++}if(ut.source=B,le==null){if(V===ye.indexMaxZoom||ut.numPoints<=ye.indexMaxPoints)continue}else{if(V===ye.maxZoom||V===le)continue;if(le!=null){let Di=le-V;if(X!==ce>>Di||ae!==we>>Di)continue}}if(ut.source=null,B.length===0)continue;Ne>1&&console.time("clipping");let dt=.5*ye.buffer/ye.extent,Ft=.5-dt,It=.5+dt,Dt=1+dt,Ve=null,Gt=null,qi=null,Zi=null,Bt=Or(B,Oe,X-dt,X+It,0,ut.minX,ut.maxX,ye),ni=Or(B,Oe,X+Ft,X+Dt,0,ut.minX,ut.maxX,ye);B=null,Bt&&(Ve=Or(Bt,Oe,ae-dt,ae+It,1,ut.minY,ut.maxY,ye),Gt=Or(Bt,Oe,ae+Ft,ae+Dt,1,ut.minY,ut.maxY,ye),Bt=null),ni&&(qi=Or(ni,Oe,ae-dt,ae+It,1,ut.minY,ut.maxY,ye),Zi=Or(ni,Oe,ae+Ft,ae+Dt,1,ut.minY,ut.maxY,ye),ni=null),Ne>1&&console.timeEnd("clipping"),ne.push(Ve||[],V+1,2*X,2*ae),ne.push(Gt||[],V+1,2*X,2*ae+1),ne.push(qi||[],V+1,2*X+1,2*ae),ne.push(Zi||[],V+1,2*X+1,2*ae+1)}}getTile(B,V,X){B=+B,V=+V,X=+X;let ae=this.options,{extent:le,debug:ce}=ae;if(B<0||B>24)return null;let we=1<<B,ne=Qa(B,V=V+we&we-1,X);if(this.tiles[ne])return sc(this.tiles[ne],le);ce>1&&console.log("drilling down to z%d-%d-%d",B,V,X);let ye,Ne=B,Oe=V,Ke=X;for(;!ye&&Ne>0;)Ne--,Oe>>=1,Ke>>=1,ye=this.tiles[Qa(Ne,Oe,Ke)];return ye&&ye.source?(ce>1&&(console.log("found parent tile z%d-%d-%d",Ne,Oe,Ke),console.time("drilling down")),this.splitTile(ye.source,Ne,Oe,Ke,B,V,X),ce>1&&console.timeEnd("drilling down"),this.tiles[ne]?sc(this.tiles[ne],le):null):null}}function Qa(_e,B,V){return 32*((1<<_e)*V+B)+_e}function ke(_e,B){let V=_e.tileID.canonical;if(!this._geoJSONIndex)return void B(null,null);let X=this._geoJSONIndex.getTile(V.z,V.x,V.y);if(!X)return void B(null,null);let ae=ye=>ye.tags&&"3d_elevation_id"in ye.tags&&"source"in ye.tags&&ye.tags.source==="elevation",le=X.features.filter(ye=>ae(ye)),ce={_geojsonTileLayer:X.features};le.length>0&&(ce={_geojsonTileLayer:X.features.filter(ye=>!ae(ye)),hd_road_elevation:le});let we=new tc(ce),ne=function(ye){let Ne=new U.b2;for(let Oe of Object.keys(ye))Ne.writeMessage(3,ia,{name:Oe,features:ye[Oe]});return Ne.finish()}(ce).buffer;B(null,{vectorTile:we,rawData:ne})}class Xo extends _s{constructor(B){super(B),this.loadVectorData=ke,this._dynamicIndex=new kn}loadData(B,V){let X=B&&B.request,ae=X&&X.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(B,(le,ce)=>{if(le||!ce)return V(le);if(typeof ce!="object")return V(new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`));{try{if(B.filter){let ne=U.U(B.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(ne.result==="error")throw new Error(ne.value.map(ye=>`${ye.key}: ${ye.message}`).join(", "));ce.features=ce.features.filter(ye=>ne.value.evaluate({zoom:0},ye))}B.dynamic?(ce.type==="Feature"&&(ce={type:"FeatureCollection",features:[ce]}),B.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(ce.features,this.loaded),B.cluster&&(ce.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=B.cluster?new Za(function({superclusterOptions:ne,clusterProperties:ye}){if(!ye||!ne)return ne;let Ne={},Oe={},Ke={accumulated:null,zoom:0},ut={properties:null},dt=Object.keys(ye);for(let Ft of dt){let[It,Dt]=ye[Ft],Ve=U.U(Dt),Gt=U.U(typeof It=="string"?[It,["accumulated"],["get",Ft]]:It);Ne[Ft]=Ve.value,Oe[Ft]=Gt.value}return ne.map=Ft=>{ut.properties=Ft;let It={};for(let Dt of dt)It[Dt]=Ne[Dt].evaluate(Ke,ut);return It},ne.reduce=(Ft,It)=>{ut.properties=It;for(let Dt of dt)Ke.accumulated=Ft[Dt],Ft[Dt]=Oe[Dt].evaluate(Ke,ut)},ne}(B)).load(ce.features):B.dynamic?this._dynamicIndex:function(ne,ye){return new Oh(ne,ye)}(ce,B.geojsonVtOptions)}catch(ne){return V(ne)}let we={};if(ae){let ne=Pn(X);ne&&(we.resourceTiming={},we.resourceTiming[B.source]=JSON.parse(JSON.stringify(ne)))}V(null,we)}})}reloadTile(B,V){let X=this.loaded;return X&&X[B.uid]?B.partial?V(null,void 0):super.reloadTile(B,V):this.loadTile(B,V)}loadGeoJSON(B,V){if(B.request)U.m(B.request,V);else{if(typeof B.data!="string")return V(new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return V(null,JSON.parse(B.data))}catch{return V(new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`))}},0)}}
7getClusterExpansionZoom(B,V){try{V(null,this._geoJSONIndex.getClusterExpansionZoom(B.clusterId))}catch(X){V(X)}}getClusterChildren(B,V){try{V(null,this._geoJSONIndex.getChildren(B.clusterId))}catch(X){V(X)}}getClusterLeaves(B,V){try{V(null,this._geoJSONIndex.getLeaves(B.clusterId,B.limit,B.offset))}catch(X){V(X)}}}class vs{constructor(B,V,X){this.tileID=new U.aU(B.tileID.overscaledZ,B.tileID.wrap,B.tileID.canonical.z,B.tileID.canonical.x,B.tileID.canonical.y),this.tileZoom=B.tileZoom,this.uid=B.uid,this.zoom=B.zoom,this.canonical=B.tileID.canonical,this.pixelRatio=B.pixelRatio,this.tileSize=B.tileSize,this.source=B.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=B.projection,this.brightness=V,this.worldview=X}parse(B,V,X,ae){this.status="parsing";let le=new U.aU(X.tileID.overscaledZ,X.tileID.wrap,X.tileID.canonical.z,X.tileID.canonical.x,X.tileID.canonical.y),ce=[],we=V.familiesBySource[X.source],ne=new U.fj(le,X.promoteId);ne.bucketLayerIDs=[],ne.is3DTile=!0,U.fF(B).then(ye=>{let Ne=ye.json.extensionsUsed&&ye.json.extensionsUsed.includes("MAPBOX_mesh_features")||ye.json.asset.extras&&ye.json.asset.extras.MAPBOX_mesh_features,Oe=ye.json.extensionsUsed&&ye.json.extensionsUsed.includes("EXT_meshopt_compression"),Ke=new U.ab(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(let ut in we)for(let dt of we[ut]){let Ft=dt[0];ne.bucketLayerIDs.push(dt.map(Ve=>U.t(Ve.id,Ve.scope))),Ft.recalculate(Ke,[]);let It=U.fG(ye,1/U.cW(X.tileID.canonical)),Dt=new U.fH(dt,It,le,Ne,Oe,this.brightness,ne,this.worldview);Ne||(Dt.needsUpload=!0),ce.push(Dt),Dt.evaluate(Ft)}this.status="done",ae(null,{buckets:ce,featureIndex:ne,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(ye=>ae(new Error(ye.message)))}}class ua{constructor({actor:B,layerIndex:V,availableImages:X,availableModels:ae,brightness:le,worldview:ce}){this.actor=B,this.layerIndex=V,this.availableImages=X,this.availableModels=ae,this.brightness=le,this.loading={},this.loaded={},this.worldview=ce}loadTile(B,V){let X=B.uid,ae=this.loading[X]=new vs(B,this.brightness,this.worldview);U.b4(B.request,(le,ce)=>{let we=!this.loading[X];return delete this.loading[X],we||le?(ae.status="done",we||(this.loaded[X]=ae),V(le)):ce&&ce.byteLength!==0?void ae.parse(ce,this.layerIndex,B,(ne,ye)=>{ae.status="done",this.loaded=this.loaded||{},this.loaded[X]=ae,ne||!ye?V(ne):V(null,ye)}):(ae.status="done",this.loaded[X]=ae,V())})}reloadTile(B,V){let X=this.loaded,ae=B.uid;if(X&&X[ae]){let le=X[ae];le.projection=B.projection,le.brightness=B.brightness;let ce=(we,ne)=>{le.reloadCallback&&(delete le.reloadCallback,this.loadTile(B,V)),V(we,ne)};le.status==="parsing"?le.reloadCallback=ce:le.status==="done"&&this.loadTile(B,V)}}abortTile(B,V){let X=B.uid;this.loading[X]&&delete this.loading[X],V()}removeTile(B,V){let X=this.loaded,ae=B.uid;X&&X[ae]&&delete X[ae],V()}}class el{constructor(B){this.self=B,this.actor=new U.ap(B,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=U.c4({name:"mercator"}),this.workerSourceTypes={vector:_s,geojson:Xo,"raster-dem":$o,"raster-array":Kl,"batched-model":ua},this.workerSources={},this.self.registerWorkerSource=(V,X)=>{if(this.workerSourceTypes[V])throw new Error(`Worker source with name "${V}" already registered.`);this.workerSourceTypes[V]=X}
7,this.self.registerRTLTextPlugin=V=>{if(U.fJ.isParsed())throw new Error("RTL text plugin already registered.");U.fJ.setState({pluginStatus:U.fK.parsed,pluginURL:U.fJ.getPluginURL()}),U.fJ.applyArabicShaping=V.applyArabicShaping,U.fJ.processBidirectionalText=V.processBidirectionalText,U.fJ.processStyledBidirectionalText=V.processStyledBidirectionalText;for(let X of this.rtlPluginParsingListeners)X(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(B,V,X){delete this.layerIndexes[B],delete this.availableImages[B],delete this.availableModels[B],delete this.workerSources[B],X()}checkIfReady(B,V,X){X()}setReferrer(B,V){this.referrer=V}spriteLoaded(B,V){this.isSpriteLoaded[B]||(this.isSpriteLoaded[B]={});let{scope:X,isLoaded:ae}=V;if(this.isSpriteLoaded[B][X]=ae,this.workerSources[B]&&this.workerSources[B][X])for(let le in this.workerSources[B][X]){let ce=this.workerSources[B][X][le];for(let we in ce){let ne=ce[we];ne instanceof _s&&(ne.isSpriteLoaded=ae,ne.fire(new U.z("isSpriteLoaded")))}}}setImages(B,V,X){this.availableImages[B]||(this.availableImages[B]={});let{scope:ae,images:le}=V;if(this.availableImages[B][ae]=le,this.workerSources[B]&&this.workerSources[B][ae]){for(let ce in this.workerSources[B][ae]){let we=this.workerSources[B][ae][ce];for(let ne in we)we[ne].availableImages=le}X()}else X()}setModels(B,{scope:V,models:X},ae){if(this.availableModels[B]||(this.availableModels[B]={}),this.availableModels[B][V]=X,this.workerSources[B]&&this.workerSources[B][V]){for(let le in this.workerSources[B][V]){let ce=this.workerSources[B][V][le];for(let we in ce)ce[we].availableModels=X}ae()}else ae()}setProjection(B,V){this.projections[B]=U.c4(V)}setBrightness(B,V,X){this.brightness=V,X()}setContextParams(B,V,X){this.maxUniformBufferBindings=V.maxBindingPoints,this.maxUniformBlockSizeDwords=V.maxUniformBlockSizeDwords,this.disableSymbolUBO=V.disableSymbolUBO,X()}setWorldview(B,V,X){this.worldview=V,X()}setLayers(B,V,X){this.getLayerIndex(B,V.scope).replace(V.layers,V.options),X()}updateLayers(B,V,X){this.getLayerIndex(B,V.scope).update(V.layers,V.removedIds,V.options),X()}loadTile(B,V,X){V.projection=this.projections[B]||this.defaultProjection,this.getWorkerSource(B,V).loadTile(V,X)}decodeRasterArray(B,V,X){this.getWorkerSource(B,V).decodeRasterArray(V,X)}reloadTile(B,V,X){V.projection=this.projections[B]||this.defaultProjection,this.getWorkerSource(B,V).reloadTile(V,X)}abortTile(B,V,X){this.getWorkerSource(B,V).abortTile(V,X)}removeTile(B,V,X){this.getWorkerSource(B,V).removeTile(V,X)}removeSource(B,V,X){if(!(this.workerSources[B]&&this.workerSources[B][V.scope]&&this.workerSources[B][V.scope][V.type]&&this.workerSources[B][V.scope][V.type][V.source]))return;let ae=this.workerSources[B][V.scope][V.type][V.source];delete this.workerSources[B][V.scope][V.type][V.source],ae.removeSource!==void 0?ae.removeSource(V,X):X()}loadTileProvider(B,V,X){U.aT(V.name,V.url).then(ae=>{let le=new ae(V.options);return this.getWorkerSource(B,{type:V.type,source:V.source,scope:V.scope},le),le.load&&V.request?le.load({request:V.request}):null}).then(ae=>X(null,ae)).catch(ae=>X(ae instanceof Error?ae:new Error(String(ae))))}async syncRTLPluginState(B,V,X){if(U.fJ.isParsed())return void X(null,!0);if(U.fJ.isParsing())return void this.rtlPluginParsingListeners.push(X);U.fJ.setState(V);let ae=U.fJ.getPluginURL();if(!U.fJ.isLoaded()||U.fJ.isParsed()||U.fJ.isParsing())X(null,!1);else{U.fJ.setState({pluginStatus:U.fK.parsing,pluginURL:ae});try{await import(ae),U.fJ.isParsed()?X(null,!0):this.rtlPluginParsingListeners.push(X)}catch(le){U.fJ.setState({pluginStatus:U.fK.error,pluginURL:ae}),X(le);for(let ce of this.rtlPluginParsingListeners)ce(le);this.rtlPluginParsingListeners=[]}}}setConfig(B,V){Object.assign(U.g,V)}getAvailableImages(B,V){this.availableImages[B]||(this.availableImages[B]={});let X=this.availableImages[B][V];return X||(X=[]),X}getAvailableModels(B,V){this.availableModels[B]||(this.availableModels[B]={});let X=this.availableModels[B][V];return X||(X={}),X}getLayerIndex(B,V){this.layerIndexes[B]||(this.layerIndexes[B]={});let X=this.layerIndexes[B][V];return X||(X=this.layerIndexes[B][V]=new Qr,X.scope=V),X}getWorkerSource(B,V,X){let{type:ae,source:le,scope:ce}=V,we=this.workerSources;if(we[B]||(we[B]={}),we[B][ce]||(we[B][ce]={}),we[B][ce][ae]||(we[B][ce][ae]={}),this.isSpriteLoaded[B]||(this.isSpriteLoaded[B]={}),we[B][ce][ae][le])X&&(we[B][ce][ae][le].tileProvider=X);else{let ne={send:(Ne,Oe,Ke,ut,dt,Ft)=>this.actor.send(Ne,Oe,Ke,B,dt,Ft),scheduler:this.actor.scheduler},ye=this.workerSourceTypes[ae];if(!ye)throw new Error(`Unknown worker source type "${ae}".`);we[B][ce][ae][le]=new ye({actor:ne,layerIndex:this.getLayerIndex(B,ce),availableImages:this.getAvailableImages(B,ce),availableModels:this.getAvailableModels(B,ce),isSpriteLoaded:this.isSpriteLoaded[B][ce],tileProvider:X,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return we[B][ce][ae][le]}enforceCacheSizeLimit(B,V){U.fL(V)}getWorkerPerformanceMetrics(B,V,X){X(void 0,void 0)}}return U.fI(self)&&(self.worker=new el(self)),el}),Ai(["./shared"],function(h){var U="3.24.1";let Pn={create:"create",load:"load",fullLoad:"fullLoad"},wi={mark(a){performance.mark(a)},measure(a,t,o){performance.measure(a,t,o)}};function Fn(a){let t=a.name.split("?")[0];return h.a(t)&&t.includes("mapbox-gl.js")?"javascript":h.a(t)&&t.includes("mapbox-gl.css")?"css":h.b(t)?"fontRange":h.c(t)?"sprite":h.i(t)?"style":h.d(t)?"tilejson":"other"}var yr,Qr={},Xn=function(){if(yr)return Qr;function a(c){return!t(c)}function t(c){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var m,_,y=new Blob([""],{type:"text/javascript"}),v=URL.createObjectURL(y);try{_=new Worker(v),m=!0}catch{m=!1}return _&&_.terminate(),URL.revokeObjectURL(v),m}()?function(){var m=document.createElement("canvas");m.width=m.height=1;var _=m.getContext("2d");if(!_)return!1;var y=_.getImageData(0,0,1,1);return y&&y.width===m.width}()?(o[d=c&&c.failIfMajorPerformanceCaveat]===void 0&&(o[d]=function(m){var _,y=function(v){var T=document.createElement("canvas"),E=Object.create(a.webGLContextAttributes);return E.failIfMajorPerformanceCaveat=v,T.getContext("webgl2",E)}(m);if(!y)return!1;try{_=y.createShader(y.VERTEX_SHADER)}catch{return!1}return!(!_||y.isContextLost())&&(y.shaderSource(_,"void main() {}"),y.compileShader(_),y.getShaderParameter(_,y.COMPILE_STATUS)===!0)}(d)),o[d]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var d}
7yr=1,Qr.supported=a,Qr.notSupportedReason=t;var o={};return a.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},Qr}();let eo=/firefox/i,Rr=/macintosh/i;function Mt(a,t,o){let c=document.createElement(a);return t!=null&&(c.className=t),o&&o.appendChild(c),c}function Bn(a,t,o){let c=document.createElementNS("http://www.w3.org/2000/svg",a);for(let d of Object.keys(t))c.setAttributeNS(null,d,String(t[d]));return o&&o.appendChild(c),c}let xi=typeof document<"u"?document.documentElement&&document.documentElement.style:null,$n=xi&&xi.userSelect!==void 0?"userSelect":"WebkitUserSelect",Yn;function Go(){xi&&$n&&(Yn=xi[$n],xi[$n]="none")}function Ho(){xi&&$n&&(xi[$n]=Yn)}function fo(a){a.preventDefault(),a.stopPropagation(),window.removeEventListener("click",fo,!0)}function _s(){window.addEventListener("click",fo,!0),window.setTimeout(()=>{window.removeEventListener("click",fo,!0)},0)}function $o(a,t){let o=a.getBoundingClientRect();return Ql(a,o,t)}function ta(a,t){let o=a.getBoundingClientRect(),c=[];for(let d=0;d<t.length;d++)c.push(Ql(a,o,t[d]));return c}function Kl(a){return eo.test(navigator.userAgent)&&Rr.test(navigator.userAgent)&&a.button===2&&a.ctrlKey?0:a.button}function Ql(a,t,o){let c=a.offsetWidth===t.width?1:a.offsetWidth/t.width;return new h.P((o.clientX-t.left)*c,(o.clientY-t.top)*c)}let ec="01",ai=/(\.(png|jpg)\d*)(?=$)/,tc=/^.+\/v4\//,Dn=/\.[\w]+$/,kn=/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/,Mi=/^access_token=(.*)$/,nn="NO_ACCESS_TOKEN";class mo{constructor(t,o,c){this._transformRequestFn=t,this._customAccessToken=o,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){let t=function(){let o="";for(let c=0;c<10;c++)o+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",ec,o].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,o){return this._transformRequestFn&&this._transformRequestFn(t,o)||{url:t}}normalizeStyleURL(t,o){if(!h.e(t))return t;let c=Rn(t);return c.params.push(`sdk=js-${U}`),c.path=`/styles/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||o)}normalizeGlyphsURL(t,o){if(!h.e(t))return t;let c=Rn(t);return c.path=`/fonts/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||o)}normalizeModelURL(t,o){if(!h.e(t))return t;let c=Rn(t);return c.path=`/models/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||o)}normalizeSourceURL(t,o,c,d){if(!h.e(t))return t;let m=Rn(t);return m.path=`/v4/${m.authority}.json`,m.params.push("secure"),c&&m.params.push(`language=${c}`),d&&m.params.push(`worldview=${d}`),this._makeAPIURL(m,this._customAccessToken||o)}normalizeIconsetURL(t,o){let c=Rn(t);return h.e(t)?(c.path=`/styles/v1${c.path}/iconset.pbf`,this._makeAPIURL(c,this._customAccessToken||o)):Lr(c)}normalizeSpriteURL(t,o,c,d){let m=Rn(t);return h.e(t)?(m.path=`/styles/v1${m.path}/sprite${o}${c}`,this._makeAPIURL(m,this._customAccessToken||d)):(m.path+=`${o}${c}`,Lr(m))}normalizeTileURL(t,o,c){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!h.e(t))return t;let d=Rn(t);d.path=d.path.replace(ai,`${o||c&&d.authority!=="raster"&&c===512?"@2x":""}${h.k.supported?".webp":"$1"}`),d.authority==="raster"?d.path=`/${h.g.RASTER_URL_PREFIX}${d.path}`:d.authority==="rasterarrays"?d.path=`/${h.g.RASTERARRAYS_URL_PREFIX}${d.path}`:d.authority==="3dtiles"?d.path=`/${h.g.TILES3D_URL_PREFIX}${d.path}`:(d.path=d.path.replace(tc,"/"),d.path=`/${h.g.TILE_URL_VERSION}${d.path}`);let m=this._customAccessToken||function(_){for(let y of _){let v=y.match(Mi);if(v)return v[1]}return null}(d.params)||h.g.ACCESS_TOKEN;return h.g.REQUIRE_ACCESS_TOKEN&&m&&this._skuToken&&d.params.push(`sku=${this._skuToken}`),this._makeAPIURL(d,m)}canonicalizeTileURL(t,o){let c=Rn(t);if(!kn.test(c.path)||!Dn.test(c.path))return t;let d="mapbox://";c.path.startsWith("/raster/v1/")?d+=`raster/${c.path.replace(`/${h.g.RASTER_URL_PREFIX}/`,"")}`:c.path.startsWith("/rasterarrays/v1/")?d+=`rasterarrays/${c.path.replace(`/${h.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:d+=`tiles/${c.path.replace(`/${h.g.TILE_URL_VERSION}/`,"")}`;let m=c.params;return o&&(m=m.filter(_=>!_.match(Mi))),m.length&&(d+=`?${m.join("&")}`),d}canonicalizeTileset(t,o){let c=!!o&&h.e(o),d=[];for(let m of t.tiles||[])h.f(m)?d.push(this.canonicalizeTileURL(m,c)):d.push(m);return d}_makeAPIURL(t,o){let c="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",d=Rn(h.g.API_URL);if(t.protocol=d.protocol,t.authority=d.authority,t.protocol==="http"){let m=t.params.indexOf("secure");m>=0&&t.params.splice(m,1)}if(d.path!=="/"&&(t.path=`${d.path}${t.path}`),!h.g.REQUIRE_ACCESS_TOKEN)return Lr(t);if(o=o||h.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!o)throw new Error(`An API access token is required to use Mapbox GL. ${c}`);
7if(o[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${c}`)}return t.params=t.params.filter(m=>!m.includes("access_token")),t.params.push(`access_token=${o||""}`),Lr(t)}}let ic=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Rn(a){let t=a.match(ic);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Lr(a){let t=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${t}`}let Fi="mapbox.eventData";function zr(a){if(!a)return null;let t=a.split(".");if(!t||t.length!==3)return null;try{return JSON.parse(h.l(t[1]))}catch{return null}}function ia(a){return!(!h.g.EVENTS_URL||!a&&!h.g.ACCESS_TOKEN)}class qo{constructor(t){this.type=t,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){let o=zr(h.g.ACCESS_TOKEN),c="";return c=o&&o.u?h.j(o.u):h.g.ACCESS_TOKEN||"",t?`${Fi}.${t}:${c}`:`${Fi}:${c}`}fetchEventData(){let t=h.s("localStorage"),o=this.getStorageKey(),c=this.getStorageKey("uuid"),d=this.getStorageKey("uuidTimestamp");if(t)try{let m=localStorage.getItem(o);m&&(this.eventData=JSON.parse(m));let _=localStorage.getItem(c);_&&(this.anonId=_);let y=localStorage.getItem(d);y&&(this.anonIdTimestamp=Number(y));let v=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<v)&&this.refreshUUID()}catch{h.w("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=h.u(),this.anonIdTimestamp=Date.now()}saveEventData(){let t=h.s("localStorage"),o=this.getStorageKey(),c=this.getStorageKey("uuid"),d=this.getStorageKey("uuidTimestamp"),m=this.anonId,_=this.anonIdTimestamp;if(t&&m)try{localStorage.setItem(c,m),Object.keys(this.eventData).length>=1&&localStorage.setItem(o,JSON.stringify(this.eventData)),_&&localStorage.setItem(d,_.toString())}catch{h.w("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,o,c,d){if(!h.g.EVENTS_URL)return;let m=Rn(h.g.EVENTS_URL);m.params.push(`access_token=${d||h.g.ACCESS_TOKEN||""}`);let _={event:this.type,created:new Date(t).toISOString()},y=o?Object.assign(_,o):_,v={url:Lr(m),headers:{"Content-Type":"text/plain"},body:JSON.stringify([y])};this.pendingRequest=h.p(v,T=>{this.pendingRequest=null,c(T),this.saveEventData(),this.processRequests(d)})}queueRequest(t,o){this.queue.push(t),this.processRequests(o)}}class nc extends qo{constructor(t){super("metrics"),t&&(this.data=t)}postMetricsEvent(t){if(!ia(t))return;this.anonId||this.fetchEventData(),h.v(this.anonId)||this.refreshUUID();let o=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:o},t)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;let{timestamp:o,payload:c}=this.queue.shift();this.postEvent(o,c,()=>{},t)}}let _o=new class extends qo{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,t){ia(t)&&Array.isArray(a)&&a.some(o=>h.e(o)||h.f(o))&&this.queueRequest(Date.now(),t)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();let t=zr(h.g.ACCESS_TOKEN),o=t?t.u:h.g.ACCESS_TOKEN,c=o!==this.eventData.tokenU;h.v(this.anonId)||(this.refreshUUID(),c=!0);let d=this.queue.shift();if(this.eventData.lastSuccess){let m=new Date(this.eventData.lastSuccess),_=new Date(d),y=(d-this.eventData.lastSuccess)/864e5;c=c||y>=1||y<-1||m.getDate()!==_.getDate()}else c=!0;c?this.postEvent(d,{sdkIdentifier:"mapbox-gl-js",sdkVersion:U,skuId:ec,"enabled.telemetry":!1,userId:this.anonId},m=>{m||(this.eventData.lastSuccess=d,this.eventData.tokenU=o)},a):this.processRequests()}},hi=_o.postTurnstileEvent.bind(_o),en=new class extends qo{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(a,t,o,c){this.skuToken=t,this.errorCb=c,h.g.EVENTS_URL&&(o||h.g.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},o):this.errorCb(new Error(nn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;let{id:t,timestamp:o}=this.queue.shift();t&&this.success[t]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),h.v(this.anonId)||this.refreshUUID(),this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:U,skuId:ec,skuToken:this.skuToken,userId:this.anonId},c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},a))}remove(){this.errorCb=null}},Jn=en.postMapLoadEvent.bind(en),na=new class extends qo{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(a){let t=this.mapInstanceIdMap.get(a);return t||(t=h.u(),this.mapInstanceIdMap.set(a,t)),t}getEventId(a){let t=this.eventIdPerMapInstanceMap.get(a)||0;return this.eventIdPerMapInstanceMap.set(a,t+1),t}postStyleLoadEvent(a,t){let{map:o,style:c,importedStyles:d}=t;
7if(!ia(a))return;let m=this.getMapInstanceId(o),_={mapInstanceId:m,eventId:this.getEventId(m),style:c};d.length&&(_.importedStyles=d),this.queueRequest({timestamp:Date.now(),payload:_},a)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;let{timestamp:t,payload:o}=this.queue.shift();this.postEvent(t,o,()=>{},a)}},Bi=na.postStyleLoadEvent.bind(na),gs=new nc({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Za=gs.postMetricsEvent.bind(gs),Wa=new nc({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),Po=Wa.postMetricsEvent.bind(Wa),$i=new class extends qo{constructor(){super("gljs.performance")}postPerformanceEvent(a,t){ia(a)&&this.queueRequest({timestamp:Date.now(),performanceData:t},a)}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;let{timestamp:t,performanceData:o}=this.queue.shift(),c=function(d){let m=performance.getEntriesByType("resource"),_=performance.getEntriesByType("mark"),y=function(D){let z={};if(D){for(let O in D)if(O!=="other")for(let k of D[O]){let N=`${O}ResolveRangeMin`,q=`${O}ResolveRangeMax`,Z=`${O}RequestCount`,G=`${O}RequestCachedCount`;z[N]=Math.min(z[N]||1/0,k.startTime),z[q]=Math.max(z[q]||-1/0,k.responseEnd);let re=te=>{z[te]===void 0&&(z[te]=0),++z[te]};k.transferSize!==void 0&&k.transferSize===0&&re(G),re(Z)}}return z}(function(D,z){let O={};if(D)for(let k of D){let N=z(k);O[N]===void 0&&(O[N]=[]),O[N].push(k)}return O}(m,Fn)),v=window.devicePixelRatio,T=navigator.connection||navigator.mozConnection||navigator.webkitConnection,E=T?T.effectiveType:void 0,P={counters:[],metadata:[],attributes:[]},A=(D,z,O)=>{O!=null&&D.push({name:z,value:O.toString()})};for(let D in y)A(P.counters,D,y[D]);if(d.interactionRange[0]!==1/0&&d.interactionRange[1]!==-1/0&&(A(P.counters,"interactionRangeMin",d.interactionRange[0]),A(P.counters,"interactionRangeMax",d.interactionRange[1])),_)for(let D of Object.values(Pn)){let z=_.find(O=>O.name===D);z&&A(P.counters,D,z.startTime)}return A(P.counters,"visibilityHidden",d.visibilityHidden),A(P.attributes,"style",function(D){if(D)for(let z of D){let O=z.name.split("?")[0];if(h.i(O)){let k=O.split("/").slice(-2);if(k.length===2)return`mapbox://styles/${k[0]}/${k[1]}`}}}(m)),A(P.attributes,"terrainEnabled",d.terrainEnabled?"true":"false"),A(P.attributes,"fogEnabled",d.fogEnabled?"true":"false"),A(P.attributes,"projection",d.projection),A(P.attributes,"zoom",d.zoom),A(P.metadata,"devicePixelRatio",v),A(P.metadata,"connectionEffectiveType",E),A(P.metadata,"navigatorUserAgent",navigator.userAgent),A(P.metadata,"screenWidth",window.screen.width),A(P.metadata,"screenHeight",window.screen.height),A(P.metadata,"windowWidth",window.innerWidth),A(P.metadata,"windowHeight",window.innerHeight),A(P.metadata,"mapWidth",d.width/v),A(P.metadata,"mapHeight",d.height/v),A(P.metadata,"webglRenderer",d.renderer),A(P.metadata,"webglVendor",d.vendor),A(P.metadata,"sdkVersion",U),A(P.metadata,"sdkIdentifier","mapbox-gl-js"),P}(o);for(let d of c.metadata);for(let d of c.counters);for(let d of c.attributes);this.postEvent(t,c,()=>{},a)}},Xa=$i.postPerformanceEvent.bind($i),ra=new class extends qo{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(a,t,o,c){if(!h.g.API_URL||!h.g.SESSION_PATH)return;let d=Rn(h.g.API_URL+h.g.SESSION_PATH);d.params.push(`sku=${t||""}`),d.params.push(`access_token=${c||h.g.ACCESS_TOKEN||""}`);let m={url:Lr(d),headers:{"Content-Type":"text/plain"}};this.pendingRequest=h.h(m,_=>{this.pendingRequest=null,o(_),this.saveEventData(),this.processRequests(c)})}getSessionAPI(a,t,o,c){this.skuToken=t,this.errorCb=c,h.g.EVENTS_URL&&h.g.SESSION_PATH&&h.g.API_URL&&(o||h.g.ACCESS_TOKEN?this.queueRequest({id:a,timestamp:Date.now()},o):this.errorCb(new Error(nn)))}processRequests(a){if(this.pendingRequest||this.queue.length===0)return;let{id:t,timestamp:o}=this.queue.shift();t&&this.success[t]||this.getSession(o,this.skuToken,c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},a)}remove(){this.errorCb=null}},Ya=ra.getSessionAPI.bind(ra),oa=new Set;function Zo(a,t){t?oa.add(a):oa.delete(a)}class xr{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(t,o){this._updatedSourceCaches[t]=o,this.setDirty()}discardSourceCacheUpdate(t){delete this._updatedSourceCaches[t]}updateLayer(t){let o=t.scope;this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._updatedLayers[o].add(t.id),this.setDirty()}removeLayer(t){let o=t.scope;this._removedLayers[o]=this._removedLayers[o]||{},this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._removedLayers[o][t.id]=t,this._updatedLayers[o].delete(t.id),this._updatedPaintProps.delete(t.fqid),this.setDirty()}getRemovedLayer(t){return this._removedLayers[t.scope]?this._removedLayers[t.scope][t.id]:null}discardLayerRemoval(t){this._removedLayers[t.scope]&&delete this._removedLayers[t.scope][t.id]}getLayerUpdatesByScope(){let t={};for(let o in this._updatedLayers)t[o]=t[o]||{},t[o].updatedIds=Array.from(this._updatedLayers[o].values());for(let o in this._removedLayers)t[o]=t[o]||{},t[o].removedIds=Object.keys(this._removedLayers[o]);return t}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(t){this._updatedPaintProps.add(t.fqid),this.setDirty()}getUpdatedImages(t){return this._updatedImages[t]?Array.from(this._updatedImages[t].values()):[]}updateImage(t,o){this._updatedImages[o]=this._updatedImages[o]||new Set,this._updatedImages[o].add(h.I.toString(t)),this.setDirty()}resetUpdatedImages(t){this._updatedImages[t]&&this._updatedImages[t].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function ys(a){let{userImage:t}=a;return!!(t&&t.render&&t.render())&&(a.data.replace(new Uint8Array(t.data.buffer)),!0)}let xs=new h.C(0,0,0);function Ja(a,t,o){a===1&&t.icons.push(function(c,d){return function(m){if(m.usvg_tree.height||(m.usvg_tree.height=m.usvg_tree.width),!m.metadata)return m;let{metadata:_}=m;if(_.content_area){let{content_area:y}=_;y.left==null&&(y.left=0),y.top==null&&(y.top=y.left),y.width==null&&(y.width=m.usvg_tree.width),y.height==null&&(y.height=y.width)}if(_.text_placeholder){let{text_placeholder:y}=_;y.top==null&&(y.top=y.left),y.height==null&&(y.height=y.width)}return _.stretch_x&&_.stretch_x.length&&sa(_,"x"),_.stretch_y&&_.stretch_y.length&&sa(_,"y"),m}(c.readFields(vr,{name:void 0},d))}(o,o.readVarint()+o.pos))}function sa(a,t){let o=[],c=a[`stretch_${t}`],d=null;for(let m=0;m<c.length;m++)d===null?d=o.length===0?c[0]:o.at(-1)[1]+c[m]:(o.push([d,d+c[m]]),d=null);a[`stretch_${t}_areas`]=o}function vr(a,t,o){a===1?t.name=o.readString():a===2?t.metadata=function(c,d){return c.readFields(rc,{stretch_x:null,stretch_y:null,
7stretch_x_areas:null,stretch_y_areas:null,variables:[]},d)}(o,o.readVarint()+o.pos):a===3&&(t.usvg_tree=function(c,d){return c.readFields(Kn,{width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[]},d)}(o,o.readVarint()+o.pos),t.data="usvg_tree")}function rc(a,t,o){a===1?t.stretch_x=o.readPackedVarint():a===2?t.stretch_y=o.readPackedVarint():a===3?t.content_area=Or(o,o.readVarint()+o.pos):a===4?t.variables.push(function(c,d){return c.readFields(oc,{name:void 0},d)}(o,o.readVarint()+o.pos)):a===5&&(t.text_placeholder=Or(o,o.readVarint()+o.pos))}function Or(a,t){return a.readFields(cu,{},t)}function cu(a,t,o){a===1?t.left=o.readVarint():a===2?t.width=o.readVarint():a===3?t.top=o.readVarint():a===4&&(t.height=o.readVarint())}function oc(a,t,o){a===1?t.name=o.readString():a===2&&(t.rgb_color=Do(o.readVarint()),t.value="rgb_color")}function Kn(a,t,o){a===1?t.width=t.height=o.readVarint():a===2?t.height=o.readVarint():a===3?t.children.push(go(o,o.readVarint()+o.pos)):a===4?t.linear_gradients.push(function(c,d){return c.readFields(uu,{spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0},d)}(o,o.readVarint()+o.pos)):a===5?t.radial_gradients.push(function(c,d){return c.readFields(Oh,{spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0},d)}(o,o.readVarint()+o.pos)):a===7?t.clip_paths.push(function(c,d){return c.readFields(Qa,{children:[]},d)}(o,o.readVarint()+o.pos)):a===8&&t.masks.push(function(c,d){let m=c.readFields(ke,{left:0,width:20,mask_type:1,children:[]},d);return m.height==null&&(m.height=m.width),m.top==null&&(m.top=m.left),m}(o,o.readVarint()+o.pos))}function go(a,t){return a.readFields(Wo,{},t)}function Wo(a,t,o){a===1?(t.group=function(c,d){return c.readFields(aa,{opacity:255,children:[]},d)}(o,o.readVarint()+o.pos),t.node="group"):a===2&&(t.path=function(c,d){return c.readFields(ca,{paint_order:1,commands:[],step:1,diffs:[],rule:1},d)}(o,o.readVarint()+o.pos),t.node="path")}function aa(a,t,o){a===1?t.transform=yo(o,o.readVarint()+o.pos):a===2?t.opacity=o.readVarint():a===5?t.clip_path_idx=o.readVarint():a===6?t.mask_idx=o.readVarint():a===7&&t.children.push(go(o,o.readVarint()+o.pos))}function yo(a,t){return a.readFields(la,{sx:1,ky:0,kx:0,sy:1,tx:0,ty:0},t)}function la(a,t,o){a===1?t.sx=o.readFloat():a===2?t.ky=o.readFloat():a===3?t.kx=o.readFloat():a===4?t.sy=o.readFloat():a===5?t.tx=o.readFloat():a===6&&(t.ty=o.readFloat())}function ca(a,t,o){a===1?t.fill=function(c,d){return c.readFields(sc,{rgb_color:xs,paint:"rgb_color",opacity:255},d)}(o,o.readVarint()+o.pos):a===2?t.stroke=function(c,d){return c.readFields(ac,{rgb_color:xs,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1},d)}(o,o.readVarint()+o.pos):a===3?t.paint_order=o.readVarint():a===5?o.readPackedVarint(t.commands):a===6?t.step=o.readFloat():a===7?o.readPackedSVarint(t.diffs):a===8&&(t.rule=o.readVarint())}function sc(a,t,o){a===1?(t.rgb_color=Do(o.readVarint()),t.paint="rgb_color"):a===2?(t.linear_gradient_idx=o.readVarint(),t.paint="linear_gradient_idx"):a===3?(t.radial_gradient_idx=o.readVarint(),t.paint="radial_gradient_idx"):a===5&&(t.opacity=o.readVarint())}function Do(a){return new h.C((a>>16&255)/255,(a>>8&255)/255,(255&a)/255,1)}function ac(a,t,o){a===1?(t.rgb_color=Do(o.readVarint()),t.paint="rgb_color"):a===2?(t.linear_gradient_idx=o.readVarint(),t.paint="linear_gradient_idx"):a===3?(t.radial_gradient_idx=o.readVarint(),t.paint="radial_gradient_idx"):a===5?o.readPackedFloat(t.dasharray):a===6?t.dashoffset=o.readFloat():a===7?t.miterlimit=o.readFloat():a===8?t.opacity=o.readVarint():a===9?t.width=o.readFloat():a===10?t.linecap=o.readVarint():a===11&&(t.linejoin=o.readVarint())}function uu(a,t,o){a===1?t.transform=yo(o,o.readVarint()+o.pos):a===2?t.spread_method=o.readVarint():a===3?t.stops.push(Ka(o,o.readVarint()+o.pos)):a===4?t.x1=o.readFloat():a===5?t.y1=o.readFloat():a===6?t.x2=o.readFloat():a===7&&(t.y2=o.readFloat())}function Ka(a,t){return a.readFields(hu,{offset:0,opacity:255,rgb_color:xs},t)}function hu(a,t,o){a===1?t.offset=o.readFloat():a===2?t.opacity=o.readVarint():a===3&&(t.rgb_color=Do(o.readVarint()))}function Oh(a,t,o){a===1?t.transform=yo(o,o.readVarint()+o.pos):a===2?t.spread_method=o.readVarint():a===3?t.stops.push(Ka(o,o.readVarint()+o.pos)):a===4?t.cx=o.readFloat():a===5?t.cy=o.readFloat():a===6?t.r=o.readFloat():a===7?t.fx=o.readFloat():a===8?t.fy=o.readFloat():a===9&&(t.fr=o.readFloat())}function Qa(a,t,o){a===1?t.transform=yo(o,o.readVarint()+o.pos):a===2?t.clip_path_idx=o.readVarint():a===3&&t.children.push(go(o,o.readVarint()+o.pos))}function ke(a,t,o){a===1?t.left=t.top=o.readFloat():a===2?t.width=t.height=o.readFloat():a===3?t.top=o.readFloat():a===4?t.height=o.readFloat():a===5?t.mask_type=o.readVarint():a===6?t.mask_idx=o.readVarint():a===7&&t.children.push(go(o,o.readVarint()+o.pos))}class Xo{static calculate(t={},o=[]){let c=new Map,d=new Map;if(Object.keys(t).length===0)return c;o.forEach(m=>{d.set(m.name,m.rgb_color||new h.C(0,0,0))});for(let[m,_]of Object.entries(t))d.has(m)?c.set(d.get(m).toString(),_):console.warn(`Ignoring unknown image variable "${m}"`);return c}}function vs(a,t=255,o){let c=o.get(a.toString())||a;if(t===255)return c.toString();let d=c.clone();return d.a*=t/255,d.toString()}let ua=[],el=0;function _e(a,t){if(el>=ua.length){let c=h.r()?new OffscreenCanvas(a,t):document.createElement("canvas");ua.push(c.getContext("2d",{willReadFrequently:!0}))}let o=ua[el++];return o.canvas.width=a,o.canvas.height=t,o}function B(){el--}
7function V(a,t,o,c,d){for(let m of c.children)X(a,t,o,m,d)}function X(a,t,o,c,d){c.group?(a.save(),function(m,_,y,v,T){let E=v.mask_idx!=null?y.masks[v.mask_idx]:null,P=v.clip_path_idx!=null?y.clip_paths[v.clip_path_idx]:null;if(v.transform&&(_=Ke(v.transform).preMultiplySelf(_)),!function(D,z,O){return D.opacity!==255||z||O}(v,P!=null,E!=null))return void V(m,_,y,v,T);let A=_e(m.canvas.width,m.canvas.height);V(A,_,y,v,T),P&&Ne(A,_,y,P),E&&Oe(A,_,y,E,T),m.globalAlpha=v.opacity/255,m.drawImage(A.canvas,0,0),B()}(a,t,o,c.group,d),a.restore()):c.path&&(a.save(),function(m,_,y,v,T){m.setTransform(_),v.paint_order===1?(ae(m,y,v,T),ce(m,y,v,T)):(ce(m,y,v,T),ae(m,y,v,T))}(a,t,o,c.path,d),a.restore())}function ae(a,t,o,c){let d=o.fill;if(!d)return;let m=d.opacity/255;switch(a.save(),a.beginPath(),ut(o,a),d.paint){case"rgb_color":a.fillStyle=vs(d.rgb_color,d.opacity,c);break;case"linear_gradient_idx":{let _=t.linear_gradients[d.linear_gradient_idx];_.transform&&a.setTransform(Ke(_.transform).preMultiplySelf(a.getTransform())),a.fillStyle=we(a,_,m,c);break}case"radial_gradient_idx":{let _=t.radial_gradients[d.radial_gradient_idx];_.transform&&a.setTransform(Ke(_.transform).preMultiplySelf(a.getTransform())),a.fillStyle=ne(a,_,m,c)}}a.fill(le(o)),a.restore()}function le(a){return a.rule===1?"nonzero":a.rule===2?"evenodd":void 0}function ce(a,t,o,c){let d=o.stroke;if(!d)return;let m=dt(o);a.lineWidth=d.width,a.miterLimit=d.miterlimit,a.setLineDash(d.dasharray),a.lineDashOffset=d.dashoffset;let _=d.opacity/255;switch(d.paint){case"rgb_color":a.strokeStyle=vs(d.rgb_color,d.opacity,c);break;case"linear_gradient_idx":a.strokeStyle=we(a,t.linear_gradients[d.linear_gradient_idx],_,c,!0);break;case"radial_gradient_idx":a.strokeStyle=ne(a,t.radial_gradients[d.radial_gradient_idx],_,c,!0)}switch(d.linejoin){case 2:case 1:a.lineJoin="miter";break;case 3:a.lineJoin="round";break;case 4:a.lineJoin="bevel"}switch(d.linecap){case 1:a.lineCap="butt";break;case 2:a.lineCap="round";break;case 3:a.lineCap="square"}a.stroke(m)}function we(a,t,o,c,d=!1){if(t.stops.length===1){let A=t.stops[0];return vs(A.rgb_color,A.opacity*o,c)}let{x1:m,y1:_,x2:y,y2:v}=t,T=new DOMPoint(m,_),E=new DOMPoint(y,v);if(d){let A=Ke(t.transform);T=A.transformPoint(T),E=A.transformPoint(E)}let P=a.createLinearGradient(T.x,T.y,E.x,E.y);for(let A of t.stops)P.addColorStop(A.offset,vs(A.rgb_color,A.opacity*o,c));return P}function ne(a,t,o,c,d=!1){if(t.stops.length===1){let N=t.stops[0];return vs(N.rgb_color,N.opacity*o,c)}let m=Ke(t.transform),{fx:_,fy:y,fr:v,cx:T,cy:E,r:P}=t,A=new DOMPoint(_,y),D=new DOMPoint(T,E),z=v,O=P;if(d){A=m.transformPoint(A),D=m.transformPoint(D);let N=(m.a+m.d)/2;z=v*N,O=t.r*N}let k=a.createRadialGradient(A.x,A.y,z,D.x,D.y,O);for(let N of t.stops)k.addColorStop(N.offset,vs(N.rgb_color,N.opacity*o,c));return k}function ye(a,t,o,c){let d=c.transform?Ke(c.transform).preMultiplySelf(t):t,m=_e(a.canvas.width,a.canvas.height);for(let y of c.children)if(y.group)ye(m,d,o,y.group);else if(y.path){let v=y.path,T=new Path2D;T.addPath(dt(v),d),m.fill(T,le(v))}let _=c.clip_path_idx!=null?o.clip_paths[c.clip_path_idx]:null;_&&Ne(m,d,o,_),a.globalCompositeOperation="source-over",a.drawImage(m.canvas,0,0),B()}function Ne(a,t,o,c){let d=_e(a.canvas.width,a.canvas.height);ye(d,t,o,c),a.globalCompositeOperation="destination-in",a.drawImage(d.canvas,0,0),B()}function Oe(a,t,o,c,d){if(c.children.length===0)return;let m=c.mask_idx!=null?o.masks[c.mask_idx]:null;m&&Oe(a,t,o,m,d);let _=a.canvas.width,y=a.canvas.height,v=_e(_,y),T=c.width,E=c.height,P=c.left,A=c.top,D=new Path2D,z=new Path2D;z.rect(P,A,T,E),D.addPath(z,t),v.clip(D);for(let N of c.children)X(v,t,o,N,d);let O=v.getImageData(0,0,_,y),k=O.data;if(c.mask_type===1)for(let N=0;N<k.length;N+=4)k[N+3]=k[N+3]/255*(.2126*k[N]+.7152*k[N+1]+.0722*k[N+2]);v.putImageData(O,0,0),a.globalCompositeOperation="destination-in",a.drawImage(v.canvas,0,0),B()}function Ke(a){return a?new DOMMatrix([a.sx,a.ky,a.kx,a.sy,a.tx,a.ty]):new DOMMatrix}function ut(a,t){let o=a.step,c=a.diffs[0]*o,d=a.diffs[1]*o;t.moveTo(c,d);for(let m=0,_=2;m<a.commands.length;m++)switch(a.commands[m]){case 1:c+=a.diffs[_++]*o,d+=a.diffs[_++]*o,t.moveTo(c,d);break;case 2:c+=a.diffs[_++]*o,d+=a.diffs[_++]*o,t.lineTo(c,d);break;case 3:{let y=c+a.diffs[_++]*o,v=d+a.diffs[_++]*o;c=y+a.diffs[_++]*o,d=v+a.diffs[_++]*o,t.quadraticCurveTo(y,v,c,d);break}case 4:{let y=c+a.diffs[_++]*o,v=d+a.diffs[_++]*o,T=y+a.diffs[_++]*o,E=v+a.diffs[_++]*o;c=T+a.diffs[_++]*o,d=E+a.diffs[_++]*o,t.bezierCurveTo(y,v,T,E,c,d);break}case 5:t.closePath();break;default:}return t}function dt(a){return ut(a,new Path2D)}function Ft(a,t){}class It{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(t){return new h.q(t,t.data)}getFromCache(t,o,c){return this.cacheMap.has(c)||this.cacheMap.set(c,new h.L(150)),this.cacheMap.get(c).get(h.t(t.toString(),o))}setInCache(t,o,c,d){this.cacheDependenciesMap.has(d)||this.cacheDependenciesMap.set(d,new Map),this.cacheMap.has(d)||this.cacheMap.set(d,new h.L(150));let m=this.cacheDependenciesMap.get(d),_=h.t(t.id.toString(),c);m.get(_)||m.set(_,new Set);let y=this.cacheMap.get(d),v=t.toString();m.get(_).add(v),y.put(h.t(t.toString(),c),o)}removeImagesFromCacheByIds(t,o,c=0){if(!this.cacheMap.has(c)||!this.cacheDependenciesMap.has(c))return;let d=this.cacheMap.get(c),m=this.cacheDependenciesMap.get(c);for(let _ of t){let y=h.t(_.toString(),o);if(m.has(y)){for(let v of m.get(y))d.delete(v);m.delete(y)}}}rasterize(t,o,c,d){let m=this.getFromCache(t,c,d);if(m)return m.clone();let _=function(v,T){let E=Xo.calculate(T.params,v.metadata?v.metadata.variables:[]),P=v.usvg_tree,A=P.width,D=P.height,z=Math.max(1,Math.round(A*T.sx)),O=Math.max(1,Math.round(D*T.sy)),k=new DOMMatrix([z/A,0,0,O/D,0,0]),N=_e(z,O);V(N,k,P,P,E);let q=N.getImageData(0,0,z,O);return B(),q}(o.icon,t),y=It._getImage(_);return this.setInCache(t,y,c,d),y.clone()}}class Dt extends h.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new h.x,this.dirty=!0,this.spriteFormat=t,this.imageRasterizer=new It}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.imageVersions.set(t,new Map),this.patterns.set(t,new Map),this.atlasImage.set(t,new h.q({width:1,height:1}))}removeScope(t){this.loaded.delete(t),this.imageProviders.delete(t),this.images.delete(t),this.updatedImages.delete(t),this.callbackDispatchedThisFrame.delete(t),this.imageVersions.delete(t),this.patterns.delete(t),this.atlasImage.delete(t);let o=this.atlasTexture.get(t);o&&(o.destroy(),this.atlasTexture.delete(t))}addImageProvider(t,o){this.imageProviders.has(o)||this.imageProviders.set(o,new Map),this.imageProviders.get(o).set(t.id,t)}removeImageProvider(t,o){this.imageProviders.has(o)&&this.imageProviders.get(o).delete(t)}getPendingImageProviders(){let t=[];for(let o of this.imageProviders.values())for(let c of o.values())c.hasPendingRequests()&&t.push(c);return t}isLoaded(){for(let t of this.loaded.keys())if(!this.loaded.get(t))return!1;return!0}setLoaded(t,o){if(this.loaded.get(o)!==t&&(this.loaded.set(o,t),t)){for(let{ids:c,callback:d}of this.requestors)this._notify(c,o,d);this.requestors=[]}}hasImage(t,o){return!!this.getImage(t,o)}getImage(t,o){return this.images.get(o).get(t.toString())}
7addImage(t,o,c){if(this._validate(t,c)){this.images.get(o).set(t.toString(),c);let d=this.imageVersions.get(o),m=d.get(t.toString())||0;d.set(t.toString(),m+1)}}_validate(t,o){let c=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new h.y(new Error(`Image "${t.name}" has invalid "stretchX" value`))),c=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new h.y(new Error(`Image "${t.name}" has invalid "stretchY" value`))),c=!1),this._validateContent(o.content,o)||(this.fire(new h.y(new Error(`Image "${t.name}" has invalid "content" value`))),c=!1),c}_validateStretch(t,o){if(!t)return!0;let c=0;for(let d of t){if(d[0]<c||d[1]<d[0]||o<d[1])return!1;c=d[1]}return!0}_validateContent(t,o){return t?t.length!==4||!o.usvg&&(t[0]<0||o.data.width<t[0]||t[1]<0||o.data.height<t[1]||t[2]<0||o.data.width<t[2]||t[3]<0||o.data.height<t[3])?!1:!(t[2]<t[0]||t[3]<t[1]):!0}updateImage(t,o,c){let d=this.images.get(o).get(t.toString());c.version=d.version+1,this.images.get(o).set(t.toString(),c),this.updatedImages.get(o).add(t);let m=this.imageVersions.get(o),_=m.get(t.toString())||0;m.set(t.toString(),_+1),this.removeFromImageRasterizerCache(t,o)}clearUpdatedImages(t){this.updatedImages.get(t).clear()}removeFromImageRasterizerCache(t,o){this.spriteFormat!=="raster"&&this.imageRasterizer.removeImagesFromCacheByIds([t],o)}removeImage(t,o){let c=this.images.get(o),d=c.get(t.toString());c.delete(t.toString());let m=this.imageVersions.get(o),_=m.get(t.toString())||0;m.set(t.toString(),_+1),this.patterns.get(o).delete(t.toString()),this.removeFromImageRasterizerCache(t,o),d.userImage&&d.userImage.onRemove&&d.userImage.onRemove()}listImages(t){return Array.from(this.images.get(t).keys()).map(o=>h.I.from(o))}getImageVersions(t){let o=this.imageVersions.get(t);if(o)return o}getImages(t,o,c){let d=[],m=[],_=this.imageProviders.get(o);for(let E of t){if(!E.iconsetId){d.push(E);continue}let P=_.get(E.iconsetId);P&&(this.getImage(E,o)?m.push(E):P.addPendingRequest(E))}if(d.length===0)return void this._notify(m,o,c);let y=!0,v=!!this.loaded.get(o),T=this.images.get(o);if(!v)for(let E of d)T.has(E.toString())||(y=!1);v||y?this._notify(d,o,c):this.requestors.push({ids:d,scope:o,callback:c})}rasterizeImages(t,o){let c=new Map,{iconTasks:d,patternTasks:m,scope:_}=t;for(let y of[d,m])for(let[v,T]of y.entries()){let E=this.getImage(T.id,_);E&&c.set(v,{image:E,imageVariant:T})}o(null,this._rasterizeImages(_,c))}_rasterizeImages(t,o){let c=new Map;for(let[d,{image:m,imageVariant:_}]of o.entries())c.set(d,this.imageRasterizer.rasterize(_,m,t,0));return c}getUpdatedImages(t){return this.updatedImages.get(t)||new Set}_notify(t,o,c){let d=this.images.get(o),m=new Map;for(let _ of t){if(!d.get(_.toString())){if(_.iconsetId)continue;this.fire(new h.z("styleimagemissing",{id:_.name}))}let y=d.get(_.toString());if(!y){h.w(`Image "${_.name}" 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.`);continue}let v={data:y.usvg?null:y.data.clone(),pixelRatio:y.pixelRatio,sdf:y.sdf,usvg:y.usvg,stretchX:y.stretchX,stretchY:y.stretchY,content:y.content,hasRenderCallback:!!(y.userImage&&y.userImage.render)};y.usvg&&Object.assign(v,{width:y.icon.usvg_tree.width,height:y.icon.usvg_tree.height}),m.set(h.I.toString(_),v)}c(null,{images:m,versions:this.getImageVersions(o)})}getPixelSize(t){let{width:o,height:c}=this.atlasImage.get(t);return{width:o,height:c}}getPattern(t,o,c){let d=t.toString(),m=this.patterns.get(o),_=m.get(d),y=this.getImage(t,o);if(!y)return null;if(_){if(_.position.version===y.version)return _.position;_.position.version=y.version}else{if(y.usvg&&!y.data){let v=this.getPatternInFlightId(d,o);if(this.patternsInFlight.has(v))return null;this.patternsInFlight.add(v);let T=new h.A(t).scaleSelf(h.o.devicePixelRatio),E=new Map([[T.toString(),{image:y,imageVariant:T}]]),P=this._rasterizeImages(o,E);return this.storePatternImage(T,o,y,c,P),null}this.storePattern(t,o,y)}return this._updatePatternAtlas(o,c),m.get(d).position}getPatternInFlightId(t,o){return h.t(t,o)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(t,o,c,d,m){let _=t.toString(),y=m?m.get(_):void 0;y&&(c.data=y,this.storePattern(t.id,o,c),this._updatePatternAtlas(o,d),this.patternsInFlight.delete(this.getPatternInFlightId(t.id.toString(),o)))}storePattern(t,o,c){let d={w:c.data.width+2*h.B,h:c.data.height+2*h.B,x:0,y:0},m=new h.D(d,c,h.B);this.patterns.get(o).set(t.toString(),{bin:d,position:m})}destroyAtlasTextures(){for(let t of this.atlasTexture.values())t&&t.destroy();this.atlasTexture.clear()}bind(t,o){let c=t.gl,d=this.atlasTexture.get(o);d?this.dirty&&(d.update(this.atlasImage.get(o)),this.dirty=!1):(d=new h.T(t,this.atlasImage.get(o),c.RGBA8),this.atlasTexture.set(o,d)),d.bind(c.LINEAR,c.CLAMP_TO_EDGE)}_updatePatternAtlas(t,o){let c=this.patterns.get(t),d=Array.from(c.values()).map(({bin:T})=>T),{w:m,h:_}=h.F(d),y=this.atlasImage.get(t);y.resize({width:m||1,height:_||1});let v=this.images.get(t);for(let[T,{bin:E,position:P}]of c.entries()){let A=P.padding,D=E.x+A,z=E.y+A,O=v.get(T).data,k=O.width,N=O.height;A=A>1?A-1:A,h.q.copy(O,y,{x:0,y:0},{x:D,y:z},{width:k,height:N},o),h.q.copy(O,y,{x:0,y:N-A},{x:D,y:z-A},{width:k,height:A},o),h.q.copy(O,y,{x:0,y:0},{x:D,y:z+N},{width:k,height:A},o),h.q.copy(O,y,{x:k-A,y:0},{x:D-A,y:z},{width:A,height:N},o),h.q.copy(O,y,{x:0,y:0},{x:D+k,y:z},{width:A,height:N},o),h.q.copy(O,y,{x:k-A,y:N-A},{x:D-A,y:z-A},{width:A,height:A},o),h.q.copy(O,y,{x:0,y:N-A},{x:D+k,y:z-A},{width:A,height:A},o),h.q.copy(O,y,{x:0,y:0},{x:D+k,y:z+N},{width:A,height:A},o),h.q.copy(O,y,{x:k-A,y:0},{x:D-A,y:z+N},{width:A,height:A},o)}this.dirty=!0}beginFrame(){for(let t of this.images.keys())this.callbackDispatchedThisFrame.set(t,new Set)}
vendor: 6,508 bytes, line 7
7dispatchRenderCallbacks(t,o){let c=this.images.get(o);for(let d of t){if(this.callbackDispatchedThisFrame.get(o).has(d.toString()))continue;this.callbackDispatchedThisFrame.get(o).add(d.toString());let m=c.get(d.toString());ys(m)&&this.updateImage(d,o,m)}}}class Ve{constructor(t,o,c,d){this.message=(t?`${t}: `:"")+c,d&&(this.identifier=d),o!=null&&o.__line__&&(this.line=o.__line__)}}class Gt extends Ve{}function qi(a){let t=a.value,o=a.valueSpec,c=a.style,d=a.styleSpec,m=a.key,_=a.arrayElementValidator||Ri;if(!Array.isArray(t))return[new Ve(m,t,`array expected, ${h.J(t)} found`)];if(o.length&&t.length!==o.length)return[new Ve(m,t,`array length ${o.length} expected, length ${t.length} found`)];if(o["min-length"]&&t.length<o["min-length"])return[new Ve(m,t,`array length at least ${o["min-length"]} expected, length ${t.length} found`)];let y={type:o.value,values:o.values,minimum:o.minimum,maximum:o.maximum,function:void 0};d.$version<7&&(y.function=o.function),h.G(o.value)&&(y=o.value);let v=[];for(let T=0;T<t.length;T++)v=v.concat(_({array:t,arrayIndex:T,value:t[T],valueSpec:y,style:c,styleSpec:d,key:`${m}[${T}]`},!0));return v}function Zi(a){let t=a.key,o=a.value,c=a.valueSpec;if(!h.K(o))return[new Ve(t,o,`number expected, ${h.J(o)} found`)];if(o!=o)return[new Ve(t,o,"number expected, NaN found")];if("minimum"in c){let d=c.minimum;if(Array.isArray(c.minimum)&&(d=c.minimum[a.arrayIndex]),o<d)return[new Ve(t,o,`${o} is less than the minimum value ${d}`)]}if("maximum"in c){let d=c.maximum;if(Array.isArray(c.maximum)&&(d=c.maximum[a.arrayIndex]),o>d)return[new Ve(t,o,`${o} is greater than the maximum value ${d}`)]}return[]}function Bt(a){let t=a.key,o=a.value;if(!h.G(o))return[new Ve(t,o,`object expected, ${h.J(o)} found`)];let c=a.valueSpec,d=h.H(o.type),m,_,y,v={},T=d!=="categorical"&&o.property===void 0,E=!T,P=function(O){let k=O.stops;return Array.isArray(k)&&Array.isArray(k[0])&&h.G(k[0][0])}(o),A=Sn({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(O){if(d==="identity")return[new Ve(O.key,O.value,'identity function may not have a "stops" property')];let k=[],N=O.value;return k=k.concat(qi({key:O.key,value:N,valueSpec:O.valueSpec,style:O.style,styleSpec:O.styleSpec,arrayElementValidator:D})),Array.isArray(N)&&N.length===0&&k.push(new Ve(O.key,N,"array must have at least one stop")),k},default:function(O){return Ri({key:O.key,value:O.value,valueSpec:c,style:O.style,styleSpec:O.styleSpec})}}});return d==="identity"&&T&&A.push(new Ve(a.key,a.value,'missing required property "property"')),d==="identity"||o.stops||A.push(new Ve(a.key,a.value,'missing required property "stops"')),d==="exponential"&&c.expression&&!h.M(c)&&A.push(new Ve(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(E&&!h.N(c)?A.push(new Ve(a.key,a.value,"property functions not supported")):T&&!h.O(c)&&A.push(new Ve(a.key,a.value,"zoom functions not supported"))),d!=="categorical"&&!P||o.property!==void 0||A.push(new Ve(a.key,a.value,'"property" property is required')),A;function D(O){let k=[],N=O.value,q=O.key;if(!Array.isArray(N))return[new Ve(q,N,`array expected, ${h.J(N)} found`)];if(N.length!==2)return[new Ve(q,N,`array length 2 expected, length ${N.length} found`)];if(P){if(!h.G(N[0]))return[new Ve(q,N,`object expected, ${h.J(N[0])} found`)];let Z=N[0];if(Z.zoom===void 0)return[new Ve(q,N,"object stop key must have zoom")];if(Z.value===void 0)return[new Ve(q,N,"object stop key must have value")];let G=h.H(Z.zoom);if(typeof G!="number")return[new Ve(q,Z.zoom,"stop zoom values must be numbers")];if(y&&y>G)return[new Ve(q,Z.zoom,"stop zoom values must appear in ascending order")];G!==y&&(y=G,_=void 0,v={}),k=k.concat(Sn({key:`${q}[0]`,value:N[0],valueSpec:{zoom:{}},style:O.style,styleSpec:O.styleSpec,objectElementValidators:{zoom:Zi,value:z}}))}else k=k.concat(z({key:`${q}[0]`,value:N[0],style:O.style,styleSpec:O.styleSpec},N));return h.Q(h.S(N[1]))?k.concat([new Ve(`${q}[1]`,N[1],"expressions are not allowed in function stops.")]):k.concat(Ri({key:`${q}[1]`,value:N[1],valueSpec:c,style:O.style,styleSpec:O.styleSpec}))}function z(O,k){let N=h.J(O.value),q=h.H(O.value),Z=O.value!==null?O.value:k;if(m){if(N!==m)return[new Ve(O.key,Z,`${N} stop domain type must match previous stop domain type ${m}`)]}else m=N;if(N!=="number"&&N!=="string"&&N!=="boolean"&&typeof q!="number"&&typeof q!="string"&&typeof q!="boolean")return[new Ve(O.key,Z,"stop domain value must be a number, string, or boolean")];if(N!=="number"&&d!=="categorical"){let G=`number expected, ${N} found`;return h.N(c)&&d===void 0&&(G+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ve(O.key,Z,G)]}return d!=="categorical"||N!=="number"||typeof q=="number"&&isFinite(q)&&Math.floor(q)===q?d!=="categorical"&&N==="number"&&typeof q=="number"&&typeof _=="number"&&_!==void 0&&q<_?[new Ve(O.key,Z,"stop domain values must appear in ascending order")]:(_=q,d==="categorical"&&q in v?[new Ve(O.key,Z,"stop domain values must be unique")]:(v[q]=!0,[])):[new Ve(O.key,Z,`integer expected, found ${String(q)}`)]}}function ni(a){let t=(a.expressionContext==="property"?h.V:h.U)(h.S(a.value),a.valueSpec);if(t.result==="error")return t.value.map(c=>new Ve(`${a.key}${c.key}`,a.value,c.message));let o=t.value.expression||t.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!o.outputDefined())return[new Ve(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`)];if(a.expressionContext==="property"&&a.propertyType==="layout"&&!h.Y(o))return[new Ve(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter")return Di(o,a);if(a.expressionContext==="appearance")return rn(o,a);if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!h.W(o,["zoom","feature-state"]))return[new Ve(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!h.X(o))return[new Ve(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Di(a,t){let o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(let d of t.valueSpec.expression.parameters)o.delete(
7d);if(o.size===0)return[];let c=[];return a instanceof h.Z&&o.has(a.name)?[new Ve(t.key,t.value,`["${a.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(a.eachChild(d=>{c.push(...Di(d,t))}),c)}function rn(a,t){let o=new Set;if(t.valueSpec&&t.valueSpec.expression)for(let d of t.valueSpec.expression.parameters)o.add(d);if(o.size===0)return[];let c=[];return a instanceof h.Z&&!o.has(a.name)?[new Ve(t.key,t.value,`["${a.name}"] is not an allowed parameter`)]:(a.eachChild(d=>{c.push(...rn(d,t))}),c)}function ri(a){let t=a.key,o=a.value,c=a.valueSpec,d=[];return Array.isArray(c.values)?c.values.includes(h.H(o))||d.push(new Ve(t,o,`expected one of [${c.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(c.values).includes(h.H(o))||d.push(new Ve(t,o,`expected one of [${Object.keys(c.values).join(", ")}], ${JSON.stringify(o)} found`)),d}function Ci(a){return h.a1(h.S(a.value))?ni(Object.assign({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${a.layerType||"fill"}`]})):Ni(a)}function Ni(a){let t=a.value,o=a.key;if(!Array.isArray(t))return[new Ve(o,t,`array expected, ${h.J(t)} found`)];if(t.length<1)return[new Ve(o,t,"filter array must have at least 1 element")];let c=a.styleSpec,d=ri({key:`${o}[0]`,value:t[0],valueSpec:c.filter_operator}),m=()=>{t.length>=2&&(h.$(t[1])||d.push(new Ve(`${o}[1]`,t[1],`string expected, ${h.J(t[1])} found`)));for(let _=2;_<t.length;_++)h.H(t[1])==="$type"?d=d.concat(ri({key:`${o}[${_}]`,value:t[_],valueSpec:c.geometry_type})):h.$(t[_])||h.K(t[_])||h._(t[_])||d.push(new Ve(`${o}[${_}]`,t[_],`string, number, or boolean expected, ${h.J(t[_])} found.`))};switch(h.H(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&h.H(t[1])==="$type"&&d.push(new Ve(o,t,`"$type" cannot be use with operator "${t[0]}"`)),t.length!==3&&d.push(new Ve(o,t,`filter array for operator "${t[0]}" must have 3 elements`)),m();break;case"==":case"!=":t.length!==3&&d.push(new Ve(o,t,`filter array for operator "${t[0]}" must have 3 elements`)),m();break;case"in":case"!in":m();break;case"any":case"all":case"none":for(let _=1;_<t.length;_++)d=d.concat(Ni({key:`${o}[${_}]`,value:t[_],style:a.style,styleSpec:a.styleSpec}));break;case"has":case"!has":t.length!==2?d.push(new Ve(o,t,`filter array for "${t[0]}" operator must have 2 elements`)):h.$(t[1])||d.push(new Ve(`${o}[1]`,t[1],`string expected, ${h.J(t[1])} found`))}return d}let vi=/^{([^}]+)}$/;function Xi(a,t){let o=a.key,c=a.style,d=a.layer,m=a.styleSpec,_=a.value,y=a.objectKey,v=m[`${t}_${a.layerType}`];if(!v)return[];let T=y.match(h.a2);if(T&&v[T[1]])return h.Q(h.S(_))?[].concat(Ri({key:o,value:_,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:c,styleSpec:m,expressionContext:"property",propertyType:t,propertyKey:y})):Ri({key:o,value:_,valueSpec:{type:"string"},style:c,styleSpec:m});let E=y.match(h.a3);if(t==="paint"&&E&&v[E[1]]&&v[E[1]].transition)return Ri({key:o,value:_,valueSpec:m.transition,style:c,styleSpec:m});let P=a.valueSpec||v[y];if(!P)return[new Gt(o,_,`unknown property "${y}"`)];let A;if(h.$(_)&&h.N(P)&&!P.tokens&&(A=vi.exec(_))){let z=`\`{ "type": "identity", "property": ${A?JSON.stringify(A[1]):'"_"'} }\``;return[new Ve(o,_,`"${y}" does not support interpolation syntax
8Use an identity property function instead: ${z}.`)]}let D=[];if(a.layerType==="symbol")y!=="text-field"||!c||c.glyphs||c.imports||D.push(new Ve(o,_,'use of "text-field" requires a style "glyphs" property')),y==="text-font"&&h.a4(h.S(_))&&h.H(_.type)==="identity"&&D.push(new Ve(o,_,'"text-font" does not support identity functions'));else if(a.layerType==="model"&&t==="paint"&&d&&d.layout&&Object.hasOwn(d.layout,"model-id")&&h.N(P)&&(h.a5(P)||h.O(P))){let z=h.V(h.S(_),P).value,O="expression"in z&&z.expression||"_styleExpression"in z&&z._styleExpression&&z._styleExpression.expression;O&&!h.W(O,["measure-light"])&&(y==="model-emissive-strength"&&h.X(O)&&h.Y(O)||D.push(new Ve(o,_,`${y} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return D.concat(Ri({key:a.key,value:_,valueSpec:P,style:c,styleSpec:m,expressionContext:"property",propertyType:t,propertyKey:y}))}function Nn(a){return Xi(a,"paint")}function gn(a){return Xi(a,"layout")}function Ln(a){let t=[],o=a.value,c=a.key,d=a.style,m=a.styleSpec;if(!h.G(o))return[new Ve(c,o,"object expected")];o.type||o.ref||t.push(new Ve(c,o,'either "type" or "ref" is required'));let _=h.H(o.type),y=h.H(o.ref);
8if(o.id){let v=h.H(o.id);for(let T=0;T<a.arrayIndex;T++){let E=d.layers[T];h.H(E.id)===v&&t.push(new Ve(c,o.id,`duplicate layer id "${v}", previously used at line ${E.id.__line__}`))}}if("ref"in o){let v;["type","source","source-layer","filter","layout"].forEach(T=>{T in o&&t.push(new Ve(c,o[T],`"${T}" is prohibited for ref layers`))}),d.layers.forEach(T=>{h.H(T.id)===y&&(v=T)}),v?v.ref?t.push(new Ve(c,o.ref,"ref cannot reference another ref layer")):_=h.H(v.type):typeof y=="string"&&t.push(new Ve(c,o.ref,`ref layer "${y}" not found`))}else if(_!=="background"&&_!=="sky"&&_!=="slot")if(o.source)if(h.$(o.source)){let v=d.sources&&d.sources[o.source],T=v&&h.H(v.type);v?T==="vector"&&_==="raster"?t.push(new Ve(c,o.source,`layer "${o.id}" requires a raster source`)):T==="raster"&&_!=="raster"?t.push(new Ve(c,o.source,`layer "${o.id}" requires a vector source`)):T!=="vector"||o["source-layer"]?T==="raster-dem"&&_!=="hillshade"?t.push(new Ve(c,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):T!=="raster-array"||["raster","raster-particle"].includes(_)?_==="line"&&o.paint&&o.paint["line-gradient"]&&T==="geojson"&&!v.lineMetrics?t.push(new Ve(c,o,`layer "${o.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):_==="line"&&o.paint&&o.paint["line-trim-offset"]&&T==="geojson"&&!v.lineMetrics?t.push(new Ve(c,o,`layer "${o.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):_==="raster-particle"&&T!=="raster-array"&&t.push(new Ve(c,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):t.push(new Ve(c,o.source,"raster-array source can only be used with layer type 'raster'.")):t.push(new Ve(c,o,`layer "${o.id}" must specify a "source-layer"`)):t.push(new Ve(c,o.source,`source "${o.source}" not found`))}else t.push(new Ve(`${c}.source`,o.source,'"source" must be a string'));else t.push(new Ve(c,o,'missing required property "source"'));return t=t.concat(Sn({key:c,value:o,valueSpec:m.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Ri({key:`${c}.type`,value:o.type,valueSpec:m.layer.type,style:a.style,styleSpec:a.styleSpec,object:o,objectKey:"type"}),filter:v=>Ci(Object.assign({layerType:_},v)),layout:v=>Sn({layer:o,key:v.key,value:v.value,valueSpec:{},style:v.style,styleSpec:v.styleSpec,objectElementValidators:{"*":T=>gn(Object.assign({layerType:_},T))}}),paint:v=>Sn({layer:o,key:v.key,value:v.value,valueSpec:{},style:v.style,styleSpec:v.styleSpec,objectElementValidators:{"*":T=>Nn(Object.assign({layerType:_,layer:o},T))}}),appearances(v){let T=qi({key:v.key,value:v.value,valueSpec:v.valueSpec,style:v.style,styleSpec:v.styleSpec,arrayElementValidator:A=>function(D){let{key:z,layer:O,layerType:k}=D,N=h.H(D.value),q=h.H(N.name),Z=h.H(N.condition),G=Sn({key:z,value:N,valueSpec:D.styleSpec.appearance,style:D.style,styleSpec:D.styleSpec,objectElementValidators:{condition:re=>function(te){let se=[];return se.push(...ni({key:te.key,value:te.object.condition,valueSpec:h.a6.appearance.condition,expressionContext:"appearance"})),se}(Object.assign({layer:O,layerType:k},re)),properties:re=>function(te){let se=[],{styleSpec:K,layer:J,layerType:oe}=te,ue=K[`paint_${oe}`],de=K[`layout_${oe}`],be=te.object[te.objectKey];for(let ve in be){let Fe=ve in ue?"paint":ve in de?"layout":void 0;if(!Fe){se.push(new Ve(te.key,ve,`unknown property "${ve}" for layer type "${oe}"`));continue}let pe=Object.assign({},te,{key:`${te.key}.${ve}`,object:be,objectKey:ve,layer:J,layerType:oe,value:be[ve],valueSpec:Fe==="paint"?ue[ve]:de[ve]});se.push(...Xi(pe,Fe))}return se}(Object.assign({layer:O,layerType:k},re))}});return q!=="hidden"&&Z===void 0&&G.push(new Ve(D.key,"name",'Appearance with name different than "hidden" must have a condition')),G}(Object.assign({layerType:_,layer:o},A))}),E=Array.isArray(v.value)?v.value:[],P=new Set;return E.forEach((A,D)=>{let z=h.H(A.name);if(z)if(P.has(z)){let O=h.H(o.id);T.push(new Ve(v.key,z,`Duplicated appearance name "${z}" for layer "${O}"`))}else P.add(z)}),T}}})),t}function Fr({key:a,value:t}){return h.$(t)?[]:[new Ve(a,t,`string expected, ${h.J(t)}
8 found`)]}let xo={promoteId:function a({key:t,value:o}){if(h.$(o))return Fr({key:t,value:o});if(Array.isArray(o)){let d=[],m=h.S(o),_=h.U(m);return _.result==="error"?(_.value.forEach(y=>{d.push(new Ve(`${t}${y.key}`,null,`${y.message}`))}),d):(h.W(_.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||d.push(new Ve(`${t}`,null,"promoteId expression should be only feature dependent")),d)}if(!h.G(o))return[new Ve(t,o,`string, expression or object expected, "${h.J(o)}" found`)];let c=[];for(let d in o)c.push(...a({key:`${t}.${d}`,value:o[d]}));return c}};function di(a){let t=a.value,o=a.key,c=a.styleSpec,d=a.style;if(!h.G(t))return[new Ve(o,t,`object expected, ${h.J(t)} found`)];if(!("type"in t))return[new Ve(o,t,'"type" is required')];let m=h.H(t.type),_=[];switch(["vector","raster","raster-dem","raster-array"].includes(m)&&("url"in t||"tiles"in t||_.push(new Gt(o,t,'Either "url" or "tiles" is required.'))),m){case"vector":case"raster":case"raster-dem":case"raster-array":return _=_.concat(Sn({key:o,value:t,valueSpec:c[`source_${m.replace("-","_")}`],style:a.style,styleSpec:c,objectElementValidators:xo})),_;case"geojson":if(_=Sn({key:o,value:t,valueSpec:c.source_geojson,style:d,styleSpec:c,objectElementValidators:xo}),"cluster"in t&&"clusterProperties"in t){if(!h.G(t.clusterProperties))return[new Ve(`${o}.clusterProperties`,t,`object expected, ${h.J(t)} found`)];for(let y in t.clusterProperties){let v=t.clusterProperties[y];if(!Array.isArray(v))return[new Ve(`${o}.clusterProperties.${y}`,v,"array expected")];let[T,E]=v,P=typeof T=="string"?[T,["accumulated"],["get",y]]:T;_.push(...ni({key:`${o}.${y}.map`,value:E,expressionContext:"cluster-map"})),_.push(...ni({key:`${o}.${y}.reduce`,value:P,expressionContext:"cluster-reduce"}))}}return _;case"video":return Sn({key:o,value:t,valueSpec:c.source_video,style:d,styleSpec:c});case"image":return Sn({key:o,value:t,valueSpec:c.source_image,style:d,styleSpec:c});case"canvas":return[new Ve(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ri({key:`${o}.type`,value:t.type,valueSpec:{values:ha(c)}})}}function ha(a){return a.source.reduce((t,o)=>{let c=a[o];return c.type.type==="enum"&&(t=t.concat(Object.keys(c.type.values||{}))),t},[])}function da(a,t){let o=!a.includes("://");try{return new URL(a,o&&t?"http://example.com":void 0),!0}catch{return!1}}function pa(a){let t=a.value;return t?h.$(t)?da(t,!0)?[]:[new Ve(a.key,t,`invalid url "${t}"`)]:[new Ve(a.key,t,`string expected, "${h.J(t)}" found`)]:[]}function bs(a){let t=a.value,o=a.styleSpec,c=o.light,d=a.style;if(t===void 0)return[];if(!h.G(t))return[new Ve("light",t,`object expected, ${h.J(t)} found`)];let m=[];for(let _ in t){let y=_.match(h.a3),v=_.match(h.a2);m=m.concat(v&&c[v[1]]?Ri({key:_,value:t[_],valueSpec:{type:"string"},style:d,styleSpec:o}):y&&c[y[1]]&&c[y[1]].transition?Ri({key:_,value:t[_],valueSpec:o.transition,style:d,styleSpec:o}):c[_]?Ri({key:_,value:t[_],valueSpec:c[_],style:d,styleSpec:o}):[new Ve(_,t[_],`unknown property "${_}"`)])}return m}function tl(a){let t=a.value;if(!t)return[];let o=a.key;if(!h.G(t))return[new Ve(o,t,`object expected, ${h.J(t)} found`)];let c=[],d=a.styleSpec,m=d["light-3d"],_=a.style,y=a.style.lights;for(let E of["type","id"])if(!(E in t))return c=c.concat([new Ve(o,t,`missing property "${E}"`)]),c;if(!h.$(t.type))return c=c.concat([new Ve(`${o}.type`,t.type,"string expected")]),c;if(y)for(let E=0;E<a.arrayIndex;E++){let P=h.H(t.type),A=y[E];h.H(A.type)===P&&c.push(new Ve(o,t.id,`duplicate light type "${t.type}", previously defined at line ${A.id.__line__}`))}let v=`properties_light_${t.type}`;if(!(v in d))return c=c.concat([new Ve(`${o}.type`,t,`Invalid light type ${t.type}`)]),c;let T=d[v];for(let E in t)if(E==="properties"){let P=t[E];if(!h.G(P))return c=c.concat([new Ve("properties",P,`object expected, ${h.J(P)} found`)]),c;for(let A in P){let D=A.match(h.a3),z=A.match(h.a2);c=c.concat(z&&T[z[1]]?Ri({key:E,value:P[A],valueSpec:{type:"string"},style:_,styleSpec:d}):D&&T[D[1]]&&T[D[1]].transition?Ri({key:E,value:t[E],valueSpec:d.transition,style:_,styleSpec:d}):T[A]?Ri({key:A,value:P[A],valueSpec:T[A],style:_,styleSpec:d}):[new Gt(a.key,P[A],`unknown property "${A}"`)])}}else c=c.concat(m[E]?Ri({key:E,value:t[E],valueSpec:m[E],style:_,styleSpec:d}):[new Gt(E,t[E],`unknown property "${E}"`)]);return c}function du(a){let t=a.value,o=a.key,c=a.style,d=a.styleSpec,m=d.terrain;if(t==null)return[];if(!h.G(t))return[new Ve("terrain",t,`object expected, ${h.J(t)}
8 found`)];let _=[];for(let y in t){let v=y.match(h.a3),T=y.match(h.a2);_=_.concat(T&&m[T[1]]?Ri({key:y,value:t[y],valueSpec:{type:"string"},style:c,styleSpec:d}):v&&m[v[1]]&&m[v[1]].transition?Ri({key:y,value:t[y],valueSpec:d.transition,style:c,styleSpec:d}):m[y]?Ri({key:y,value:t[y],valueSpec:m[y],style:c,styleSpec:d}):[new Gt(y,t[y],`unknown property "${y}"`)])}if(t.source)if(h.$(t.source)){let y=c.sources&&c.sources[t.source],v=y&&h.H(y.type);y?v!=="raster-dem"&&_.push(new Ve(`${o}.source`,t.source,`terrain cannot be used with a source of type ${v}, it only be used with a "raster-dem" source type`)):_.push(new Ve(`${o}.source`,t.source,`source "${t.source}" not found`))}else _.push(new Ve(`${o}.source`,t.source,"source must be a string"));else _.push(new Ve(o,t,'terrain is missing required property "source"'));return _}function lc(a){let t=a.value,o=a.style,c=a.styleSpec,d=c.fog;if(t===void 0)return[];if(!h.G(t))return[new Ve("fog",t,`object expected, ${h.J(t)} found`)];let m=[];for(let _ in t){let y=_.match(h.a3),v=_.match(h.a2);m=m.concat(v&&d[v[1]]?Ri({key:_,value:t[_],valueSpec:{type:"string"},style:o,styleSpec:c}):y&&d[y[1]]&&d[y[1]].transition?Ri({key:_,value:t[_],valueSpec:c.transition,style:o,styleSpec:c}):d[_]?Ri({key:_,value:t[_],valueSpec:d[_],style:o,styleSpec:c}):[new Gt(_,t[_],`unknown property "${_}"`)])}return m}let pu={"*":()=>[],array:qi,boolean:function(a){let t=a.value,o=a.key;return h._(t)?[]:[new Ve(o,t,`boolean expected, ${h.J(t)} found`)]},number:Zi,color:function({key:a,value:t}){return h.$(t)?h.a0.parseCSSColor(t)===null?[new Ve(a,t,`color expected, "${t}" found`)]:[]:[new Ve(a,t,`color expected, ${h.J(t)} found`)]},enum:ri,filter:Ci,function:Bt,layer:Ln,object:Sn,source:di,model:pa,light:bs,"light-3d":tl,terrain:du,fog:lc,string:Fr,formatted:function(a){return Fr(a).length===0?[]:ni(a)},resolvedImage:function(a){return Fr(a).length===0?[]:ni(a)},projection:function(a){let t=a.value,o=a.styleSpec,c=o.projection,d=a.style;if(h.G(t)){let m=[];for(let _ in t)m=m.concat(Ri({key:_,value:t[_],valueSpec:c[_],style:d,styleSpec:o}));return m}return h.$(t)?[]:[new Ve("projection",t,`object or string expected, ${h.J(t)} found`)]},import:function(a){let t=a.key,{value:o,styleSpec:c}=a;if(!h.G(o))return[new Ve(t,o,"import must be an object")];let{data:d,...m}=o;Object.defineProperty(m,"__line__",{value:o.__line__,enumerable:!1});let _=Sn(Object.assign({},a,{value:m,valueSpec:c.import}));return h.H(m.id)===""&&_.push(new Ve(`${a.key}.id`,m,"import id can't be an empty string")),d&&(_=_.concat(Fh(d,c,{key:`${a.key}.data`}))),_},iconset:function(a){let t=a.value,o=a.key,c=a.styleSpec,d=a.style;if(!h.G(t))return[new Ve(o,t,"object expected")];if(!t.type)return[new Ve(o,t,'"type" is required')];let m=h.H(t.type),_=[];if(_=_.concat(Sn({key:o,value:t,valueSpec:c[`iconset_${m}`],style:d,styleSpec:c})),function(y,v){return!(y!=="source"||!v.source)}(m,t)){let y=d.sources&&d.sources[t.source],v=y&&h.H(y.type);y?v!=="raster-array"&&_.push(new Ve(o,t.source,`iconset cannot be used with a source of type ${String(v)}, it only be used with a "raster-array" source type`)):_.push(new Ve(o,t.source,`source "${t.source}" not found`))}return _}};function Ri(a,t=!1){let o=a.value,c=a.valueSpec,d=a.styleSpec;if(c.expression){if(h.a4(h.H(o)))return Bt(a);if(h.Q(h.S(o)))return ni(a)}if(c.type&&pu[c.type]){let m=pu[c.type](a);return t===!0&&m.length>0&&Array.isArray(a.value)?ni(a):m}return Sn(Object.assign({},a,{valueSpec:c.type?d[c.type]:c}))}function Sn(a){let t=a.key,o=a.value,c=a.valueSpec||{},d=a.objectElementValidators||{},m=a.style,_=a.styleSpec;if(!h.G(o))return[new Ve(t,o,`object expected, ${h.J(o)} found`)];let y=[];for(let v in o){let T=v.split(".")[0],E;d[T]?E=d[T]:c[T]?E=Ri:d["*"]?E=d["*"]:c["*"]&&(E=Ri),E?y=y.concat(E({key:(t&&`${t}.`)+v,value:o[v],valueSpec:c[T]||c["*"],style:m,styleSpec:_,object:o,objectKey:v},o)):y.push(new Gt(t,o[v],`unknown property "${v}"`))}for(let v in c){if(d[v])continue;let T=c[v];T.required&&T.default===void 0&&o[v]===void 0&&y.push(new Ve(t,o,`missing required property "${v}"`))}return y}function cc({key:a,value:t}){let o=Fr({key:a,value:t});if(o.length)return o;let c=t;return c.includes("{fontstack}")||o.push(new Ve(a,t,'"glyphs" url must include a "{fontstack}" token')),c.includes("{range}")||o.push(new Ve(a,t,'"glyphs" url must include a "{range}" token')),o}function Fh(a,t=h.a6,o={}){return Sn({key:o.key||"",value:a,valueSpec:Object.assign({},t.$root,{"*":{type:"*"}}),styleSpec:t,style:a,objectElementValidators:{glyphs:cc}})}function yn(a,t=h.a6){return qn(Fh(a,t))}let Yp=a=>qn(di(a)),Bh=a=>qn(bs(a)),Jp=a=>qn(tl(a)),Kp=a=>qn(du(a)),Qp=a=>qn(lc(a)),ef=a=>qn(function(t){let o=t.value,c=t.style,d=t.styleSpec,m=d.snow;if(o===void 0)return[];if(!h.G(o))return[new Ve("snow",o,`object expected, ${h.J(o)} found`)];let _=[];for(let y in o){let v=y.match(h.a3);_=_.concat(v&&m[v[1]]&&m[v[1]].transition?Ri({key:y,value:o[y],valueSpec:d.transition,style:c,styleSpec:d}):m[y]?Ri({key:y,value:o[y],valueSpec:m[y],style:c,styleSpec:d}):[new Gt(y,o[y],`unknown property "${y}"`)])}return _}(a)),Yo=a=>qn(function(t){let o=t.value,c=t.style,d=t.styleSpec,m=d.rain;if(o===void 0)return[];if(!h.G(o))return[new Ve("rain",o,`object expected, ${h.J(o)} found`)];let _=[];for(let y in o){let v=y.match(h.a3);_=_.concat(v&&m[v[1]]&&m[v[1]].transition?Ri({key:y,value:o[y],valueSpec:d.transition,style:c,styleSpec:d}):m[y]?Ri({key:y,value:o[y],valueSpec:m[y],style:c,styleSpec:d}):[new Gt(y,o[y],`unknown property "${y}"`)])}return _}(a)),tf=a=>qn(Ln(a)),fa=a=>qn(Ci(a)),kh=a=>qn(Nn(a)),Nh=a=>qn(gn(a)),uc=a=>
8qn(pa(a));function qn(a){return a.slice().sort((t,o)=>t.line&&o.line?t.line-o.line:0)}function ma(a,t){let o=!1;if(t&&t.length)for(let c of t)c instanceof Gt?h.w(c.message):(a.fire(new h.y(new Error(c.message))),o=!0);return o}let hc=h.a6.light,Uh;class Vh extends h.E{constructor(t,o="flat"){super(),this._transitionable=new h.a7(Uh||(Uh=new h.a8({anchor:new h.a9(hc.anchor),position:new h.aa(hc.position),color:new h.a9(hc.color),intensity:new h.a9(hc.intensity)}))),this.setLight(t,o),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,o,c={}){this._validate(Bh,t,c)||(this._transitionable.setTransitionOrValue(t),this.id=o)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,o,c){return(!c||c.validate!==!1)&&ma(this,t.call(yn,Object.assign({value:o,style:{glyphs:!0,sprite:!0},styleSpec:h.a6})))}}let ws=h.a6.terrain,jh=class extends h.E{constructor(a,t,o,c,d){super(),this.scope=o,this._transitionable=new h.a7(new h.a8({source:new h.a9(ws.source),exaggeration:new h.a9(ws.exaggeration)}),o,c),this._transitionable.setTransitionOrValue(a,c),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t,this.worldview=d}get(){return this._transitionable.serialize()}set(a,t){this._transitionable.setTransitionOrValue(a,t)}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}getExaggeration(a){return this._transitioning.possiblyEvaluate(new h.ab(a,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;let a=this._transitionable._values.exaggeration;if(!a)return null;let t=a.value.expression;if(!t)return null;let o=-1,c=-1,d=1;for(let m of t.zoomStops)d=t.evaluate(new h.ab(m,{worldview:this.worldview})),d>.01?(o=m,c=-1):c=m;return d<.01&&o>0&&c>o?[o,c]:null}isZoomDependent(){let a=this._transitionable._values.exaggeration;return a!=null&&a.value!=null&&a.value.expression!=null&&a.value.expression instanceof h.ac}},Ts=.05;function il(a,t,o){let c=h.ag(45,65,o),[d,m]=a.range,_=1-Math.min(1,Math.exp((t-d)/(m-d)*-6));return _*=_*_,_=Math.min(1,1.00747*_),_*c*a.alpha}function nf(a,t,o,c,d){let m=h.ae([],[t,o,c],d.mercatorFogMatrix);return il(a,h.af(m),d.pitch)}function rf(a,t,o,c,d,m,_){let y=[[o,c,0],[d,c,0],[d,m,0],[o,m,0]],v=Number.MAX_VALUE,T=-Number.MAX_VALUE;for(let E of y){let P=h.ae([],E,t),A=h.af(P);v=Math.min(v,A),T=Math.max(T,A)}return[il(a,v,_.pitch),il(a,T,_.pitch)]}let Br=h.a6.fog;class of extends h.E{constructor(t,o,c,d){super();let m=new h.a8({range:new h.a9(Br.range),color:new h.a9(Br.color),"color-use-theme":new h.a9({type:"string","property-type":"data-constant",default:"default"}),"high-color":new h.a9(Br["high-color"]),"high-color-use-theme":new h.a9({type:"string","property-type":"data-constant",default:"default"}),"space-color":new h.a9(Br["space-color"]),"space-color-use-theme":new h.a9({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new h.a9(Br["horizon-blend"]),"star-intensity":new h.a9(Br["star-intensity"]),"vertical-range":new h.a9(Br["vertical-range"])});this._transitionable=new h.a7(m,c,d),this.set(t,d),this._transitioning=this._transitionable.untransitioned(),this._transform=o,this.properties=new h.ah(m),this.scope=c}get state(){let t=this._transform,o=t.projection.name==="globe",c=h.ai(t.zoom),d=this.properties.get("range"),m=[2,4.5],_=.5/Math.tan(.5*t._fov),y=[d[0]+_,d[1]+_];return{range:o?[h.aj(m[0],y[0],c),h.aj(m[1],y[1],c)]:y,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,o,c={}){if(this._validate(Qp,t,c))return;let d=Object.assign({},t);for(let m of Object.keys(Br))d[m]===void 0&&(d[m]=Br[m].default);this._options=d,this._transitionable.setTransitionOrValue(this._options,o)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;let o=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:h.ag(45,65,t))*o.a}getOpacityAtLatLng(t,o){return this._transform.projection.supportsFog?function(c,d,m){let _=h.ad.fromLngLat(d),y=m.elevation?m.elevation.getAtPointOrZero(_):0;return nf(c,_.x,_.y,y,m)}(this.state,t,o):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];let o=this._transform.calculateFogTileMatrix(t.toUnwrapped());return rf(this.state,o,0,0,h.ak,h.ak,this._transform)}getOpacityForBounds(t,o,c,d,m){return this._transform.projection.supportsFog?rf(this.state,t,o,c,d,m,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;let o=[4,5,6,7];for(let c of o){let d=t.points[c],m;if(d[2]>=0)m=d;else{let _=t.points[c-4];m=h.al(_,d,_[2]/(_[2]-d[2]))}if(nf(this.state,m[0],m[1],0,this._transform)>=Ts)return!0}return!1}updateConfig(t){this._transitionable.setTransitionOrValue(this._options,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,o,c){return(!c||c.validate!==!1)&&ma(this,t.call(yn,Object.assign({value:o,style:{glyphs:!0,sprite:!0},styleSpec:h.a6})))}}let nl,sf,fu=class extends h.E{constructor(a,t,o,c){super();let d=nl||(nl=new h.a8({density:new h.a9(h.a6.snow.density),intensity:new h.a9(h.a6.snow.intensity),color:new h.a9(h.a6.snow.color),opacity:new h.a9(h.a6.snow.opacity),vignette:new h.a9(h.a6.snow.vignette),"vignette-color":new h.a9(h.a6.snow["vignette-color"]),"center-thinning":new h.a9(h.a6.snow["center-thinning"]),direction:new h.a9(h.a6.snow.direction),"flake-size":new h.a9(h.a6.snow["flake-size"])}));this._transitionable=new h.a7(d,o,c),this.set(a,c),this._transitioning=this._transitionable.untransitioned(),this.properties=new h.ah(d),this.scope=o}get state(){let a=this.properties.get("opacity"),t=this.properties.get("color"),o=this.properties.get("direction"),c=h.am(o[0]),d=-Math.max(h.am(o[1]),.01),m=[Math.cos(c)*Math.cos(d),Math.sin(c)*Math.cos(d),Math.sin(d)],_=this.properties.get("vignette"),y=this.properties.get("vignette-color");return y.a=_,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new h.C(t.r,t.g,t.b,t.a*a),direction:m,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:y}}get(){return this._transitionable.serialize()}set(a,t,o={}
8){if(this._validate(ef,a,o))return;let c=Object.assign({},a),d=h.a6.snow;for(let m of Object.keys(d))c[m]===void 0&&(c[m]=d[m].default);this._options=c,this._transitionable.setTransitionOrValue(this._options,t)}updateConfig(a){this._transitionable.setTransitionOrValue(this._options,a)}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}_validate(a,t,o){return(!o||o.validate!==!1)&&ma(this,a.call(yn,Object.assign({value:t,style:{glyphs:!0,sprite:!0},styleSpec:h.a6})))}},dc=class extends h.E{constructor(a,t,o,c){super();let d=sf||(sf=new h.a8({density:new h.a9(h.a6.rain.density),intensity:new h.a9(h.a6.rain.intensity),color:new h.a9(h.a6.rain.color),opacity:new h.a9(h.a6.rain.opacity),vignette:new h.a9(h.a6.rain.vignette),"vignette-color":new h.a9(h.a6.rain["vignette-color"]),"center-thinning":new h.a9(h.a6.rain["center-thinning"]),direction:new h.a9(h.a6.rain.direction),"droplet-size":new h.a9(h.a6.rain["droplet-size"]),"distortion-strength":new h.a9(h.a6.rain["distortion-strength"])}));this._transitionable=new h.a7(d,o,c),this.set(a,c),this._transitioning=this._transitionable.untransitioned(),this.properties=new h.ah(d),this.scope=o}get state(){let a=this.properties.get("opacity"),t=this.properties.get("color"),o=this.properties.get("direction"),c=h.am(o[0]),d=-Math.max(h.am(o[1]),.01),m=[Math.cos(c)*Math.cos(d),Math.sin(c)*Math.cos(d),Math.sin(d)],_=this.properties.get("vignette-color");return _.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new h.C(t.r,t.g,t.b,t.a*a),direction:m,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:_}}get(){return this._transitionable.serialize()}set(a,t,o={}){if(this._validate(Yo,a,o))return;let c=Object.assign({},a),d=h.a6.rain;for(let m of Object.keys(d))c[m]===void 0&&(c[m]=d[m].default);this._options=c,this._transitionable.setTransitionOrValue(this._options,t)}updateConfig(a){this._transitionable.setTransitionOrValue(this._options,a)}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}_validate(a,t,o){return(!o||o.validate!==!1)&&ma(this,a.call(yn,Object.assign({value:t,style:{glyphs:!0,sprite:!0},styleSpec:h.a6})))}},to={workerUrl:"",workerClass:null,workerParams:void 0};function af(a){return to.workerClass!=null?new to.workerClass:new self.Worker(to.workerUrl,Object.assign({name:a},to.workerParams))}let mu="mapboxgl_preloaded_worker_pool";class Ss{constructor(t){this.active={},this.name=t}acquire(t,o=Ss.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<o;){let c=af(`${this.name||""}WorkerPool: ${t}-${this.workers.length}`);this.workers.push(c)}return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.workers&&this.numActive()===0&&(this.workers.forEach(o=>{o.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[mu]}numActive(){return Object.keys(this.active).length}}Ss.workerCount=2;class Es{constructor(t,o,c="Worker",d=Ss.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=h.an();let m=this.workerPool.acquire(this.id,d);for(let _=0;_<m.length;_++){let y=new Es.Actor(m[_],o,this.id);y.name=`${c} ${_}`,this.actors.push(y)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(t,o,c){h.ao(this.actors,(d,m)=>{d.send(t,o,m)},c=c||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(t=>{t.remove()}),this.actors=[],this.workerPool.release(this.id)}}Es.Actor=h.ap;class Gh extends h.E{constructor(t,o,c,d){super(),this.scope=c,this._options=t,this.properties=new h.ah(o),this._transitionable=new h.a7(o,c,d),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(t){this._transitionable.setTransitionOrValue(this._options.properties,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(t,o){this._options=t,this._transitionable.setTransitionOrValue(t.properties,o)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}let Hh,z_=()=>Hh||(Hh=new h.a8({color:new h.a9(h.a6.properties_light_ambient.color),"color-use-theme":new h.a9({type:"string",default:"default","property-type":"data-constant"}),intensity:new h.a9(h.a6.properties_light_ambient.intensity)})),pc,Jo=()=>pc||(pc=new h.a8({direction:new h.aq(h.a6.properties_light_directional.direction),color:new h.a9(h.a6.properties_light_directional.color),"color-use-theme":new h.a9({type:"string",default:"default","property-type":"data-constant"}),intensity:new h.a9(h.a6.properties_light_directional.intensity),"cast-shadows":new h.a9(h.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new h.a9(h.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new h.a9(h.a6.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new h.a9(h.a6.properties_light_directional["shadow-draw-before-layer"])}));class rl{constructor(t,o,c){this.screenBounds=t,this.cameraPoint=c.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=o,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,c)}static createFromScreenPoints(t,o){let c,d;if(t instanceof h.P||typeof t[0]=="number"){let m=h.P.convert(t);c=[m],d=o.isPointAboveHorizon(m)}else{let m=h.P.convert(t[0]),_=h.P.convert(t[1]),y=m.add(_)._div(2);c=[m,_],d=h.ar(m,_).every(v=>o.isPointAboveHorizon(v))&&o.isPointAboveHorizon(y)}return new rl(c,d,o)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(t){return h.ar(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){let o=this.screenBounds[0],c=this.screenBounds.length===1?this.screenBounds[0].add(new h.P(1,1)):this.screenBounds[1],d=h.ar(o,c,0,!1);return this.cameraPoint.y>c.y&&(this.cameraPoint.x>o.x&&this.cameraPoint.x<c.x?d.splice(3,0,this.cameraPoint):this.cameraPoint.x>=c.x?d[2]=this.cameraPoint:this.cameraPoint.x<=o.x&&(d[3]=this.cameraPoint)),h.as(d,t)}bufferedCameraGeometryGlobe(t){let o=this.screenBounds[0],c=this.screenBounds.length===1?this.screenBounds[0].add(new h.P(1,1)):this.screenBounds[1],d=h.ar(o,c,t),m=this.cameraPoint.clone(),_=+(m.x>o.x)+ +(m.x>c.x);switch(3*(+(m.y>o.y)+ +(m.y>c.y))+_){case 0:d[0]=m,d[4]=m.clone();break;case 1:d.splice(1,0,m);break;case 2:d[1]=m;break;case 3:d.splice(4,0,m);break;case 5:d.splice(2,0,m);break;case 6:d[3]=m;break;case 7:d.splice(3,0,m);break;case 8:d[2]=m}return d}containsTile(t,o,c,d=0){let m=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/o._pixelsPerMercatorPixel+1,_=c?this._bufferedCameraMercator(m,o):this._bufferedScreenMercator(m,o),y=t.t
8ileID.wrap+(_.unwrapped?d:0),v=_.polygon.map(k=>h.at(t.tileTransform,k,y));if(!h.au(v,0,0,h.ak,h.ak))return;y=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?d:0);let T=this.screenGeometryMercator.polygon.map(k=>h.av(t.tileTransform,k,y)),E=T.map(k=>new h.P(k[0],k[1])),P=o.getFreeCameraOptions().position||new h.ad(0,0,0),A=h.av(t.tileTransform,P,y),D=T.map(k=>{let N=h.aw(k,k,A);return h.ax(N,N),new h.ay(A,N)}),z=h.az(t,1,o.zoom)*o._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:E,tilespaceRays:D,bufferedTilespaceGeometry:v,bufferedTilespaceBounds:(O=h.aA(v),O.min.x=h.aB(O.min.x,0,h.ak),O.min.y=h.aB(O.min.y,0,h.ak),O.max.x=h.aB(O.max.x,0,h.ak),O.max.y=h.aB(O.max.y,0,h.ak),O),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:z};var O}_bufferedScreenMercator(t,o){let c=ol(t);if(this._screenRaycastCache[c])return this._screenRaycastCache[c];{let d;return d=o.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(t),o):{polygon:this.bufferedScreenGeometry(t).map(m=>o.pointCoordinate3D(m)),unwrapped:!0},this._screenRaycastCache[c]=d,d}}_bufferedCameraMercator(t,o){let c=ol(t);if(this._cameraRaycastCache[c])return this._cameraRaycastCache[c];{let d;return d=o.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),o):{polygon:this.bufferedCameraGeometry(t).map(m=>o.pointCoordinate3D(m)),unwrapped:!0},this._cameraRaycastCache[c]=d,d}}_projectAndResample(t,o){let c=function(m,_){let y=h.aC([],_.pixelMatrix,_.globeMatrix),v=[0,-h.aE,0,1],T=[0,h.aE,0,1],E=[0,0,0,1];h.aD(v,v,y),h.aD(T,T,y),h.aD(E,E,y);let P=new h.P(v[0]/v[3],v[1]/v[3]),A=new h.P(T[0]/T[3],T[1]/T[3]),D=h.aF(m,P)&&v[3]<E[3],z=h.aF(m,A)&&T[3]<E[3];if(!D&&!z)return null;let O=function(K,J,oe){for(let ue=1;ue<K.length;ue++){let de=_a(J.pointCoordinate3D(K[ue-1]).x),be=_a(J.pointCoordinate3D(K[ue]).x);if(oe<0){if(de<be)return{idx:ue,t:-de/(be-1-de)}}else if(be<de)return{idx:ue,t:(1-de)/(be+1-de)}}return null}(m,_,D?-1:1);if(!O)return null;let{idx:k,t:N}=O,q=k>1?_u(m.slice(0,k),_):[],Z=k<m.length?_u(m.slice(k),_):[];q=q.map(K=>new h.P(_a(K.x),K.y)),Z=Z.map(K=>new h.P(_a(K.x),K.y));let G=[...q];G.length===0&&G.push(Z.at(-1));let re=G.at(-1),te=h.aj(re.y,(Z.length===0?q[0]:Z[0]).y,N),se;return se=D?[new h.P(0,te),new h.P(0,0),new h.P(1,0),new h.P(1,te)]:[new h.P(1,te),new h.P(1,1),new h.P(0,1),new h.P(0,te)],G.push(...se),Z.length===0?G.push(q[0]):G.push(...Z),{polygon:G.map(K=>new h.ad(K.x,K.y)),unwrapped:!1}}(t,o);if(c)return c;let d=function(m,_){let y=!1,v=-1/0,T=0;for(let P=0;P<m.length-1;P++)m[P].x>v&&(v=m[P].x,T=P);for(let P=0;P<m.length-1;P++){let A=(T+P)%(m.length-1),D=m[A],z=m[A+1];Math.abs(D.x-z.x)>.5&&(D.x<z.x?(D.x+=1,A===0&&(m.at(-1).x+=1)):(z.x+=1,A+1===m.length-1&&(m[0].x+=1)),y=!0)}let E=h.aG(_.center.lng);return y&&E<Math.abs(E-1)&&m.forEach(P=>{P.x-=1}),{polygon:m,unwrapped:y}}(_u(t,o).map(m=>new h.P(_a(m.x),m.y)),o);return{polygon:d.polygon.map(m=>new h.ad(m.x,m.y)),unwrapped:d.unwrapped}}}function _u(a,t){return h.aH(a,o=>{let c=t.pointCoordinate3D(o);o.x=c.x,o.y=c.y},1/256)}function _a(a){return a<0?1+a%1:a%1}function ol(a){return 100*a|0}function br(a,t){let o=Math.pow(2,t.z),c=Math.floor(h.aG(a.getWest())*o),d=Math.floor(h.aJ(a.getNorth())*o),m=Math.ceil(h.aG(a.getEast())*o),_=Math.ceil(h.aJ(a.getSouth())*o);return t.x>=c&&t.x<m&&t.y>=d&&t.y<_}class ga{constructor(t,o,c){this.bounds=t?h.aI.convert(this.validateBounds(t)):null,this.minzoom=o||0,this.maxzoom=c||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}addExtraBounds(t){if(t){this.extraBounds||(this.extraBounds=[]);for(let o of t)this.extraBounds.push(h.aI.convert(this.validateBounds(o)))}}contains(t){if(t.z>this.maxzoom||t.z<this.minzoom||this.bounds&&!br(this.bounds,t))return!1;if(!this.extraBounds)return!0;for(let o of this.extraBounds)if(br(o,t))return!0;return!1}static fromTileJSON(t){if(!t.bounds&&!t.extra_bounds)return null;let o=new ga(t.bounds,t.minzoom,t.maxzoom);return o.addExtraBounds(t.extra_bounds),o}}class gu extends h.E{constructor(t,o,c,d){if(super(),this.id=t,this.dispatcher=c,this.type="vector",this.provider=o.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,h.aK(o,["url","scheme","tileSize","promoteId"])),this._options=Object.assign({type:"vector"},o),this._collectResourceTiming=!!o.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(d),this._tileWorkers={},this._deduped=new h.aL}load(t){this._loaded=!1,this.fire(new h.z("dataloading",{dataType:"source"}));let o=Array.isArray(this.map._language)?this.map._language.join():this.map._language,c=this.map.getWorldview(),d=(_,y)=>{this._tileJSONRequest=null,this._loaded=!0,_?(o&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${o}`),c&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${c}`),this.fire(new h.y(_))):y&&(this._setTileJSON(y),hi(y.tiles,this.map._requestManager._customAccessToken),this.fire(new h.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(_)};this.provider=this._options.provider;let m=h.aM(this._options);return m instanceof Error?(this._loaded=!0,this.fire(new h.y(m)),void(t&&t())):this.provider&&!m?(this._loaded=!0,this.fire(new h.y(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=m?this.loadTileJSONWithProvider(m,d):h.aN(this._options,this.map._requestManager,o,c,d))}loadTileJSONWithProvider(t,o){this.provider=t.name;let{request:c,options:d}=h.aO(this._options,this.map._requestManager),m=new AbortController;return this.dispatcher.broadcast("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.t
8ype,options:d,request:c},(_,y)=>{if(m.signal.aborted)return;if(_)return void o(_);let v=y?y.find(E=>E!=null):null,T=h.aP(this._options,v,this.map._requestManager);T instanceof Error?o(T):o(null,T)}),{cancel:()=>m.abort()}}_setTileJSON(t){if(Object.assign(this,t),this.hasWorldviews=!!t.worldview_options,t.worldview_default&&(this.worldviewDefault=t.worldview_default),t.vector_layers){this.vectorLayers=t.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(let o of t.vector_layers)this.vectorLayerIds.push(o.id),t.worldview&&t.worldview[o.source]&&this.localizableLayerIds.add(o.id)}this.tileBounds=ga.fromTileJSON(t)}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();let t=h.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(t){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(t,o){let c=t.tileID.canonical.url(this.tiles,this.scheme),d=this.map._requestManager.normalizeTileURL(c),m=this.map._requestManager.transformRequest(d,h.R.Tile),_=this.map.style?this.map.style.getLut(this.scope):null,y=_?{image:_.image.clone()}:null,v={request:m,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:y,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.t
8ype,source:this.id,scope:this.scope,pixelRatio:h.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&h.e(c)&&(v.localizableLayerIds=this.localizableLayerIds),v.request.collectResourceTiming=this._collectResourceTiming,t.actor&&t.state!=="expired")t.state==="loading"?t.reloadCallback=o:t.request=t.actor.send("reloadTile",v,T.bind(this));else if(t.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)t.request=t.actor.send("loadTile",v,T.bind(this),void 0,!0);else{let E=h.aQ.call({deduped:this._deduped},v,(P,A)=>{if(P||!A)T.call(this,P);else{let D=h.aR(A.responseHeaders);v.data={rawData:A.rawData.slice(0),expires:D.expires,cacheControl:D.cacheControl},t.actor&&t.actor.send("loadTile",v,T.bind(this),void 0,!0)}},!0);t.request={cancel:E}}function T(E,P){return delete t.request,t.aborted?o(null):E?o(E):(P&&P.resourceTiming&&(t.resourceTiming=P.resourceTiming),this.map._refreshExpiredTiles&&P&&t.setExpiryData(P),t.loadVectorData(P,this.map.painter),h.aS(this.dispatcher),o(null,P),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.t
8ype,source:this.id,scope:this.scope})}unloadTile(t,o){t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope}),t.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class fc extends h.E{constructor(t,o,c,d){super(),this.id=t,this.dispatcher=c,this.setEventedParent(d),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},o),Object.assign(this,h.aK(o,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new h.z("dataloading",{dataType:"source"}));let o=this.map.getWorldview(),c=(m,_)=>{this._tileJSONRequest=null,this._loaded=!0,m?this.fire(new h.y(m)):_&&(Object.assign(this,_),_.raster_layers&&(this.rasterLayers=_.raster_layers,this.rasterLayerIds=this.rasterLayers.map(y=>y.id)),this.tileBounds=ga.fromTileJSON(_),hi(_.tiles),this.fire(new h.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(m)};this.provider=typeof this._options.provider=="string"?this._options.provider:void 0,this._tileProvider=void 0;let d=h.aM(this._options);return d instanceof Error?(this._loaded=!0,this.fire(new h.y(d)),void(t&&t())):this.provider&&!d?(this._loaded=!0,this.fire(new h.y(new Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=d?this.loadTileJSONWithProvider(d,c):h.aN(this._options,this.map._requestManager,null,o,c))}loadTileJSONWithProvider(t,o){this.provider=t.name;let{request:c,options:d}=h.aO(this._options,this.map._requestManager),m=new AbortController;return h.aT(t.name,t.url).then(_=>{if(m.signal.aborted)return;let y=new _(d);return y.load&&c?y.load({request:c}).then(v=>(this._tileProvider=y,v)):(this._tileProvider=y,null)}).then(_=>{if(m.signal.aborted)return;let y=h.aP(this._options,_,this.map._requestManager);y instanceof Error?o(y):o(null,y)}).catch(_=>{m.signal.aborted||o(_ instanceof Error?_:new Error(String(_)))}),{cancel:()=>m.abort()}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();let t=h.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(t){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,o){let c=h.o.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),c,this.tileSize),m=this.map._requestManager.transformRequest(d,h.R.Tile);if(this._tileProvider){let _=new AbortController;t.request={cancel:()=>_.abort()},this.loadTileWithProvider(t,this._tileProvider,m,_,o)}else t.request=h.n(m,(_,y,v)=>{if(delete t.request,t.aborted)return t.state="unloaded",o(null);if(_)return t.state="errored",o(_);if(!y)return o(null);let T=h.aR(v);this.map._refreshExpiredTiles&&t.setExpiryData(T),t.setTexture(y,this.map.painter),t.state="loaded",h.aS(this.dispatcher),o(null)})}async loadTileWithProvider(t,o,c,d,m){let{z:_,x:y,y:v}=t.tileID.canonical;try{let T=await o.loadTile({z:_,x:y,y:v},{request:c,signal:d.signal});if(d.signal.aborted)return t.state="unloaded",m(null);if(T==null){let P=new Error("Tile not found");return P.status=404,t.state="errored",m(P)}if(T.data==null)return t.state="loaded",m(null);let E=await createImageBitmap(new Blob([T.data]));if(d.signal.aborted)return t.state="unloaded",m(null);t.setTexture(E,this.map.painter),t.state="loaded",this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:T.cacheControl,expires:T.expires}),m(null)}catch(T){if(d.signal.aborted||T instanceof DOMException&&T.name==="AbortError")return t.state="unloaded",m(null);t.state="errored",m(T instanceof Error?T:new Error(String(T)))}finally{delete t.request}}abortTile(t,o){t.request&&(t.request.cancel(),delete t.request),o&&o()}unloadTile(t,o){t.texture&&t.texture instanceof h.T?(t.destroy(!1),t.texture&&t.texture instanceof h.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),o&&o()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function mt([a,t],o,c,{scaled:d=!0}={}){let{tileSize:m,buffer:_}=c,{x:y,y:v,z:T}=o;if(!isFinite(y)||!isFinite(v)||!isFinite(T))throw new Error("Invalid MRT header");let E=2**T,P=E*h.aG(a),A=E*h.aJ(t);return function([D,z],O,{scaled:k=!0}
8={}){if(!O)throw new Error("bandView is undefined");let{data:N,tileSize:q,buffer:Z,offset:G,scale:re,dimension:te}=O;if(D<-Z||D>q+Z||z<-Z||z>q+Z)throw new Error(`Point (${D}, ${z}) out of bounds for tileSize=${q}, buffer=${Z}`);let se=(z+Z)*(q+2*Z)+(D+Z);if(new Uint32Array(N.buffer)[se]===4294967295)return null;let K=[];K=k?[]:new O.data.constructor(te);for(let J=0;J<te;J++)K[J]=Math.round(1e12*(N[te*se+J]*re+G))/1e12;return K}([Math.min(Math.max(-_,Math.floor((P-y)*m)),m-1+_),Math.min(Math.max(-_,Math.floor((A-v)*m)),m-1+_)],c,{scaled:d})}class Ht extends fc{constructor(t,o,c,d){super(t,o,c,d),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options=Object.assign({type:"raster-array"},o)}triggerRepaint(t){let o=this.map.painter._terrain,c=this.map.style.getSourceCache(this.id);o&&o.enabled&&c&&o._clearRenderCacheForTile(c.id,t.tileID),this.map.triggerRepaint()}loadTile(t,o){let c=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),d=this.map._requestManager.transformRequest(c,h.R.Tile),m={request:d,uid:t.uid,tileID:t.tileID,type:this.t
8ype,source:this.id,scope:this.scope,partial:this.partial};t.source=this.id,t.scope=this.scope,t.requestParams=d,t.actor||(t.actor=this.dispatcher.getActor());let _=(y,v,T)=>{if(delete t.request,t.aborted)return t.state="unloaded",o(null);if(y)return y.name==="AbortError"?void 0:(t.state="errored",o(y));if(this.map._refreshExpiredTiles&&v){let E=h.aR(T);t.setExpiryData(E)}if(this.partial&&t.state!=="expired")t.state="empty";else if(!this.partial){if(!v)return o(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=v}o(null)};t.request=this.partial?t.fetchHeader(void 0,_.bind(this)):t.actor.send("loadTile",m,_.bind(this),void 0,!0)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(t,o){let c=t.texturePerLayer;if(t.flushAllQueues(),c.size){t.destroy(!1);for(let d of c.values())this.map.painter.saveTileTexture(d)}else t.destroy()}prepareTile(t,o,c,d){t._isHeaderLoaded&&(t.state!=="empty"&&(t.state="reloading"),t.fetchBandForRender(o,c,d,(m,_)=>{m?(t.state="errored",this.fire(new h.y(m))):_&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(c,_,this.map.painter),t.state="loaded"),this.triggerRepaint(t)}))}getInitialBand(t){if(!this.rasterLayers)return 0;let o=this.rasterLayers.find(({id:m})=>m===t),c=o&&o.fields,d=c&&c.bands&&c.bands;return d?d[0]:0}getTextureDescriptor(t,o,c){if(!t)return;let d=o.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!d)return;let m=null;o instanceof h.aV?m=o.paint.get("raster-array-band"):o instanceof h.aW&&(m=o.paint.get("raster-particle-array-band"));let _=m||this.getInitialBand(d);if(_==null)return;if(!t.textureDescriptorPerLayer.get(o.id))return void this.prepareTile(t,d,o.id,_);
8if(t.updateNeeded(o.id,_)&&!c)return;let y=t.textureDescriptorPerLayer.get(o.id);return Object.assign({},y,{texture:t.texturePerLayer.get(o.id)})}getImages(t,o){let c=new Map;for(let d of t)for(let m of o){let[_,y]=m.split("/"),v=d.getLayer(_);if(!v||!v.hasBand(y)||!v.hasDataForBand(y))continue;let{bytes:T,tileSize:E,buffer:P}=v.getBandView(y),A=E+2*P,D={data:new h.q({width:A,height:A},T),pixelRatio:2,sdf:!1,usvg:!1,version:0};c.set(m,D)}return c}queryRasterArrayValueByBandId(t,o,c){let d=o._mrt;return new Promise(m=>{let _={},y=new Set;for(let[v,T]of Object.entries(d.layers)){if(c.layerName&&v!==c.layerName)continue;let E={};_[v]=E;for(let{bands:P}of T.dataIndex)for(let A of P)c.bands&&!c.bands.includes(A)||(y.add(h.t(v,A)),o.fetchBand(v,null,A,D=>{h.o.frame(()=>{E[A]=D?null:mt([t.lng,t.lat],d,T.getBandView(A)),y.delete(h.t(v,A)),y.size===0&&m(_)})},!1))}y.size===0&&m(_)})}_loadTileForQuery(t,o){if(this._loadTileLoaded[t.uid])return void o(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(o);this._loadTilePending[t.uid]=[o];let c=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),d=this.map._requestManager.transformRequest(c,h.R.Tile);t.actor.send("loadTile",{request:d,uid:t.uid,tileID:t.tileID,type:this.t
8ype,source:this.id,scope:this.scope,partial:!1},(m,_,y)=>{if(m)return this._loadTilePending[t.uid].forEach(v=>v(m,null)),void delete this._loadTilePending[t.uid];if(!_)return this._loadTilePending[t.uid].forEach(v=>v(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&_){let v=h.aR(y);t.setExpiryData(v)}t._mrt=_,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(v=>v(null,_)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid]},void 0,!0)}queryRasterArrayValueByAllBands(t,o,c){return new Promise((d,m)=>{this._loadTileForQuery(o,(_,y)=>{_?m(_):d(y?this.queryRasterArrayValueByBandId(t,o,c):null)})})}queryRasterArrayValue(t,o){let c=h.aX.convert(t),d=this.findLoadedParent(c);return d&&d._mrt?o.bands||!this.partial?this.queryRasterArrayValueByBandId(c,d,o):this.queryRasterArrayValueByAllBands(c,d,o):Promise.resolve(null)}findLoadedParent(t){let o=h.ad.fromLngLat(t,this.map.transform.tileSize),c=this.maxzoom+1,d=1<<c,m=Math.floor(o.x),_=Math.floor((o.x-m)*d),y=Math.floor(o.y*d),v=this.map.style.getSourceCache(this.id),T=new h.aU(c,m,c,_,y);return v.findLoadedParent(T,this.minzoom)}}let yu={vector:gu,raster:fc,"raster-dem":class extends fc{constructor(a,t,o,c){super(a,t,o,c),this.type="raster-dem",this.maxzoom=22,this._options=Object.assign({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTileJSONWithProvider(a,t){this.provider=a.name;let{request:o,options:c}=h.aO(this._options,this.map._requestManager),d=new AbortController;return this.dispatcher.broadcast("loadTileProvider",{name:a.name,url:a.url,source:this.id,scope:this.scope,type:this.type,options:c,request:o},(m,_)=>{if(d.signal.aborted)return;if(m)return void t(m);let y=_?_.find(T=>T!=null):null,v=h.aP(this._options,y,this.map._requestManager);v instanceof Error?t(v):t(null,v)}),{cancel:()=>d.abort()}}loadTile(a,t){let o=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),c=this.map._requestManager.transformRequest(o,h.R.Tile),d={uid:a.uid,tileID:a.tileID,source:this.id,type:this.t
8ype,scope:this.scope,request:c,encoding:this.encoding};a.actor&&a.state!=="expired"||(a.actor=this.dispatcher.getActor(),a.request=a.actor.send("loadTile",d,function(m,_){return delete a.request,a.aborted?(a.state="unloaded",t(null)):m?(a.state="errored",t(m)):(_&&(this.map._refreshExpiredTiles&&a.setExpiryData(_),_.borderReady||a.neighboringTiles||(a.neighboringTiles=this._getNeighboringTiles(a.tileID)),a.dem=_.dem,a.dem.onDeserialize(),a.needsHillshadePrepare=!0,a.needsDEMTextureUpload=!0),a.state="loaded",void t(null))}.bind(this),void 0,!0))}abortTile(a,t){a.request&&(a.request.cancel(),delete a.request),a.actor&&a.actor.send("abortTile",{uid:a.uid,type:this.type,source:this.id,scope:this.scope}),t&&t()}_getNeighboringTiles(a){let t=a.canonical,o=Math.pow(2,t.z),c=(t.x-1+o)%o,d=t.x===0?a.wrap-1:a.wrap,m=(t.x+1+o)%o,_=t.x+1===o?a.wrap+1:a.wrap,y={};return y[new h.aU(a.overscaledZ,d,t.z,c,t.y).key]={backfilled:!1},y[new h.aU(a.overscaledZ,_,t.z,m,t.y).key]={backfilled:!1},t.y>0&&(y[new h.aU(a.overscaledZ,d,t.z,c,t.y-1).key]={backfilled:!1},y[new h.aU(a.overscaledZ,a.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},y[new h.aU(a.overscaledZ,_,t.z,m,t.y-1).key]={backfilled:!1}),t.y+1<o&&(y[new h.aU(a.overscaledZ,d,t.z,c,t.y+1).key]={backfilled:!1},y[new h.aU(a.overscaledZ,a.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},y[new h.aU(a.overscaledZ,_,t.z,m,t.y+1).key]={backfilled:!1}),y}},"raster-array":Ht,geojson:class extends h.E{constructor(a,t,o,c){super(),this.id=a,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=o.getActor(),this.setEventedParent(c),this._data=t.data,this._options=Object.assign({},t),this._collectResourceTiming=t.collectResourceTiming,t.maxzoom!==void 0&&(this.maxzoom=t.maxzoom),t.minzoom!==void 0&&(this.minzoom=t.minzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;let d=h.ak/this.tileSize;this.workerOptions=Object.assign({source:this.id,scope:this.scope,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(t.buffer!==void 0?t.buffer:128)*d,tolerance:(t.tolerance!==void 0?t.tolerance:.375)*d,extent:h.ak,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:t.clusterMaxZoom!==void 0?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:h.ak,radius:(t.clusterRadius!==void 0?t.clusterRadius:50)*d,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter,dynamic:t.dynamic},t.workerOptions)}onAdd(a){this.map=a,this.setData(this._data)}setData(a){return this._data=a,this._updateWorkerData(),this}
8updateData(a){if(!this._options.dynamic)return this.fire(new h.y(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if(typeof a!="string"&&(a.type==="Feature"&&(a={type:"FeatureCollection",features:[a]}),a.type!=="FeatureCollection"))return this.fire(new h.y(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&typeof a!="string"&&typeof this._data!="string"&&this._data.type==="FeatureCollection"){let t=new Map;for(let o of this._data.features)t.set(o.id,o);for(let o of a.features)t.set(o.id,o);this._data.features=[...t.values()]}else this._data=a;return this._updateWorkerData(!0),this}getClusterExpansionZoom(a,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:a,source:this.id,scope:this.scope},t),this}getClusterChildren(a,t){return this.actor.send("geojson.getClusterChildren",{clusterId:a,source:this.id,scope:this.scope},t),this}getClusterLeaves(a,t,o,c){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:a,limit:t,offset:o},c),this}_updateWorkerData(a=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new h.z("dataloading",{dataType:"source"})),this._loaded=!1;let t=Object.assign({append:a},this.workerOptions);t.scope=this.scope;let o=this._data;typeof o=="string"?(t.request=this.map._requestManager.transformRequest(h.o.resolveURL(o),h.R.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(o),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,(c,d)=>{if(this._loaded=!0,this._pendingLoad=null,c)this.fire(new h.y(c));else{let m={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&d&&d.resourceTiming&&d.resourceTiming[this.id]&&(m.resourceTiming=d.resourceTiming[this.id]),a&&(this._partialReload=!0),this.fire(new h.z("data",m)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(a),this._coalesce=!1)})}loaded(){return this._loaded}reload(){let a=h.t(this.id,this.scope);this.map.style.clearSource(a),this._updateWorkerData()}loadTile(a,t){let o=a.actor?"reloadTile":"loadTile";a.actor=this.actor;let c=this.map.style?this.map.style.getLut(this.scope):null,d=c?{image:c.image.clone()}:null,m=this._partialReload,_={type:this.type,uid:a.uid,tileID:a.tileID,tileZoom:a.tileZoom,zoom:a.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:d,scope:this.scope,pixelRatio:h.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:a.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:m,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};a.request=this.actor.send(o,_,(y,v)=>m&&!v?(a.state="loaded",t(null)):(delete a.request,a.destroy(!1),a.aborted?t(null):y?t(y):(a.loadVectorData(v,this.map.painter,o==="reloadTile"),t(null))),void 0,o==="loadTile")}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.aborted=!0}unloadTile(a,t){this.actor.send("removeTile",{uid:a.uid,type:this.t
8ype,source:this.id,scope:this.scope}),a.destroy()}onRemove(a){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends h.aY{constructor(a,t,o,c){super(a,t,o,c),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;let a=this.options;this.urls=[];for(let t of a.urls)this.urls.push(this.map._requestManager.transformRequest(t,h.R.Source).url);h.aZ(this.urls,(t,o)=>{this._loaded=!0,t?this.fire(new h.y(t)):o&&(this.video=o,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(a){if(this.video){let t=this.video.seekable;a<t.start(0)||a>t.end(0)?this.fire(new h.y(new Ve(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=a}}getVideo(){return this.video}
8onAdd(a){this.map||(this.map=a,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;let a=this.map.painter.context,t=a.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new h.T(a,this.video,t.RGBA8),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(a)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:h.aY,model:h.a$,"batched-model":class extends h.E{constructor(a,t,o,c){super(),this.type="batched-model",this.id=a,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=o,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(c)}onAdd(a){this.map=a,this.load()}reload(){this.cancelTileJSONRequest();let a=h.t(this.id,this.scope);this.load(()=>this.map.style.clearSource(a))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(a){this._loaded=!1,this.fire(new h.z("dataloading",{dataType:"source"}));let t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=h.aN(this._options,this.map._requestManager,t,o,(c,d)=>{this._tileJSONRequest=null,this._loaded=!0,c?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),o&&o.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new h.y(c))):d&&(Object.assign(this,d),d.bounds&&(this.tileBounds=new ga(d.bounds,this.minzoom,this.maxzoom)),hi(d.tiles,this.map._requestManager._customAccessToken),this.fire(new h.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))),a&&a(c)})}hasTransition(){return!1}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loaded(){return this._loaded}loadTile(a,t){let o=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme)),c={request:this.map._requestManager.transformRequest(o,h.R.Tile),data:void 0,uid:a.uid,tileID:a.tileID,tileZoom:a.tileZoom,zoom:a.tileID.overscaledZ,tileSize:this.tileSize*a.tileID.overscaleFactor(),type:this.t
8ype,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:a.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:h.o.devicePixelRatio,promoteId:this.promoteId};if(a.actor&&a.state!=="expired")if(a.state==="loading")a.reloadCallback=t;else{if(a.buckets){let m=Object.values(a.buckets);for(let _ of m)_.dirty=!0;return void(a.state="loaded")}a.request=a.actor.send("reloadTile",c,d.bind(this))}else a.actor=this.dispatcher.getActor(),a.request=a.actor.send("loadTile",c,d.bind(this),void 0,!0);function d(m,_){return a.aborted?t(null):m&&m.status!==404?t(m):(this.map._refreshExpiredTiles&&_&&a.setExpiryData(_),a.loadModelData(_,this.map.painter),a.state="loaded",void t(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends h.aY{constructor(a,t,o,c){super(a,t,o,c),t.coordinates?Array.isArray(t.coordinates)&&t.coordinates.length===4&&!t.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(m=>typeof m!="number"))||this.fire(new h.y(new Ve(`sources.${a}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new h.y(new Ve(`sources.${a}`,null,'missing required property "coordinates"'))),t.animate&&typeof t.animate!="boolean"&&this.fire(new h.y(new Ve(`sources.${a}`,null,'optional "animate" property must be a boolean value'))),t.canvas?typeof t.canvas=="string"||t.canvas instanceof HTMLCanvasElement||this.fire(new h.y(new Ve(`sources.${a}`,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 h.y(new Ve(`sources.${a}`,null,'missing required property "canvas"'))),this.options=t,this.animate=t.animate===void 0||t.animate}load(){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 h.y(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(a){this.map=a,this.load(),this.canvas&&this.animate&&this.play()}onRemove(a){this.pause()}prepare(){let a=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,a=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,a=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;let t=this.map.painter.context;this.texture?!a&&!this._playing||this.texture instanceof h.a_||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new h.T(t,this.canvas,t.gl.RGBA8,{premultiply:!0}),this._prepareData(t)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let a of[this.canvas.width,this.canvas.height])if(isNaN(a)||a<=0)return!0;return!1}},custom:class extends h.E{constructor(a,t,o,c){super(),this.id=a,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=t,this.setEventedParent(c),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new h.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new h.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ga(this._implementation.bounds,this.minzoom,this.maxzoom));let d=t;d.update=this._update.bind(this),d.clearTiles=this._clearTiles.bind(this),d.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,h.aK(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return h.aK(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new h.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(a){this.map=a,this._loaded=!1,this.fire(new h.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(a),this.load()}onRemove(a){this._implementation.onRemove&&this._implementation.onRemove(a)}hasTile(a){if(this._implementation.hasTile){let{x:t,y:o,z:c}=a.canonical;return this._implementation.hasTile({x:t,y:o,z:c})}return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(a,t){let{x:o,y:c,z:d}
8=a.tileID.canonical,m=new AbortController,_=Promise.resolve(this._implementation.loadTile({x:o,y:c,z:d},{signal:m.signal})).then(function(y){return delete a.request,a.aborted?(a.state="unloaded",t(null)):y===void 0?(a.state="errored",t(null)):y===null?(this.loadTileData(a,{width:this.tileSize,height:this.tileSize,data:null}),a.state="loaded",t(null)):function(v){return v instanceof ImageData||v instanceof HTMLCanvasElement||v instanceof ImageBitmap||v instanceof HTMLImageElement}(y)?(this.loadTileData(a,y),a.state="loaded",void t(null)):(a.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(y=>{y.name!=="AbortError"&&(a.state="errored",t(y))});_.cancel=()=>m.abort(),a.request=_}loadTileData(a,t){a.setTexture(t,this.map.painter)}unloadTile(a,t){if(a.texture&&a.texture instanceof h.T?(a.destroy(!1),a.texture&&a.texture instanceof h.T&&this.map.painter.saveTileTexture(a.texture)):a.destroy(),this._implementation.unloadTile){let{x:o,y:c,z:d}=a.tileID.canonical;this._implementation.unloadTile({x:o,y:c,z:d})}t&&t()}abortTile(a,t){a.request&&a.request.cancel&&(a.request.cancel(),delete a.request),t&&t()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(a=>({x:a.canonical.x,y:a.canonical.y,z:a.canonical.z}))}_clearTiles(){let a=h.t(this.id,this.scope);this.map.style.clearSource(a)}_update(){this.fire(new h.z("data",{dataType:"source",sourceDataType:"content"}))}}},$h=function(a,t,o,c){let d=new yu[t.type](a,t,o,c);if(d.id!==a)throw new Error(`Expected Source id to be ${a} instead of ${d.id}`);return h.b0(["load","abort","unload","serialize","prepare"],d),d};function lf(a,t,o=""){return`${o}:${t.id||""}:${t.layer.id}:${function(c){if("layerId"in c)return`layer:${c.layerId}`;{let{featuresetId:d,importId:m}=c;return`featureset:${d}${m?`:import:${m}`:""}`}}(a.target)}`}function qh(a,t,o,c=""){if(a.uniqueFeatureID){let d=lf(a,t,c);if(o.has(d))return!0;o.add(d)}return!1}function xu(a,t,o,c,d=!1,m=void 0){let _=t.sourceCache.transform,y=t.sourceCache.tilesIn(a,t.has3DLayers,d);y.sort(ya);let v=[];for(let T of y){let E=T.tile.queryRenderedFeatures(t,T,o,c,_,d,m);Object.keys(E).length&&v.push({wrappedTileID:T.tile.tileID.wrapped().key,queryResults:E})}for(let T in t.layers){let E=t.layers[T];if(E.styleLayer){let P=E.styleLayer.queryRenderedFeatures(a,t.sourceCache,c);Object.keys(P).length&&v.push({wrappedTileID:0,queryResults:P})}}return v.length===0?{}:function(T){let E={},P={};for(let A of T){let D=A.queryResults,z=A.wrappedTileID,O=P[z]=P[z]||{};for(let k in D){let N=D[k],q=O[k]=O[k]||{},Z=E[k]=E[k]||[];for(let G of N)q[G.featureIndex]||(q[G.featureIndex]=!0,Z.push(G))}}return E}(v)}function vo(a,t,o,c,d,m){let _={},y=c.queryRenderedSymbols(a),v=[];for(let T of Object.keys(y).map(Number))v.push(d[T]);v.sort(ya);for(let T of v){let E=T.featureIndex.lookupSymbolFeatures(y[T.bucketInstanceId],T.bucketIndex,T.sourceLayerIndex,t,o,m);for(let P in E){let A=_[P]=_[P]||[],D=E[P];D.sort((z,O)=>{let k=T.featureSortOrder;if(k){let N=k.indexOf(z.featureIndex);return k.indexOf(O.featureIndex)-N}return O.featureIndex-z.featureIndex});for(let z of D)A.push(z)}}return _}function Zh(a,t){let o=a.getRenderableIds().map(m=>a.getTileByID(m)),c=[],d={};for(let m=0;m<o.length;m++){let _=o[m],y=_.tileID.canonical.key;d[y]||(d[y]=!0,_.querySourceFeatures(c,t))}return c}function ya(a,t){let o=a.tileID,c=t.tileID;return o.overscaledZ-c.overscaledZ||o.canonical.y-c.canonical.y||o.wrap-c.wrap||o.canonical.x-c.canonical.x}h.b1.setPbf(h.b2);class at extends h.b3{constructor(t,o,c,d,m){super(t,o,c,d,m),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(t){return this._mrt&&this._mrt.getLayer(t)}setTexturePerLayer(t,o,c){let d=c.context,m=d.gl,_=this.texturePerLayer.get(t)||c.getTileTexture(o.width);_&&_ instanceof h.T?_.update(o,{premultiply:!1}):_=new h.T(d,o,m.RGBA8,{premultiply:!1}),this.texturePerLayer.has(t)||this.texturePerLayer.set(t,_)}flushQueues(t){let o=this._workQueuePerLayer.get(t)||[],c=this._fetchQueuePerLayer.get(t)||[];for(;o.length;)o.pop()();for(;c.length;)c.pop()()}flushAllQueues(){for(let t of this._workQueuePerLayer.keys()){let o=this._workQueuePerLayer.get(t)||[];for(;o.length;)o.pop()()}for(let t of this._fetchQueuePerLayer.keys()){let o=this._fetchQueuePerLayer.get(t)||[];for(;o.length;)o.pop()()}}fetchHeader(t=16384,o){let c=this._mrt=new h.b1(30),d=Object.assign({}
8,this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=h.b4(d,(m,_,y)=>{if(m)o(m);else try{let v=c.getHeaderLength(_);if(v>t)return void(this.request=this.fetchHeader(v,o));c.parseHeader(_),this._isHeaderLoaded=!0;let T=0;for(let E of Object.values(c.layers))T=Math.max(T,E.dataIndex.at(-1).lastByte);_.byteLength>=T&&(this.entireBuffer=_),o(null,this.entireBuffer||_,y)}catch(v){o(v)}}),this.request}fetchBandForRender(t,o,c,d){this.fetchBand(t,o,c,m=>{if(m)return void d(m);this.updateTextureDescriptor(t,o,c);let _=this.textureDescriptorPerLayer.get(o);d(null,_?_.img:null)})}fetchBand(t,o,c,d,m=!0){let _=this._mrt;if(!this._isHeaderLoaded||!_)return void d(new Error("Tile header is not ready"));let y=this.actor;if(!y)return void d(new Error("Can't fetch tile band without an actor"));let v,T=h.t(String(c),h.t(this.tileID.key,t)),E=this._taskQueue.get(T);E?E.add(d):(E=new Set,E.add(d),this._taskQueue.set(T,E));let P=(O,k)=>{v.complete(O,k),O?d(O):(E.forEach(N=>N(null,k)),this._taskQueue.delete(T))},A=(O,k)=>{if(O)return d(O);let N=y.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:k,task:v},P,void 0,!0);if(o!==null){let q=this._workQueuePerLayer.get(o)||[];q.push(()=>{N&&N.cancel(),v.cancel()}),this._workQueuePerLayer.has(o)||this._workQueuePerLayer.set(o,q)}},D;try{D=_.getLayer(t)}catch(O){if(this.state==="reloading")return;throw O}if(!D)return void d(new Error(`Unknown sourceLayer "${t}"`));if(D.hasDataForBand(c))return E.forEach(O=>O(null,null)),void this._taskQueue.delete(T);let z=D.getDataRange([c]);if(v=_.createDecodingTask(z),!v||v.tasks.length)if(o!==null&&this.flushQueues(o),this.entireBuffer)A(null,this.entireBuffer.slice(z.firstByte,z.lastByte+1));else{let O=Object.assign({},this.requestParams,{headers:{Range:`bytes=${z.firstByte}-${z.lastByte}`}}),k=h.b4(O,A);if(o!==null){let N=this._fetchQueuePerLayer.get(o)||[];N.push(()=>{k.cancel(),v.cancel()}),this._fetchQueuePerLayer.has(o)||this._fetchQueuePerLayer.set(o,N)}}}updateNeeded(t,o){return(!this.textureDescriptorPerLayer.get(t)||this.textureDescriptorPerLayer.get(t).band!==o||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(t,o,c){if(!this._mrt)return;let d=this._mrt.getLayer(t);if(!d||!d.hasBand(c)||!d.hasDataForBand(c))return;let{bytes:m,tileSize:_,buffer:y,offset:v,scale:T}=d.getBandView(c),E=_+2*y,P=new h.q({width:E,height:E},m),A=this.texturePerLayer.get(o);A&&A instanceof h.T&&A.update(P,{premultiply:!1}),this.textureDescriptorPerLayer.set(o,{layer:t,band:c,img:P,buffer:y,offset:v,tileSize:_,format:d.pixelFormat,mix:[T,256*T,65536*T,16777216*T]})}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(let o of this.texturePerLayer.values())o&&o instanceof h.T&&o.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class ei{constructor(t,o){this.max=t,this.onRemove=o,this.reset()}reset(){for(let t in this.data)for(let o of this.data[t])o.timeout&&clearTimeout(o.timeout),this.onRemove(o.value);return this.data={},this.order=[],this}add(t,o,c){let d=t.wrapped().key;this.data[d]===void 0&&(this.data[d]=[]);let m={value:o,timeout:void 0};if(c!==void 0&&(m.timeout=setTimeout(()=>{this.remove(t,m)},c)),this.data[d].push(m),this.order.push(d),this.order.length>this.max){let _=this._getAndRemoveByKey(this.order[0]);_&&this.onRemove(_)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){let o=this.data[t].shift();return o.timeout&&clearTimeout(o.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),o.value}getByKey(t){let o=this.data[t];return o?o[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,o){if(!this.has(t))return this;let c=t.wrapped().key,d=o===void 0?0:this.data[c].indexOf(o),m=this.data[c][d];return this.data[c].splice(d,1),m.timeout&&clearTimeout(m.timeout),this.data[c].length===0&&delete this.data[c],this.onRemove(m.value),this.order.splice(this.order.indexOf(c),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){let o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(t){let o=[];for(let c in this.data)for(let d of this.data[c])t(d.value)||o.push(d);for(let c of o)this.remove(c.value.tileID,c)}}class oi{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,o,c){let d=String(o);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][d]=this.stateChanges[t][d]||{},Object.assign(this.stateChanges[t][d],c),this.deletedStates[t]===null){this.deletedStates[t]={};for(let m in this.state[t])m!==d&&(this.deletedStates[t][m]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][d]===null){this.deletedStates[t][d]={};for(let m in this.state[t][d])c[m]||(this.deletedStates[t][d][m]=null)}else for(let m in c)this.deletedStates[t]&&this.deletedStates[t][d]&&this.deletedStates[t][d][m]===null&&delete this.deletedStates[t][d][m]}removeFeatureState(t,o,c){if(this.deletedStates[t]===null)return;let d=String(o);if(this.deletedStates[t]=this.deletedStates[t]||{},c&&o!==void 0)this.deletedStates[t][d]!==null&&(this.deletedStates[t][d]=this.deletedStates[t][d]||{},this.deletedStates[t][d][c]=null);else if(o!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][d])for(c in this.deletedStates[t][d]={},this.stateChanges[t][d])this.deletedStates[t][d][c]=null;else this.deletedStates[t][d]=null;else this.deletedStates[t]=null}getState(t,o){let c=this.state[t]||{},d=this.stateChanges[t]||{},m=this.deletedStates[t];if(m===null)return{};if(o!==void 0){let y=String(o),v=Object.assign({},c[y],d[y]);if(m){let T=m[o];if(T===null)return{};for(let E in T)delete v[E]}return v}let _=Object.assign({},c,d);if(m)for(let y in m)delete _[y];return _}
8initializeTileState(t,o){t.refreshFeatureState(o)}coalesceChanges(t,o){let c={};for(let d in this.stateChanges){this.state[d]=this.state[d]||{};let m={};for(let _ in this.stateChanges[d])this.state[d][_]||(this.state[d][_]={}),Object.assign(this.state[d][_],this.stateChanges[d][_]),m[_]=this.state[d][_];c[d]=m}for(let d in this.deletedStates){this.state[d]=this.state[d]||{};let m={};if(this.deletedStates[d]===null)for(let _ in this.state[d])m[_]={},this.state[d][_]={};else for(let _ in this.deletedStates[d]){if(this.deletedStates[d][_]===null)this.state[d][_]={};else if(this.state[d][_])for(let y of Object.keys(this.deletedStates[d][_]))delete this.state[d][_][y];m[_]=this.state[d][_]}c[d]=c[d]||{},Object.assign(c[d],m)}if(this.stateChanges={},this.deletedStates={},Object.keys(c).length!==0)for(let d in t)t[d].refreshFeatureState(o,c)}}class on extends h.E{constructor(t,o,c){super(),this.id=t,this._renderSourceType=c,this._maxzoomOverride=null,o.on("data",d=>{d.dataType==="source"&&d.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&d.dataType==="source"&&d.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),o.on("error",()=>{this._sourceErrored=!0}),this._source=o,this._tiles={},this._cache=new ei(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=o.minTileCacheSize,this._maxTileCacheSize=o.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new oi,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&"_dataType"in this._source&&this._source._dataType==="raster",this._supportsFading=this._source.type==="raster"||this._source.type==="raster-array"||this._source.type==="image"||this._source.type==="video"||this._source.type==="custom",this._isRasterElevatedOverTerrain=!1}onAdd(t){this.map=t,this._minTileCacheSize=this._minTileCacheSize===void 0&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(let t in this._tiles)if(!this._tiles[t].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(t){this._maxzoomOverride=t}_loadTile(t,o){return t.renderSourceType=this._renderSourceType,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,o)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(let o in this._tiles){let c=this._tiles[o];c.upload(t,this.map?this.map.painter:void 0),c.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(xa).map(t=>t.key)}getRenderableIds(t,o){let c=[];for(let d in this._tiles)this._isIdRenderable(+d,t,o)&&c.push(this._tiles[d]);return t?c.sort((d,m)=>{let _=d.tileID,y=m.tileID,v=new h.P(_.canonical.x,_.canonical.y)._rotate(this.transform.angle),T=new h.P(y.canonical.x,y.canonical.y)._rotate(this.transform.angle);return _.overscaledZ-y.overscaledZ||T.y-v.y||T.x-v.x}).map(d=>d.tileID.key):c.map(d=>d.tileID).sort(xa).map(d=>d.key)}hasRenderableParent(t){let o=this.findLoadedParent(t,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(t,o,c){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(o||!this._tiles[t].holdingForFade())&&(c||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(let t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(+t,"reloading")}}_reloadTile(t,o){let c=this._tiles[t];c&&(c.state!=="loading"&&(c.state=o),this._loadTile(c,this._tileLoaded.bind(this,c,t,o)))}_tileLoaded(t,o,c,d,m){if(d){if(t.state="errored",h.b5(d)){if(this._source.fire(new h.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){let y=this.map.painter.terrain;this.update(this.transform,y.getScaledDemTileSize(),!0),y.resetTileLookupCache(this.id
8)}else this.update(this.transform)}else this._source.fire(new h.y(d,{tile:t}));return}t.timeAdded=h.o.now(),c==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(o,t),this._source.type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let _=new Map;m&&m.responseHeaders&&(_=m.responseHeaders),this._source.fire(new h.z("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:_}))}_hasTunnelGeometry(){for(let t in this._tiles){let o=this._tiles[t];if(o&&o.hasTunnelGeometry)return!0}return!1}_backfillDEM(t){let o=this.getRenderableIds();for(let d=0;d<o.length;d++){let m=o[d];if(t.neighboringTiles&&t.neighboringTiles[m]){let _=this.getTileByID(m);c(t,_),c(_,t)}}function c(d,m){if(!d.dem||d.dem.borderReady)return;d.needsHillshadePrepare=!0,d.needsDEMTextureUpload=!0;let _=m.tileID.canonical.x-d.tileID.canonical.x,y=m.tileID.canonical.y-d.tileID.canonical.y,v=Math.pow(2,d.tileID.canonical.z),T=m.tileID.key;_===0&&y===0||Math.abs(y)>1||(Math.abs(_)>1&&(Math.abs(_+v)===1?_+=v:Math.abs(_-v)===1&&(_-=v)),m.dem&&d.dem&&(d.dem.backfillBorder(m.dem,_,y),d.neighboringTiles&&d.neighboringTiles[T]&&(d.neighboringTiles[T].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,o,c,d){for(let m in this._tiles){let _=this._tiles[m];if(d[m]||!_.hasData()||_.tileID.overscaledZ<=o||_.tileID.overscaledZ>c)continue;let y=_.tileID;for(;_&&_.tileID.overscaledZ>o+1;){let T=_.tileID.scaledTo(_.tileID.overscaledZ-1);_=this._tiles[T.key],_&&_.hasData()&&(y=T)}let v=y;for(;v.overscaledZ>o;)if(v=v.scaledTo(v.overscaledZ-1),t[v.key]){d[y.key]=y;break}}}findLoadedParent(t,o){if(t.key in this._loadedParentTiles){let c=this._loadedParentTiles[t.key];return c&&c.tileID.overscaledZ>=o?c:null}for(let c=t.overscaledZ-1;c>=o;c--){let d=t.scaledTo(c),m=this._getLoadedTile(d);if(m)return m}}_getLoadedTile(t){let o=this._tiles[t.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,o){o=o||this._source.tileSize;let c=Math.ceil(t.width/o)+1,d=Math.ceil(t.height/o)+1,m=Math.floor(c*d*5),_=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,m):m,y=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,_):_;this._cache.setMaxSize(y)}handleWrapJump(t){let o=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,o){let c={};for(let d in this._tiles){let m=this._tiles[d];m.tileID=m.tileID.unwrapTo(m.tileID.wrap+o),c[m.tileID.key]=m}this._tiles=c;for(let d in this._timers)clearTimeout(this._timers[d]),delete this._timers[d];for(let d in this._tiles)this._setTileReloadTimer(+d,this._tiles[d])}}update(t,o,c,d,m){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!c)return;this.updateCacheSize(t,o),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};let _=this._source.type==="batched-model",y,v=this._source.maxzoom;this._maxzoomOverride!==null&&(v=Math.min(v,this._maxzoomOverride));let T=this.map&&this.map.painter?this.map.painter._terrain:null;if(T&&T.sourceCache===this&&T.attenuationRange()){let D=T.attenuationRange()[0],z=Math.floor(D)-Math.log2(T.getDemUpscale());v>z&&(v=z)}let E=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)y=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(D=>new h.aU(D.canonical.z,D.wrap,D.canonical.z,D.canonical.x,D.canonical.y));else if(this.tileCoverLift!==0){let D=t.clone();D.tileCoverLift=this.tileCoverLift,y=D.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:v,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:E,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:_}),this._source.minzoom<=1&&t.projection.name==="globe"&&(y.push(new h.aU(1,0,1,0,0)),y.push(new h.aU(1,0,1,1,0)),y.push(new h.aU(1,0,1,0,1)),y.push(new h.aU(1,0,1,1,1)))}else if(y=t.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:v,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:E,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:_}),this._source.hasTile){let D=this._source.hasTile.bind(this._source);y=y.filter(z=>D(z))}}else y=[];if(y.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){let D=t.coveringZoomLevel({tileSize:o||this._source.tileSize,roundZoom:this._source.roundZoom&&!c}),z=Math.min(D,v);if(_){let O=t.extendTileCover(y,z);for(let k of O)y.push(k)}else if(m){let O=this.transform.getFrustum(z),k=t.extendTileCoverToNearPlane(y,O,z);for(let N of k)y.push(N);if(z>=18&&this._hasTunnelGeometry()){let N=t.extendTileCoverForTunnels(y,O,z,20);for(let q of N)y.push(q)}}else if(this.castsShadows&&d){let O=t.extendTileCover(y,z,d,16);for(let k of O)this._shadowCasterTiles[k.key]=!0,y.push(k)}}let P=this._updateRetainedTiles(y);if(this._supportsFading&&y.length!==0){let D={},z={},O=h.o.now(),k=Object.keys(P);
8for(let q of k){let Z=P[q],G=this._tiles[q];if(!G||G.fadeEndTime!==void 0&&G.fadeEndTime<=O)continue;let re=this.findLoadedParent(Z,Math.max(Z.overscaledZ-on.maxOverzooming,this._source.minzoom));re&&(this._addTile(re.tileID),D[re.tileID.key]=re.tileID),z[q]=Z}let N=y.at(-1).overscaledZ;for(let q in this._tiles){let Z=this._tiles[q];if(P[q]||!Z.hasData())continue;let G=Z.tileID;for(;G.overscaledZ>N;){G=G.scaledTo(G.overscaledZ-1);let re=this._tiles[G.key];if(re&&re.hasData()&&z[G.key]){P[q]=Z.tileID;break}}}for(let q in D)P[q]||(this._coveredTiles[q]=!0,P[q]=D[q])}for(let D in P)this._tiles[D].clearFadeHold();let A=h.b6(this._tiles,P);for(let D of A){let z=this._tiles[D];z.hasSymbolBuckets&&!z.holdingForFade()?z.setHoldDuration(this.map._fadeDuration):z.hasSymbolBuckets&&!z.symbolFadeFinished()||this._removeTile(+D)}this._updateLoadedParentTileCache(),this._renderSourceType===h.b7.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(let t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){let o={};if(t.length===0)return o;let c={},d=t.reduce((T,E)=>Math.min(T,E.overscaledZ),1/0),m=t[0].overscaledZ,_=Math.max(m-on.maxOverzooming,this._source.minzoom),y=Math.max(m+on.maxUnderzooming,this._source.minzoom),v={};for(let T of t){let E=this._addTile(T);o[T.key]=T,E.hasData()||d<this._source.maxzoom&&(v[T.key]=T)}this._retainLoadedChildren(v,d,y,o);for(let T of t){let E=this._tiles[T.key];if(E.hasData())continue;if(T.canonical.z>=this._source.maxzoom){let A=T.children(this._source.maxzoom)[0],D=this.getTile(A);if(D&&D.hasData()){o[A.key]=A;continue}}else{let A=T.children(this._source.maxzoom);if(o[A[0].key]&&o[A[1].key]&&o[A[2].key]&&o[A[3].key])continue}let P=E.wasRequested();for(let A=T.overscaledZ-1;A>=_;--A){let D=T.scaledTo(A);if(c[D.key]||(c[D.key]=!0,E=this.getTile(D),!E&&P&&(E=this._addTile(D)),E&&(o[D.key]=D,P=E.wasRequested(),E.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(let t in this._tiles){let o=[],c,d=this._tiles[t].tileID;for(;d.overscaledZ>0;){if(d.key in this._loadedParentTiles){c=this._loadedParentTiles[d.key];break}o.push(d.key);let m=d.scaledTo(d.overscaledZ-1);if(c=this._getLoadedTile(m),c)break;d=m}for(let m of o)this._loadedParentTiles[m]=c}}_addTile(t){let o=this._tiles[t.key];if(o)return o.isExtraShadowCaster!==!0||this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),o;o=this._cache.getAndRemove(t),o&&(this._setTileReloadTimer(t.key,o),o.tileID=t,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,o)));let c=!!o;if(!c){let d=this.map?this.map.painter:null,m=this._source.tileSize*t.overscaleFactor();o=this._source.type==="raster-array"?new at(t,m,this.transform.tileZoom,d,this._isRaster):new h.b3(t,m,this.transform.tileZoom,d,this._isRaster,this._source.worldview),this._loadTile(o,this._tileLoaded.bind(this,o,t.key,o.state))}return o.uses++,this._tiles[t.key]=o,c||this._source.fire(new h.z("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o}_setTileReloadTimer(t,o){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);let c=o.getExpiryTimeout();c&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},c))}_removeTile(t){let o=this._tiles[t];o&&(o.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),o.uses>0||(o.hasData()&&o.state!=="reloading"||o.state==="empty"?this._cache.add(o.tileID,o,o.getExpiryTimeout()):(o.aborted=!0,this._abortTile(o),this._unloadTile(o))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(let t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,o,c){let d=[],m=this.transform;if(!m)return d;let _=m.projection.name==="globe",y=h.aG(m.center.lng);for(let v in this._tiles){let T=this._tiles[v];if(c&&T.clearQueryDebugViz(),T.holdingForFade())continue;let E;if(_){let P=T.tileID.canonical;if(P.z===0){let A=[Math.abs(h.aB(y,...Wt(P,-1))-y),Math.abs(h.aB(y,...Wt(P,1))-y)];E=[0,2*A.indexOf(Math.min(...A))-1]}else{let A=[Math.abs(h.aB(y,...Wt(P,-1))-y),Math.abs(h.aB(y,...Wt(P,0))-y),Math.abs(h.aB(y,...Wt(P,1))-y)];E=[A.indexOf(Math.min(...A))-1]}}else E=[0];for(let P of E){let A=t.containsTile(T,m,o,P);A&&d.push(A)}}return d}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,o){let c=this.getRenderableIds(t,o).map(m=>this._tiles[m].tileID),d=this.transform.projection.name==="globe";for(let m of c)m.projMatrix=this.transform.calculateProjMatrix(m.toUnwrapped()),m.expandedProjMatrix=d?this.transform.calculateProjMatrix(m.toUnwrapped(),!1,!0):m.projMatrix;return c}sortCoordinatesByDistance(t){let o=t.slice(),c=this.transform._camera.position,d=this.transform._camera.forward(),m={};for(let _ of o){let y=1/(1<<_.canonical.z);m[_.key]=((_.canonical.x+.5)*y+_.wrap-c[0])*d[0]+((_.canonical.y+.5)*y-c[1])*d[1]-c[2]*d[2]}return o.sort((_,y)=>m[_.key]-m[y.key]),o}hasTransition(){if(this._source.hasTransition())return!0;
8if(this._supportsFading){let t=h.o.now();for(let o in this._tiles){let c=this._tiles[o];if(c.fadeEndTime!==void 0&&c.fadeEndTime>=t)return!0}}return!1}setFeatureState(t,o,c){this._state.updateState(t=t||"_geojsonTileLayer",o,c)}removeFeatureState(t,o,c){this._state.removeFeatureState(t=t||"_geojsonTileLayer",o,c)}getFeatureState(t,o){return this._state.getState(t=t||"_geojsonTileLayer",o)}setDependencies(t,o,c){let d=this._tiles[t];d&&d.setDependencies(o,c)}reloadTilesForDependencies(t,o){for(let c in this._tiles)this._tiles[c].hasDependency(t,o)&&this._reloadTile(+c,"reloading");this._cache.filter(c=>!c.hasDependency(t,o))}_preloadTiles(t,o){if(!this._sourceLoaded){let v=()=>{this._sourceLoaded&&(this._source.off("data",v),this._preloadTiles(t,o))};return void this._source.on("data",v)}let c=new Map,d=Array.isArray(t)?t:[t],m=this.map.painter.terrain,_=this.usedForTerrain&&m?m.getScaledDemTileSize():this._source.tileSize;for(let v of d){let T=v.coveringTiles({tileSize:_,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(let E of T)c.set(E.key,E);this.usedForTerrain&&v.updateElevation(!1)}let y=Array.from(c.values());h.ao(y,(v,T)=>{let E=new h.b3(v,this._source.tileSize*v.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(E,P=>{this._source.type==="raster-dem"&&E.dem&&this._backfillDEM(E),T(P,E)})},o)}}function xa(a,t){let o=Math.abs(2*a.wrap)-+(a.wrap<0),c=Math.abs(2*t.wrap)-+(t.wrap<0);return a.overscaledZ-t.overscaledZ||c-o||t.canonical.y-a.canonical.y||t.canonical.x-a.canonical.x}function Wt(a,t){let o=1<<a.z;return[a.x/o+t,(a.x+1)/o+t]}on.maxOverzooming=10,on.maxUnderzooming=3;class vu{constructor(t){this.style=t,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];let t=!1,o=!1;for(let c in this.style._mergedLayers){let d=this.style._mergedLayers[c];if(d.type==="fill-extrusion"||d.type==="building")this.layers.push({layer:d,visible:t,visibilityChanged:o});else if(d.type==="model"){let m=this.style.getLayerSource(d);m&&m.type==="batched-model"&&this.layers.push({layer:d,visible:t,visibilityChanged:o})}}}onNewFrame(t){this.layersGotHidden=!1;for(let o of this.layers){let c=o.layer,d=!1;c.type==="fill-extrusion"?d=!c.isHidden(t)&&c.paint.get("fill-extrusion-opacity")>0:c.type==="building"?d=!c.isHidden(t)&&c.paint.get("building-opacity")>0:c.type==="model"&&(d=!c.isHidden(t)&&c.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!d&&o.visible,o.visible=d}}updateZOffset(t,o){this.currentBuildingBuckets=[];for(let d of this.layers){let m=d.layer,_=this.style.getLayerSourceCache(m),y=1;m.type==="fill-extrusion"?y=d.visible?m.paint.get("fill-extrusion-vertical-scale"):0:m.type==="building"&&(y=d.visible?m.paint.get("building-vertical-scale"):0);let v=_?_.getTile(o):null;if(!v&&_)for(let T in _._tiles){let E=_._tiles[T];if(o.canonical.isChildOf(E.tileID.canonical)){v=E;break}}this.currentBuildingBuckets.push({bucket:v?v.getBucket(m):null,tileID:v?v.tileID:o,verticalScale:y})}t.hasAnyZOffset=!1;let c=!1;for(let d=0;d<t.symbolInstances.length;d++){let m=t.symbolInstances.get(d),_=m.zOffset,y=this._getHeightAtTileOffset(o,m.tileAnchorX,m.tileAnchorY);m.zOffset=y!==Number.NEGATIVE_INFINITY?y:_,c||_===m.zOffset||(c=!0),t.hasAnyZOffset||m.zOffset===0||(t.hasAnyZOffset=!0)}c&&(t.zOffsetBuffersNeedUpload=!0,t.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(t,o,c,d){let m=o,_=c;if(t.canonical.z!==d.canonical.z){let y=d.canonical,v=1/(1<<t.canonical.z-y.z);m=(o+t.canonical.x*h.ak)*v-y.x*h.ak|0,_=(c+t.canonical.y*h.ak)*v-y.y*h.ak|0}return{tileX:m,tileY:_}}_getHeightAtTileOffset(t,o,c){let d,m;for(let _=0;_<this.layers.length;++_){let y=this.layers[_].layer;if(y.type!=="fill-extrusion"&&y.type!=="building")continue;let{bucket:v,tileID:T,verticalScale:E}=this.currentBuildingBuckets[_];if(!v)continue;let{tileX:P,tileY:A}=this._mapCoordToOverlappingTile(t,o,c,T),D=v.getHeightAtTileCoord(P,A);D&&D.height!==void 0&&(D.hidden?d=D.height:m=Math.max(D.height*E,m||0))}if(m!==void 0)return m;for(let _=0;_<this.layers.length;++_){let y=this.layers[_];if(y.layer.type!=="model"||!y.visible)continue;let{bucket:v,tileID:T}=this.currentBuildingBuckets[_];if(!v)continue;let{tileX:E,tileY:P}=this._mapCoordToOverlappingTile(t,o,c,T),A=v.getHeightAtTileCoord(E,P);if(A&&!A.hidden)return A.height===void 0&&d!==void 0?Math.min(A.maxHeight,d)*A.verticalScale:A.height?A.height*A.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}let Ko;function sl(){return Ko||(Ko=new Ss),Ko}function Qn(a,t){let o={};for(let c in a)c!=="ref"&&(o[c]=a[c]);return h.b8.forEach(c=>
8{c in t&&(o[c]=t[c])}),o}function sn(a){a=a.slice();let t=Object.create(null);for(let o of a)t[o.id]=o;for(let o=0;o<a.length;o++){let c=a[o];if(c&&"ref"in c){let d=t[c.ref];d&&(a[o]=Qn(c,d))}}return a}let Yt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setSnow:"setSnow",setRain:"setRain",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport",addIconset:"addIconset",removeIconset:"removeIconset"};function al(a,t,o){o.push({command:Yt.addSource,args:[a,t[a]]})}function bu(a,t,o){t.push({command:Yt.removeSource,args:[a]}),o[a]=!0}function mc(a,t,o,c){bu(a,o,c),al(a,t,o)}function wu(a,t,o){let c;for(c in a[o])if(Object.hasOwn(a[o],c)&&c!=="data"&&!h.b9(a[o][c],t[o][c]))return!1;for(c in t[o])if(Object.hasOwn(t[o],c)&&c!=="data"&&!h.b9(a[o][c],t[o][c]))return!1;return!0}function ll(a,t,o,c,d,m){let _;for(_ in t=t||{},a=a||{})Object.hasOwn(a,_)&&(h.b9(a[_],t[_])||o.push({command:m,args:[c,_,t[_],d]}));for(_ in t)Object.hasOwn(t,_)&&!Object.hasOwn(a,_)&&(h.b9(a[_],t[_])||o.push({command:m,args:[c,_,t[_],d]}))}function va(a){return a.id}function Un(a,t){return a[t.id]=t,a}function wr(a,t,o){let c=t.createTileMatrix(a,a.worldSize,o.toUnwrapped());return h.aC(new Float32Array(16),a.projMatrix,c)}function dr(a,t,o){if(t.projection.name===o.projection.name)return a.projMatrix;let c=o.clone();return c.setProjection(t.projection),wr(c,t.getProjection(),a)}function Tu(a,t,o){return t.name===o.projection.name?a.projMatrix:wr(o,t,a)}class cl{constructor(t,o){this.reset(t,o)}reset(t,o){this.points=t||[],this._distances=[0];for(let c=1;c<this.points.length;c++)this._distances[c]=this._distances[c-1]+this.points[c].dist(this.points[c-1]);this.length=this._distances.at(-1),this.padding=Math.min(o||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(this.points.length===1)return this.points[0];t=h.aB(t,0,1);let o=1,c=this._distances[o],d=t*this.paddedLength+this.padding;for(;c<d&&o<this._distances.length;)c=this._distances[++o];let m=o-1,_=this._distances[m],y=c-_,v=y>0?(d-_)/y:0;return this.points[m].mult(1-v).add(this.points[o].mult(v))}}let xn=Math.tan(85*Math.PI/180);function Tr(a,t,o,c,d,m,_){let y=h.bd();if(o)if(m.name==="globe"){let v=h.be(d,t);h.aC(y,y,v)}else{let v=h.bf([],_);y[0]=v[0],y[1]=v[1],y[4]=v[2],y[5]=v[3],c||h.bc(y,y,d.angle)}else h.aC(y,d.labelPlaneMatrix,a);return y}function bo(a,t,o,c,d,m,_){let y=Tr(a,t,o,c,d,m,_);return m.name==="globe"&&o||(y[2]=y[6]=y[10]=y[14]=0),y}function an(a,t,o,c,d,m,_){if(o){if(m.name==="globe"){let y=Tr(a,t,o,c,d,m,_);return h.ba(y,y),h.aC(y,a,y),y}{let y=h.bb(a),[v,T,E,P]=_,[A,D,z,O,k,N,q,Z]=y;return y[0]=v*A+T*k,y[1]=v*D+T*N,y[2]=v*z+T*q,y[3]=v*O+T*Z,y[4]=E*A+P*k,y[5]=E*D+P*N,y[6]=E*z+P*q,y[7]=E*O+P*Z,c||h.bc(y,y,-d.angle),y}}return d.glCoordMatrix}function kr(a,t,o,c){let d=[a,t,o,1];o?h.aD(d,d,c):cf(d,d,c);let m=d[3];return d[0]/=m,d[1]/=m,d[2]/=m,d}function io(a,t){return Math.min(.5+a/t*.5,1.5)}function _c(a,t){let o=a[0]/a[3],c=a[1]/a[3];return o>=-t[0]&&o<=t[0]&&c>=-t[1]&&c<=t[1]}function gc(a,t,o,c,d,m,_,y,v,T,E=1){let P=o.transform,A=c?a.textSizeData:a.iconSizeData,D=h.bl(A,o.transform.zoom,E),z=P.projection.name==="globe",O=[256/o.width*2+1,256/o.height*2+1],k=c?a.text.dynamicLayoutVertexArray:a.icon.dynamicLayoutVertexArray;k.clear();let N=null;z&&(N=c?a.text.globeExtVertexArray:a.icon.globeExtVertexArray);let q=a.lineVertexArray,Z=c?a.text.placedSymbolArray:a.icon.placedSymbolArray,G=o.transform.width/o.transform.height,re,te=!1;for(let se=0;se<Z.length;se++){let K=Z.get(se),{numGlyphs:J,writingMode:oe}=K;if(oe!==h.bm.vertical||te||re===h.bm.horizontal||(te=!0),re=oe,(K.hidden||oe===h.bm.vertical)&&!te){Sr(J,k);continue}te=!1;let ue=new h.P(K.tileAnchorX,K.tileAnchorY),de=a.elevationType==="road",be=!!P.elevation||de,{x:ve,y:Fe,z:pe}=P.projection.projectTilePoint(ue.x,ue.y,T.canonical),Ee=null;if(be){let it=de?a.getElevationFeatureForText(se):null;Ee={getElevation:v,elevation:P.elevation,elevationFeature:it};let[ht,vt,gt]=v(ue,P.elevation,it);ve+=ht,Fe+=vt,pe+=gt}let fe=[ve,Fe,pe,1];if(h.aD(fe,fe,t),!_c(fe,O)){Sr(J,k);continue}let Pe=fe[3],Ce=io(o.transform.getCameraToCenterDistance(P.projection),Pe),Re=h.bn(A,D,K),Ye=_?Re/Ce:Re*Ce,He=kr
8(ve,Fe,pe,d);if(He[3]<=0){Sr(J,k);continue}let je={},Ue=h.am(a.layers[0].layout.get("text-max-angle")),lt=Math.cos(Ue),st=_?null:Ee,et=Xh(K,Ye,!1,y,t,d,m,a.glyphOffsetArray,q,k,N,He,ue,je,G,st,P.projection,T,_,lt);te=et.useVertical,st&&et.needsFlipping&&(je={}),(et.notEnoughRoom||te||et.needsFlipping&&Xh(K,Ye,!0,y,t,d,m,a.glyphOffsetArray,q,k,N,He,ue,je,G,st,P.projection,T,_,lt).notEnoughRoom)&&Sr(J,k)}c?(a.text.dynamicLayoutVertexBuffer.updateData(k),N&&a.text.globeExtVertexBuffer&&a.text.globeExtVertexBuffer.updateData(N)):(a.icon.dynamicLayoutVertexBuffer.updateData(k),N&&a.icon.globeExtVertexBuffer&&a.icon.globeExtVertexBuffer.updateData(N))}function Su(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k){let{lineStartIndex:N,glyphStartIndex:q,segment:Z}=y,G=q+y.numGlyphs,re=N+y.lineLength,te=t.getoffsetX(q),se=t.getoffsetX(G-1),K=Eu(a*te,o,c,d,m,_,Z,N,re,v,T,E,P,A,!0,D,z,O,k);if(!K)return null;let J=Eu(a*se,o,c,d,m,_,Z,N,re,v,T,E,P,A,!0,D,z,O,k);return J?{first:K,last:J}:null}function Wh(a,t,o,c){return a===h.bm.horizontal&&Math.abs(c)>Math.abs(o)?{useVertical:!0}:a===h.bm.vertical?c>0?{needsFlipping:!0}:null:t!==0&&function(d,m){return d===0||Math.abs(m/d)>xn}(o,c)?t===1?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Xh(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k,N,q,Z){let G=t/24,re=a.lineOffsetX*G,te=a.lineOffsetY*G,{lineStartIndex:se,glyphStartIndex:K,numGlyphs:J,segment:oe,writingMode:ue,flipState:de}=a,be=se+a.lineLength,ve=Fe=>{if(E){let[Pe,Ce,Re]=Fe.up,Ye=T.length;h.bo(E,Ye+0,Pe,Ce,Re),h.bo(E,Ye+1,Pe,Ce,Re),h.bo(E,Ye+2,Pe,Ce,Re),h.bo(E,Ye+3,Pe,Ce,Re)}let[pe,Ee,fe]=Fe.point;h.bp(T,pe,Ee,fe,Fe.angle)};if(J>1){let Fe=Su(G,y,re,te,o,P,A,a,v,m,D,O,!1,k,N,q,Z);if(!Fe)return{notEnoughRoom:!0};if(c&&!o){let[pe,Ee,fe]=Fe.first.point,[Pe,Ce,Re]=Fe.last.point;[pe,Ee]=kr(pe,Ee,fe,_),[Pe,Ce]=kr(Pe,Ce,Re,_);let Ye=Wh(ue,de,(Pe-pe)*z,Ce-Ee);if(a.flipState=Ye&&Ye.needsFlipping?1:2,Ye)return Ye}ve(Fe.first);for(let pe=K+1;pe<K+J-1;pe++){let Ee=Eu(G*y.getoffsetX(pe),re,te,o,P,A,oe,se,be,v,m,D,O,!1,!1,k,N,q,Z);if(!Ee)return T.length-=4*(pe-K),{notEnoughRoom:!0};ve(Ee)}ve(Fe.last)}else{if(c&&!o){let pe=kr(A.x,A.y,0,d),Ee=se+oe+1,fe=new h.P(v.getx(Ee),v.gety(Ee)),Pe=kr(fe.x,fe.y,0,d),Ce=Pe[3]>0?Pe:Yh(A,fe,pe,1,d,void 0,k,N.canonical),Re=Wh(ue,de,(Ce[0]-pe[0])*z,Ce[1]-pe[1]);if(a.flipState=Re&&Re.needsFlipping?1:2,Re)return Re}let Fe=Eu(G*y.getoffsetX(K),re,te,o,P,A,oe,se,be,v,m,D,O,!1,!1,k,N,q,Z);if(!Fe)return{notEnoughRoom:!0};ve(Fe)}return{}}function yc(a,t,o,c,d){let{x:m,y:_,z:y}=c.projectTilePoint(a.x,a.y,t);if(!d)return kr(m,_,y,o);let[v,T,E]=d.getElevation(a,d.elevation,d.elevationFeature);return kr(m+v,_+T,y+E,o)}function Yh(a,t,o,c,d,m,_,y){let v=yc(a.sub(t)._unit()._add(a),y,d,_,m);return h.aw(v,o,v),h.ax(v,v),h.bi(v,o,v,c)}function Eu(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k,N,q){let Z=c?a-t:a+t,G=Z>0?1:-1,re=0;c&&(G*=-1,re=Math.PI),G<0&&(re+=Math.PI);let te=y+_+(G>0?0:1)|0,se=d,K=d,J=0,oe=0,ue=Math.abs(Z),de=[],be=[],ve=m,Fe=ve,pe=h.bg([]),Ee=()=>Yh(Fe,ve,K,ue-J+1,E,A,O,k.canonical);for(;J+oe<=ue;){if(te+=G,te<y||te>=v)return null;if(K=se,Fe=ve,de.push(K),D&&be.push(Fe),ve=new h.P(T.getx(te),T.gety(te)),se=P[te],!se){let st=yc(ve,k.canonical,E,O,A);se=st[3]>0?P[te]=st:Ee()}J+=oe;let Ue=h.aw([],se,K),lt=h.bh(K,se);if(o&&lt>0&&oe>0&&h.bk(pe,Ue)/(oe*lt)<q)return null;oe=lt,pe=Ue}z&&A&&(P[te]&&(se=Ee(),oe=h.bh(K,se),pe=h.aw([],se,K)),P[te]=se);let fe=(ue-J)/oe,Pe=ve.sub(Fe)._mult(fe)._add(Fe),Ce=h.bi([],K,pe,fe),Re=[0,0,1],Ye=pe[0],He=pe[1];if(N&&(Re=O.upVector(k.canonical,Pe.x,Pe.y),Re[0]!==0||Re[1]!==0||Re[2]!==1)){let Ue=[Re[2],0,-Re[0]],lt=h.bj([],Re,Ue);h.ax(Ue,Ue),h.ax(lt,lt),Ye=h.bk(pe,Ue),He=h.bk(pe,lt)}if(o){let Ue=h.bj([],Re,pe);h.ax(Ue,Ue),h.bi(Ce,Ce,Ue,o*G)}let je=re+Math.atan2(He,Ye);return de.push(Ce),D&&be.push(Pe),{point:Ce,angle:je,path:de,tilePath:be,up:Re}}function Sr(a,t){let o=t.length,c=o+4*a;t.resize(c),t.float32.fill(-1/0,4*o,4*c)}function cf(a,t,o){let c=t[0],d=t[1];return a[0]=o[0]*c+o[4]*d+o[12],a[1]=o[1]*c+o[5]*d+o[13],a[3]=o[3]*c+o[7]*d+o[15],a}let no=100;class pr{constructor(t,o,c=new h.bq(t.width+200,t.height+200,25),d=new h.bq(t.width+200,t.height+200,25)){this.transform=t,this.grid=c,this.ignoredGrid=d,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+no,this.screenBottomBoundary=t.height+no,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=o,this.clippedSymbol
8s=new Map}clearClippedSymbolsForBucket(t){this.clippedSymbols.delete(t)}markSymbolAsClipped(t,o){let c=this.clippedSymbols.get(t);c||(c=new Set,this.clippedSymbols.set(t,c)),c.add(o)}placeCollisionBox(t,o,c,d,m,_,y,v,T,E,P){let A=c.projectedAnchorX,D=c.projectedAnchorY,z=c.projectedAnchorZ,O=c.tileAnchorX,k=c.tileAnchorY,N=c.elevation,q=c.tileID,Z=t.getProjection();if(N&&q){let[be,ve,Fe]=Z.upVector(q.canonical,c.tileAnchorX,c.tileAnchorY),pe=Z.upVectorScale(q.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;A+=be*N*pe,D+=ve*N*pe,z+=Fe*N*pe}let G=t.projection.name==="globe",re=t.projection.name==="globe"?h.ai(this.transform.zoom):0;if(q&&G&&re<1&&!_){let be=1<<q.canonical.z,ve=h.br(O,k);h.bs(ve,ve,1/h.ak),h.bt(ve,ve,h.br(q.canonical.x,q.canonical.y)),h.bs(ve,ve,1/be),h.bu(ve,ve,h.br(d[0],d[1])),ve[0]=h.bv(ve[0],-.5,.5),h.bs(ve,ve,h.ak);let Fe=h.bw(ve[0],ve[1],h.ak/(2*Math.PI),1);h.aD(Fe,Fe,m),A=h.aj(A,Fe[0],re),D=h.aj(D,Fe[1],re),z=h.aj(z,Fe[2],re)}let te=this.projectAndGetPerspectiveRatio(E,A,D,z,c.tileID,Z.name==="globe"||!!N||this.transform.pitch>0,Z),se=T*te.perspectiveRatio,K=(c.x1*o+y.x-c.padding)*se+te.point.x,J=(c.y1*o+y.y-c.padding)*se+te.point.y,oe=(c.x2*o+y.x+c.padding)*se+te.point.x,ue=(c.y2*o+y.y+c.padding)*se+te.point.y,de=te.perspectiveRatio<=.55||te.occluded;return!this.isInsideGrid(K,J,oe,ue)||!v&&this.grid.hitTest(K,J,oe,ue,P)||de?{box:[],offscreen:!1,occluded:te.occluded}:{box:[K,J,oe,ue],offscreen:this.isOffscreen(K,J,oe,ue),occluded:!1}}placeCollisionCircles(t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k){let N=[],q=this.transform.elevation,Z=t.getProjection(),G=t.elevationType==="road",re=!!q||G,te=h.bx.getAtTileOffsetFunc(k,this.transform.center.lat,this.transform.worldSize,Z),se=new h.P(c.tileAnchorX,c.tileAnchorY),K=new h.P(c.tileAnchorX,c.tileAnchorY),{x:J,y:oe,z:ue}=Z.projectTilePoint(K.x,K.y,k.canonical),de=null;if(re){let lt=G?t.getElevationFeatureForText(d):null;de={getElevation:te,elevation:q,elevationFeature:lt};let[st,et,it]=te(se,q,lt);J+=st,oe+=et,ue+=it}let be=Z.name==="globe",ve=this.projectAndGetPerspectiveRatio(v,J,oe,ue,k,be||!!q||this.transform.pitch>0,Z),{perspectiveRatio:Fe}=ve,pe=(A?y/Fe:y*Fe)/h.bC,Ee=kr(J,oe,ue,T),fe=c.lineOffsetX*pe,Pe=c.lineOffsetY*pe,Ce=h.am(t.layers[0].layout.get("text-max-angle")),Re=Math.cos(Ce),Ye=ve.signedDistanceFromCamera>0?Su(pe,_,fe,Pe,G&&c.flipState===1,Ee,K,c,m,T,{},re&&!A?de:null,A&&re,Z,k,A,Re):null,He=!1,je=!1,Ue=!0;if(Ye&&!ve.occluded){let lt=.5*z*Fe+O,st=new h.P(-100,-100),et=new h.P(this.screenRightBoundary,this.screenBottomBoundary),it=new cl,{first:ht,last:vt}=Ye,gt=ht.path.length,Et=[];for(let Tt=gt-1;Tt>=1;Tt--)Et.push(ht.path[Tt]);for(let Tt=1;Tt<vt.path.length;Tt++)Et.push(vt.path[Tt]);let xt=2.5*lt;E&&(Et=Et.map(([Tt,Vt,qt],bi)=>(re&&!be&&(qt=te(bi<gt-1?ht.tilePath[gt-1-bi]:vt.tilePath[bi-gt+2],q,de.elevationFeature)[2]),kr(Tt,Vt,qt,E))),Et.some(Tt=>Tt[3]<=0)&&(Et=[]));let kt=[];if(Et.length>0){let Tt=1/0,Vt=-1/0,qt=1/0,bi=-1/0;for(let li of Et)Tt=Math.min(Tt,li[0]),qt=Math.min(qt,li[1]),Vt=Math.max(Vt,li[0]),bi=Math.max(bi,li[1]);Vt>=st.x&&Tt<=et.x&&bi>=st.y&&qt<=et.y&&(kt=[Et.map(li=>new h.P(li[0],li[1]))],(Tt<st.x||Vt>et.x||qt<st.y||bi>et.y)&&(kt=h.by(kt,st.x,st.y,et.x,et.y)))}for(let Tt of kt){it.reset(Tt,.25*lt);let Vt=0;Vt=it.length<=.5*lt?1:Math.ceil(it.paddedLength/xt)+1;for(let qt=0;qt<Vt;qt++){let bi=qt/Math.max(Vt-1,1),li=it.lerp(bi),Xt=li.x+no,At=li.y+no;N.push(Xt,At,lt,0);let Ct=Xt-lt,ci=At-lt,Li=Xt+lt,ti=At+lt;if(Ue=Ue&&this.isOffscreen(Ct,ci,Li,ti),je=je||this.isInsideGrid(Ct,ci,Li,ti),!o&&this.grid.hitTestCircle(Xt,At,lt,D)&&(He=!0,!P))return{circles:[],offscreen:!1,collisionDetected:He,occluded:!1}}}}return{circles:!P&&He||!je?[]:N,offscreen:Ue,collisionDetected:He,occluded:ve.occluded}}queryRenderedSymbols(t){if(t.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};let o=[],c=1/0,d=1/0,m=-1/0,_=-1/0;for(let E of t){let P=new h.P(E.x+no,E.y+no);c=Math.min(c,P.x),d=Math.min(d,P.y),m=Math.max(m,P.x),_=Math.max(_,P.y),o.push(P)}let y=this.grid.query(c,d,m,_).concat(this.ignoredGrid.query(c,d,m,_)),v={},T={};for(let E of y){let P=E.key;if(v[P.bucketInstanceId]===void 0&&(v[P.bucketInstanceId]={}),v[P.bucketInstanceId][P.featureIndex])continue;
8let A=this.clippedSymbols.get(P.bucketInstanceId);if(A&&A.has(P.featureIndex))continue;let D=[new h.P(E.x1,E.y1),new h.P(E.x2,E.y1),new h.P(E.x2,E.y2),new h.P(E.x1,E.y2)];h.bz(o,D)&&(v[P.bucketInstanceId][P.featureIndex]=!0,T[P.bucketInstanceId]===void 0&&(T[P.bucketInstanceId]=[]),T[P.bucketInstanceId].push(P.featureIndex))}return T}insertCollisionBox(t,o,c,d,m){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:d,collisionGroupID:m},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,o,c,d,m){let _=o?this.ignoredGrid:this.grid,y={bucketInstanceId:c,featureIndex:d,collisionGroupID:m};for(let v=0;v<t.length;v+=4)_.insertCircle(y,t[v],t[v+1],t[v+2])}projectAndGetPerspectiveRatio(t,o,c,d,m,_,y){let v=[o,c,d,1],T=!1;d||this.transform.pitch>0?(h.aD(v,v,t),this.fogState&&m&&y.name!=="globe"&&(T=function(A,D,z,O,k,N){let q=N.calculateFogTileMatrix(k),Z=[D,z,O];return h.ae(Z,Z,q),il(A,h.af(Z),N.pitch)}(this.fogState,o,c,d,m.toUnwrapped(),this.transform)>.9)):cf(v,v,t);let E=v[3];return{point:new h.P((v[0]/E+1)/2*this.transform.width+no,(-v[1]/E+1)/2*this.transform.height+no),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(y)/E*.5,1.5),signedDistanceFromCamera:E,occluded:_&&v[2]>E||T}}isOffscreen(t,o,c,d){return c<no||t>=this.screenRightBoundary||d<no||o>this.screenBottomBoundary}isInsideGrid(t,o,c,d){return c>=0&&t<this.gridRightBoundary&&d>=0&&o<this.gridBottomBoundary}getViewportMatrix(){let t=h.bA([]);return h.bB(t,t,[-100,-100,0]),t}}class uf{constructor(t,o,c,d){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?o:-o))):d&&c?1:0,this.placed=c}isHidden(){return this.opacity===0&&!this.placed}}class Is{constructor(t,o,c,d,m,_=!1){this.text=new uf(t?t.text:null,o,c,m),this.icon=new uf(t?t.icon:null,o,d,m),this.clipped=_}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class xc{constructor(t,o,c,d=!1){this.text=t,this.icon=o,this.skipFade=c,this.clipped=d}}class vc{constructor(){this.invProjMatrix=h.bd(),this.viewportMatrix=h.bd(),this.circles=[]}}class O_{constructor(t,o,c,d,m){this.bucketInstanceId=t,this.featureIndex=o,this.sourceLayerIndex=c,this.bucketIndex=d,this.tileID=m}}class F_{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let o=++this.maxGroupID;this.collisionGroups[t]={ID:o,predicate:c=>c.collisionGroupID===o}}return this.collisionGroups[t]}}function ul(a,t,o,c,d){let{horizontalAlign:m,verticalAlign:_}=h.bJ(a),y=-(m-.5)*t,v=-(_-.5)*o,T=h.bK(a,c);return new h.P(y+T[0]*d,v+T[1]*d)}function ba(a,t,o,c,d){let m=new h.P(a,t);return o&&m._rotate(c?d:-d),m}class B_{constructor(t,o,c,d,m,_){this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new pr(this.transform,m),this.buildingIndex=_,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new F_(c),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(t,o,c,d,m=1){let _=c.getBucket(o),y=c.latestFeatureIndex;if(!_||!y||o.fqid!==_.layerIds[0])return;let v=_.layers[0].layout,T=_.layers[0].paint,E=c.collisionBoxArray,P=Math.pow(2,this.transform.zoom-c.tileID.overscaledZ),A=c.tileSize/h.ak,D=c.tileID.toUnwrapped();this.transform.setProjection(_.projection);let z=(O=c.tileID,k=_.getProjection(),N=this.transform,k.name===this.projection?N.calculateProjMatrix(O.toUnwrapped()):wr(N,k,O));var O,k,N;let q=v.get("text-pitch-alignment")==="map",Z=v.get("text-rotation-alignment")==="map";o.compileFilter(o.options);let G=o.dynamicFilter(),re=o.dynamicFilterNeedsFeature(),te=o.dynamicFilterNeedsGeometry(),se=this.transform.calculatePixelsToTileUnitsMatrix(c),K=bo(z,c.tileID.canonical,q,Z,this.transform,_.getProjection(),se),J=null,oe=_.getProjection().createInversionMatrix(this.transform,c.tileID.canonical);if(q){let Pe=an(z,c.tileID.canonical,q,Z,this.transform,_.getProjection(),se);
8J=h.aC([],this.transform.labelPlaneMatrix,Pe)}let ue=null;G&&c.latestFeatureIndex&&(ue={unwrappedTileID:D,dynamicFilter:G,dynamicFilterNeedsFeature:re,needGeometry:te}),this.retainedQueryData[_.bucketInstanceId]=new O_(_.bucketInstanceId,y,_.sourceLayerIndex,_.index,c.tileID);let[de,be]=_.layers[0].layout.get("text-size-scale-range"),ve=h.aB(m,de,be),[Fe,pe]=v.get("icon-size-scale-range"),Ee=h.aB(m,Fe,pe),fe={bucket:_,layout:v,paint:T,posMatrix:z,invMatrix:oe,mercatorCenter:[h.aG(this.transform.center.lng),h.aJ(this.transform.center.lat)],textLabelPlaneMatrix:K,labelToScreenMatrix:J,clippingData:ue,scale:P,textPixelRatio:A,holdingForFade:c.holdingForFade(),collisionBoxArray:E,partiallyEvaluatedTextSize:h.bl(_.textSizeData,this.transform.zoom,ve),partiallyEvaluatedIconSize:h.bl(_.iconSizeData,this.transform.zoom,Ee),collisionGroup:this.collisionGroups.get(_.sourceID),latestFeatureIndex:c.latestFeatureIndex};if(d)for(let Pe of _.sortKeyRanges){let{sortKey:Ce,symbolInstanceStart:Re,symbolInstanceEnd:Ye}=Pe;t.push({sortKey:Ce,symbolInstanceStart:Re,symbolInstanceEnd:Ye,parameters:fe})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:_.symbolInstances.length,parameters:fe})}attemptAnchorPlacement(t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k,N,q,Z,G,re){let{textOffset0:te,textOffset1:se,crossTileID:K}=O,J=[te,se],oe=ul(t,_,y,J,v),ue=this.collisionIndex.placeCollisionBox(N,v,o,c,d,m,ba(oe.x,oe.y,T,E,this.transform.angle),z,P,A,D.predicate);if(Z){let de=N.getSymbolInstanceIconSize(re,this.transform.zoom,O.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(N,de,Z,c,d,m,ba(oe.x,oe.y,T,E,this.transform.angle),z,P,A,D.predicate).box.length===0)return}if(ue.box.length>0){let de;return this.prevPlacement&&this.prevPlacement.variableOffsets[K]&&this.prevPlacement.placements[K]&&this.prevPlacement.placements[K].text&&(de=this.prevPlacement.variableOffsets[K].anchor),this.variableOffsets[K]={textOffset:J,width:_,height:y,anchor:t,textScale:v,prevAnchor:de},this.markUsedJustification(N,t,O,q),N.allowVerticalPlacement&&(this.markUsedOrientation(N,q,O),this.placedOrientations[K]=q),{shift:oe,placedGlyphBoxes:ue}}}placeLayerBucketPart(t,o,c,d,m=1){let{bucket:_,layout:y,paint:v,posMatrix:T,textLabelPlaneMatrix:E,labelToScreenMatrix:P,clippingData:A,textPixelRatio:D,mercatorCenter:z,invMatrix:O,holdingForFade:k,collisionBoxArray:N,partiallyEvaluatedTextSize:q,partiallyEvaluatedIconSize:Z,collisionGroup:G,latestFeatureIndex:re}=t.parameters,te=y.get("text-optional"),se=y.get("icon-optional"),K=y.get("text-allow-overlap"),J=y.get("icon-allow-overlap"),oe=y.get("text-rotation-alignment")==="map",ue=y.get("icon-rotation-alignment")==="map",de=y.get("text-pitch-alignment")==="map",be=v.get("symbol-z-offset"),ve=y.get("symbol-elevation-reference")==="sea",Fe=y.get("symbol-placement"),[pe,Ee]=y.get("text-size-scale-range"),[fe,Pe]=y.get("icon-size-scale-range"),Ce=h.aB(m,pe,Ee),Re=h.aB(m,fe,Pe),Ye=y.get("text-variable-anchor"),He=oe&&Fe!=="point",je=ue&&Fe!=="point",Ue=Ye&&_.hasTextData(),lt=_.hasIconTextFit()&&Ue&&_.hasIconData();this.transform.setProjection(_.projection);let st=Ue||He,et=je||lt,it=K&&(J||!_.hasIconData()||se),ht=J&&(K||!_.hasTextData()||te),vt=!be.isConstant();!_.collisionArrays&&N&&_.deserializeCollisionBoxes(N),c&&d&&_.updateCollisionDebugBuffers(this.transform.zoom,N,Ce,Re);let gt=(xt,kt,Tt)=>{let{crossTileID:Vt,numVerticalGlyphVertices:qt}=xt,bi=null;if(A&&A.dynamicFilterNeedsFeature||vt){let Ii=this.retainedQueryData[_.bucketInstanceId],ii=re.loadFeature({featureIndex:xt.featureIndex,bucketIndex:Ii.bucketIndex,sourceLayerIndex:Ii.sourceLayerIndex,layoutVertexArrayOffset:0}),si=ii.properties?ii.properties.worldview:null;if(_.localizable&&_.worldview&&typeof si=="string")if(si==="all")ii.properties.$localized=!0;else{if(!si.split(",").includes(_.worldview))return;ii.properties.$localized=!0,ii.properties.worldview=_.worldview}bi=A&&A.needGeometry?h.bH(ii,!0):ii}if(A&&!(0,A.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:_.worldview},bi,this.retainedQueryData[_.bucketInstanceId].tileID.canonical,new h.P(xt.tileAnchorX,xt.tileAnchorY),this.transform.calculateDistanceTileData(A.unwrappedTileID)))return this.placements[Vt]=new xc(!1,!1,!1,!0),void o.add(Vt);let li=be.evaluate(bi,{});if((xt.zOffset||0)+(li||0)>
80&&this.frontCutoffStart>0){let Ii=2*this.frontCutoffStart-1,ii=[xt.tileAnchorX,xt.tileAnchorY,0,1],si=h.aD(h.bI(),ii,T);if(si[1]/si[3]<Ii)return this.placements[Vt]=new xc(!1,!1,!1,!0),void o.add(Vt)}if(o.has(Vt))return;if(k)return void(this.placements[Vt]=new xc(!1,!1,!1));let Xt=!1,At=!1,Ct=!0,ci=!1,Li=!1,ti=null,wt={box:null,offscreen:null,occluded:null},yi={box:null},fi=null,Ui=null,Nt=null,Ji=0,Vn=0,pn=0;Tt.textFeatureIndex?Ji=Tt.textFeatureIndex:xt.useRuntimeCollisionCircles&&(Ji=xt.featureIndex),Tt.verticalTextFeatureIndex&&(Vn=Tt.verticalTextFeatureIndex);let In=_.elevationFeatures?_.elevationFeatures[xt.elevationFeatureIndex]:void 0,cn=Ii=>{Ii.tileID=this.retainedQueryData[_.bucketInstanceId].tileID;let ii=this.transform.elevation;Ii.elevation=ve?li:li+h.bx.getAtTileOffset(Ii.tileID,new h.P(Ii.tileAnchorX,Ii.tileAnchorY),ii,In),Ii.elevation+=xt.zOffset},cr=Tt.textBox;if(cr){cn(cr);let Ii=si=>{let Ki=h.bm.horizontal;if(_.allowVerticalPlacement&&!si&&this.prevPlacement){let vn=this.prevPlacement.placedOrientations[Vt];vn&&(this.placedOrientations[Vt]=vn,Ki=vn,this.markUsedOrientation(_,Ki,xt))}return Ki},ii=(si,Ki)=>{if(_.allowVerticalPlacement&&qt>0&&Tt.verticalTextBox){for(let vn of _.writingModes)if(vn===h.bm.vertical?(wt=Ki(),yi=wt):wt=si(),wt&&wt.box&&wt.box.length)break}else wt=si()};if(Ye){let si=Ye;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Vt]){let ki=this.prevPlacement.variableOffsets[Vt];si.indexOf(ki.anchor)>0&&(si=si.filter(bn=>bn!==ki.anchor),si.unshift(ki.anchor))}let Ki=(ki,bn,Zr)=>{let ur=_.getSymbolInstanceTextSize(q,xt,this.transform.zoom,kt),lo=(ki.x2-ki.x1)*ur+2*ki.padding,cs=(ki.y2-ki.y1)*ur+2*ki.padding,us=xt.hasIconTextFit&&!J?bn:null;us&&cn(us);let Eo={box:[],offscreen:!1,occluded:!1},Jc=K?2*si.length:si.length;for(let Zs=0;Zs<Jc;++Zs){let Va=this.attemptAnchorPlacement(si[Zs%si.length],ki,z,O,st,lo,cs,ur,oe,de,D,T,G,Zs>=si.length,xt,kt,_,Zr,us,q,Z);if(Va&&(Eo=Va.placedGlyphBoxes,Eo&&Eo.box&&Eo.box.length)){Xt=!0,ti=Va.shift;break}}return Eo};ii(()=>Ki(cr,Tt.iconBox,h.bm.horizontal),()=>{let ki=Tt.verticalTextBox;return ki&&cn(ki),_.allowVerticalPlacement&&!(wt&&wt.box&&wt.box.length)&&qt>0&&ki?Ki(ki,Tt.verticalIconBox,h.bm.vertical):{box:null,offscreen:null,occluded:null}}),wt&&(Xt=wt.box,Ct=wt.offscreen,ci=wt.occluded);let vn=Ii(!(!wt||!wt.box));if(!Xt&&this.prevPlacement){let ki=this.prevPlacement.variableOffsets[Vt];ki&&(this.variableOffsets[Vt]=ki,this.markUsedJustification(_,ki.anchor,xt,vn))}}else{let si=(Ki,vn)=>{let ki=_.getSymbolInstanceTextSize(q,xt,this.transform.zoom,kt),bn=this.collisionIndex.placeCollisionBox(_,ki,Ki,z,O,st,new h.P(0,0),K,D,T,G.predicate);return bn&&bn.box&&bn.box.length&&(this.markUsedOrientation(_,vn,xt),this.placedOrientations[Vt]=vn),bn};ii(()=>si(cr,h.bm.horizontal),()=>{let Ki=Tt.verticalTextBox;return _.allowVerticalPlacement&&qt>0&&Ki?(cn(Ki),si(Ki,h.bm.vertical)):{box:null,offscreen:null,occluded:null}}),Ii(!!(wt&&wt.box&&wt.box.length))}}if(fi=wt,Xt=fi&&fi.box&&fi.box.length>0,Ct=fi&&fi.offscreen,ci=fi&&fi.occluded,xt.useRuntimeCollisionCircles){let Ii=xt.centerJustifiedTextSymbolIndex>=0?xt.centerJustifiedTextSymbolIndex:xt.verticalPlacedTextSymbolIndex,ii=_.text.placedSymbolArray.get(Ii),si=h.bn(_.textSizeData,q,ii),Ki=y.get("text-padding");Ui=this.collisionIndex.placeCollisionCircles(_,K,ii,Ii,_.lineVertexArray,_.glyphOffsetArray,si,T,E,P,c,de,G.predicate,xt.collisionCircleDiameter*si/h.bC,Ki,this.retainedQueryData[_.bucketInstanceId].tileID),Xt=K||Ui.circles.length>0&&!Ui.collisionDetected,Ct=Ct&&Ui.offscreen,ci=Ui.occluded}if(Tt.iconFeatureIndex&&(pn=Tt.iconFeatureIndex),Tt.iconBox){let Ii=ii=>{cn(ii);let si=xt.hasIconTextFit&&ti?ba(ti.x,ti.y,oe,de,this.transform.angle):new h.P(0,0),Ki=_.getSymbolInstanceIconSize(Z,this.transform.zoom,xt.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(_,Ki,ii,z,O,et,si,J,D,T,G.predicate)};yi&&yi.box&&yi.box.length&&Tt.verticalIconBox?(Nt=Ii(Tt.verticalIconBox),At=Nt.box.length>0):(Nt=Ii(Tt.iconBox),At=Nt.box.length>0),Ct=Ct&&Nt.offscreen,Li=Nt.occluded}let tr=te||xt.numHorizontalGlyphVertices===0&&qt===0,zi=se||xt.numIconVertices===0;if(tr||zi?zi?tr||(At=At&&Xt):Xt=At&&Xt:At=Xt=At&&Xt,Xt&&fi&&fi.box&&this.collisionIndex.insertCollisionBox(fi.box,y.get("text-ignore-placement"),_.bucketInstanceId,yi&&yi.box&&Vn?Vn:Ji,G.ID),At&&Nt&&this.collisionIndex.insertCollisionBox(Nt.box,y.get("icon-ignore-placement"),_.bucketInstanceId,pn,G.ID),Ui&&(Xt&&this.collisionIndex.insertCollisionCircles(Ui.circles,y.get("text-ignore-placement"),_.bucketInstanceId,Ji,G.ID),c)){let Ii=_.bucketInstanceId,ii=this.collisionCircleArrays[Ii];ii===void 0&&(ii=this.collisionCircleArrays[Ii]=new vc);for(let si=0;si<Ui.circles.length;si+=4)ii.circles.push(Ui.circles[si+0]),ii.circles.push(Ui.circles[si+1]),ii.circles.push(Ui.circles[si+2]),ii.circles.push(Ui.collisionDetected?1:0)}let Vi=_.projection.name!=="globe";it=it&&(Vi||!ci),ht=ht&&(Vi||!Li),this.placements[Vt]=new xc(Xt||it,At||ht,Ct||_.justReloaded),o.add(Vt)},Et=this.retainedQueryData[_.bucketInstanceId].tileID;if(_.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(_,Et),_.elevationType==="road"&&_.updateRoadElevation(Et.canonical),_.updateZOffset(),_.sortFeaturesByY){let xt=_.getSortedSymbolIndexe
8s(this.transform.angle);for(let kt=xt.length-1;kt>=0;--kt){let Tt=xt[kt];gt(_.symbolInstances.get(Tt),Tt,_.collisionArrays[Tt])}_.hasAnyZOffset&&h.w(`${_.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(_.hasAnyZOffset){let xt=_.getSortedIndexesByZOffset();for(let kt=0;kt<xt.length;++kt){let Tt=xt[kt];gt(_.symbolInstances.get(Tt),Tt,_.collisionArrays[Tt])}}else for(let xt=t.symbolInstanceStart;xt<t.symbolInstanceEnd;xt++)gt(_.symbolInstances.get(xt),xt,_.collisionArrays[xt]);if(c&&_.bucketInstanceId in this.collisionCircleArrays){let xt=this.collisionCircleArrays[_.bucketInstanceId];h.ba(xt.invProjMatrix,T),xt.viewportMatrix=this.collisionIndex.getViewportMatrix()}_.justReloaded=!1}markUsedJustification(t,o,c,d){let{leftJustifiedTextSymbolIndex:m,centerJustifiedTextSymbolIndex:_,rightJustifiedTextSymbolIndex:y,verticalPlacedTextSymbolIndex:v,crossTileID:T}=c,E=h.bL(o),P=d===h.bm.vertical?v:E==="left"?m:E==="center"?_:E==="right"?y:-1;m>=0&&(t.text.placedSymbolArray.get(m).crossTileID=P>=0&&m!==P?0:T),_>=0&&(t.text.placedSymbolArray.get(_).crossTileID=P>=0&&_!==P?0:T),y>=0&&(t.text.placedSymbolArray.get(y).crossTileID=P>=0&&y!==P?0:T),v>=0&&(t.text.placedSymbolArray.get(v).crossTileID=P>=0&&v!==P?0:T)}markUsedOrientation(t,o,c){let d=o===h.bm.horizontal||o===h.bm.horizontalOnly?o:0,m=o===h.bm.vertical?o:0,{leftJustifiedTextSymbolIndex:_,centerJustifiedTextSymbolIndex:y,rightJustifiedTextSymbolIndex:v,verticalPlacedTextSymbolIndex:T}=c,E=t.text.placedSymbolArray;_>=0&&(E.get(_).placedOrientation=d),y>=0&&(E.get(y).placedOrientation=d),v>=0&&(E.get(v).placedOrientation=d),T>=0&&(E.get(T).placedOrientation=m)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let o=this.prevPlacement,c=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;let d=o?o.symbolFadeChange(t):1,m=o?o.opacities:{},_=o?o.variableOffsets:{},y=o?o.placedOrientations:{};for(let v in this.placements){let T=this.placements[v],E=m[v];E?(this.opacities[v]=new Is(E,d,T.text,T.icon,null,T.clipped),c=c||T.text!==E.text.placed||T.icon!==E.icon.placed):(this.opacities[v]=new Is(null,d,T.text,T.icon,T.skipFade,T.clipped),c=c||T.text||T.icon)}for(let v in m){let T=m[v];if(!this.opacities[v]){let E=new Is(T,d,!1,!1);E.isHidden()||(this.opacities[v]=E,c=c||T.text.placed||T.icon.placed)}}for(let v in _)this.variableOffsets[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.variableOffsets[v]=_[v]);for(let v in y)this.placedOrientations[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.placedOrientations[v]=y[v]);c?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:t)}updateLayerOpacities(t,o,c,d){d&&(this.lastReplacementSourceUpdateTime=d.updateTime);let m=new Set;for(let _ of o){let y=_.getBucket(t);y&&_.latestFeatureIndex&&t.fqid===y.layerIds[0]&&(this.updateBucketOpacities(y,m,_,_.collisionBoxArray,c,d,_.tileID,t.scope),y.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(y,_.tileID),y.elevationType==="road"&&y.updateRoadElevation(_.tileID.canonical),y.updateZOffset())}}updateBucketOpacities(t,o,c,d,m,_,y,v){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();let T=t.layers[0].layout,E=t.layers[0].paint,P=!!t.layers[0].dynamicFilter(),A=new Is(null,0,!1,!1,!0),D=T.get("text-allow-overlap"),z=T.get("icon-allow-overlap"),O=T.get("text-variable-anchor"),k=T.get("text-rotation-alignment")==="map",N=T.get("text-pitch-alignment")==="map",q=E.get("symbol-z-offset"),Z=T.get("symbol-elevation-reference")==="sea",G=!q.isConstant(),re=new Is(null,0,D&&(z||!t.hasIconData()||T.get("icon-optional")),z&&(D||!t.hasTextData()||T.get("text-optional")),!0);!t.collisionArrays&&d&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(d);let te=(K,J,oe)=>{for(let ue=0;ue<J/4;ue++)K.opacityVertexArray.emplaceBack(oe)},se=0;_&&t.updateReplacement(y,_),this.collisionIndex.clearClippedSymbol
8sForBucket(t.bucketInstanceId);for(let K=0;K<t.symbolInstances.length;K++){let J=t.symbolInstances.get(K),{numHorizontalGlyphVertices:oe,numVerticalGlyphVertices:ue,crossTileID:de,numIconVertices:be,tileAnchorX:ve,tileAnchorY:Fe}=J,pe=null,Ee=this.retainedQueryData[t.bucketInstanceId];G&&J&&Ee&&(pe=c.latestFeatureIndex.loadFeature({featureIndex:J.featureIndex,bucketIndex:Ee.bucketIndex,sourceLayerIndex:Ee.sourceLayerIndex,layoutVertexArrayOffset:0}));let fe=q.evaluate(pe,{}),Pe=o.has(de),Ce=this.opacities[de];Pe?Ce=A:Ce||(Ce=re,this.opacities[de]=Ce),o.add(de);let Re=oe>0||ue>0,Ye=be>0,He=this.placedOrientations[de],je=He===h.bm.vertical,Ue=He===h.bm.horizontal||He===h.bm.horizontalOnly;!Re&&!Ye||Ce.isHidden()||se++;let lt=!1;if((Re||Ye)&&_)for(let st of t.activeReplacements){if(h.bD(st,m,h.bE.Symbol,v)||st.min.x>ve||ve>st.max.x||st.min.y>Fe||Fe>st.max.y)continue;let et=h.bF(ve,Fe,y.canonical,st.footprintTileId.canonical);if(lt=h.bG(et,st.footprint),lt)break}if(lt&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,J.featureIndex),Re){let st=lt?wa:df(Ce.text);te(t.text,oe,je?wa:st),te(t.text,ue,Ue?wa:st);let et=Ce.text.isHidden(),{leftJustifiedTextSymbolIndex:it,centerJustifiedTextSymbolIndex:ht,rightJustifiedTextSymbolIndex:vt,verticalPlacedTextSymbolIndex:gt}=J,Et=t.text.placedSymbolArray,xt=et||je?1:0;it>=0&&(Et.get(it).hidden=xt),ht>=0&&(Et.get(ht).hidden=xt),vt>=0&&(Et.get(vt).hidden=xt),gt>=0&&(Et.get(gt).hidden=et||Ue?1:0);let kt=this.variableOffsets[de];kt&&this.markUsedJustification(t,kt.anchor,J,He);let Tt=this.placedOrientations[de];Tt&&(this.markUsedJustification(t,"left",J,Tt),this.markUsedOrientation(t,Tt,J))}if(Ye){let st=lt?wa:df(Ce.icon),{placedIconSymbolIndex:et,verticalPlacedIconSymbolIndex:it}=J,ht=t.icon.placedSymbolArray,vt=Ce.icon.isHidden()?1:0;et>=0&&(te(t.icon,be,je?wa:st),ht.get(et).hidden=vt),it>=0&&(te(t.icon,J.numVerticalIconVertices,Ue?wa:st),ht.get(it).hidden=vt)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let st=t.collisionArrays[K];if(st){let et=new h.P(0,0),it=!0;if(st.textBox||st.verticalTextBox){if(O){let vt=this.variableOffsets[de];vt?(et=ul(vt.anchor,vt.width,vt.height,vt.textOffset,vt.textScale),k&&et._rotate(N?this.transform.angle:-this.transform.angle)):it=!1}P&&(it=!Ce.clipped),st.textBox&&Iu(t.textCollisionBox.collisionVertexArray,Ce.text.placed,!it||je,fe,Z,et.x,et.y),st.verticalTextBox&&Iu(t.textCollisionBox.collisionVertexArray,Ce.text.placed,!it||Ue,fe,Z,et.x,et.y)}let ht=it&&!!(!Ue&&st.verticalIconBox);st.iconBox&&Iu(t.iconCollisionBox.collisionVertexArray,Ce.icon.placed,ht,fe,Z,J.hasIconTextFit?et.x:0,J.hasIconTextFit?et.y:0),st.verticalIconBox&&Iu(t.iconCollisionBox.collisionVertexArray,Ce.icon.placed,!ht,fe,Z,J.hasIconTextFit?et.x:0,J.hasIconTextFit?et.y:0)}}}if(t.fullyClipped=se===0,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){let K=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=K.invProjMatrix,t.placementViewportMatrix=K.viewportMatrix,t.collisionCircleArray=K.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,o){let c=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*c>t}isStale(){return this.stale}setStale(){this.stale=!0}}function Iu(a,t,o,c,d,m,_){a.emplaceBack(t?1:0,o?1:0,m||0,_||0,c,d?1:0),a.emplaceBack(t?1:0,o?1:0,m||0,_||0,c,d?1:0),a.emplaceBack(t?1:0,o?1:0,m||0,_||0,c,d?1:0),a.emplaceBack(t?1:0,o?1:0,m||0,_||0,c,d?1:0)}let hl=Math.pow(2,25),hf=Math.pow(2,24),Au=Math.pow(2,17),Jh=Math.pow(2,16),As=Math.pow(2,9),k_=Math.pow(2,8),N_=Math.pow(2,1);function df(a){if(a.opacity===0&&!a.placed)return 0;if(a.opacity===1&&a.placed)return 4294967295;let t=a.placed?1:0,o=Math.floor(127*a.opacity);return o*hl+t*hf+o*Au+t*Jh+o*As+t*k_+o*N_+t}let wa=0;class U_{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&t.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(t,o,c,d,m,_){let y=this._bucketParts;for(;this._currentTileIndex<t.length;)if(o.getBucketParts(y,d,t[this._currentTileIndex],this._sortAcrossTiles,_),this._currentTileIndex++,m())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,y.sort((v,T)=>
8v.sortKey-T.sortKey));this._currentPartIndex<y.length;){let v=y[this._currentPartIndex];if(o.placeLayerBucketPart(v,this._seenCrossTileIDs,c,v.symbolInstanceStart===0,_),this._currentPartIndex++,m())return!0}return!1}}class Mu{startNewPlacement(t,o,c,d,m,_,y,v){return this.placement=new B_(t,d,m,_,y,v),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=c,this._fadeDuration=d,this._done=!1,this._inProgressLayer=null,this}requestFullPlacement(){this._forceFullPlacement=!0}isFullPlacementRequested(){return this._forceFullPlacement}setStale(){this.placement&&(this.placement.stale=!0)}isStale(){return!!this.placement&&this.placement.stale}isDone(){return this._done}continuePlacement(t,o,c,d,m){let _=h.o.now(),y=()=>{let v=h.o.now()-_;return!this.isFullPlacementRequested()&&this._fadeDuration!==0&&v>2};for(;this._currentPlacementIndex>=0;){let v=o[t[this._currentPlacementIndex]],T=this.placement.collisionIndex.transform.zoom;if(v.type==="symbol"&&v.visibility!=="none"&&(!v.minzoom||v.minzoom<=T)&&(!v.maxzoom||v.maxzoom>T)){let E=v,P=E.layout.get("symbol-z-elevate"),A=E.layout.get("symbol-sort-key").constantOr(1)!==void 0,D=E.layout.get("symbol-z-order"),z=D==="viewport-y"||D==="auto"&&!(D!=="viewport-y"&&A),O=E.layout.get("text-allow-overlap")||E.layout.get("icon-allow-overlap")||E.layout.get("text-ignore-placement")||E.layout.get("icon-ignore-placement"),k=z&&O,N=this._inProgressLayer=this._inProgressLayer||new U_(E),q=h.t(v.source,v.scope);if(N.continuePlacement(P||k?d[q]:c[q],this.placement,this._showCollisionBoxes,v,y,m))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(t){return this.placement.commit(t),this.placement}}let Cu=512/h.ak/2;class pf{constructor(t,o,c){this.tileID=t,this.bucketInstanceId=c,this.index=new h.bM(o.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];let d=t.canonical.x*h.ak,m=t.canonical.y*h.ak;for(let _=0;_<o.length;_++){let{key:y,crossTileID:v,tileAnchorX:T,tileAnchorY:E}=o.get(_),P=Math.floor((d+T)*Cu),A=Math.floor((m+E)*Cu);this.index.add(P,A),this.keys.push(y),this.crossTileIDs.push(v)}this.index.finish()}findMatches(t,o,c){let d=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z),m=Cu/Math.pow(2,o.canonical.z-this.tileID.canonical.z),_=o.canonical.x*h.ak,y=o.canonical.y*h.ak;for(let v=0;v<t.length;v++){let T=t.get(v);if(T.crossTileID)continue;let{key:E,tileAnchorX:P,tileAnchorY:A}=T,D=Math.floor((_+P)*m),z=Math.floor((y+A)*m),O=this.index.range(D-d,z-d,D+d,z+d).sort((k,N)=>k-N);for(let k of O){let N=this.crossTileIDs[k];if(this.keys[k]===E&&!c.has(N)){c.add(N),T.crossTileID=N;break}}}}}class ff{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class mf{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let o=Math.round((t-this.lng)/360);if(o!==0)for(let c in this.indexes){let d=this.indexes[c],m={};for(let _ in d){let y=d[_];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+o),m[y.tileID.key]=y}this.indexes[c]=m}this.lng=t}addBucket(t,o,c){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let m=0;m<o.symbolInstances.length;m++)o.symbolInstances.get(m).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]=new Set);let d=this.usedCrossTileIDs[t.overscaledZ];for(let m in this.indexes){let _=this.indexes[m];if(Number(m)>t.overscaledZ)for(let y in _){let v=_[y];v.tileID.isChildOf(t)&&v.findMatches(o.symbolInstances,t,d)}else{let y=_[t.scaledTo(Number(m)).key];y&&y.findMatches(o.symbolInstances,t,d)}}for(let m=0;m<o.symbolInstances.length;m++){let _=o.symbolInstances.get(m);_.crossTileID||(_.crossTileID=c.generate(),d.add(_.crossTileID))}return this.indexes[t.overscaledZ]===void 0&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new pf(t,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(t,o){for(let c of o.crossTileIDs)this.usedCrossTileIDs[t].delete(c)}removeStaleBuckets(t){let o=!1;for(let c in this.indexes){let d=this.indexes[c];for(let m in d)t[d[m].bucketInstanceId]||(this.removeBucketCrossTileIDs(c,d[m]),delete d[m],o=!0)}return o}}class Ta{constructor(){this.layerIndexes={},this.crossTileIDs=new ff,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,o,c,d){let m=this.layerIndexes[t.fqid];m===void 0&&(m=this.layerIndexes[t.fqid]=new mf);let _=!1,y={};d.name!=="globe"&&m.handleWrapJump(c);for(let v of o){let T=v.getBucket(t);T&&t.fqid===T.layerIds[0]&&(T.bucketInstanceId||(T.bucketInstanceId=++this.maxBucketInstanceId),m.addBucket(v.tileID,T,this.crossTileIDs)&&(_=!0),y[T.bucketInstanceId]=!0)}return m.removeStaleBuckets(y)&&(_=!0),_}pruneUnusedLayers(t){let o={};t.forEach(c=>{o[c]=!0});for(let c in this.layerIndexes)o[c]||delete this.layerIndexes[c]}}let Sa=770,Ms=771;class _t{constructor(t,o,c,d){this.blendFunction=t,this.blendColor=o.toNonPremultipliedRenderColor(null),this.mask=c,this.blendEquation=d}}_t.Replace=[1,0,1,0],_t.disabled=new _t(_t.Replace,h.C.transparent,[!1,!1,!1,!1]),_t.unblended=new _t(_t.Replace,h.C.transparent,[!0,!0,!0,!0]),_t.alphaBlended=new _t([1,Ms,1,Ms],h.C.transparent,[!0,!0,!0,!0]),_t.alphaBlendedNonPremultiplied=new _t([Sa,Ms,Sa,Ms],h.C.transparent,[!0,!0,!0,!0]),_t.multiply=new _t([774,0,774,0],h.C.transparent,[!0,!0,!0,!0]),_t.multiplyAccumulateAlpha=new _t([774,0,1,Ms],h.C.transparent,[!0,!0,!0,!0]),_t.additive=new _t([1,1,1,1],h.C.transparent,[!0,!0,!0,!0]),_t.additiveAlphaWeighted=new _t([Sa,1,773,1],h.C.transparent,[!0,!0,!0,!0]),_t.additiveAlphaWeightedUnboundedAlpha=new _t([Sa,1,1,1],h.C.transparent,[!0,!0,!0,!0]);
8class nt{constructor(t,o,c){this.func=t,this.mask=o,this.range=c}}nt.ReadOnly=!1,nt.ReadWrite=!0,nt.disabled=new nt(519,nt.ReadOnly,[0,1]);let Ea=7680;class yt{constructor(t,o,c,d,m,_){this.test=t,this.ref=o,this.mask=c,this.fail=d,this.depthFail=m,this.pass=_}}yt.disabled=new yt({func:519,mask:0},0,0,Ea,Ea,Ea);let bc=1029,Er=2305;class pt{constructor(t,o,c){this.enable=t,this.mode=o,this.frontFace=c}}function Xe(a,t){let o=h.bS(a,3);h.bV(a,t),h.b_(a,3,o)}function Pu(a,t){let o=h.bP([]);return h.bQ(o,o,-t),h.bR(o,o,-a),o}function Kh(a,t){let o=[a[0],a[1],0],c=[t[0],t[1],0];if(h.af(o)>=1e-15){let _=h.ax([],o);h.bN(c,_,h.bk(c,_)),t[0]=c[0],t[1]=c[1]}let d=h.bj([],t,a);if(h.bO(d)<1e-15)return null;let m=Math.atan2(-d[1],d[0]);return Pu(Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2]),m)}pt.disabled=new pt(!1,bc,Er),pt.backCCW=new pt(!0,bc,Er),pt.backCW=new pt(!0,bc,2304),pt.frontCW=new pt(!0,1028,2304),pt.frontCCW=new pt(!0,1028,Er);class wc{constructor(t,o){this.position=t,this.orientation=o}get position(){return this._position}set position(t){if(t){let o=t instanceof h.ad?t:new h.ad(t[0],t[1],t[2]);
8this._renderWorldCopies&&(o.x=h.bv(o.x,0,1)),this._position=o}else this._position=null}lookAtPoint(t,o,c){if(this.orientation=null,!this.position)return;let d=this.position,m=c||(this._elevation?this._elevation.getAtPointOrZero(h.ad.fromLngLat(t)):0),_=h.ad.fromLngLat(t,m),y=[_.x-d.x,_.y-d.y,_.z-d.z];o||(o=[0,0,1]),o[2]=Math.abs(o[2]),this.orientation=Kh(y,o)}setPitchBearing(t,o){this.orientation=Pu(h.am(t),h.am(-o))}}class ro{constructor(t,o){this._transform=h.bA([]),this.orientation=o,this.position=t}get mercatorPosition(){let t=this.position;return new h.ad(t[0],t[1],t[2])}get position(){let t=h.bS(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var o;t&&h.b_(this._transform,3,[(o=t)[0],o[1],o[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||h.bP([]),t&&Xe(this._transform,this._orientation)}getPitchBearing(){let t=this.forward(),o=this.right();return{bearing:Math.atan2(-o[1],o[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,o){this._orientation=Pu(t,o),Xe(this._transform,this._orientation)}forward(){let t=h.bS(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){let t=h.bS(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){let t=h.bS(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,o){let c=new Float64Array(16);return h.ba(c,this.getWorldToCamera(t,o)),c}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,o,c){let d=this.position;h.bN(d,d,-t);let m=new Float64Array(16);return h.bT(m,[c,c,c]),h.bB(m,m,d),m[10]*=o,m}getWorldToCamera(t,o){let c=new Float64Array(16),d=new Float64Array(4),m=this.position;return h.bU(d,this._orientation),h.bN(m,m,-t),h.bV(c,d),h.bB(c,c,m),c[1]*=-1,c[5]*=-1,c[9]*=-1,c[13]*=-1,c[8]*=o,c[9]*=o,c[10]*=o,c[11]*=o,c}getCameraToClipPerspective(t,o,c,d){let m=new Float64Array(16);return h.bW(m,t,o,c,d),m}getCameraToClipOrthographic(t,o,c,d,m,_){let y=new Float64Array(16);return h.bX(y,t,o,c,d,m,_),y}getDistanceToElevation(t,o=!1){let c=t===0?0:h.bY(t,o?h.bZ(this.position[1]):this.position[1]),d=this.forward();return(c-this.position[2])/d[2]}clone(){return new ro([...this.position],[...this.orientation])}}let Qh=(a,t)=>({u_matrix:a,u_ground_shadow_factor:t});class Qo{constructor(t=0,o=0,c=0,d=0){if(isNaN(t)||t<0||isNaN(o)||o<0||isNaN(c)||c<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=o,this.left=c,this.right=d}interpolate(t,o,c){return o.top!=null&&t.top!=null&&(this.top=h.aj(t.top,o.top,c)),o.bottom!=null&&t.bottom!=null&&(this.bottom=h.aj(t.bottom,o.bottom,c)),o.left!=null&&t.left!=null&&(this.left=h.aj(t.left,o.left,c)),o.right!=null&&t.right!=null&&(this.right=h.aj(t.right,o.right,c)),this}getCenter(t,o){let c=h.aB((this.left+t-this.right)/2,0,t),d=h.aB((this.top+o-this.bottom)/2,0,o);return new h.P(c,d)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Qo(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let Ro=15;class Cs{constructor(t,o,c,d,m,_,y){this.tileSize=512,this._renderWorldCopies=m===void 0||m,this._minZoom=t||0,this._maxZoom=o||22,this._minPitch=c??0,this._maxPitch=d??60,this.setProjection(_),this.setMaxBounds(y),this.width=0,this.height=0,this._center=new h.aX(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new Qo,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new ro,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1,this.mercatorMatrix=new Float64Array(16),this.mercatorFogMatrix=new Float32Array(16),this.invProjMatrix=new Float64Array(16),this._expandedFarZProjMatrixBuf=new Float64Array(16),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf,this.starsProjMatrix=new Float32Array(16),this.skyboxMatrix=new Float32Array(16),this._mat4Scratch=new Float64Array(16),this.alignedProjMatrix=new Float64Array(16),this.labelPlaneMatr
8ix=new Float32Array(16),this.glCoordMatrix=new Float32Array(16),this.pixelMatrix=new Float64Array(16),this.pixelMatrixInverse=new Float64Array(16)}clone(){let t=new Cs(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.mercatorFromTransition=this.mercatorFromTransition,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._nearClipOffset=this._nearClipOffset,t._averageElevation=this._averageElevation,t._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t._allowWorldUnderZoom=this._allowWorldUnderZoom,t}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<Ro}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(t){this._nearClipOffset=t,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(t,o=!1){let c=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForE
8xaggeration;(this._seaLevelZoom==null||c)&&this._updateCameraOnTerrain(),(t||c)&&this._constrainCamera(o),this._calcMatrices()}getProjection(){return h.aK(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};let o=this.projection?this.getProjection():void 0;this.projection=h.c4(this.projectionOptions);let c=this.getProjection(),d=!h.b9(o,c);return d&&this._calcMatrices(),this.mercatorFromTransition=!1,d}setOrthographicProjectionAtLowPitch(t){return this._orthographicProjectionAtLowPitch!==t&&(this._orthographicProjectionAtLowPitch=t,this._calcMatrices(),!0)}setMercatorFromTransition(){let t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=h.c4({name:"mercator"});let o=t!==this.projection.name;return o&&this._calcMatrices(),o}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){let t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get cameraWorldSize(){let t=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return h.bY(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new h.P(this.width,this.height)}get bearing(){return h.bv(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(t){let o=-t*Math.PI/180;if(this.angle===o)return;this._unmodified=!1,this.angle=o,this._calcMatrices();let c=Math.sin(this.angle),d=Math.cos(this.angle);this.rotationMatrix=[d,c,-c,d]}get pitch(){return this._pitch/Math.PI*180}set pitch(t){let o=h.aB(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==o&&(this._unmodified=!1,this._pitch=o,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=h.am(t),this._calcMatrices())}get fovX(){return this._fov}get fovY(){let t=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/t)}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){let o=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==o&&(this._unmodified=!1,this._setZoom(o),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(t){this._tileCoverLift!==t&&(this._tileCoverLift=t)}_updateCameraOnTerrain(){let t=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,o=this.elevation&&t===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>
80&&this._centerAltitudeValidForExaggeration;if(!this._elevation||t===Number.NEGATIVE_INFINITY&&(!o||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);let c=this._elevation;o||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&c.exaggeration()&&this._centerAltitudeValidForExaggeration!==c.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*c.exaggeration(),this._centerAltitudeValidForExaggeration=c.exaggeration()):(this._centerAltitude=t||0,this._centerAltitudeValidForExaggeration=c.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;let t=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(t)}sampleAverageElevation(){if(!this._elevation)return 0;let t=this._elevation,o=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],c=this.horizonLineFromTop(),d=0,m=0;for(let _=0;_<o.length;_++){let y=new h.P(o[_][0]*this.width,c+o[_][1]*(this.height-c)),v=t.pointCoordinate(y);if(!v)continue;let T=1/Math.hypot(v[0]-this._camera.position[0],v[1]-this._camera.position[1]);d+=v[3]*T,m+=T}return m===0?NaN:d/m}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;let t=this._seaLevelZoom,o=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),c=this.pixelsPerMeter/this.worldSize*o,d=this._mercatorZfromZoom(t),m=this._mercatorZfromZoom(this._maxZoom),_=Math.max(d-c,m);this._setZoom(this._zoomFromMercatorZ(_))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}equals(t){let o=this.elevation,c=t.elevation,d=o!=null!=(c!=null)||o&&c&&o.exaggeration()!==c.exaggeration();return this.width===t.width&&this.height===t.height&&this.center.lng===t.center.lng&&this.center.lat===t.center.lat&&this.zoom===t.zoom&&this.bearing===t.bearing&&this.pitch===t.pitch&&this.fov===t.fov&&this.projection.name===t.projection.name&&this._edgeInsets.equals(t.padding)&&!d}computeZoomRelativeTo(t){let o=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude())),c;c=t.z<this._camera.position[2]?[o.x,o.y,o.z]:[t.x,t.y,t.z];let d=h.af(h.aw([],this._camera.position,c));return h.aB(this._zoomFromMercatorZ(d),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height||!t.position&&!t.orientation)return;this._updateCameraState();let o=!1;if(t.orientation&&!h.c5(t.orientation,this._camera.orientation)&&(o=this._setCameraOrientation(t.orientation)),t.position){let c=[t.position.x,t.position.y,t.position.z];h.c6(c,this._camera.position)||(this._setCameraPosition(c),o=!0)}o&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();let t=this._camera.position,o=new wc;return o.position=new h.ad(t[0],t[1],t[2]),o.orientation=this._camera.orientation,o._elevation=this.elevation,o._renderWorldCopies=this.renderWorldCopies,o}_setCameraOrientation(t){if(!h.c7(t))return!1;h.c8(t,t);let o=h.c9([],[0,0,-1],t),c=h.c9([],[0,-1,0],t);if(c[2]<0)return!1;let d=Kh(o,c);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(t){let o=this.zoomScale(this.minZoom)*this.tileSize,c=this.zoomScale(this.maxZoom)*this.tileSize,d=this.cameraToCenterDistance;t[2]=h.aB(t[2],d/c,d/o),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,o,c){this._unmodified=!1,this._edgeInsets.interpolate(t,o,c),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){let o=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,o)}getVisibleUnwrappedCoordinates(t){let o=[new h.ca(0,t)];if(this.renderWorldCopies){let c=this.pointCoordinate(new h.P(0,0)),d=this.pointCoordinate(new h.P(this.width,0)),m=this.pointCoordinate(new h.P(this.width,this.height)),_=this.pointCoordinate(new h.P(0,this.height)),y=Math.floor(Math.min(c.x,d.x,m.x,_.x)),v=Math.floor(Math.max(c.x,d.x,m.x,_.x)),T=1;for(let E=y-T;E<=v+T;E++)E!==0&&o.push(new h.ca(E,t))}return o}isLODDisabled(t){return(!t||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(t,o,c,d){let m=[],_=c!=null,y=!_;if(y&&this.zoom<o||_&&c[0]===0&&c[1]===0)return m;let v=new Set,T=(P,A,D,z,O)=>{let k=h.cm(A,P,D,z,O);v.has(k)||(m.push(new h.aU(P,A,D,z,O)),v.add(k))};for(let P=0;P<t.length;P++){let A=t[P];if(y&&A.canonical.z!==o||_&&d!==void 0&&d>A.canonical.z)continue;let D=A.canonical,z=A.overscaledZ,O=A.wrap,k=1<<D.z,N=D.x+1<k,q=D.x>0,Z=D.y+1<k,G=D.y>0,re=A.wrap-(q?0:1),te=A.wrap+(N?0:1),se=q?D.x-1:k-1,K=N?D.x+1:0;if(_)c[0]<0?(T(z,te,D.z,K,D.y),c[1]<0&&Z&&(T(z,O,D.z,D.x,D.y+1),T(z,te,D.z,K,D.y+1)),c[1]>0&&G&&(T(z,O,D.z,D.x,D.y-1),T(z,te,D.z,K,D.y-1))):c[0]>0?(T(z,re,D.z,se,D.y),c[1]<0&&Z&&(T(z,O,D.z,D.x,D.y+1),T(z,re,D.z,se,D.y+1)),c[1]>0&&G&&(T(z,O,D.z,D.x,D.y-1),T(z,re,D.z,se,D.y-1))):c[1]<0&&Z?T(z,O,D.z,D.x,D.y+1):G&&T(z,O,D.z,D.x,D.y-1);else{let J=A.visibleQuadrants;1&J&&(T(z,re,D.z,se,D.y),G&&(T(z,O,D.z,D.x,D.y-1),T(z,re,D.z,se,D.y-1))),2&J&&(T(z,te,D.z,K,D.y),G&&(T(z,O,D.z,D.x,D.y-1),T(z,te,D.z,K,D.y-1))),4&J&&(T(z,re,D.z,se,D.y),Z&&(T(z,O,D.z,D.x,D.y+1),T(z,re,D.z,se,D.y+1))),8&J&&(T(z,te,D.z,K,D.y),Z&&(T(z,O,D.z,D.x,D.y+1),T(z,te,D.z,K,D.y+1)))}}let E=[];for(let P of m)m.some(A=>P.isChildOf(A))||E.push(P);if(m=E.filter(P=>!t.some(A=>!!(P.overscaledZ<o&&A.isChildOf(P))||P.equals(A)||P.isChildOf(A))),y){let P=1<<o,A=this.projection.name==="globe"?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),D=[P*A.x,P*A.y],z=4,O=z*z;m=m.filter(k=>{let N=k.canonical.x+.5-D[0],q=k.canonical.y+.5-D[1];return N*N+q*q<O})}return m}extendTileCoverToNearPlane(t,o,c){let d=[],m=new Set;for(let q of t)m.add(q.key);let _=(q,Z,G,re,te)=>{let se=h.cm(Z,q,G,re,te);m.has(se)||(d.push(new h.aU(q,Z,G,re,te)),m.add(se))},y=t.reduce((q,Z)=>
8Math.max(q,Z.overscaledZ),c),v=1<<c,T=[new h.P(0,0),new h.P(h.ak,0),new h.P(h.ak,h.ak),new h.P(0,h.ak)],E=new h.P(0,0),P=new h.P(0,0),A=(q,Z)=>{let G=Math.floor(q[0]),re=Math.floor(q[1]),te=(q[0]-G)*h.ak,se=(q[1]-re)*h.ak,K=Math.floor(Z[0]),J=Math.floor(Z[1]),oe=(Z[0]-K)*h.ak,ue=(Z[1]-J)*h.ak;for(let de=-1;de<=1;de++){let be=G+de;if(!(be<0||be>=v)){E.x=te-de*h.ak,P.x=oe-(be-K)*h.ak;for(let ve=-1;ve<=1;ve++){let Fe=re+ve;E.y=se-ve*h.ak,P.y=ue-(Fe-J)*h.ak,h.cM(E,P,T)&&_(y,0,c,be,Fe)}}}},D=o.points,z=D[h.cb],O=D[h.cc],k=this._projectToGround(z,D[h.cd]),N=this._projectToGround(O,D[h.ce]);return A(z,k),A(O,N),d}_projectToGround(t,o){return h.cf(h.cg(),t,o,t[2]/(t[2]-o[2]))}_projectToZ(t,o,c){let d=t[2]-o[2];return Math.abs(d)<1e-6?h.ch(t):h.cf(h.cg(),t,o,(t[2]-c)/d)}extendTileCoverForTunnels(t,o,c,d){if(c<18)return[];let m=o.points,_=m[h.ci],y=m[h.cj],v=m[h.ck],T=m[h.cl];if(v[2]>=0&&T[2]>=0||_[2]<=0||y[2]<=0)return[];let E=v[2]<0?this._projectToZ(_,v,0):v,P=T[2]<0?this._projectToZ(y,T,0):T,A=-d,D=v[2]<A?this._projectToZ(_,v,A):v,z=T[2]<A?this._projectToZ(y,T,A):T,O=this._findExtensionTilesInQuad(t,c,[z,D,P,E],[.5*(E[0]+P[0]),.5*(E[1]+P[1])]);return O.length>3&&(O.length=3),O}_findExtensionTilesInQuad(t,o,c,d){let m=[],_=new Set;for(let K of t)_.add(K.key);let y=t.reduce((K,J)=>Math.max(K,J.overscaledZ),o),v=1<<o,T=[new h.P(c[0][0],c[0][1]),new h.P(c[1][0],c[1][1]),new h.P(c[3][0],c[3][1]),new h.P(c[2][0],c[2][1]),new h.P(c[0][0],c[0][1])],E=c[0][0],P=c[1][0],A=c[2][0],D=c[3][0],z=c[0][1],O=c[1][1],k=c[2][1],N=c[3][1],q=Math.max(0,Math.floor(Math.min(E,P,A,D))),Z=Math.min(v-1,Math.ceil(Math.max(E,P,A,D))-1),G=Math.max(0,Math.floor(Math.min(z,O,k,N))),re=Math.min(v-1,Math.ceil(Math.max(z,O,k,N))-1);for(let K=G;K<=re;K++)for(let J=q;J<=Z;J++){if(!h.au(T,J,K,J+1,K+1))continue;let oe=h.cm(0,y,o,J,K);_.has(oe)||(m.push(new h.aU(y,0,o,J,K)),_.add(oe))}let te=d[0],se=d[1];return m.sort((K,J)=>{let oe=K.canonical.x+.5-te,ue=K.canonical.y+.5-se,de=J.canonical.x+.5-te,be=J.canonical.y+.5-se;return oe*oe+ue*ue-(de*de+be*be)||K.canonical.x-J.canonical.x||K.canonical.y-J.canonical.y}),m}coveringTiles(t){let o=this.coveringZoomLevel(t),c=o,d=this.elevation&&this.elevation.exaggeration(),m=d&&!t.isTerrainDEM,_=this.projection.name==="mercator";if(t.minzoom!==void 0&&o<t.minzoom)return[];t.maxzoom!==void 0&&o>t.maxzoom&&(o=t.maxzoom);let y=this.locationCoordinate(this.center),v=this.center.lat,T=1<<o,E=[T*y.x,T*y.y,0],P=this.projection.name==="globe",A=!P,D=h.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,o,A),z=P?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),O=T*h.bY(1,this.center.lat),k=this._camera.position[2]/h.bY(1,this.center.lat),N=[T*z.x,T*z.y,k*(A?1:O)],q=P||d,Z=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),G=this.isLODDisabled(!0)?o:0,re;if(this._elevation&&t.isTerrainDEM)re=1e4*this._elevation.exaggeration();else if(this._elevation){let fe=this._elevation.getMinMaxForVisibleTiles();re=fe?fe.max:this._centerAltitude}else re=this._centerAltitude;let te=t.isTerrainDEM?-re:this._elevation?this._elevation.getMinElevationBelowMSL():0,se=this.projection.isReprojectedInTileSpace?h.co(this):1,K=fe=>{let Ce=new h.ad(fe.x+25e-6,fe.y,fe.z),Re=new h.ad(fe.x,fe.y+25e-6,fe.z),Ye=fe.toLngLat(),He=Ce.toLngLat(),je=Re.toLngLat(),Ue=this.locationCoordinate(Ye),lt=this.locationCoordinate(He),st=this.locationCoordinate(je),et=Math.hypot(lt.x-Ue.x,lt.y-Ue.y),it=Math.hypot(st.x-Ue.x,st.y-Ue.y);return Math.sqrt(et*it)*se/25e-6},J=fe=>{let Pe=re,Ce=te;return{aabb:h.cr(this,T,0,0,0,fe,Ce,Pe,this.projection),zoom:0,x:0,y:0,minZ:Ce,maxZ:Pe,wrap:fe,fullyVisible:!1}},oe=[],ue=[],de=o,be=t.reparseOverscaled?c:o,ve=(k-this._centerAltitude)*O,Fe=fe=>{if(!this._elevation||!fe.tileID||!_)return;let Pe=this._elevation.getMinMaxForTile(fe.tileID),Ce=fe.aabb;Pe?(Ce.min[2]=Pe.min,Ce.max[2]=Pe.max,Ce.center[2]=(Ce.min[2]+Ce.max[2])/2):(fe.shouldSplit=Ee(fe),fe.shouldSplit||(Ce.min[2]=Ce.max[2]=Ce.center[2]=this._centerAltitude))},pe=(fe,Pe)=>{if(.707*Pe<fe)return 1;let Ce=Pe/fe;return Ce/(1.4144271570014144+(Math.pow(1.1,Ce-1.4144271570014144+1)-1)/(1.1-1)-1)},Ee=fe=>{if(fe.zoom<G)return!0;
8if(fe.zoom===de)return!1;if(fe.shouldSplit!=null)return fe.shouldSplit;let Pe=fe.aabb.distanceX(N),Ce=fe.aabb.distanceY(N),Re=ve,Ye=1;if(P){Re=fe.aabb.distanceZ(N);let it=Math.pow(2,fe.zoom),ht=h.bZ((fe.y+1)/it),vt=h.bZ(fe.y/it),gt=Math.min(Math.max(v,ht),vt),Et=h.cQ(gt)/h.cQ(v);if(Ye=gt===v?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,Et/this._mercatorScaleRatio),this.zoom<=h.cN&&fe.zoom===de-1&&Et>=.9)return!0}else if(m&&(Re=fe.aabb.distanceZ(N)*O),this.projection.isReprojectedInTileSpace&&c<=5){let it=Math.pow(2,fe.zoom),ht=K(new h.ad((fe.x+.5)/it,(fe.y+.5)/it));Ye=ht>.85?1:ht}if(!_&&!P){let it=Math.sqrt(Pe*Pe+Ce*Ce+Re*Re),ht=(1<<de-fe.zoom)*Z*Ye;return ht*=pe(Math.max(Re,ve),it),it<ht}let He=Number.MAX_VALUE,je=0,Ue=fe.aabb.getCorners(),lt=[0,0,0];for(let it of Ue){h.aw(lt,it,N),P||(m?lt[2]*=O:lt[2]=ve);let ht=h.bk(lt,this._camera.forward());ht<He&&(He=ht,je=Math.abs(lt[2]))}let st=(1<<de-fe.zoom)*Z*Ye;if(st*=pe(Math.max(je,ve),He),He<st)return!0;let et=fe.aabb.closestPoint(E);return et[0]===E[0]&&et[1]===E[1]};if(this.renderWorldCopies)for(let fe=1;fe<=3;fe++)oe.push(J(-fe)),oe.push(J(fe));for(oe.push(J(0));oe.length>0;){let fe=oe.pop(),Pe=fe.x,Ce=fe.y,Re=fe.fullyVisible,Ye=()=>this.projection.name==="globe"&&(fe.y===0||fe.y===(1<<fe.zoom)-1);if(!Re){let He=q?fe.aabb.intersects(D):fe.aabb.intersectsFlat(D);if(He===0&&Ye()){let je=new h.cp(fe.zoom,Pe,Ce);He=h.cq(this,T,je,!0).intersects(D)}if(He===0)continue;Re=He===2}if(fe.zoom===de||!Ee(fe)){let He=fe.zoom===de?be:fe.zoom;if(t.minzoom&&t.minzoom>He)continue;let je=0;if(!Re){let et=q?fe.aabb.intersectsPrecise(D):fe.aabb.intersectsPreciseFlat(D);if(et===0&&Ye()){let it=new h.cp(fe.zoom,Pe,Ce);et=h.cq(this,T,it,!0).intersectsPrecise(D)}if(et===0)continue;if(t.calculateQuadrantVisibility)if(D.containsPoint(fe.aabb.center))je=15;else for(let it=0;it<4;it++)fe.aabb.quadrant(it).intersects(D)!==0&&(je|=1<<it)}let Ue=E[0]-(.5+Pe+(fe.wrap<<fe.zoom))*(1<<o-fe.zoom),lt=E[1]-.5-Ce,st=fe.tileID?fe.tileID:new h.aU(He,fe.wrap,fe.zoom,Pe,Ce);t.calculateQuadrantVisibility&&(st.visibleQuadrants=je),ue.push({tileID:st,distanceSq:Ue*Ue+lt*lt});continue}for(let He=0;He<4;He++){let je=(Pe<<1)+He%2,Ue=(Ce<<1)+(He>>1),lt={aabb:_?fe.aabb.quadrant(He):h.cr(this,T,fe.zoom+1,je,Ue,fe.wrap,fe.minZ,fe.maxZ,this.projection),zoom:fe.zoom+1,x:je,y:Ue,wrap:fe.wrap,fullyVisible:Re,tileID:void 0,shouldSplit:void 0,minZ:fe.minZ,maxZ:fe.maxZ};m&&!P&&(lt.tileID=new h.aU(fe.zoom+1===de?be:fe.zoom+1,fe.wrap,fe.zoom+1,je,Ue),Fe(lt)),oe.push(lt)}}if(this.fogCullDistSq){let fe=this.fogCullDistSq,Pe=this.horizonLineFromTop();ue=ue.filter(Ce=>{let Re=[0,0,0,1],Ye=[h.ak,h.ak,0,1],He=this.calculateFogTileMatrix(Ce.tileID.toUnwrapped());h.aD(Re,Re,He),h.aD(Ye,Ye,He);let je=h.cs([],Re,Ye),Ue=h.ct([],Re,Ye),lt=h.cO(je,Ue);if(lt===0)return!0;let st=!1,et=this._elevation;if(et&&lt>fe&&Pe!==0){let it=this.calculateProjMatrix(Ce.tileID.toUnwrapped()),ht;t.isTerrainDEM||(ht=et.getMinMaxForTile(Ce.tileID)),ht||(ht={min:te,max:re});let vt=h.cu(this.rotation),gt=[vt[0]*h.ak,vt[1]*h.ak,ht.max];h.ae(gt,gt,it),st=(1-gt[1])*this.height*.5<Pe}return lt<fe||st})}return ue.sort((fe,Pe)=>fe.distanceSq-Pe.distanceSq).map(fe=>fe.tileID)}resize(t,o){this.width=t,this.height=o,this.pixelsToGLUnits=[2/t,-2/o],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log2(t)}project(t){let o=h.aB(t.lat,-h.cv,h.cv),c=this.projection.project(t.lng,o);return new h.P(c.x*this.worldSize,c.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/h.bY(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,o){let c,d,m=this.centerPoint;if(this.projection.name==="globe"){let y=this.worldSize;c=(o.x-m.x)/y,d=(o.y-m.y)/y}else{let y=this.pointCoordinate(o),v=this.pointCoordinate(m);c=y.x-v.x,d=y.y-v.y}let _=this.locationCoordinate(t);this.setLocation(new h.ad(_.x-c,_.y-d))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t,o){return this.projection.locationPoint(this,t,o)}locationPoint3D(t,o){return this.projection.locationPoint(this,t,o,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t,o){return this.coordinateLocation(this.pointCoordinate3D(t,o))}locationCoordinate(t,o){let c=o?h.bY(o,t.lat):void 0,d=this.projection.project(t.lng,t.lat);return new h.ad(d.x,d.y,c)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(t,o){let c=o??this._centerAltitude,d=[t.x,t.y,0,1],m=[t.x,t.y,1,1];h.aD(d,d,this.pixelMatrixInverse),h.aD(m,m,this.pixelMatrixInverse);let _=m[3];h.cw(d,d,1/d[3]),h.cw(m,m,1/_);let y=d[2],v=m[2];return{p0:d,p1:m,t:y===v?0:(c-y)/(v-y)}}screenPointToMercatorRay(t){let o=[t.x,t.y,0,1],c=[t.x,t.y,1,1];return h.aD(o,o,this.pixelMatrixInverse),h.aD(c,c,this.pixelMatrixInverse),h.
8cw(o,o,1/o[3]),h.cw(c,c,1/c[3]),o[2]=h.bY(o[2],this._center.lat)*this.worldSize,c[2]=h.bY(c[2],this._center.lat)*this.worldSize,h.cw(o,o,1/this.worldSize),h.cw(c,c,1/this.worldSize),new h.ay([o[0],o[1],o[2]],h.ax([],h.aw([],c,o)))}rayIntersectionCoordinate(t){let{p0:o,p1:c,t:d}=t,m=h.bY(o[2],this._center.lat),_=h.bY(c[2],this._center.lat);return new h.ad(h.aj(o[0],c[0],d)/this.worldSize,h.aj(o[1],c[1],d)/this.worldSize,h.aj(m,_,d))}pointCoordinate(t,o=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,o)}pointCoordinate3D(t,o){if(!this.elevation)return this.pointCoordinate(t,o);let c=this.projection.pointCoordinate3D(this,t.x,t.y);if(c)return new h.ad(c[0],c[1],c[2]);let d=0,m=this.horizonLineFromTop();if(t.y>m)return this.pointCoordinate(t,o);let _=.02*m,y=t.clone();for(let v=0;v<10&&m-d>_;v++){y.y=h.aj(d,m,.66);let T=this.projection.pointCoordinate3D(this,y.x,y.y);T?(m=y.y,c=T):d=y.y}return c?new h.ad(c[0],c[1],c[2]):this.pointCoordinate(t)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=h.cx)return!this.isPointAboveHorizon(t);let o=this.pointCoordinate(t);return o.y>=0&&o.y<=1}_coordinatePoint(t,o){let c=o&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,d=[t.x*this.worldSize,t.y*this.worldSize,c+t.toAltitude(),1];return h.aD(d,d,this.pixelMatrix),d[3]>0?new h.P(d[0]/d[3],d[1]/d[3]):new h.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){let{top:t,left:o}=this._edgeInsets,c=this.height-this._edgeInsets.bottom,d=this.width-this._edgeInsets.right,m=this.pointLocation3D(new h.P(o,t)),_=this.pointLocation3D(new h.P(d,t)),y=this.pointLocation3D(new h.P(d,c)),v=this.pointLocation3D(new h.P(o,c)),T=Math.min(m.lng,_.lng,y.lng,v.lng),E=Math.max(m.lng,_.lng,y.lng,v.lng),P=Math.min(m.lat,_.lat,y.lat,v.lat),A=Math.max(m.lat,_.lat,y.lat,v.lat),D=Math.pow(2,-this.zoom)/16*270,z=this.projection.name==="globe"?1:4,O=(k,N,q,Z,G)=>{let re=(k+q)/2,te=(N+Z)/2,se=new h.P(re,te),{lng:K,lat:J}=this.pointLocation3D(se),oe=Math.max(0,T-K,P-J,K-E,J-A);T=Math.min(T,K),E=Math.max(E,K),P=Math.min(P,J),A=Math.max(A,J),(G<z||oe>D)&&(O(k,N,re,te,G+1),O(re,te,q,Z,G+1))};if(O(o,t,d,t,1),O(d,t,d,c,1),O(d,c,o,c,1),O(o,c,o,t,1),this.projection.name==="globe"){let[k,N]=h.cy(this);k?(A=90,E=180,T=-180):N&&(P=-90,E=180,T=-180)}return new h.aI(new h.aX(T,P),new h.aX(E,A))}_getBoundsRectangular(t,o){let{top:c,left:d}=this._edgeInsets,m=this.height-this._edgeInsets.bottom,_=this.width-this._edgeInsets.right,y=new h.P(d,c),v=new h.P(_,c),T=new h.P(_,m),E=new h.P(d,m),P=this.pointCoordinate(y,t),A=this.pointCoordinate(v,t),D=this.pointCoordinate(T,o),z=this.pointCoordinate(E,o),O=(k,N)=>(N.y-k.y)/(N.x-k.x);return P.y>1&&A.y>=0?P=new h.ad((1-z.y)/O(z,P)+z.x,1):P.y<0&&A.y<=1&&(P=new h.ad(-z.y/O(z,P)+z.x,0)),A.y>1&&P.y>=0?A=new h.ad((1-D.y)/O(D,A)+D.x,1):A.y<0&&P.y<=1&&(A=new h.ad(-D.y/O(D,A)+D.x,0)),new h.aI().extend(this.coordinateLocation(P)).extend(this.coordinateLocation(A)).extend(this.coordinateLocation(z)).extend(this.coordinateLocation(D))}_getBoundsRectangularTerrain(){let t=this.elevation;if(!t.visibleDemTiles.length||t.isUsingMockSource())return this._getBoundsRectangular(0,0);let o=t.visibleDemTiles.reduce((c,d)=>{if(d.dem){let m=d.dem.tree;c.min=Math.min(c.min,m.minimums[0]),c.max=Math.max(c.max,m.maximums[0])}return c},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(o.min*t.exaggeration(),o.max*t.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(t=!0){let o=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,c=this.height/2-o*(1-this._horizonShift);return t?Math.max(0,c):c}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-h.cv,this.maxLat=h.cv,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=h.aG(this.minLng)*this.tileSize,this.worldMaxX=h.aG(this.maxLng)*this.tileSize,this.worldMinY=h.aJ(this.maxLat)*this.tileSize,this.worldMaxY=h.aJ(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,o){return this.projection.createTileMatrix(this,o,t)}calculateDistanceTileData(t){let o=t.key,c=this._distanceTileDataCache;if(c[o])return c[o];let d=t.canonical,m=1/this.height,_=this.cameraWorldSize,y=_/this.zoomScale(d.z),v=(d.x+Math.pow(2,d.z)*t.wrap)*y,T=d.y*y,E=this.point;E.x*=_/this.worldSize,E.y*=_/this.worldSize;let P=this.angle,A=Math.sin(-P),D=-Math.cos(-P);return c[o]={bearing:[A,D],center:[(E.x-v)*m,(E.y-T)*m],scale:y/h.ak*m},c[o]}calculateFogTileMatrix(t){let o=t.key,c=this._fogTileMatrixCache;if(c[o])return c[o];let d=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return h.aC(d,this.worldToFogMatrix,d),c[o]=new Float32Array(d),c[o]}calculateProjMatrix(t,o=!1,c=!1){let d=t.key,m;if(m=c?this._expandedProjMatrixCache:o?this._alignedProjMatrixCache:this._projMatrixCache,m[d])return m[d];let _=this.calculatePosMatrix(t,this.worldSize),y;return y=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:c?this.expandedFarZProjMatrix:o?this.alignedProjMatrix:this.projMatrix,h.aC(_,y,_),m[d]=new Float32Array(_),m[d]}calculatePixelsToTileUnitsMatrix(t){let o=t.tileID.key,c=this._pixelsToTileUnitsCache;if(c[o])return c[o];let d=h.cz(t,this);return c[o]=d,c[o]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){let t=1/this.worldSize,o=h.bT([],[t,t,t]);return h.aC(o,o,this.globeMatrix),o}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;let t=this._elevation;this._updateCameraState();let o=h.bY(1,this._center.lat)*this.worldSize,c=this._computeCameraPosition(o),d=this._camera.forward(),m=h.bY(1,this._center.lat);c[2]/=m,d[2]/=m,h.ax(d,d);let _=t.raycast(c,d,t.exaggeration());if(_){let y=h.bi([],c,d,_),v=new h.ad(y[0],y[1],h.bY(y[2],h.bZ(y[1]))),T=(v.z+h.af([v.x-c[0],v.y-c[1],v.z-c[2]*m]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(T),this._centerAltitude=v.toAltitude(),this._center=this.coordinateLocation(v),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(t=!1){if(!this._elevation)return;let o=this._elevation,c=h.bY(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(c),m=o.getAtPointOrZero(new h.ad(...d)),_=this.pixelsPerMeter/this.worldSize*m,y=this._minimumHeightOverTerrain(),v=d[2]-_;if(v<=y)if(v<0||t){let T=this.locationCoordinate(this._center,this._centerAltitude),E=[d[0],d[1],T.z-d[2]],P=h.af(E);E[2]-=(y-v)/this._pixelsPerMercatorPixel;let A=h.af(E);if(A===0)return;h.bN(E,E,P/A*this._pixelsPerMercatorPixel),this._camera.position=[d[0],d[1],T.z*this._pixelsPerMercatorPixel-E[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){let A=this.center;return A.lat=h.aB(A.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(A.lng=h.aB(A.lng,this.minLng,this.maxLng)),this.center=A,void(this._constraining=!1)}let o=this._unmodified,{x:c,y:d}=this.point,m=0,_=c,y=d,v=this.width/2,T=this.height/2,E=this.worldMinY*this.scale,P=this.worldMaxY*this.scale;if(d-T<E&&(y=E+T),d+T>P&&(y=P-T),P-E<this.height&&(m=Math.max(m,this.height/(P-E)),y=(P+E)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){let A=this.worldMinX*this.scale,D=this.worldMaxX*this.scale,z=this.worldSize/2-(A+D)/2;_=(c+z+this.worldSize)%this.worldSize-z,_-v<A&&(_=A+v),_+v>D&&(_=D-v),D-A<this.width&&(m=Math.max(m,this.width/(D-A)),_=(D+A)/2)}_===c&&y===d||this._allowWorldUnderZoom||(this.center=this.unproject(new h.P(_,y))),m&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(m)),this._constrainCamera(),this._unmodified=o,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}
8_calcMatrices(){if(!this.height)return;let t=this.centerOffset,o=this.projection.name==="globe",c=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=h.bY(1,this.center.lat)/h.bY(1,h.cR));let d=h.cA(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,d),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;let m=this.projection.zAxisUnit==="meters"?c:1,_=this._camera.getWorldToCamera(this.worldSize,m),y,v=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(v[8]=2*-t.x/this.width,v[9]=2*t.y/this.height,this.isOrthographic){let re=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),te=re*this.aspect,se=-te,K=-re;te-=t.x,se-=t.x,re+=t.y,K+=t.y,y=this._camera.getCameraToClipOrthographic(se,te,K,re,this._nearZ+this._nearClipOffset,this._farZ),((J,oe,ue,de)=>{for(let be=0;be<16;be++)J[be]=h.aj(oe[be],ue[be],de)})(y,y,v,h.cP(this.pitch>=Ro?1:this.pitch/Ro))}else y=v;let T=h.cB([],v,_),E=h.cB([],y,_);if(this.projection.isReprojectedInTileSpace){let re=this.locationCoordinate(this.center);h.bA(this._mat4Scratch);let te=this._mat4Scratch;h.bB(te,te,[re.x*this.worldSize,re.y*this.worldSize,0]),h.aC(te,te,h.cC(this)),h.bB(te,te,[-re.x*this.worldSize,-re.y*this.worldSize,0]),h.aC(E,E,te),h.aC(T,T,te),this.inverseAdjustmentMatrix=h.cD(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(h.cE(this.mercatorMatrix,E,[this.worldSize,this.worldSize,this.worldSize/m,1]),this.projMatrix=E,h.ba(this.invProjMatrix,this.projMatrix),o){let re=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);re[8]=2*-t.x/this.width,re[9]=2*t.y/this.height,h.cB(this._expandedFarZProjMatrixBuf,re,_),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf}else this.expandedFarZProjMatrix=this.projMatrix;h.ba(this._mat4Scratch,y),this.frustumCorners=h.cF.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=h.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!o),h.bT(this.skyboxMatrix,[1,-1,1]),h.cG(this.skyboxMatrix,this.skyboxMatrix,this._pitch),h.bc(this.skyboxMatrix,this.skyboxMatrix,this.angle),h.bW(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);let P=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;h.cH(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=2*-t.x/this.width,this._mat4Scratch[9]=2*(t.y+P)/this.height,h.aC(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);let A=this.point,D=A.x,z=A.y,O=this.width%2/2,k=this.height%2/2,N=Math.cos(this.angle),q=Math.sin(this.angle),Z=D-Math.round(D)+N*O+q*k,G=z-Math.round(z)+N*k+q*O;if(h.cH(this.alignedProjMatrix,E),h.bB(this.alignedProjMatrix,this.alignedProjMatrix,[Z>.5?Z-1:Z,G>.5?G-1:G,0]),h.bT(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),h.bB(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),h.bT(this.glCoordMatrix,[1,-1,1]),h.bB(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),h.cE(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),h.aC(this.pixelMatrix,this.labelPlaneMatrix,T),this._calcFogMatrices(),this._distanceTileDataCache={},!h.ba(this.pixelMatrixInverse,this.pixelMatrix))throw new Error("failed to invert matrix");if(this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=h.cI(this);let re=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=h.ae(re,re,_),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};let t=this.cameraWorldSizeForFog,o=this.cameraPixelsPerMeter,c=this._camera.position,d=1/this.height/this._pixelsPerMercatorPixel,m=[t,t,o];h.bN(m,m,d),h.bN(c,c,-1),h.cJ(c,c,m),h.cK(this.mercatorFogMatrix,c),h.cE(this.mercatorFogMatrix,this.mercatorFogMatrix,m),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,o,d)}_computeCameraPosition(t){let o=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,c=this._camera.forward(),d=this.point,m=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*o-t/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-c[0]*m,d.y/this.worldSize-c[1]*m,t/this.worldSize*this._centerAltitude-c[2]*m]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){let o=this._maxCameraBoundsDistance()*Math.cos(this._pitch),c=this._camera.position[2],d=t[2],m=1;this.projection.wrap&&(this.center=this.center.wrap()),d>0&&(m=Math.min((o-c)/d,1)),this._camera.position=h.bi([],this._camera.position,t,m),this._updateStateFromCamera()}_updateStateFromCamera(){let t=this._camera.position,o=this._camera.forward(),{pitch:c,bearing:d}=this._camera.getPitchBearing(),m=h.bY(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,_=this._mercatorZfromZoom(this._maxZoom)*Math.cos(h.am(this._maxPitch)),y=Math.max((t[2]-m)/Math.cos(c),_),v=this._zoomFromMercatorZ(y);h.bi(t,t,o,y),this._pitch=h.aB(c,h.am(this.minPitch),h.am(this.maxPitch)),this.angle=h.bv(d,-Math.PI,Math.PI),this._setZoom(h.aB(v,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new h.ad(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){let t=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,t)*this.tileSize))}zoomFromMercatorZAdjusted(t){let o=0,c=h.cx,d=0,m=1/0;for(;c-o>1e-6&&c>o;){let _=o+.5*(c-o),y=this.tileSize*Math.pow(2,_),v=this.getCameraToCenterDistance(this.projection,_,y),T=this.scaleZoom(v/(Math.max(0,t)*this.tileSize)),E=Math.abs(_-T);E<m&&(m=E,d=_),_<T?o=_:c=_}return d}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(h.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,o){let c=Math.min(t.x,o.x),d=Math.max(t.x,o.x),m=Math.min(t.y,o.y),_=Math.max(t.y,o.y);if(m<this.horizonLineFromTop(!1))return!0;
8if(this.projection.name!=="mercator")return!1;let y=[new h.P(c,m),new h.P(d,_),new h.P(c,_),new h.P(d,m)],v=this.renderWorldCopies?-3:0,T=this.renderWorldCopies?4:1;for(let E of y){let P=this.pointRayIntersection(E);if(P.t<0)return!0;let A=this.rayIntersectionCoordinate(P);if(A.x<v||A.y<0||A.x>T||A.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+h.cL(this.fovAboveCenter)>88||this.anyCornerOffEdge(new h.P(0,0),new h.P(this.width,this.height))}zoomDeltaToMovement(t,o){let c=h.af(h.aw([],this._camera.position,t)),d=this._zoomFromMercatorZ(c)+o;return c-this._mercatorZfromZoom(d)}getCameraPoint(){if(this.projection.name==="globe"){let t=function([o,c,d],m){let _=[o,c,d,1];h.aD(_,_,m);let y=_[3]=Math.max(_[3],1e-6);return _[0]/=y,_[1]/=y,_[2]/=y,_}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new h.P(t[0],t[1])}{let t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new h.P(0,t))}}getCameraToCenterDistance(t,o=this.zoom,c=this.worldSize){let d=h.cA(t,o,this.width,this.height,1024),m=t.pixelSpaceConversion(this.center.lat,c,d),_=.5/Math.tan(.5*this._fov)*this.height*m;return this.isOrthographic&&(_=h.aj(1,_,h.cP(this.pitch>=Ro?1:this.pitch/Ro))),_}getWorldToCameraMatrix(){let t=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&h.aC(t,t,this.globeMatrix),t}getFrustum(t){return h.cn.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,this.projection.zAxisUnit==="meters")}}let Ps=(a,t)=>{if(t>0&&a.terrain&&h.w("Cutoff is currently disabled on terrain"),t<=0||a.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};let o=a.transform,c=o.pitch,d=o.isLODDisabled(!1)?60:30;if(c<d-15)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};let m=o._farZ-o._nearZ,_=t*o.height*1.3,y=Math.pow(2,.85*Math.max(o._zoom-a.minCutoffZoom,0)),v=1.4*o.cameraToCenterDistance*y,T=h.ag(d-15,d,c),E=(1-(P=T))*(o._farZ+_)+P*v;var P;let A=Math.min(_,E-o._nearZ);return{shouldRenderCutoff:T>0,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(E-o._nearZ)/m,(E-A-o._nearZ)/m]}}},_f=[];function Tc(a){return _f[a]=_f[a]||new Float64Array(16)}class V_{constructor(t,o){this.aabb=t,this.lastCascade=o}}class gf{add(t,o){let c=this.receivers[t.key];c!==void 0?(c.aabb.min[0]=Math.min(c.aabb.min[0],o.min[0]),c.aabb.min[1]=Math.min(c.aabb.min[1],o.min[1]),c.aabb.min[2]=Math.min(c.aabb.min[2],o.min[2]),c.aabb.max[0]=Math.max(c.aabb.max[0],o.max[0]),c.aabb.max[1]=Math.max(c.aabb.max[1],o.max[1]),c.aabb.max[2]=Math.max(c.aabb.max[2],o.max[2])):this.receivers[t.key]=new V_(o,null)}clear(){this.receivers={}}get(t){return this.receivers[t.key]}computeRequiredCascades(t,o,c){let d=h.cY.fromPoints(t.points),m=0;for(let _ in this.receivers){let y=this.receivers[_];if(!y||!d.intersectsAabb(y.aabb))continue;y.aabb.min=d.closestPoint(y.aabb.min),y.aabb.max=d.closestPoint(y.aabb.max);let v=y.aabb.getCorners();for(let T=0;T<c.length;T++){let E=!0;for(let P of v){let A=[P[0]*o,P[1]*o,P[2]];if(h.ae(A,A,c[T].matrix),A[0]<-1||A[0]>1||A[1]<-1||A[1]>1){E=!1;break}}if(y.lastCascade=T,m=Math.max(m,T),E)break}}return m+1}}class yf{constructor(t){this.painter=t,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new gf,this._depthMode=new nt(t.context.gl.LEQUAL,nt.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this._devtoolsFolder=null,this.useNormalOffset=!1,this._shadowParameters={cascadeCount:2,normalOffset:3,shadowMapResolution:2048}}destroy(){for(let t of this._cascades)t.texture.destroy(),t.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,o){let c=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!o||!o.properties)return;let d=o.properties.get("shadow-intensity"),m=o.properties.get("shadow-draw-before-layer");if(!o.shadowsEnabled()||d<=0)return;let _=-1,y=0;for(let N of c.style.order){let q=c.style._mergedLayers[N];q.hasShadowPass()&&!q.isHidden(t.zoom)&&(_=y),!m||m!==N&&m!==q.slot||(this._drawShadowAfterLayer=y>0?y-1:0),y+=1}if(this._enabled=_>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=_);let v=c.context,T=this._shadowParameters.shadowMapResolution,E=this._shadowParameters.shadowMapResolution;if(this._cascades.length===0||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let N=0;N<this._shadowParameters.cascadeCount;++N){let q=v.gl,Z=v.createFramebuffer(T,E,0,"texture"),G=new h.T(v,{width:T,height:E,data:null},q.DEPTH_COMPONENT16);Z.depthAttachment.set(G.texture),this._cascades.push({framebuffer:Z,texture:G,matrix:[],far:0,boundingSphereRadius:0,frustum:new h.cn,scale:0})}}this.shadowDirection=xf(o);let P=0;if(t.elevation){let N=t.elevation,q=[1e4,-1e4];N.visibleDemTiles.filter(Z=>Z.dem).forEach(Z=>{let G=Z.dem.tree;q[0]=Math.min(q[0],G.minimums[0]),q[1]=Math.max(q[1],G.maximums[0])}),q[0]!==1e4&&(P=(q[1]-q[0])*N.exaggeration())}let A=1.5*t.cameraToCenterDistance,D=3*A,z=new Float64Array(16);for(let N=0;N<this._cascades.length;++N){let q=this._cascades[N],Z=t.height/50,G=1;this._shadowParameters.cascadeCount===1?G=D:N===0?G=A:(Z=A,G=D);let[re,te]=j_(t,this.shadowDirection,Z,G,this._shadowParameters.shadowMapResolution,P);q.scale=t.scale,q.matrix=re,q.boundingSphereRadius=te,h.ba(z,q.matrix),q.frustum=h.cn.fromInvProjectionMatrix(z,1,0,!0),q.far=G}let O=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[O].far,this._cascades[O].far],this._uniformValues.u_shadow_intensity=d,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadowmap_0=11,this._uniformValues.u_shadowmap_1=12,this._groundShadowTiles=c.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});let k=c.transform.elevation;for(let N of this._groundShadowTiles){let q={min:0,max:0};if(k){let Z=k.getMinMaxForTile(N);Z&&(q=Z)}this.addShadowReceiver(N.toUnwrapped(),q.min,q.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(t){this._enabled=t}drawShadowPass(t,o){if(!this.enabled)return;let c=this.painter,d=c.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(c.transform.getFrustum(0),c.transform.worldSize,this._cascades),d.viewport.set([0,0,this._shadowParameters.shadowMapResolution,this._shadowParameters.shadowMapResolution]);for(let m=0;m<this._numCascadesToRender;++m){c.currentShadowCascade=m,d.bindFramebuffer.set(this._cascades[m].framebuffer.framebuffer),d.clear({color:h.C.white,depth:1});for(let _ of t.order){let y=t._mergedLayers[_];if(!y.hasShadowPass()||y.isHidden(c.transform.zoom))continue;let v=t.getLayerSourceCache(y),T=v?o[v.id]:void 0;(y.type==="model"||T&&T.length)&&c.renderLayer(c,v,y,T)}}c.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;let t=this.painter,o=t.style,c=t.context,d=c.gl,m=o.directionalLight,_=o.ambientLight;if(!m||!_)return;let y=[],v=Ps(t,t.longestCutoffRange);v.shouldRenderCutoff&&y.push("RENDER_CUTOFF"),y.push("RENDER_SHADOWS"),this.useNormalOffset&&y.push("NORMAL_OFFSET");let T=Ia(o,m,_),E=new nt(d.LEQUAL,nt.ReadOnly,t.depthRangeFor3D),P=new yt({func:d.EQUAL,mask:255},0,255,d.KEEP,d.KEEP,d.KEEP);for(let A of this._groundShadowTiles){let D=A.toUnwrapped(),z=t.isTileAffectedByFog(A),O=t.getOrCreateProgram("groundShadow",{defines:y,overrideFog:z});this.setupShadows(D,O),t.uploadCommonUniforms(c,O,D,null,v);let k=Qh(t.transform.calculateProjMatrix(D),T);O.draw(t,d.TRIANGLES,E,P,_t.multiply,pt.disabled,k,"ground_shadow",t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments,null,t.transform.zoom,null,null)}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(t){let o=this.painter.transform,c=o.calculatePosMatrix(t,o.worldSize);return h.aC(c,this._cascades[this.painter.currentShadowCascade].matrix,c),Float32Array.from(c)}
8calculateShadowPassMatrixFromMatrix(t){let o=h.bb(t);return h.aC(o,this._cascades[this.painter.currentShadowCascade].matrix,t),o}setupShadows(t,o,c){if(!this.enabled)return;let d=this.painter.transform,m=this.painter.context,_=m.gl,y=this._uniformValues,v=d.calculatePosMatrix(t,d.worldSize);for(let T=0;T<this._cascades.length;T++){let E=Tc(T);h.aC(E,this._cascades[T].matrix,v),y[T===0?"u_light_matrix_0":"u_light_matrix_1"]=E,m.activeTexture.set(_.TEXTURE0+11+T),this._cascades[T].texture.bindExtraParam(_.LINEAR,_.LINEAR,_.CLAMP_TO_EDGE,_.CLAMP_TO_EDGE,_.GREATER)}if(this.useNormalOffset=!!c,this.useNormalOffset){let T=h.cW(t.canonical),E=2/d.tileSize*h.ak/this._shadowParameters.shadowMapResolution,P=E*this._cascades[0].boundingSphereRadius,A=E*this._cascades.at(-1).boundingSphereRadius,D=(c==="vector-tile"?1:3)*function(z){let O=h.aB((z-22)/-22,0,1);return .125*(1-O)+4*O}(d.zoom);y.u_shadow_normal_offset=[T,P*D,A*D],y.u_shadow_bias=[1e-4,.0012,.012]}else y.u_shadow_bias=[36e-5,.0012,.012];o.setShadowUniformValues(m,y)}setupShadowsFromMatrix(t,o,c=!1){if(!this.enabled)return;let d=this.painter.context,m=d.gl,_=this._uniformValues;for(let y=0;y<this._shadowParameters.cascadeCount;y++){let v=Tc(y);h.aC(v,this._cascades[y].matrix,t),_[y===0?"u_light_matrix_0":"u_light_matrix_1"]=v,d.activeTexture.set(m.TEXTURE0+11+y),this._cascades[y].texture.bindExtraParam(m.LINEAR,m.LINEAR,m.CLAMP_TO_EDGE,m.CLAMP_TO_EDGE,m.GREATER)}if(this.useNormalOffset=c,c){let y=this._shadowParameters.normalOffset;_.u_shadow_normal_offset=[1,y,y],_.u_shadow_bias=[6e-5,.0012,.012]}else _.u_shadow_bias=[36e-5,.0012,.012];o.setShadowUniformValues(d,_)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,o,c,d){if(d[2]>=0)return{};let m=function(v,T,E){let P=E/(1<<v.canonical.z);return new h.cY([v.canonical.x*P+v.wrap*E,v.canonical.y*P+v.wrap*E,0],[(v.canonical.x+1)*P+v.wrap*E,(v.canonical.y+1)*P+v.wrap*E,T])}(t,o,c).getCorners(),_=o/-d[2];d[0]<0?(h.cX(m[0],m[0],[d[0]*_,0,0]),h.cX(m[3],m[3],[d[0]*_,0,0])):d[0]>0&&(h.cX(m[1],m[1],[d[0]*_,0,0]),h.cX(m[2],m[2],[d[0]*_,0,0])),d[1]<0?(h.cX(m[0],m[0],[0,d[1]*_,0]),h.cX(m[1],m[1],[0,d[1]*_,0])):d[1]>0&&(h.cX(m[2],m[2],[0,d[1]*_,0]),h.cX(m[3],m[3],[0,d[1]*_,0]));let y={};return y.vertices=m,y.planes=[dl(m[1],m[0],m[4]),dl(m[2],m[1],m[5]),dl(m[3],m[2],m[6]),dl(m[0],m[3],m[7])],y}addShadowReceiver(t,o,c){this._receivers.add(t,h.cY.fromTileIdAndHeight(t,o,c))}getMaxCascadeForTile(t){let o=this._receivers.get(t);return o&&o.lastCascade?o.lastCascade:0}}function dl(a,t,o){let c=h.aw([],o,t),d=h.aw([],a,t),m=h.bj([],c,d),_=h.af(m);return _===0?[0,0,1,0]:(h.bN(m,m,1/_),[m[0],m[1],m[2],-h.bk(m,t)])}function xf(a){let t=a.properties.get("direction"),o=h.cT(t.x,t.y,t.z);o[2]=h.aB(o[2],0,75);let c=h.cV([o[0],o[1],o[2]]);return h.cU(c.x,c.y,c.z)}function Ia(a,t,o){let c=t.properties.get("color-use-theme")==="none",d=t.properties.get("color"),m=t.properties.get("intensity"),_=t.properties.get("direction"),y=[_.x,_.y,_.z],v=o.properties.get("color-use-theme")==="none",T=o.properties.get("color"),E=o.properties.get("intensity"),P=Math.max(h.bk([0,0,1],y),0),A=[0,0,0];h.bN(A,T.toPremultipliedRenderColor(v?null:a.getLut(t.scope)).toArray01Linear().slice(0,3),E);let D=[0,0,0];return h.bN(D,d.toPremultipliedRenderColor(c?null:a.getLut(o.scope)).toArray01Linear().slice(0,3),P*m),h.c_([A[0]>0?A[0]/(A[0]+D[0]):0,A[1]>0?A[1]/(A[1]+D[1]):0,A[2]>0?A[2]/(A[2]+D[2]):0])}function j_(a,t,o,c,d,m){let _=a.zoom,y=a.scale,v=a.worldSize,T=1/v,E=a.aspect,P=Math.sqrt(1+E*E)*Math.tan(.5*a.fovX),A=P*P,D=c-o,z=c+o,O,k;A>D/z?(O=c,k=c*P):(O=.5*z*(1+A),k=.5*Math.sqrt(D*D+2*(c*c+o*o)*A+z*z*A*A));let N=a.projection.pixelsPerMeter(a.center.lat,v),q=a._camera.getCameraToWorldMercator(),Z=[0,0,-O*T];h.ae(Z,Z,q);let G=k*T,re=function(Re){return Re[0]/=y,Re[1]/=y,Re[2]=h.bY(Re[2],a._center.lat),Re},te=a._edgeInsets;if(!(te.left===0&&te.top===0&&te.right===0&&te.bottom===0||te.left===te.right&&te.top===te.bottom)){let Re=a._camera.getWorldToCamera(a.worldSize,a.projection.zAxisUnit==="meters"?N:1),Ye=a._camera.getCameraToClipPerspective(a._fov,a.width/a.height,o,c);Ye[8]=2*-a.centerOffset.x/a.width,Ye[9]=2*a.centerOffset.y/a.height;let He=new Float64Array(16);h.cB(He,Ye,Re);let je=new Float64Array(16);h.ba(je,He);let Ue=h.cn.fromInvProjectionMatrix(je,v,_,!0);for(let lt of Ue.points){let st=re(lt);G=Math.max(G,h.bO(h.cZ([],Z,st)))}}G*=d/(d-1);let se=Math.acos(t[2]),K=Math.atan2(-t[0],-t[1]),J=new ro;J.position=Z,J.setPitchBearing(se,K);let oe=J.getWorldToCamera(v,N),ue=G*v,de=Math.min(a._mercatorZfromZoom(17)*v*-2,-2*ue),be=J.getCameraToClipOrthographic(-ue,ue,-ue,ue,de,(ue+m*N)/t[2]),ve=new Float64Array(16);h.aC(ve,be,oe);let Fe=h.cU(Math.floor(1e6*Z[0])/1e6*v,Math.floor(1e6*Z[1])/1e6*v,0),pe=.5*d,Ee=[0,0,0];h.ae(Ee,Fe,ve),h.bN(Ee,Ee,pe);let fe=[Math.floor(Ee[0]),Math.floor(Ee[1]),Math.floor(Ee[2])],Pe=[0,0,0];h.aw(Pe,Ee,fe),h.bN(Pe,Pe,-1/pe);let Ce=new Float64Array(16);return h.bA(Ce),h.bB(Ce,Ce,Pe),h.aC(ve,Ce,ve),[ve,ue]}class G_ extends h.E{constructor(t){super(),this.requestManager=t,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(t,o){return h.c$(this.requestManager.transformRequest(o,h.R.Model).url).then(c=>{let d=h.d0(c),m=new h.d1(t,o,void 0,void 0,d);return m.computeBoundsAndApplyParent(),m}).catch(c=>{if(c&&c.status===404)return null;this.fire(new h.y(new Error(`Could not load model ${t} from ${o}: ${c.message}`)))})}load(t,o,c={forceReload:!1}){this.models[o]||(this.models[o]={});let d=Object.keys(t),m=[],_=[];for(let y of d){let v=t[y];this.hasURLBeenRequested(v)&&!c.forceReload||(this.modelByURL[v]={modelId:y,scope:o},m.push(this.loadModel(y,v)),_.push(y)),this.models[o][y]||(this.models[o][y]={model:null,numReferences:1})}this.numModelsLoading[o]=(this.numModelsLoading[o]||0)+_.length,Promise.allSettled(m).then(y=>{for(let v=0;v<y.length;v++){let{status:T}=y[v];if(T==="rejected")continue;let{value:E}=y[v];this.models[o][_[v]]||(this.models[o][_[v]]={model:null,numReferences:1}),this.models[o][_[v]].model=E}this.numModelsLoading[o]-=_.length,this.fire(new h.z("data",{dataType:"style"}))}).catch(y=>{this.fire(new h.y(new Error(`Could not load models: ${y.message}`)))})}isLoaded(){for(let t in this.numModelsLoading)if(this.numModelsLoading[t]>0)return!1;return!0}hasModel(t,o,c={exactIdMatch:!1}){return!!(c.exactIdMatch?this.getModel(t,o):this.getModelByURL(this.modelUris[o][t]))}getModel(t,o){return this.models[o]||(this.models[o]={}),this.models[o][t]?this.models[o][t].model:void 0}getModelByURL(t){if(!t)return null;let o=this.modelByURL[t];return o?this.models[o.scope][o.modelId].model:null}hasModelBeenAdded(t,o){return this.models[o]&&this.models[o][t]!==void 0}getModelURIs(t){return this.modelUris[t]||{}}addModel(t,o,c){this.models[c]||(this.models[c]={}),this.modelUris[c]||(this.modelUris[c]={});let d=this.requestManager.normalizeModelURL(o);if((this.hasModel(t,c,{exactIdMatch:!0})||this.hasModelBeenAdded(t,c))&&this.modelUris[c][t]===d)this.models[c][t].numReferences++;else if(this.hasURLBeenRequested(d)){let{scope:m,modelId:_}=this.modelByURL[d];this.models[m][_].numReferences++}else this.modelUris[c][t]=d,this.load({[t]:this.modelUris[c][t]},c)}addModelURLs(t,o){this.models[o]||(this.models[o]={}),this.modelUris[o]||(this.modelUris[o]={});let c=this.modelUris[o];for(let d in t)c[d]=this.requestManager.normalizeModelURL(t[d])}
8reloadModels(t){this.load(this.modelUris[t],t,{forceReload:!0})}addModelsFromBucket(t,o){this.models[o]||(this.models[o]={}),this.modelUris[o]||(this.modelUris[o]={});let c={};for(let d of t)this.hasModel(d,o,{exactIdMatch:!0})||this.hasURLBeenRequested(d)?this.models[o][d].numReferences++:this.modelUris[o][d]&&!this.hasURLBeenRequested(d)?c[d]=this.modelUris[o][d]:!this.hasURLBeenRequested(d)&&da(d,!1)&&(this.modelUris[o][d]=this.requestManager.normalizeModelURL(d),c[d]=this.modelUris[o][d]);this.load(c,o)}hasURLBeenRequested(t){return this.modelByURL[t]!==void 0}removeModel(t,o,c=!1,d=!1){if(this.models[o]&&this.models[o][t]&&(this.models[o][t].numReferences--,this.models[o][t].numReferences===0||d)){let m=this.modelUris[o][t];c||delete this.modelUris[o][t],delete this.modelByURL[m];let _=this.models[o][t].model;if(!_)return;delete this.models[o][t],_.destroy()}}destroy(){for(let t of Object.keys(this.models))for(let o of Object.keys(this.models[t])){let c=this.models[t][o].model;delete this.models[t][o],c&&c.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(t){return this.models[t]||(this.models[t]={}),Object.keys(this.models[t])}upload(t,o){this.models[o]||(this.models[o]={});for(let c in this.models[o])this.models[o][c].model&&this.models[o][c].model.upload(t.context)}}let vf=["RENDER_SHADOWS","NORMAL_OFFSET"],H_=new Set(["symbol","circle"]),pl=class jy{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null}needsBuild(){return this._needsBuild}buildQueue(t,o,c){this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;let d=c.stylesheet,m=!!c.fog,_=!!(c.getTerrain()||d&&d.terrain),y=!(!c.projection||c.projection.name!=="globe"),v=_||y,T=!(!c.directionalLight||!c.directionalLight.shadowsEnabled()),E=c.map&&c.map.painter,P=!E||!E.context.extParallelShaderCompile,A=!!E&&E.emissiveMode==="mrt-fallback",D=(z,O=[],k={})=>{this._queue.push({programId:z,params:Object.assign({},k.params,{defines:O,overrideFog:!!k.fog,overrideTerrain:!!k.terrain,overrideGlobe:!!k.globe,overrideRtt:!!k.rtt,precompiled:!0})})};for(let z of t){if(z.visibility==="none")continue;let O=z.getProgramIds();if(O)for(let k of O){if(H_.has(k))continue;let N=z.getDefaultProgramParams(k,o.zoom,c._styleColorTheme.lut);if(!N)continue;let q=E?E.getShaderSource(k):null,Z=v&&(!q||q.usedDefines.has("RENDER_TO_TEXTURE")),G=A&&Z?(N.defines||[]).concat("USE_MRT1"):N.defines;if(P){D(k,N.defines,{params:N}),Z&&D(k,G,{params:N,rtt:!0});continue}let re=m&&(!q||q.usedDefines.has("FOG")),te=_&&!z.isDraped()&&(!q||q.usedDefines.has("TERRAIN")),se=y&&(!q||q.usedDefines.has("GLOBE")),K=T&&z.hasElevation()&&(!q||q.usedDefines.has("RENDER_SHADOWS"));for(let J of K?[!1,!0]:[!1]){let oe=J?(N.defines||[]).concat(vf):N.defines||[];for(let ue of te?[!1,!0]:[!1])for(let de of se?[!1,!0]:[!1])for(let be of re?[!1,!0]:[!1])D(k,oe,{params:N,fog:be,terrain:ue,globe:de})}Z&&D(k,G,{params:N,rtt:!0})}}if(D("clippingMask"),_)for(let z of[!1,!0])D("terrainRaster",z?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:m});if(!P){if(t.some(z=>z.type==="hillshade")&&D("hillshadePrepare"),T)for(let z of[!1,!0])for(let O of[!1,!0]){let k=[];z&&k.push("RENDER_CUTOFF"),k.push("RENDER_SHADOWS"),O&&k.push("NORMAL_OFFSET"),D("groundShadow",k),m&&D("groundShadow",k,{fog:!0})}if(y){for(let z of[[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(let O of[!1,!0]){let k=[...z,"PROJECTION_GLOBE_VIEW"];O&&k.push("CUSTOM_ANTIALIASING"),D("globeRaster",k,{terrain:_,globe:!0,fog:m})}for(let z of[!1,!0]){let O=z?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];D("globeAtmosphere",O,{fog:!0,terrain:_,globe:z}),D("globeAtmosphere",[...O,"ALPHA_PASS"],{fog:!0,terrain:_,globe:z})}D("stars",[],{fog:m,terrain:_,globe:!0})}}}_executeBatch(t,o,c){if(c.map&&c.map.isMoving())return void(this._idleHandle=h.o.requestIdleCallback(y=>this._executeBatch(y,o,c)));o.context.sweepPendingPrograms();let d=o.context.extParallelShaderCompile?jy.DEADLINE_MARGIN_KHR_MS:jy.DEADLINE_MARGIN_SYNC_MS,m=0;for(;this._queue.length>0;){let y=this._queue.shift();if(!y||(o.style=c,o._fogVisible=!!y.params.overrideFog,o.getOrCreateProgram(y.programId,y.params),m++,t.timeRemaining()<=d))break}let _=this._queue.length===0||t.timeRemaining()>d;m>0&&_&&o.context.gl.flush(),this._idleHandle=this._queue.length>0||o.context._pendingPrograms.size>0?h.o.requestIdleCallback(y=>this._executeBatch(y,o,c)):null}processQueue(t,o){this._queue.length!==0&&(this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=h.o.requestIdleCallback(c=>this._executeBatch(c,t,o)))}reset(){this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0}};pl.DEADLINE_MARGIN_KHR_MS=5,pl.DEADLINE_MARGIN_SYNC_MS=25;let $_=pl,Du=h.a6.colorTheme,ed=new h.a8({data:new h.a9(Du.data)});function Ru(a){if(!a.metadata||!a.metadata.content_area)return;let t=h.o.devicePixelRatio,{left:o,top:c,width:d,height:m}=a.metadata.content_area,_=o*t,y=c*t;return[_,y,_+d*t,y+m*t]}function Lu(a){if(a)return a.map(([t,o])=>[t*h.o.devicePixelRatio,o*h.o.devicePixelRatio])}class Aa{constructor(t,o,c){this.id=t,this.scope=o,this.sourceCache=c,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(t){this.missingRequests.has(t.name)||this.pendingRequests.has(t.name)||this.pendingRequests.add(t.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){let t=new Map;if(!this.sourceCache.loaded())return t;let o=this.sourceCache.getVisibleCoordinates();if(o.length===0)return t;let c=this.sourceCache.getSource();if(!(c instanceof Ht))return t;let d=o.map(_=>this.sourceCache.getTile(_)),m=c.getImages(d,Array.from(this.pendingRequests));for(let[_,y]of m)t.set(h.I.from({name:_,iconsetId:this.id}),y),this.pendingRequests.delete(_);for(let _ of this.pendingRequests)this.missingRequests.add(_);return this.pendingRequests.clear(),t}}class Ma{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indo
8orMinimumZoom=16}findClosestBuilding(t,o,c,d,m){if(c<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let _=null,y=Number.MAX_VALUE,v=Number.MAX_VALUE,T=!1,E=this._previousClosestBuildingId?t[this._previousClosestBuildingId]:null;this._previousClosestBuildingId&&E&&this._isBuildingVisible(E,d,m)&&(T=!0,v=this._calculateDistance(o,E));for(let[P,A]of Object.entries(t)){if(!this._isBuildingVisible(A,d,m))continue;let D=this._calculateDistance(o,A);D<y&&(y=D,_=P)}return T&&_&&this._previousClosestBuildingId&&_!==this._previousClosestBuildingId?y>v*this._hysteresisRatio&&(_=this._previousClosestBuildingId):T&&!_&&(_=this._previousClosestBuildingId),this._previousClosestBuildingId=_,_}_calculateDistance(t,o){if(!o.center)return Number.MAX_VALUE;let c=t.lat-o.center[1],d=t.lng-o.center[0];return c*c+d*d}_isBuildingVisible(t,o,c){if(!c)return!1;for(let d of t.floorIds){let m=t.floors[d];if(!m.geometry)continue;let _=m.geometry;if(_.type==="Polygon"){let y=this._convertRingToPoints(_.coordinates[0]);if(h.bz(y,c))return!0}else if(_.type==="MultiPolygon"){let y=this._convertMultiPolygonToPoints(_.coordinates);if(h.d2(c,y))return!0}}return!1}_convertRingToPoints(t){return t.map(o=>new h.P(o[0],o[1]))}_convertMultiPolygonToPoints(t){return t.map(o=>o.length===0?[]:o[0].map(c=>new h.P(c[0],c[1])))}}class fl extends h.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Ma,this._initialLoadDone=!1,h.b0(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI()}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI))})}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(t){t===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=t,this._recalculateActiveFloors())}setActiveFloorsVisibility(t){this._updateActiveFloors(t),this._updateIndoorSelector()}setIndoorData(t){let o=!1;for(let[c,d]of Object.entries(t.buildings))if(this._buildings[c])for(let m of d.floorIds)this._buildings[c].floorIds.add(m),this._buildings[c].floors[m]?this._mergeFloors(this._buildings[c].floors[m],d.floors[m]):(this._buildings[c].floors[m]=d.floors[m],o=!0);else this._buildings[c]=d,o=!0;o&&this._recalculateActiveFloors()}getIndoorTileOptions(t,o){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(t,o),indoorState:this._indoorState}:null}getControlState(){let t=this._buildings,o=this._closestBuildingId,c=o&&t?t[o]:void 0;if(!c)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let d=null;for(let _ of c.floorIds)if(this._activeFloors&&this._activeFloors.has(_)){d=_;break}let m=Array.from(c.floorIds).map(_=>({id:_,name:c.floors[_].name,zIndex:c.floors[_].zIndex})).sort((_,y)=>y.zIndex-_.zIndex).filter((_,y,v)=>y===0||_.zIndex!==v[y-1].zIndex);return{selectedFloorId:d,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:m}}_updateUI(){this._initialLoadDone=!0;let t=this._style.map.transform,o=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,t.center,t.zoom,t.getBounds(),this._makeViewportPolygon());if(o!==this._closestBuildingId){let c=this._closestBuildingId;this._closestBuildingId=o,this._onBuildingTransition(c,o),this._updateIndoorSelector()}}_onBuildingTransition(t,o){if(!this._indoorState)return;!o&&t?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):!!o&&!t&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new h.z("selector-update",this.getControlState()))}
8_updateActiveFloors(t){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:t,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;let t=h.d3.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(o,c){if(o===c)return!0;if(!o||!c||o.size!==c.size)return!1;for(let d of o)if(!c.has(d))return!1;return!0})(t,this._activeFloors)||(this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(t,o){o.geometry&&(t.geometry?(t.geometry.type==="Polygon"&&(t.geometry={type:"MultiPolygon",coordinates:[t.geometry.coordinates]}),o.geometry.type==="Polygon"?t.geometry.coordinates.push(o.geometry.coordinates):o.geometry.type==="MultiPolygon"&&t.geometry.coordinates.push(...o.geometry.coordinates)):t.geometry=o.geometry)}_makeViewportPolygon(){let t=this._style.map.transform,o=t.width,c=t.height;return[t.pointLocation(new h.P(0,0)),t.pointLocation(new h.P(o,0)),t.pointLocation(new h.P(o,c)),t.pointLocation(new h.P(0,c))].map(d=>new h.P(d.lng,d.lat))}}let rr=(a,t)=>ma(a,t&&t.filter(o=>o.identifier!=="source.canvas")),bf=h.aK(Yt,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),td=h.aK(Yt,["setCenter","setZoom","setBearing","setPitch"]),zu=new Set(["background","sky","slot","custom"]),ml=new Set(["building"]),Sc={version:8,layers:[],sources:{}},Ec={duration:300,delay:0};class Nr extends h.E{constructor(t,o={}){if(super(),this.map=t,this.scope=o.scope||"",this.globalId=null,this.fragments=[],this.importDepth=o.importDepth||0,this.importsCache=o.importsCache||new Map,this.resolvedImports=o.resolvedImports||new Set,this.transition=Object.assign({},Ec),this._buildingIndex=new vu(this),this.crossTileSymbolIndex=new Ta,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedFillExtrusionSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=o.styleChanges||new xr,this._hasDataDrivenEmissive=!1,this.indoorManager=new fl(this),this.dispatcher=o.dispatcher?o.dispatcher:new Es(sl(),this),this.map.painter&&this.map.painter.context){let d=this.map.painter.context.maxUniformBufferBindings,m=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:d,maxUniformBlockSizeDwords:m,disableSymbolUBO:this.map.painter.context.disableSymbolUBO})}o.imageManager?this.imageManager=o.imageManager:(this.imageManager=new Dt(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=o.glyphManager?o.glyphManager:new h.d4(t._requestManager,o.localFontFamily?h.d5.all:o.localIdeographFontFamily?h.d5.ideographs:h.d5.none,o.localFontFamily||o.localIdeographFontFamily,o.fontstackCompositing),o.modelManager?this.modelManager=o.modelManager:(this.modelManager=new G_(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._fillExtrusionSourceCaches={},this._loaded=!1,this._initialBroadcastDone=!1,this._programPrecompiler=this.map._precompilePrograms&&this.isRootStyle()?new $_:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=o.configOptions?o.configOptions:new Map,this._configDependentLayers=o.configDependentLayers?o.configDependentLayers:new Set,this._indoorDependentLayers=o.indoorDependentLayers?o.indoorDependentLayers:new Set,this._config=o.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:o.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=o.initialConfig,this.dispatcher.broadcast("setReferrer",h.d6()),this.dispatcher.broadcast("setConfig",h.d7());let c=this;this._rtlTextPluginCallback=Nr.registerForPluginStateChange(d=>{c.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:d.pluginStatus,pluginURL:d.pluginURL},(m,_)=>{if(h.d8(m),_&&_.every(y=>y))for(let y in c._sourceCaches){let v=c._sourceCaches[y],T=v.getSource().type;T!=="vector"&&T!=="geojson"||v.reload()}})}),this.on("data",d=>{if(d.dataType!=="source"||d.sourceDataType!=="metadata")return;let m=this.getOwnSource(d.sourceId);if(m&&m.vectorLayerIds)for(let _ in this._layers){let y=this._layers[_];
8y.source===m.id&&this._validateLayer(y)}})}load(t){return t?(typeof t=="string"?this.loadURL(t):this.loadJSON(t),this):this}_getGlobalId(t){if(!t)return null;if(typeof t=="string"){if(h.e(t))return t;let o=h.d9(t);if(!o.startsWith("http"))try{return new URL(o,location.href).toString()}catch{return o}return o}return`json://${h.da(JSON.stringify(t))}`}_diffStyle(t,o,c){this.globalId=this._getGlobalId(t);let d=(m,_)=>{try{_(null,this.setState(m,c))}catch(y){_(y,!1)}};if(typeof t=="string"){let m=this.map._requestManager.normalizeStyleURL(t),_=this.map._requestManager.transformRequest(m,h.R.Style);h.m(_,(y,v)=>{y?this.fire(new h.y(y)):v&&d(v,o)})}else typeof t=="object"&&d(t,o)}loadURL(t,o={}){this.fire(new h.z("dataloading",{dataType:"style"}));let c=typeof o.validate=="boolean"?o.validate:!h.e(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,o.accessToken),this.resolvedImports.add(t);let d=this.importsCache.get(t);if(d)return this._load(d,c);let m=this.map._requestManager.transformRequest(t,h.R.Style);this._request=h.m(m,(_,y)=>{if(this._request=null,_)this.fire(new h.y(_));else if(y)return this.importsCache.set(t,y),this._load(y,c)})}loadJSON(t,o={}){this.fire(new h.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=h.o.frame(()=>{this._request=null,this._load(t,o.validate!==!1)})}loadEmpty(){this.fire(new h.z("dataloading",{dataType:"style"})),this._load(Sc,!1)}_loadImports(t,o,c){if(this.importDepth>=4)return h.w("Style doesn't support nesting deeper than 5"),Promise.resolve();let d=[];for(let m of t){let _=this._createFragmentStyle(m),y=new Promise(E=>{_.once("style.import.load",E),_.once("error",E)}).then(()=>{this.mergeAll(),this.fire(new h.z("data",{dataType:"style"}))});if(d.push(y),this.resolvedImports.has(m.url)){_.loadEmpty();continue}let v=m.data||this.importsCache.get(m.url);v?(m.data?(_.fire(new h.z("dataloading",{dataType:"style"})),_.globalId=_._getGlobalId(v),queueMicrotask(()=>_._load(v,o))):_.loadJSON(v,{validate:o}),this._isInternalStyle(v)&&(_.globalId=null)):m.url?_.loadURL(m.url,{validate:o}):_.loadEmpty();let T={style:_,id:m.id,config:m.config};if(c){let E=this.fragments.findIndex(({id:P})=>P===c);this.fragments=this.fragments.slice(0,E).concat(T).concat(this.fragments.slice(E))}else this.fragments.push(T)}return Promise.allSettled(d)}getImportGlobalIds(t=this,o=new Set){for(let c of t.fragments)c.style.globalId&&o.add(c.style.globalId),this.getImportGlobalIds(c.style,o);return[...o.values()]}_createFragmentStyle(t){let o=this.scope?h.t(t.id,this.scope):t.id,c,d=this._initialConfig&&this._initialConfig[o];(t.config||d)&&(c=Object.assign({},t.config,d));let m=new Nr(this.map,{scope:o,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:c,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return m.setEventedParent(this.map,{style:m}),m}_reloadImports(t=!1){this.mergeAll(),this._updateMapProjection(),t||this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),(!t||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(t&&this.isRootStyle()?(this.forEachFragmentStyle(o=>{this.dispatcher.broadcast("setLayers",{layers:o._serializeLayers(o._order),scope:o.scope,options:o.options})}),this._initialBroadcastDone=!0):this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}))}_isInternalStyle(t){return this.isRootStyle()&&(t.fragment||!!t.schema&&t.fragment!==!1)}_load(t,o){if(this._isInternalStyle(t)){let m=Object.assign({},Sc,{imports:[{id:"basemap",data:t,url:""}]},t.center?{center:t.center}:{},t.bearing?{bearing:t.bearing}:{},t.pitch?{pitch:t.pitch}:{},t.zoom?{zoom:t.zoom}:{},t.light?{light:t.light}:{});return this._importedAsBasemap=!0,void this._load(m,o)}
8if(this.updateConfig(this._config,t.schema),o&&rr(this,yn(t)))return;this._loaded=!0;for(let m in t.sources)this.addSource(m,t.sources[m],{validate:!1,isInitialLoad:!0});this.stylesheet=h.db(t);let c=()=>{if(t.iconsets)for(let v in t.iconsets)this.addIconset(v,t.iconsets[v]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);let m=sn(this.stylesheet.layers);if(this._order=m.map(v=>v.id),this.stylesheet.light&&h.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){let v=this.stylesheet.lights[0];this.light=new Vh(v.properties,v.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Vh(this.stylesheet.light)),this._layers={};for(let v of m){let T=h.dh(v,this.scope,this._styleColorTheme.lut,this.options);T.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(T.fqid),T.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(T.fqid),this._hasAppearances=this._hasAppearances||T.getAppearances().length!==0,T.setEventedParent(this,{layer:{id:T.id}}),this._layers[T.id]=T;let E=this.getOwnLayerSourceCache(T),P=!!this.directionalLight&&this.directionalLight.shadowsEnabled();E&&T.canCastShadows()&&P&&(E.castsShadows=!0)}if(this.glyphManager.url){let v=new Set;for(let T in this._layers){let E=this._layers[T];if(E.type==="symbol"&&E.layout){let P=E.layout.get("text-font");P&&P.value&&P.value.kind==="constant"&&v.add(P.value.value.join(","))}}for(let T of v)this.glyphManager.prefetchRange(T,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);let _=this.stylesheet.terrain;_&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(_,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new h.z("data",{dataType:"style"}));let y=this.isRootStyle();t.imports?this._loadImports(t.imports,o).then(()=>{this._reloadImports(!0),this.fire(new h.z(y?"style.load":"style.import.load"))}).catch(v=>{this.fire(new h.y(new Error("Failed to load imports",v))),this.fire(new h.z(y?"style.load":"style.import.load"))}):(this._reloadImports(!0),this.fire(new h.z(y?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];let d=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(d){let m=this._evaluateColorThemeData(d);this._loadColorTheme(m).then(()=>{c()}).catch(_=>{h.w(`Couldn't load color theme from the stylesheet: ${_}`),c()})}else this._styleColorTheme.lut=null,c()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(t=>t.style.hasAppearances())}mergeAll(){let t,o,c,d,m,_,y,v,T,E,P={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(A=>{if(A.stylesheet){if(A.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),A.light!=null&&(t=A.light),A.stylesheet.lights)for(let D of A.stylesheet.lights)D.type==="ambient"&&A.ambientLight!=null&&(o=A.ambientLight),D.type==="directional"&&A.directionalLight!=null&&(c=A.directionalLight);d=this._prioritizeTerrain(d,A.terrain,A.stylesheet.terrain),A.stylesheet.fog&&A.fog!=null&&(m=A.fog),A.stylesheet.snow&&A.snow!=null&&(_=A.snow),A.stylesheet.rain&&A.rain!=null&&(y=A.rain),A.stylesheet.camera!=null&&(E=A.stylesheet.camera),A.stylesheet.projection!=null&&(v=A.stylesheet.projection),A.stylesheet.transition!=null&&(T=A.stylesheet.transition),P[A.scope]=A._styleColorTheme}}),this.light=t,this.ambientLight=o,this.directionalLight=c,this.fog=m,this.snow=_,this.rain=y,this._styleColorThemeForScope=P,d===null?delete this.terrain:this.terrain=d,this.camera=E||{"camera-projection":"perspective"},this.projection=v||{name:"mercator"},this.transition=Object.assign({},Ec,T),this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset()}forEachFragmentStyle(t){let o=c=>
8{for(let d of c.fragments)o(d.style);t(c)};o(this)}_prioritizeTerrain(t,o,c){let d=t&&t.drapeRenderMode===0;return c===null?o&&o.drapeRenderMode===0?o:d?t:null:o!=null&&(!t||d||o&&o.drapeRenderMode===1)?o:t}mergeTerrain(){let t;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(o=>{t=this._prioritizeTerrain(t,o.terrain,o.stylesheet.terrain)}),t===null?delete this.terrain:this.terrain=t,this._programPrecompiler&&this._programPrecompiler.reset()}mergeProjection(){let t;this.forEachFragmentStyle(o=>{o.stylesheet.projection!=null&&(t=o.stylesheet.projection)}),this.projection=t||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset()}mergeSources(){let t={},o={},c={},d={};this.forEachFragmentStyle(m=>{for(let _ in m._sourceCaches){let y=h.t(_,m.scope);t[y]=m._sourceCaches[_]}for(let _ in m._otherSourceCaches){let y=h.t(_,m.scope);o[y]=m._otherSourceCaches[_]}for(let _ in m._symbolSourceCaches){let y=h.t(_,m.scope);c[y]=m._symbolSourceCaches[_]}for(let _ in m._fillExtrusionSourceCaches){let y=h.t(_,m.
8scope);d[y]=m._fillExtrusionSourceCaches[_]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=o,this._mergedSymbolSourceCaches=c,this._mergedFillExtrusionSourceCaches=d}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(let o of Object.values(t.stylesheet.indoor)){let c=o,d=h.t(c.sourceId,t.scope);this._mergedIndoor[d]=new Set(c.sourceLayers||[])}})}mergeLayers(){let t={},o=[],c={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(_=>{for(let y of _._order){let v=_._layers[y];if(v.type==="slot"){let T=h.dc(y);if(t[T])continue;t[T]=[]}v.slot&&t[v.slot]?t[v.slot].push(v):o.push(v)}}),this._mergedOrder=[];let d=-1,m=(_=[])=>{for(let y of _)if(y.type==="slot"){let v=h.dc(y.id);t[v]&&m(t[v]),this._mergedSlots.push(v)}else{let v=h.t(y.id,y.scope);this._mergedOrder.push(v),c[v]=y,y.is3D(!!this.terrain)&&(this._has3DLayers=!0,d=this._mergedOrder.length-1),y.type==="circle"&&(this._hasCircleLayers=!0),y.type==="symbol"&&(this._hasSymbolLayers=!0),y.type==="clip"&&(this._clipLayerPresent=!0)}};if(m(o),this._has3DLayers){let _={};for(let y=0;y<this._mergedOrder.length;++y){let v=this._mergedOrder[y];_[v]=y===d?1:y<d?c[v].hasOcclusionOpacityProperties?2:0:4}this._mergedOrder.sort((y,v)=>_[y]-_[v])}this._mergedLayers=c,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(o,c,d){let m=Object.assign({},c);for(let y of Object.keys(Du))m[y]===void 0&&(m[y]=Du[y].default);let _=new h.a7(ed,o,new Map(d));return _.setTransitionOrValue(m,d),_.untransitioned().possiblyEvaluate(new h.ab(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;let o=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((c,d)=>{let m="data:image/png;base64,";if(!t||t.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void c();let _=t;_.startsWith(m)||(_=m+_);let y=h.I.from("mapbox-reserved-lut"),v=new Image;v.src=_,v.onerror=()=>{this._styleColorTheme.lutLoading=!1,d(new Error("Failed to load image data"))},v.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==o)return void c();this._styleColorTheme.lutLoading=!1;let{width:T,height:E,data:P}=h.o.getImageData(v);if(E>32)return void d(new Error("The height of the image must be less than or equal to 32 pixels."));if(T!==E*E)return void d(new Error("The width of the image must be equal to the height squared."));this.getImage(y)&&this.removeImage(y),this.addImage(y,{data:new h.q({width:T,height:E},P),pixelRatio:1,sdf:!1,usvg:!1,version:0});let A=this.imageManager.getImage(y,this.scope);A?(this._styleColorTheme.lut={image:A.data,data:t},c()):d(new Error("Missing LUT image."))}})}getLut(t){let o=this._styleColorThemeForScope[t];return o?o.lut:null}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(o,c,d){let m,_,y,v=h.o.devicePixelRatio>1?"@2x":"",T=h.m(c.transformRequest(c.normalizeSpriteURL(o,v,".json"),h.R.SpriteJSON),(A,D)=>{T=null,y||(y=A,m=D,P())}),E=h.n(c.transformRequest(c.normalizeSpriteURL(o,v,".png"),h.R.SpriteImage),(A,D)=>{E=null,y||(y=A,_=D,P())});function P(){if(y)d(y);else if(m&&_){let A=h.o.getImageData(_),D={};for(let z in m){let{width:O,height:k,x:N,y:q,sdf:Z,pixelRatio:G,stretchX:re,stretchY:te,content:se}=m[z],K=new h.q({width:O,height:k});h.q.copy(A,K,{x:N,y:q},{x:0,y:0},{width:O,height:k},null),D[z]={data:K,pixelRatio:G!==void 0?G:1,sdf:Z!==void 0&&Z,stretchX:re,stretchY:te,content:se,usvg:!1,version:0}}d(null,D)}}return{cancel(){T&&(T.cancel(),T=null),E&&(E.cancel(),E=null)}}}(t,this.map._requestManager,(o,c)=>{if(this._spriteRequest=null,o)this.fire(new h.y(o));else if(c){let d=new Map;for(let m in c)d.set(h.I.from(m),c[m]);this.addImages(d)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new h.z("data",{dataType:"style"}))})}
8addIconset(t,o){if(o.type==="sprite")return void this._loadSprite(o.url);let c=this.getOwnSourceCache(o.source);if(!c)return void this.fire(new h.y(new Error(`Source "${o.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));let d=c.getSource();if(d.type!=="raster-array")return void this.fire(new h.y(new Error(`Source "${o.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));d.partial=!1;let m=new Aa(t,this.scope,c);this.imageManager.addImageProvider(m,this.scope)}removeIconset(t){this.imageManager.removeImageProvider(t,this.scope)}_loadIconset(t){if(!h.e(t)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(t);let o=this.map._spriteFormat==="auto";var c,d;this._spriteRequest=(d=(m,_)=>{if(this._spriteRequest=null,m)o?this._loadSprite(t):this.fire(new h.y(m));else if(_){let y=new Map;for(let v in _)y.set(h.I.from(v),_[v]);this.addImages(y)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new h.z("data",{dataType:"style"}))},h.b4((c=this.map._requestManager).transformRequest(c.normalizeIconsetURL(t),h.R.Iconset),(m,_)=>{if(m)return void d(m);let y={},v=new h.b2(_).readFields(Ja,{icons:[]},void 0);for(let T of v.icons){let E={version:1,pixelRatio:h.o.devicePixelRatio,content:Ru(T),stretchX:T.metadata?Lu(T.metadata.stretch_x_areas):void 0,stretchY:T.metadata?Lu(T.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:T};y[T.name]=E}d(null,y)}))}_validateLayer(t){let o=this.getOwnSource(t.source);if(!o)return;let c=t.sourceLayer;c&&(o.type==="geojson"||o.vectorLayerIds&&!o.vectorLayerIds.includes(c))&&this.fire(new h.y(new Error(`Source layer "${c}" does not exist on source "${o.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(let t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(let{style:t}of this.fragments)if(!t.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((t,o)=>{let c=this.fragments[o];return c&&c.style&&(t.data=c.style.serialize()),t})}_serializeSources(){let t={};for(let o in this._sourceCaches){let c=this._sourceCaches[o].getSource();t[c.id]||(t[c.id]=c.serialize())}return t}_serializeLayers(t){let o=[];for(let c of t){let d=this._layers[c];d&&d.type!=="custom"&&o.push(d.serialize())}return o}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(let t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(let t in this._mergedLayers){let o=this._mergedLayers[t];if(o._transitionablePaint&&o._transitionablePaint._values){let c=o._transitionablePaint._values["line-emissive-strength"];if(c&&c.value&&c.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(t){return t?this.order:this._mergedOrder}isLayerDraped(t){return!!this.terrain&&t.isDraped(this.getLayerSourceCache(t))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){let o=this.getOwnLayer(t);if(o)return o;this.fire(new h.y(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){let o=this.getOwnSource(t);if(o)return o;this.fire(new h.y(new Error(`The source '${t}' does not exist in the map's style.`)))}handleIdle(){let t=this.map.painter;t&&(t.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(t,this))}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset()}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);let o=this.calculateLightsBrightness();t.brightness=o||0,o!==this._brightness&&(this._brightness=o,this.dispatcher.broadcast("setBrightness",o)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));let c=this._changes.isDirty(),d=!1;if(this._changes.isDirty()){let v=this._changes.getLayerUpdatesByScope();for(let T in v){let{updatedIds:E,removedIds:P}=v[T];(E||P)&&(this._updateWorkerLayers(T,E,P),d=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset()}let m={};for(let v in this._mergedSourceCaches){let T=this._mergedSourceCaches[v];
8m[v]=T.used,T.used=!1,T.tileCoverLift=0}let _={};for(let v of this._mergedOrder){let T=this._mergedLayers[v];if((T.visibility!=="none"||T.hasTransition())&&T.recalculate(t,this._availableImages),!T.isHidden(t.zoom)){ml.has(T.type)&&h.dd();let E=this.getLayerSourceCache(T);E&&(E.used=!0,E.tileCoverLift=Math.max(E.tileCoverLift,T.tileCoverLift()))}if(T.type==="fill-extrusion"){let E=h.t(T.source,T.scope);if(E in this._mergedFillExtrusionSourceCaches){let P=T.layout&&T.layout.get("source-max-zoom");if(P!=null){let A=_[E];_[E]=A==null?P:Math.min(A,P)}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){let v=this._mergedOrder.map(T=>this._mergedLayers[T]);this._programPrecompiler.buildQueue(v,t,this)}for(let v in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[v].setMaxzoomOverride(_[v]!=null?_[v]:null);this.terrain&&d&&this.mergeLayers();let y=this.imageManager.getPendingImageProviders();for(let v of y)v.sourceCache.used=!0;for(let v in m){let T=this._mergedSourceCaches[v];m[v]!==T.used&&T.getSource().fire(new h.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:T.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),c&&this.fire(new h.z("data",{dataType:"style"}))}updateImageProviders(){let t=this.imageManager.getPendingImageProviders();for(let o of t){let c=o.resolvePendingRequests(),d=this.getFragmentStyle(o.scope);d&&d.addImages(c)}}_updateTilesForChangedImages(){let t={};for(let o in this._mergedSourceCaches){let c=this._mergedSourceCaches[o].getSource().scope;t[c]=t[c]||this._changes.getUpdatedImages(c),t[c].length!==0&&this._mergedSourceCaches[o].reloadTilesForDependencies(["icons","patterns"],t[c])}for(let o in t)this._changes.resetUpdatedImages(o)}_updateWorkerLayers(t,o,c){let d=this.getFragmentStyle(t);d&&this.dispatcher.broadcast("updateLayers",{layers:o?d._serializeLayers(o):[],scope:t,removedIds:c||[],options:d.options})}setState(t,o){if(this._checkLoaded(),rr(this,yn(t)))return!1;(t=h.db(t)).layers=sn(t.layers);let c=function(_,y){if(!_)return[{command:Yt.setStyle,args:[y]}];let v=[];try{if(!h.b9(_.version,y.version))return[{command:Yt.setStyle,args:[y]}];if(h.b9(_.center,y.center)||v.push({command:Yt.setCenter,args:[y.center]}),h.b9(_.zoom,y.zoom)||v.push({command:Yt.setZoom,args:[y.zoom]}),h.b9(_.bearing,y.bearing)||v.push({command:Yt.setBearing,args:[y.bearing]}),h.b9(_.pitch,y.pitch)||v.push({command:Yt.setPitch,args:[y.pitch]}),h.b9(_.sprite,y.sprite)||v.push({command:Yt.setSprite,args:[y.sprite]}),h.b9(_.glyphs,y.glyphs)||v.push({command:Yt.setGlyphs,args:[y.glyphs]}),h.b9(_.imports,y.imports)||function(D=[],z=[],O){z=z||[];let k=(D=D||[]).map(va),N=z.map(va),q=D.reduce(Un,{}),Z=z.reduce(Un,{}),G=k.slice(),re,te,se,K;for(re=0,te=0;re<k.length;re++)se=k[re],Object.hasOwn(Z,se)?te++:(O.push({command:Yt.removeImport,args:[se]}),G.splice(G.indexOf(se,te),1));for(re=0,te=0;re<N.length;re++)se=N[N.length-1-re],G[G.length-1-re]!==se&&(Object.hasOwn(q,se)?(O.push({command:Yt.removeImport,args:[se]}),G.splice(G.lastIndexOf(se,G.length-te),1)):te++,K=G[G.length-re],O.push({command:Yt.addImport,args:[Z[se],K]}),G.splice(G.length-re,0,se));for(let J of z){let oe=q[J.id];oe&&(delete oe.data,h.b9(oe,J)||O.push({command:Yt.updateImport,args:[J.id,J]}))}}(_.imports,y.imports,v),h.b9(_.transition,y.transition)||v.push({command:Yt.setTransition,args:[y.transition]}),h.b9(_.light,y.light)||v.push({command:Yt.setLight,args:[y.light]}),h.b9(_.fog,y.fog)||v.push({command:Yt.setFog,args:[y.fog]}),h.b9(_.snow,y.snow)||v.push({command:Yt.setSnow,args:[y.snow]}),h.b9(_.rain,y.rain)||v.push({command:Yt.setRain,args:[y.rain]}),h.b9(_.projection,y.projection)||v.push({command:Yt.setProjection,args:[y.projection]}),h.b9(_.lights,y.lights)||v.push({command:Yt.setLights,args:[y.lights]}),h.b9(_.camera,y.camera)||v.push({command:Yt.setCamera,args:[y.camera]}),h.b9(_.iconsets,y.iconsets)||function(D,z,O){let k;for(k in z=z||{},D=D||{}
8)Object.hasOwn(D,k)&&(Object.hasOwn(z,k)||O.push({command:Yt.removeIconset,args:[k]}));for(k in z){if(!Object.hasOwn(z,k))continue;let N=z[k];Object.hasOwn(D,k)?h.b9(D[k],N)||(O.push({command:Yt.removeIconset,args:[k]}),O.push({command:Yt.addIconset,args:[k,N]})):O.push({command:Yt.addIconset,args:[k,N]})}}(_.iconsets,y.iconsets,v),!h.b9(_["color-theme"],y["color-theme"]))return[{command:Yt.setStyle,args:[y]}];let T={},E=[];(function(D,z,O,k){let N;for(N in z=z||{},D=D||{})Object.hasOwn(D,N)&&(Object.hasOwn(z,N)||bu(N,O,k));for(N in z){if(!Object.hasOwn(z,N))continue;let q=z[N];Object.hasOwn(D,N)?h.b9(D[N],q)||(D[N].type==="geojson"&&q.type==="geojson"&&wu(D,z,N)?O.push({command:Yt.setGeoJSONSourceData,args:[N,q.data]}):mc(N,z,O,k)):al(N,z,O)}})(_.sources,y.sources,E,T);let P=[];_.layers&&_.layers.forEach(D=>{D.source&&T[D.source]?v.push({command:Yt.removeLayer,args:[D.id]}):P.push(D)});let A=_.terrain;A&&T[A.source]&&(v.push({command:Yt.setTerrain,args:[void 0]}),A=void 0),v=v.concat(E),h.b9(A,y.terrain)||v.push({command:Yt.setTerrain,args:[y.terrain]}),function(D,z,O){z=z||[];let k=(D=D||[]).map(va),N=z.map(va),q=D.reduce(Un,{}),Z=z.reduce(Un,{}),G=k.slice(),re=Object.create(null),te,se,K,J,oe,ue,de;for(te=0,se=0;te<k.length;te++)K=k[te],Object.hasOwn(Z,K)?se++:(O.push({command:Yt.removeLayer,args:[K]}),G.splice(G.indexOf(K,se),1));for(te=0,se=0;te<N.length;te++)K=N[N.length-1-te],G[G.length-1-te]!==K&&(Object.hasOwn(q,K)?(O.push({command:Yt.removeLayer,args:[K]}),G.splice(G.lastIndexOf(K,G.length-se),1)):se++,ue=G[G.length-te],O.push({command:Yt.addLayer,args:[Z[K],ue]}),G.splice(G.length-te,0,K),re[K]=!0);for(te=0;te<N.length;te++)if(K=N[te],J=q[K],oe=Z[K],!re[K]&&!h.b9(J,oe))if(h.b9(J.source,oe.source)&&h.b9(J["source-layer"],oe["source-layer"])&&h.b9(J.type,oe.type)){for(de in ll(J.layout,oe.layout,O,K,null,Yt.setLayoutProperty),ll(J.paint,oe.paint,O,K,null,Yt.setPaintProperty),h.b9(J.slot,oe.slot)||O.push({command:Yt.setSlot,args:[K,oe.slot]}),h.b9(J.filter,oe.filter)||O.push({command:Yt.setFilter,args:[K,oe.filter]}),h.b9(J.minzoom,oe.minzoom)&&h.b9(J.maxzoom,oe.maxzoom)||O.push({command:Yt.setLayerZoomRange,args:[K,oe.minzoom,oe.maxzoom]}),J)Object.hasOwn(J,de)&&de!=="layout"&&de!=="paint"&&de!=="filter"&&de!=="metadata"&&de!=="minzoom"&&de!=="maxzoom"&&de!=="slot"&&(de.indexOf("paint.")===0?ll(J[de],oe[de],O,K,de.slice(6),Yt.setPaintProperty):h.b9(J[de],oe[de])||O.push({command:Yt.setLayerProperty,args:[K,de,oe[de]]}));for(de in oe)Object.hasOwn(oe,de)&&!Object.hasOwn(J,de)&&de!=="layout"&&de!=="paint"&&de!=="filter"&&de!=="metadata"&&de!=="minzoom"&&de!=="maxzoom"&&de!=="slot"&&(de.indexOf("paint.")===0?ll(J[de],oe[de],O,K,de.slice(6),Yt.setPaintProperty):h.b9(J[de],oe[de])||O.push({command:Yt.setLayerProperty,args:[K,de,oe[de]]}))}else O.push({command:Yt.removeLayer,args:[K]}),ue=G[G.lastIndexOf(K)+1],O.push({command:Yt.addLayer,args:[oe,ue]})}(P,y.layers,v)}catch(T){console.warn("Unable to compute style diff:",T),v=[{command:Yt.setStyle,args:[y]}]}return v}(this.serialize(),t).filter(_=>!(_.command in td));if(c.length===0)return!1;let d=c.filter(_=>!(_.command in bf));if(d.length>0)throw new Error(`Unimplemented: ${d.map(_=>_.command).join(", ")}.`);let m=[];return c.forEach(_=>{m.push(this[_.command](..._.args))}),o&&Promise.all(m).then(o).catch(o),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t){if(t.size===0)return this;for(let[o,c]of t.entries()){if(this.getImage(o))return this.fire(new h.y(new Error(`An image with the name "${o.name}" already exists.`)));this.imageManager.addImage(o,this.scope,c),this._changes.updateImage(o,this.scope)}return this._updateWorkerImages(),this.fire(new h.z("data",{dataType:"style"})),this}addImage(t,o){return this.getImage(t)?this.fire(new h.y(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,o),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new h.z("data",{dataType:"style"})),this)}updateImage(t,o,c=!1){this.imageManager.updateImage(t,this.scope,o),c&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new h.z("data",{dataType:"style"})))}getImage(t){return this.imageManager.getImage(t,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new h.z("data",{dataType:"style"})),this):this.fire(new h.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new h.z("data",{dataType:"style"})),this}addModel(t,o,c={}
8){return this._checkLoaded(),this._validate(uc,`models.${t}`,o,null,c)||(this.modelManager.addModel(t,o,this.getActualScope()),this.fire(new h.z("data",{dataType:"style"}))),this}hasModel(t){return this.modelManager.hasModel(t,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new h.z("data",{dataType:"style"})),this):this.fire(new h.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,o,c={}){if(this._checkLoaded(),this.getOwnSource(t)!==void 0)throw new Error(`There is already a source with ID "${t}".`);if(!o.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(o).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(o.type)&&this._validate(Yp,`sources.${t}`,o,null,c))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);let d=$h(t,o,this.dispatcher,this);d.scope=this.scope,d.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(d.id),source:d.serialize(),sourceId:d.id}));let m=_=>{let y=(_===h.b7.Symbol?"symbol:":_===h.b7.FillExtrusion?"fill-extrusion:":"other:")+d.id,v=h.t(y,this.scope),T=this._sourceCaches[y]=new on(v,d,_);_===h.b7.Symbol?this._symbolSourceCaches[d.id]=T:_===h.b7.FillExtrusion?this._fillExtrusionSourceCaches[d.id]=T:this._otherSourceCaches[d.id]=T,T.onAdd(this.map)};m(h.b7.Other),o.type!=="vector"&&o.type!=="geojson"||(m(h.b7.Symbol),o.type==="vector"&&m(h.b7.FillExtrusion)),d.onAdd&&d.onAdd(this.map),c.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();let o=this.getOwnSource(t);if(!o)throw new Error("There is no source with this ID");for(let d in this._layers)if(this._layers[d].source===t)return this.fire(new h.y(new Error(`Source "${t}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new h.y(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){let d=Object.entries(this.stylesheet.iconsets).find(([m,_])=>_.type==="source"&&_.source===t);if(d)return this.fire(new h.y(new Error(`Source "${t}" cannot be removed while iconset "${d[0]}" is using it.`)))}let c=this.getOwnSourceCaches(t);for(let d of c){let m=h.dc(d.id);delete this._sourceCaches[m],this._changes.discardSourceCacheUpdate(d.id),d.fire(new h.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this.mergeSources(),o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(t,o){this._checkLoaded(),this.getOwnSource(t).setData(o),this._changes.setDirty()}getOwnSource(t){let o=this.getOwnSourceCache(t);return o&&o.getSource()}getOwnSources(){let t=[];for(let o in this._otherSourceCaches){let c=this.getOwnSourceCache(o);c&&t.push(c.getSource())}return t}areTilesLoaded(){let t=this._mergedSourceCaches;for(let o in t){let c=t[o]._tiles;for(let d in c){let m=c[d];if(m.state!=="loaded"&&m.state!=="errored")return!1}}return!0}setLights(t){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!t)return delete this.ambientLight,void delete this.directionalLight;let o=this._getTransitionParameters();for(let m of t){if(this._validate(Jp,"lights",m))return;switch(m.type){case"ambient":if(this.ambientLight){let _=this.ambientLight;_.set(m),_.updateTransitions(o)}else this.ambientLight=new Gh(m,z_(),this.scope,this.options);break;case"directional":if(this.directionalLight){let _=this.directionalLight;_.set(m),_.updateTransitions(o)}else this.directionalLight=new Gh(m,Jo(),this.scope,this.options)}}let c=Object.assign(o,{worldview:this.map.getWorldview()}),d=new h.ab(this.z||0,c);this.ambientLight&&this.ambientLight.recalculate(d),this.directionalLight&&this.directionalLight.recalculate(d),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){let t=this.directionalLight,o=this.ambientLight;if(!t||!o)return;let c=A=>.2126*(A[0]<=.03928?A[0]/12.92:Math.pow((A[0]+.055)/1.055,2.4))+.7152*(A[1]<=.03928?A[1]/12.92:Math.pow((A[1]+.055)/1.055,2.4))+.0722*(A[2]<=.03928?A[2]/12.92:Math.pow((A[2]+.055)/1.055,2.4)),d=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),m=t.properties.get("intensity"),_=t.properties.get("direction"),y=1-h.cT(_.x,_.y,_.z)[2]/90,v=c(d)*m*y,T=o.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),E=o.properties.get("intensity"),P=c(T)*E;return Number(((v+P)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;let t=[];return this.directionalLight&&t.push(this.directionalLight.get()),this.ambientLight&&t.push(this.ambientLight.get()),t}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(t==null||t===""&&this.isRootStyle())return this;if(h.de(t)){let o=h.df(t),c=this.fragments.find(({id:m})=>m===o);if(!c)return;let d=h.dc(t);return c.style.getFragmentStyle(d)}{let o=this.fragments.find(({id:c})=>c===t);return o?o.style:void 0}}setFeaturesetSelectors(t){if(!t)return;let o=(c,d="")=>`${c}::${d}`;this._featuresetSelectors={};for(let c in t){let d={},m=this._featuresetSelectors[c]=[];
8for(let _ of t[c].selectors){if(_.featureNamespace){let v=this.getOwnLayer(_.layer);if(!v){h.w(`Layer is undefined for selector: ${_.layer}`);continue}let T=o(v.source,v.sourceLayer);if(T in d&&d[T]!==_.featureNamespace){h.w(`"featureNamespace ${_.featureNamespace} of featureset ${c}'s selector is not associated to the same source, skip this selector`);continue}d[T]=_.featureNamespace}let y;if(_.properties)for(let v in _.properties){let T=h.U(_.properties[v]);T.result==="success"&&(y=y||{},y[v]=T.value)}m.push({layerId:_.layer,namespace:_.featureNamespace,properties:y,uniqueFeatureID:_._uniqueFeatureID})}}}getFeaturesetDescriptors(t){let o=this.getFragmentStyle(t);if(!o||!o.stylesheet.featuresets)return[];let c=[];for(let d in o.stylesheet.featuresets)c.push({featuresetId:d,importId:o.scope?o.scope:void 0});return c}getFeaturesetLayers(t,o){let c=this.getFragmentStyle(o),d=c.stylesheet.featuresets;if(!d||!d[t])return this.fire(new h.y(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];let m=[];for(let _ of d[t].selectors){let y=c.getOwnLayer(_.layer);y&&m.push(y)}return m}getConfigProperty(t,o){let c=this.getFragmentStyle(t);if(!c)return null;let d=h.t(o,c.scope),m=c.options.get(d),_=m?m.value||m.default:null;return _?_.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,o){let c=h.t(t,o);return this._mergedIndoor[c]}setIndoorData(t,o){this.indoorManager.setIndoorData(o)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,o,c){let d=this.getFragmentStyle(t);if(!d)return;let m=d.stylesheet.schema;if(!m||!m[o])return;let _=h.U(c);if(_.result!=="success")return void rr(this,_.value);let y=_.value.expression,v=h.t(o,d.scope),T=d.options.get(v);if(!T)return;let E,{minValue:P,maxValue:A,stepValue:D,type:z,values:O}=m[o],k=h.U(m[o].default);k.result==="success"&&(E=k.value.expression),E?(this.options.set(v,Object.assign({},T,{value:y,default:E,minValue:P,maxValue:A,stepValue:D,type:z,values:O})),this.updateConfigDependencies(o)):this.fire(new h.y(new Error(`No schema defined for the config option "${o}" in the "${t}" fragment.`)))}getConfig(t){let o=this.getFragmentStyle(t);if(!o)return null;let c=o.stylesheet.schema;if(!c)return null;let d={};for(let m in c){let _=h.t(m,o.scope),y=o.options.get(_),v=y?y.value||y.default:null;d[m]=v?v.serialize():null}return d}setConfig(t,o){let c=this.getFragmentStyle(t);c&&(c.updateConfig(o,c.stylesheet.schema),this.updateConfigDependencies())}getSchema(t){let o=this.getFragmentStyle(t);return o?o.stylesheet.schema:null}setSchema(t,o){let c=this.getFragmentStyle(t);c&&(c.stylesheet.schema=o,c.updateConfig(c._config,o),this.updateConfigDependencies())}updateConfig(t,o){if(this._config=t,t||o)if(o)for(let c in o){let d,m,_=h.U(o[c].default);if(_.result==="success"&&(d=_.value.expression),t&&t[c]!==void 0){let A=h.U(t[c]);A.result==="success"&&(m=A.value.expression)}let{minValue:y,maxValue:v,stepValue:T,type:E,values:P}=o[c];if(d){let A=h.t(c,this.scope);this.options.set(A,{default:d,value:m,minValue:y,maxValue:v,stepValue:T,type:E,values:P})}else this.fire(new h.y(new Error(`No schema defined for config option "${c}".`)))}else this.fire(new h.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(t,o=()=>!0){for(let c of t){let d=this.getLayer(c);d&&o(d)&&(d.possiblyEvaluateVisibility(),this._updateLayer(d),this._changes.setDirty())}}updateConfigDependencies(t){this._updateLayers(this._configDependentLayers,o=>!t||o.expressionDependencies.configDependencies.has(t)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(o=>{let c=o._styleColorTheme.colorThemeOverride?o._styleColorTheme.colorThemeOverride:o._styleColorTheme.colorTheme;if(c){let d=o._evaluateColorThemeData(c);(!o._styleColorTheme.lut&&d!==""||o._styleColorTheme.lut&&d!==o._styleColorTheme.lut.data)&&o.setColorTheme(c)}}),this._changes.setDirty()}addLayer(t,o,c={}){this._checkLoaded();let d=t.id;if(this._layers[d])return void this.fire(new h.y(new Error(`Layer with i
8d "${d}" already exists on this map`)));let m;if(t.type==="custom"){if(rr(this,h.dg(t)))return;m=h.dh(t,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof t.source=="object"&&(this.addSource(d,t.source),t=h.db(t),t=Object.assign(t,{source:d})),this._validate(tf,`layers.${d}`,t,{arrayIndex:-1},c))return;m=h.dh(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(m),m.setEventedParent(this,{layer:{id:d}})}let _=h.t(m.source,m.scope);m.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(_),m.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(_);let y=this._order.length;if(o){let P=this._order.indexOf(o);if(P===-1)return void this.fire(new h.y(new Error(`Layer with id "${o}" does not exist on this map.`)));m.slot&&m.slot!==this._layers[o].slot?h.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`):y=P}this._order.splice(y,0,d),this._handleLayerOrderChange(),this._layers[d]=m;let v=this.getOwnLayerSourceCache(m),T=!!this.directionalLight&&this.directionalLight.shadowsEnabled();v&&m.canCastShadows()&&T&&(v.castsShadows=!0);let E=this._changes.getRemovedLayer(m);if(E&&m.source&&v&&m.type!=="custom"){this._changes.discardLayerRemoval(m);let P=h.t(m.source,m.scope);E.type!==m.type?this._changes.updateSourceCache(P,"clear"):(this._changes.updateSourceCache(P,"reload"),v.pause())}this._updateLayer(m),m.onAdd&&m.onAdd(this.map),m.scope=this.scope,this.mergeLayers()}moveLayer(t,o){this._checkLoaded();let c=this._checkLayer(t);if(!c||t===o)return;let d=this._order.indexOf(t);this._order.splice(d,1);let m=this._order.length;if(o){let _=this._order.indexOf(o);
8if(_===-1)return void this.fire(new h.y(new Error(`Layer with id "${o}" does not exist on this map.`)));c.slot&&c.slot!==this._layers[o].slot?h.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`):m=_}this._order.splice(m,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(t){this._checkLoaded();let o=this._checkLayer(t);if(!o)return;o.setEventedParent(null);let c=this._order.indexOf(t);this._order.splice(c,1),delete this._layers[t],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(o.fqid),this._indoorDependentLayers.delete(o.fqid),this._changes.removeLayer(o);let d=this.getOwnLayerSourceCache(o);if(d&&d.castsShadows){let m=!1;for(let _ in this._layers)if(this._layers[_].source===o.source&&this._layers[_].canCastShadows()){m=!0;break}d.castsShadows=m}o.onRemove&&o.onRemove(this.map),this.mergeLayers()}getOwnLayer(t){return this._layers[t]}hasLayer(t){return t in this._mergedLayers}hasLayerType(t){for(let o in this._layers)if(this._layers[o].type===t)return!0;return!1}setLayerZoomRange(t,o,c){this._checkLoaded();let d=this._checkLayer(t);d&&(d.minzoom===o&&d.maxzoom===c||(o!=null&&(d.minzoom=o),c!=null&&(d.maxzoom=c),this._updateLayer(d)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(t,o){this._checkLoaded();let c=this._checkLayer(t);c&&c.slot!==o&&(c.slot=o,this._updateLayer(c))}setFilter(t,o,c={}){this._checkLoaded();let d=this._checkLayer(t);if(d&&!h.b9(d.filter,o))return o==null?(d.filter=void 0,void this._updateLayer(d)):void(this._validate(fa,`layers.${d.id}.filter`,o,{layerType:d.type},c)||(d.filter=h.db(o),this._updateLayer(d)))}getFilter(t){let o=this._checkLayer(t);if(o)return h.db(o.filter)}setLayoutProperty(t,o,c,d={}){this._checkLoaded();let m=this._checkLayer(t);if(m&&!h.b9(m.getLayoutProperty(o),c)){if(c!=null&&(!d||d.validate!==!1)&&rr(m,Nh.call(yn,{key:`layers.${t}.layout.${o}`,layerType:m.type,objectKey:o,value:c,styleSpec:h.a6,style:{glyphs:!0,sprite:!0}})))return;m.setLayoutProperty(o,c),m.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(m.fqid),m.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(m.fqid),this._updateLayer(m)}}setLayerProperty(t,o,c,d={}){this._checkLoaded();let m=this._checkLayer(t);m&&(o==="appearances"?(m.setAppearances(c),this._updateLayer(m)):m.isPaintProperty(o)?this.setPaintProperty(t,o,c,d):this.setLayoutProperty(t,o,c,d))}getLayoutProperty(t,o){let c=this._checkLayer(t);if(c)return c.getLayoutProperty(o)}setPaintProperty(t,o,c,d={}){this._checkLoaded();let m=this._checkLayer(t);if(!m||h.b9(m.getPaintProperty(o),c)||c!=null&&(!d||d.validate!==!1)&&rr(m,kh.call(yn,{key:`layers.${t}.paint.${o}`,layerType:m.type,objectKey:o,value:c,styleSpec:h.a6})))return;let _=m.setPaintProperty(o,c);m.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(m.fqid),m.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(m.fqid),_&&this._updateLayer(m),this._changes.updatePaintProperties(m)}getPaintProperty(t,o){let c=this._checkLayer(t);if(c)return c.getPaintProperty(o)}setFeatureState(t,o){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){let{featuresetId:v,importId:T}=t.target,E=this.getFragmentStyle(T),P=E.getFeaturesetLayers(v);for(let{source:A,sourceLayer:D}of P)E.setFeatureState({id:t.id,source:A,sourceLayer:D},o)}else if("layerId"in t.target){let{layerId:v}=t.target,T=this.getLayer(v);this.setFeatureState({id:t.id,source:T.source,sourceLayer:T.sourceLayer},o)}return}let c=t.source,d=t.sourceLayer,m=this._checkSource(c);if(!m)return;let _=m.type;if(_==="geojson"&&d)return void this.fire(new h.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(_==="vector"&&!d)return void this.fire(new h.y(new Error("The sourceLayer parameter must be provided for vector source types.")));t.id===void 0&&this.fire(new h.y(new Error("The feature id parameter must be provided.")));let y=this.getOwnSourceCaches(c);for(let v of y)v.setFeatureState(d,t.id,o)}removeFeatureState(t,o){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){let{featuresetId:v,importId:T}=t.target,E=this.getFragmentStyle(T),P=E.getFeaturesetLayers(v);for(let{source:A,sourceLayer:D}of P)E.removeFeatureState({id:t.id,source:A,sourceLayer:D},o)}else if("layerId"in t.target){let{layerId:v}=t.target,T=this.getLayer(v);this.removeFeatureState({id:t.id,source:T.source,sourceLayer:T.sourceLayer},o)}return}let c=t.source,d=this._checkSource(c);if(!d)return;let m=d.type,_=m==="vector"?t.sourceLayer:void 0;if(m==="vector"&&!_)return void this.fire(new h.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&typeof t.id!="string"&&typeof t.id!="number")return void this.fire(new h.y(new Error("A feature id is required to remove its specific state property.")));let y=this.getOwnSourceCaches(c);for(let v of y)v.removeFeatureState(_,t.id,o)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let m;if("featuresetId"in t.target){let{featuresetId:_,importId:y}=t.target,v=this.getFragmentStyle(y),T=v.getFeaturesetLayers(_);for(let{source:E,sourceLayer:P}of T){let A=v.getFeatureState({id:t.id,source:E,sourceLayer:P});if(A&&!m)m=A;else if(!h.b9(m,A))return void this.fire(new h.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){let{layerId:_}=t.target,y=this.getLayer(_);m=this.getFeatureState({id:t.id,source:y.source,sourceLayer:y.sourceLayer})}return m}let o=t.source,c=t.sourceLayer,d=this._checkSource(o);if(d){if(d.type!=="vector"||c)return t.id===void 0&&this.fire(new h.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(o)[0].getFeatureState(c,t.id);this.fire(new h.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(t){t!==this._worldview&&(this._worldview=t,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources())}serialize(){this._checkLoaded();let t=this.getTerrain(),o=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return h.di({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:o,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},c=>c!==void 0)}_updateFilteredLayers(t){for(let o of Object.values(this._mergedLayers))t(o)&&this._updateLayer(o)}_updateLayer(t){this._changes.updateLayer(t);let o=this.getLayerSourceCache(t),c=h.t(t.source,t.scope),d=this._changes.getUpd
8atedSourceCaches();t.source&&!d[c]&&o&&o.getSource().type!=="raster"&&(this._changes.updateSourceCache(c,"reload"),o.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){let o=y=>this._mergedLayers[y].is3D(!!this.terrain),c=this.order,d={},m=[];for(let y=c.length-1;y>=0;y--){let v=c[y];if(o(v)){d[v]=y;for(let T of t){let E=T[v];if(E)for(let P of E)m.push(P)}}}m.sort((y,v)=>v.intersectionZ-y.intersectionZ);let _=[];for(let y=c.length-1;y>=0;y--){let v=c[y];if(o(v))for(let T=m.length-1;T>=0;T--){let E=m[T].feature;if(E.layer&&d[E.layer.id]<y)break;_.push(E),m.pop()}else for(let T of t){let E=T[v];if(E)for(let P of E)_.push(P.feature)}}return _}queryRasterValue(t,o,c){let d=this.getOwnSource(t);return d?d.type!=="raster-array"?(this.fire(new h.y(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):d.queryRasterArrayValue(o,c):(this.fire(new h.y(new Error(`Source with id "${t}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(t,o,c){let d;o&&!Array.isArray(o)&&o.filter&&(this._validate(fa,"queryRenderedFeatures.filter",o.filter,null,o),d=h.dj(o.filter));let m={},_=E=>{if(zu.has(E.type))return;let P=this.getOwnLayerSourceCache(E),A=m[P.id]=m[P.id]||{sourceCache:P,layers:{},has3DLayers:!1};E.is3D(!!this.terrain)&&(A.has3DLayers=!0),A.layers[E.fqid]=A.layers[E.fqid]||{styleLayer:E,targets:[]},A.layers[E.fqid].targets.push({filter:d})};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new h.y(new Error("parameters.layers must be an Array."))),[];for(let E of o.layers){let P=this._layers[E];if(!P)return this.fire(new h.y(new Error(`The layer '${E}' does not exist in the map's style and cannot be queried for features.`))),[];_(P)}}else for(let E in this._layers)_(this._layers[E]);let y=this._queryRenderedFeatures(t,m,c),v=this._flattenAndSortRenderedFeatures(y),T=[];for(let E of v)h.dk(E.layer.id)===this.scope&&T.push(E);return T}queryRenderedFeatureset(t,o,c){let d;o&&!Array.isArray(o)&&o.filter&&(this._validate(fa,"queryRenderedFeatures.filter",o.filter,null,o),d=h.dj(o.filter));let m="mock",_=[];if(o&&o.target)_.push(Object.assign({},o,{targetId:m,filter:d}));else{let E=this.getFeaturesetDescriptors();for(let P of E)_.push({targetId:m,filter:d,target:P});for(let{style:P}of this.fragments){let A=P.getFeaturesetDescriptors();for(let D of A)_.push({targetId:m,filter:d,target:D})}}let y=this.queryRenderedTargets(t,_,c),v=[],T=new Set;for(let E of y)for(let P of E.variants[m])qh(P,E,T)||v.push(new h.dl(E,P));return v}queryRenderedTargets(t,o,c){let d={},m=(y,v,T,E)=>{let P=d[v.id]=d[v.id]||{sourceCache:v,layers:{},has3DLayers:!1};if(P.layers[y.fqid]=P.layers[y.fqid]||{styleLayer:y,targets:[]},y.is3D(!!this.terrain)&&(P.has3DLayers=!0),!E)return T.uniqueFeatureID=!1,void P.layers[y.fqid].targets.push(T);P.layers[y.fqid].targets.push(Object.assign({},T,{namespace:E.namespace,properties:E.properties,uniqueFeatureID:E.uniqueFeatureID}))};for(let y of o)if("featuresetId"in y.target){let{featuresetId:v,importId:T}=y.target,E=this.getFragmentStyle(T);if(!E||!E._featuresetSelectors)continue;let P=E._featuresetSelectors[v];if(!P){this.fire(new h.y(new Error(`The featureset '${v}' does not exist in the map's style and cannot be queried for features.`)));continue}for(let A of P){let D=E.getOwnLayer(A.layerId);D&&!zu.has(D.type)&&m(D,E.getOwnLayerSourceCache(D),y,A)}}else if("layerId"in y.target){let{layerId:v}=y.target,T=this.getLayer(v);if(!T||zu.has(T.type))continue;m(T,this.getLayerSourceCache(T),y)}let _=this._queryRenderedFeatures(t,d,c);return this._flattenAndSortRenderedFeatures(_)}_queryRenderedFeatures(t,o,c){let d=[],m=!!this.map._showQueryGeometry,_=rl.createFromScreenPoints(t,c);for(let y in o){let v=xu(_,o[y],this._availableImages,c,m,this.getActualScope());Object.keys(v).length&&d.push(v)}if(this.placement)for(let y in o){if(o[y].sourceCache._renderSourceType!==h.b7.Symbol)continue;let v=vo(_.screenGeometry,o[y],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(v).length&&d.push(v)}return d}querySourceFeatures(t,o){let c=o&&o.filter;
8c&&this._validate(fa,"querySourceFeatures.filter",c,null,o);let d=[],m=this.getOwnSourceCaches(t);for(let _ of m)d=d.concat(Zh(_,o));return d}addSourceType(t,o,c){return Nr.getSourceType(t)?c(new Error(`A source type called "${t}" already exists.`)):(Nr.setSourceType(t,o),c(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,o,c={}){this._checkLoaded();let d=this.light.getLight(),m=!1;for(let y in t)if(!h.b9(t[y],d[y])){m=!0;break}if(!m)return;let _=this._getTransitionParameters();this.light.setLight(t,o,c),this.light.updateTransitions(_)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=h.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&h.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(t,o=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),o===0&&delete this.terrain,t===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let c=t,d=!("source"in t)||t.source==null;if(o===1){if(this.disableElevatedTerrain)return;if("source"in c&&typeof c.source=="object"){let y="terrain-dem-src";this.addSource(y,c.source),c=h.db(c),c=Object.assign(c,{source:y})}let m=Object.assign({},c),_={};if(this.terrain&&d){m.source=this.terrain.get().source;let y=this.terrain?this.getFragmentStyle(this.terrain.scope):null;y&&(_.style=y.serialize())}if(this._validate(Kp,"terrain",m,_))return}if(!this.terrain||this.terrain.scope!==this.scope&&!d||this.terrain&&o!==this.terrain.drapeRenderMode){if(!c)return;this._createTerrain(c,o),this.fire(new h.z("data",{dataType:"style"}))}else{let m=this.terrain,_=m.get();for(let y of Object.keys(h.a6.terrain))!Object.hasOwn(c,y)&&h.a6.terrain[y].default&&(c[y]=h.a6.terrain[y].default);for(let y in t)if(!h.b9(t[y],_[y])){m.set(t,this.options),this.stylesheet.terrain=t;let v=this._getTransitionParameters({duration:0});m.updateTransitions(v),this.fire(new h.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){let o=this.fog=new of(t,this.map.transform,this.scope,this.options);this.stylesheet.fog=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}_createSnow(t){let o=this.snow=new fu(t,this.map.transform,this.scope,this.options);this.stylesheet.snow=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}_createRain(t){let o=this.rain=new dc(t,this.map.transform,this.scope,this.options);this.stylesheet.rain=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(let t of this.map._markers)t._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),t)if(this.fog){let o=this.fog;if(!h.b9(o.get(),t)){o.set(t,this.options),this.stylesheet.fog=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}}else this._createFog(t);else delete this.fog,delete this.stylesheet.fog;this._markersNeedUpdate=!0,this._programPrecompiler&&this._programPrecompiler.reset()}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){let o=this.snow;if(!h.b9(o.get(),t)){o.set(t,this.options),this.stylesheet.snow=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}}else this._createSnow(t);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){let o=this.rain;if(!h.b9(o.get(),t)){o.set(t,this.options),this.stylesheet.rain=o.get();let c=this._getTransitionParameters({duration:0});o.updateTransitions(c)}}else this._createRain(t);
8this._markersNeedUpdate=!0}_reloadColorTheme(){let t=()=>{for(let d in this._layers)this._layers[d].lut=this._styleColorTheme.lut;for(let d in this._sourceCaches)this._sourceCaches[d].clearTiles()},o=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!o)return this._styleColorTheme.lut=null,void t();let c=this._evaluateColorThemeData(o);this._loadColorTheme(c).then(()=>{this.fire(new h.z("colorthemeset")),t()}).catch(d=>{h.w(`Couldn't set color theme: ${d}`)})}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&h.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme()}setImportColorTheme(t,o){let c=this.getFragmentStyle(t);c&&(c._styleColorTheme.colorThemeOverride=o,c._reloadColorTheme())}_getTransitionParameters(t){return{now:h.o.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;let t=[],o=[];for(let c of this._mergedOrder)this.isLayerDraped(this._mergedLayers[c])?t.push(c):o.push(c);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...o)}_createTerrain(t,o){let c=this.terrain=new jh(t,o,this.scope,this.options,this.map.getWorldview());o===1&&(this.stylesheet.terrain=t),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();let d=this._getTransitionParameters({duration:0});c.updateTransitions(d)}_force3DLayerUpdate(){for(let t in this._layers){let o=this._layers[t];o.type==="fill-extrusion"&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(let t in this._layers){let o=this._layers[t];o.type==="symbol"&&this._updateLayer(o)}}_validate(t,o,c,d,m={}){if(m&&m.validate===!1)return!1;let _=Object.assign({},this.serialize());return rr(this,t.call(yn,Object.assign({key:o,style:_,value:c,styleSpec:h.a6},d)))}_remove(){this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),h.dm.off("pluginStateChange",this._rtlTextPluginCallback);for(let t in this._mergedLayers)this._mergedLayers[t].setEventedParent(null);for(let t in this._mergedSourceCaches){let o=this._mergedSourceCaches[t];o.clearTiles(),o.setEventedParent(null);let c=o.getSource();c&&c.onRemove&&c.onRemove(this.map)}this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(t){let o=this.getSourceCaches(t);for(let c of o)c.clearTiles()}clearSources(){for(let t in this._mergedSourceCaches)this._mergedSourceCaches[t].clearTiles()}clearLayers(){for(let t in this._mergedLayers){let o=this._mergedLayers[t];o._clear&&o._clear()}}reloadSource(t){let o=this.getSourceCaches(t);for(let c of o)c.resume(),c.reload()}reloadSources(){for(let t of this.getSources())t.reload&&t.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(t=>{t.modelManager.reloadModels(t.scope)})}updateSources(t){let o;this.directionalLight&&(o=xf(this.directionalLight));let c=new Set,d=new Set,m=new Set;for(let _ in this._mergedLayers){let y=this._mergedLayers[_];y.type==="building"?c.add(y.source):y.type==="raster"&&y.paint&&y.paint.get("raster-elevation-reference")==="ground"&&m.add(y.source),y.hasElevation()&&
8!d.has(y.source)&&d.add(y.source)}for(let _ in this._mergedSourceCaches){let y=this._mergedSourceCaches[_],v=d.has(y._source.id);y._isRasterElevatedOverTerrain=m.has(y._source.id),c.has(y._source.id)&&(y._source.reparseOverscaled=!1),y.update(t,void 0,void 0,o,v)}}_reloadSources(){for(let t in this._sourceCaches){let o=this._sourceCaches[t];o.resume(),o.reload()}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new h.z("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Mu),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(t,o,c,d,m){this.pauseablePlacement||(this.pauseablePlacement=new Mu);let _=!1,y=!1,v={},T={};for(let O of this._mergedOrder){let k=this._mergedLayers[O];if(k.type!=="symbol")continue;let N=h.t(k.source,k.scope),q=v[N];if(!q){let G=this.getLayerSourceCache(k);if(!G)continue;let re=G.getRenderableIds(!0).map(te=>G.getTileByID(te));T[N]=re.slice(),q=v[N]=re.sort((te,se)=>se.tileID.overscaledZ-te.tileID.overscaledZ||(te.tileID.isLessThan(se.tileID)?-1:1))}let Z=this.crossTileSymbolIndex.addLayer(k,q,t.center.lng,t.projection);_=_||Z}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);let E=!!(this.placement&&!t.equals(this.placement.transform)),P=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!m||this.placement.lastReplacementSourceUpdateTime!==m.updateTime)),A=E||P||_,D=(A||this.pauseablePlacement.isStale())&&c===0,z=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(h.o.now(),t.zoom)&&c!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||D||z)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,o,c,d,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){let O=this.map.painter.maxFrontCutoffRawStart;if(O>0){let k=180*t.pitch/Math.PI;if(k>=15){let N=Math.min(1,Math.max(0,(k-15)/5)),q=N*N*(3-2*N);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-q)+O*q}}}if(this.pauseablePlacement.isDone()?A&&c!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,v,T,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(h.o.now()),y=!0),_&&this.pauseablePlacement.setStale()),y||_){this._buildingIndex.onNewFrame(t.zoom);for(let O=0;O<this._mergedOrder.length;O++){let k=this._mergedLayers[this._mergedOrder[O]];if(k.type!=="symbol"||k.visibility==="none")continue;let N=this.isLayerClipped(k);this.placement.updateLayerOpacities(k,v[h.t(k.source,k.scope)],O,N?m:null)}}return!this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(h.o.now())}_releaseSymbolFadeTiles(){for(let t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}addImport(t,o){this._checkLoaded();let c=this.stylesheet.imports=this.stylesheet.imports||[];if(c.findIndex(({id:m})=>m===t.id)!==-1)return void this.fire(new h.y(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!o)return c.push(t),this._loadImports([t],!0);let d=c.findIndex(({id:m})=>m===o);return d===-1&&this.fire(new h.y(new Error(`Import with id "${o}" does not exist on this map.`))),this.stylesheet.imports=c.slice(0,d).concat(t).concat(c.slice(d)),this._loadImports([t],!0,o)}updateImport(t,o){this._checkLoaded();let c=this.stylesheet.imports||[],d=this.getImportIndex(t);return d===-1?this:typeof o=="string"?(this.setImportUrl(t,o),this):(o.url&&o.url!==c[d].url&&this.setImportUrl(t,o.url),h.b9(o.config,c[d].config)||this.setImportConfig(t,o.config,o.data.schema),h.b9(o.data,c[d].data)||this.setImportData(t,o.data),this)}moveImport(t,o){this._checkLoaded();let c=this.stylesheet.imports||[],d=this.getImportIndex(t);if(d===-1)return this;let m=this.getImportIndex(o);if(m===-1)return this;let _=c[d],y=this.fragments[d];return c=c.filter(({id:v})=>v!==t),this.fragments=this.fragments.filter(({id:v})=>v!==t),this.stylesheet.imports=c.slice(0,m).concat(_).concat(c.slice(m)),this.fragments=this.fragments.slice(0,m).concat(y).concat(this.fragments.slice(m)),this.mergeLayers(),this}setImportUrl(t,o){this._checkLoaded();let c=this.stylesheet.imports||[],d=this.getImportIndex(t);if(d===-1)return this;c[d].url=o;let m=this.fragments[d];return m.style=this._createFragmentStyle(c[d]),m.style.on("style.import.load",()=>this.mergeAll()),m.style.loadURL(o),this}setImportData(t,o){this._checkLoaded();let c=this.getImportIndex(t),d=this.stylesheet.imports||[];return c===-1?this:o?(this.fragments[c].style.setState(o),this._reloadImports(),this):(delete d[c].data,this.setImportUrl(t,d[c].url))}setImportConfig(t,o,c){this._checkLoaded();let d=this.getImportIndex(t),m=this.stylesheet.imports||[];if(d===-1)return this;o?m[d].config=o:delete m[d].config;let _=this.fragments[d];c&&_.style.stylesheet&&(_.style.stylesheet.schema=c);let y=_.style.stylesheet&&_.style.stylesheet.schema;return _.config=o,_.style.updateConfig(o,y),this.updateConfigDependencies(),this}removeImport(t){this._checkLoaded();let o=this.stylesheet.imports||[],c=this.getImportIndex(t);c!==-1&&(o.splice(c,1),this.fragments[c].style._remove(),this.fragments.splice(c,1),this._reloadImports())}getImportIndex(t){let o=(this.stylesheet.imports||[]).findIndex(c=>c.id===t);return o===-1&&this.fire(new h.y(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),o}
8getLayer(t){return this._mergedLayers[t]}getSources(){let t=[];for(let o in this._mergedOtherSourceCaches){let c=this._mergedOtherSourceCaches[o];c&&t.push(c.getSource())}return t}getSource(t,o){let c=this.getSourceCache(t,o);return c&&c.getSource()}getLayerSource(t){let o=this.getLayerSourceCache(t);return o&&o.getSource()}getSourceCache(t,o){let c=h.t(t,o);return this._mergedOtherSourceCaches[c]}getLayerSourceCache(t){let o=h.t(t.source,t.scope);return t.type==="symbol"?this._mergedSymbolSourceCaches[o]:t.type==="fill-extrusion"&&this._mergedFillExtrusionSourceCaches[o]||this._mergedOtherSourceCaches[o]}getSourceCaches(t){if(t==null)return Object.values(this._mergedSourceCaches);let o=[];return this._mergedOtherSourceCaches[t]&&o.push(this._mergedOtherSourceCaches[t]),this._mergedSymbolSourceCaches[t]&&o.push(this._mergedSymbolSourceCaches[t]),this._mergedFillExtrusionSourceCaches[t]&&o.push(this._mergedFillExtrusionSourceCaches[t]),o}updateSourceCaches(){let t=this._changes.getUpdatedSourceCaches();for(let o in t){let c=t[o];c==="reload"?this.reloadSource(o):c==="clear"&&this.clearSource(o)}}updateLayers(t){let o=this._changes.getUpdatedPaintProperties();for(let c of o){let d=this.getLayer(c);d&&d.updateTransitions(t)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(t){this.stylesheet.glyphs=t,this.glyphManager.setURL(t)}getImages(t,o,c){this.imageManager.getImages(o.icons.concat(o.patterns),o.scope,c),this._updateTilesForChangedImages();let d=o.icons.map(v=>h.I.toString(v)),m=o.patterns.map(v=>h.I.toString(v)),_=v=>{v&&(v.setDependencies(o.tileID.key,"icons",d),v.setDependencies(o.tileID.key,"patterns",m))},y=h.t(o.source,o.scope);_(this._mergedOtherSourceCaches[y]),_(this._mergedSymbolSourceCaches[y]),(o.icons.some(v=>v.iconsetId)||o.patterns.some(v=>v.iconsetId))&&this.fire(new h.z("data",{dataType:"style"}))}rasterizeImages(t,o,c){this.imageManager.rasterizeImages(o,c)}checkAtlasCache(t,o,c){let d=this.imageManager.imageAtlasCache.findCachedAtlas(o.descriptor);c(null,d&&d.contentDescriptor?{iconPositions:d.iconPositions,patternPositions:d.patternPositions,sourceHash:d.contentDescriptor.hash}:null)}getGlyphs(t,o,c){this.glyphManager.getGlyphs(o.stacks,c)}getOwnSourceCache(t){return this._otherSourceCaches[t]}getOwnLayerSourceCache(t){return t.type==="symbol"?this._symbolSourceCaches[t.source]:t.type==="fill-extrusion"&&this._fillExtrusionSourceCaches[t.source]||this._otherSourceCaches[t.source]}getOwnSourceCaches(t){let o=[];return this._otherSourceCaches[t]&&o.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&o.push(this._symbolSourceCaches[t]),this._fillExtrusionSourceCaches[t]&&o.push(this._fillExtrusionSourceCaches[t]),o}_isSourceCacheLoaded(t){let o=this.getOwnSourceCaches(t);return o.length===0?(this.fire(new h.y(new Error(`There is no source with ID '${t}'`))),!1):o.every(c=>c.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(t,o){if(!this._clipLayerPresent&&t.type!=="fill-extrusion"&&t.type!=="building")return!1;let c=t.type==="fill-extrusion"&&(t.sourceLayer==="building"||t.sourceLayer==="procedural_buildings"),d=t.type==="building";if(t.is3D(!!this.terrain)){if(c||d||o&&o.type==="batched-model"||t.type==="model")return!0}else if(t.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(t=>{t.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Nr.getSourceType=function(a){return yu[a]},Nr.setSourceType=function(a,t){yu[a]=t},Nr.registerForPluginStateChange=h.dn;var _l=`
9#define EPSILON 0.0000001
10#define PI 3.141592653589793
11#ifdef RENDER_CUTOFF
12float cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}
13#endif`,gl=`
14#ifdef DUAL_SOURCE_BLENDING
15layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;
16#elif defined(FLOAT_RENDER_TARGET)
17layout(location=0) out highp vec4 glFragColor;
18#else
19layout(location=0) out vec4 glFragColor;
20#endif
21#ifdef USE_MRT1
22layout(location=1) out vec4 out_Target1;
23#endif
24highp float unpack_depth(highp vec4 rgba_depth)
25{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}
26#ifdef INDICATOR_CUTOUT
27uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;
28#endif
29const float DITHER_THRESHOLDS[16]=float[16](
301.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0
30/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0
31);vec4 applyCutout(vec4 color,float height) {
32#ifdef INDICATOR_CUTOUT
33float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);
34#else
35return color;
36#endif
37}float cutoutGroundRoofOpacity(vec4 groundRoof) {
38#ifdef INDICATOR_CUTOUT
39float fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity);
40#else
41return 1.0;
42#endif
43}
44#ifdef DEBUG_WIREFRAME
45#define HANDLE_WIREFRAME_DEBUG \\
46glFragColor=vec4(0.7,0.0,0.0,0.7); \\
47gl_FragDepth=gl_FragCoord.z-0.0001;
48#else
49#define HANDLE_WIREFRAME_DEBUG
50#endif
51#ifdef RENDER_CUTOFF
52uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;
53#endif
54vec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 premultiplyColor(vec3 nonPremultipliedColor,float a) {return vec4(nonPremultipliedColor*a,a);}vec3 unpremultiplyColor(vec4 premultipliedColor) {if (premultipliedColor.a > 0.0) {return premultipliedColor.rgb/premultipliedColor.a;}return premultipliedColor.rgb;}vec3 applyLUT(highp sampler3D lut,vec3 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return texture(lut,uvw).rgb;}vec4 applyLUT(highp sampler3D lut,vec4 premultipliedColor) {return premultiplyColor(applyLUT(lut,unpremultiplyColor(premultipliedColor)),premultipliedColor.a);}`,id=`
55#define EXTENT 8192.0
56#define RAD_TO_DEG 180.0/PI
57#define DEG_TO_RAD PI/180.0
58#define GLOBE_RADIUS EXTENT/PI/2.0
59float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
60#ifdef PROJECTION_GLOBE_VIEW
61vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
62#ifndef PROJECTED_POS_ON_VIEWPORT
63float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
64#else
65return vec3(0.0);
66#endif
67}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
68#endif
69vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec4 decode_color(const vec2 encodedColor) {return vec4(
70unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
71);}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 vec2 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);
71return (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}
72#ifdef RENDER_CUTOFF
73uniform vec4 u_cutoff_params;out float v_cutoff_opacity;
74#endif
75const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)
76{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
77#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer
78#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib
79#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib
80#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib
81#define DECLARE_MATERIAL_TABLE_INFO
82#endif`,nd="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",rd=`
83#define ELEVATION_SCALE 7.0
84#define ELEVATION_OFFSET 450.0
85#ifdef PROJECTION_GLOBE_VIEW
86uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
87mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
88#else
89vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
90#endif
91#ifdef TERRAIN
92uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {
93#ifdef TERRAIN_DEM_FLOAT_FORMAT
94vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;
95#else
96float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
97#endif
98}float prevElevation(vec2 apos) {
99#ifdef TERRAIN_DEM_FLOAT_FORMAT
100vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;
101#else
102float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
103#endif
104}
105#ifdef TERRAIN_VERTEX_MORPHING
106float elevation(vec2 apos) {
107#ifdef ZERO_EXAGGERATION
108return 0.0;
109#endif
110float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
111#else
112float elevation(vec2 apos) {
113#ifdef ZERO_EXAGGERATION
114return 0.0;
115#endif
116return currentElevation(apos);}
117#endif
118vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
119#else
120float elevation(vec2 pos) { return 0.0; }
121#endif
122#ifdef DEPTH_OCCLUSION
123uniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;
124#ifdef DEPTH_D24
125float unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}
126#else
127highp float unpack_depth_rgba(vec4 rgba_depth)
128{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}
129#endif
130bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;
131#ifdef CLIP_ZERO_TO_ONE
132coord.z=-1.0+2.0*coord.z; 
133#endif
134#ifdef DEPTH_D24
135float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);
136#else
137float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));
138#endif
139return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_
139size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;
140#ifdef DEPTH_D24
141highp vec4 depth=vec4(
142texture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r
143);depth=unpack_depth4(depth);
144#else
145highp vec4 depth=vec4(
146unpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))
147);
148#endif
149return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;
150#ifdef CLIP_ZERO_TO_ONE
151coord.z=-1.0+2.0*coord.z; 
152#endif
153int NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {
154#ifdef DEPTH_D24
155highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);
156#else
157highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));
158#endif
159res+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;
160#ifdef CLIP_ZERO_TO_ONE
161coord.z=-1.0+2.0*coord.z; 
162#endif
163highp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}
164#else
165bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }
166#endif`,Ca=`#ifdef FOG
167uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
168#endif`,od=`#ifdef FOG
169uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;
170#ifdef FLIP_Y
171uv.y=1.0-uv.y;
172#endif
173highp vec3 ray_dir=mix(
174mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}
174vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
175#endif`,sd=`
176#ifdef LIGHTING_3D_MODE
177uniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}
178#endif`,wf=`#ifdef RASTER_ARRAY
179uniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}
179vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)
180);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)
181);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}
182#endif`,Tf=`#ifdef RENDER_SHADOWS
183uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}
184#endif`,Ou=`#ifdef RENDER_SHADOWS
185precision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {
186#ifdef CLIP_ZERO_TO_ONE
187highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);
188#else
189highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);
190#endif
191return texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;
192#ifdef SHADOWS_SINGLE_CASCADE
193vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);
194#else
195light_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);
196#endif
197}highp float calculate_shadow_bias(float NDotL) {
198#ifdef NORMAL_OFFSET
199return 0.5*u_shadow_bias.x;
200#else
201return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));
202#endif
203}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)
204{highp vec2 biasUV=vec2(
205pos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}
206#endif`;
206let Fu=/#include\s+"([^"]+)"/g,Bu=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,ad=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,Sf=new Set(["ifdef","ifndef","elif","if","defined"]),Ic=new Set;Rs(_l,Ic),Rs(id,Ic),Rs(gl,Ic);let Ac={"_prelude_fog.vertex.glsl":Ca,"_prelude_terrain.vertex.glsl":rd,"_prelude_shadow.vertex.glsl":Tf,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer
207#define MATERIAL_TABLE_DEBUG 0
208uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;
209#if MATERIAL_TABLE_DEBUG
210vec4 colorDebug;
211#endif
212};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { 
213if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; 
214}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { 
215iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;
216#if MATERIAL_TABLE_DEBUG
217const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;
218#endif
219uint offset=0u;
220#if MATERIAL_TABLE_DEBUG
221bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}
222#endif
223offset++;
224#if MATERIAL_TABLE_DEBUG
225uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}
226#endif
227offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);
228#if MATERIAL_TABLE_DEBUG
229if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}
230#endif
231uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);
232#if MATERIAL_TABLE_DEBUG
233if(keepFinding)
234{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}
235#endif
236offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;
237#if MATERIAL_TABLE_DEBUG
238if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}
239#endif
240info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)
241{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}
242#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)
243#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)
244#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)
245#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));
246#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;
247#endif`,"_prelude_fog.fragment.glsl":od,"_prelude_shadow.fragment.glsl":Ou,"_prelude_lighting.glsl":sd,"_prelude_raster_array.glsl":wf},Ds={},yl="precision highp float;",ld="precision mediump float;",Ir=`
248#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)
249#extension GL_EXT_blend_func_extended : require
250#endif`,ku={preludeTerrain:Ot("",rd),preludeFog:Ot(od,Ca),preludeShadow:Ot(Ou,Tf),preludeRasterArray:Ot(wf,""),preludeLighting:Ot(sd,sd),preludePrecisionQualifiers:Ot(ld,yl),prelude:Ot(gl,id),preludeExtensions:Ot(Ir,"")},Nu=[Ir,ld,_l,ku.prelude.fragmentSource].join(`
251`),q_=[yl,_l,ku.prelude.vertexSource].join(`
252`);var Uu={background:Ot(`#include "_prelude_fog.fragment.glsl"
253#include "_prelude_lighting.glsl"
254uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;
255#ifdef LIGHTING_3D_MODE
256in vec4 v_color;
257#endif
258void main() {vec4 out_color;
259#ifdef FEATURE_CUTOUT
260vec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;
261#ifdef FLIP_Y
262uv.y=1.0-uv.y;
263#endif
264float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor);
265#else
266#ifdef LIGHTING_3D_MODE
267out_color=v_color;
268#else
269out_color=u_color;
270#endif
271#ifdef FOG
272out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
273#endif
274#endif
275glFragColor=out_color*u_opacity;
276#ifdef USE_MRT1
277out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
278#endif
279#ifdef OVERDRAW_INSPECTOR
280glFragColor=vec4(1.0);
281#endif
282HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
283#include "_prelude_lighting.glsl"
284in ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;
285#ifdef LIGHTING_3D_MODE
286uniform mediump vec4 u_color;out vec4 v_color;
287#endif
288void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
289#ifndef FEATURE_CUTOUT
290#ifdef LIGHTING_3D_MODE
291v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);
292#endif
293#ifdef FOG
294v_fog_pos=fog_position(vec2(a_pos));
295#endif
296#endif
297}`),backgroundPattern:Ot(`#include "_prelude_fog.fragment.glsl"
298#include "_prelude_lighting.glsl"
299uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);
300#ifdef LIGHTING_3D_MODE
301out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
302#endif
303#ifdef FOG
304out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
305#endif
306glFragColor=out_color*u_opacity;
307#ifdef USE_MRT1
308out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
309#endif
310#ifdef OVERDRAW_INSPECTOR
311glFragColor=vec4(1.0);
312#endif
313HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
314uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos);
315#ifdef FOG
316v_fog_pos=fog_position(pos);
317#endif
318}`),circle:Ot
vendor: 7,212 bytes, lines 318-444
318(`#include "_prelude_fog.fragment.glsl"
319#include "_prelude_lighting.glsl"
320in vec3 v_data;in float v_visibility;
321#pragma mapbox: define highp vec4 color
322#pragma mapbox: define mediump float radius
323#pragma mapbox: define lowp float blur
324#pragma mapbox: define lowp float opacity
325#pragma mapbox: define highp vec4 stroke_color
326#pragma mapbox: define mediump float stroke_width
327#pragma mapbox: define lowp float stroke_opacity
328uniform float u_emissive_strength;void main() {
329#pragma mapbox: initialize highp vec4 color
330#pragma mapbox: initialize mediump float radius
331#pragma mapbox: initialize lowp float blur
332#pragma mapbox: initialize lowp float opacity
333#pragma mapbox: initialize highp vec4 stroke_color
334#pragma mapbox: initialize mediump float stroke_width
335#pragma mapbox: initialize lowp float stroke_opacity
336vec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? 
337smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : 
338smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
339antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
340);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
341#ifdef LIGHTING_3D_MODE
342out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
343#endif
344#ifdef FOG
345out_color=fog_apply_premultiplied(out_color,v_fog_pos);
346#endif
347glFragColor=out_color*(v_visibility*opacity_t);
348#ifdef OVERDRAW_INSPECTOR
349glFragColor=vec4(1.0);
350#endif
351}`,`#include "_prelude_fog.vertex.glsl"
352#include "_prelude_terrain.vertex.glsl"
353#define NUM_VISIBILITY_RINGS 2
354#define INV_SQRT2 0.70710678
355#define ELEVATION_BIAS 0.0001
356#define NUM_SAMPLES_PER_RING 16
357uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in ivec2 a_pos;
358#ifdef PROJECTION_GLOBE_VIEW
359in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
360#endif
361#ifdef ELEVATED_ROADS
362in float a_circle_z_offset;
363#endif
364out vec3 v_data;out float v_visibility;
365#pragma mapbox: define highp vec4 color
366#pragma mapbox: define mediump float radius
367#pragma mapbox: define lowp float blur
368#pragma mapbox: define lowp float opacity
369#pragma mapbox: define highp vec4 stroke_color
370#pragma mapbox: define mediump float stroke_width
371#pragma mapbox: define lowp float stroke_opacity
372vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
373#if defined(TERRAIN)
374return elevation(pos)+ELEVATION_BIAS;
375#else
376return 0.0;
377#endif
378}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
379#ifdef PITCH_WITH_MAP
380#ifdef PROJECTION_GLOBE_VIEW
381return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
382#else
383return u_matrix*( world_center+vec4(sample_offset,0,0) );
384#endif
385#else
386return projected_center+vec4(sample_offset,0,0);
387#endif
388}float get_sample_step() {
389#ifdef PITCH_WITH_MAP
390return 2.0*PI/float(NUM_SAMPLES_PER_RING);
391#else
392return PI/float(NUM_SAMPLES_PER_RING);
393#endif
394}void main() {
395#pragma mapbox: initialize highp vec4 color
396#pragma mapbox: initialize mediump float radius
397#pragma mapbox: initialize lowp float blur
398#pragma mapbox: initialize lowp float opacity
399#pragma mapbox: initialize highp vec4 stroke_color
400#pragma mapbox: initialize mediump float stroke_width
401#pragma mapbox: initialize lowp float stroke_opacity
402vec2 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors;
403#ifdef PROJECTION_GLOBE_VIEW
404surface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);
405#else 
406surface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);
407#endif
408#ifdef ELEVATED_ROADS
409world_center.z+=a_circle_z_offset+ELEVATION_BIAS;
410#endif
411vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
412#ifdef PITCH_WITH_MAP
413#ifdef SCALE_WITH_MAP
414view_scale=1.0;
415#else
416view_scale=projected_center.w/u_camera_to_center_distance;
417#endif
418#else
419#ifdef SCALE_WITH_MAP
420view_scale=u_camera_to_center_distance;
421#else
422view_scale=projected_center.w;
423#endif
424#endif
425gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
426#ifdef TERRAIN
427float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
428#ifdef PITCH_WITH_MAP
429float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;
430#else
431occlusion_world_center=world_center;occlusion_projected_center=projected_center;
432#endif
433for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
434#else
435visibility=1.0;
436#endif
437#ifdef PROJECTION_GLOBE_VIEW
438visibility=1.0;
439#endif
440v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
441#ifdef FOG
442v_fog_pos=fog_position(world_center.xyz);
443#endif
444}`),clippingMask:
444Ot("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Ot(`#include "_prelude_fog.fragment.glsl"
445uniform highp float u_intensity;in vec2 v_extrude;
446#pragma mapbox: define highp float weight
447#define GAUSS_COEF 0.3989422804014327
448void main() {
449#pragma mapbox: initialize highp float weight
450float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);
451#ifdef FOG
452if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
453#endif
454#ifdef OVERDRAW_INSPECTOR
455glFragColor=vec4(1.0);
456#endif
457HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
458#include "_prelude_fog.vertex.glsl"
459uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos;
460#ifdef PROJECTION_GLOBE_VIEW
461in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
462#endif
463out vec2 v_extrude;
464#pragma mapbox: define highp float weight
465#pragma mapbox: define mediump float radius
466const highp float ZERO=1.0/255.0/16.0;
467#define GAUSS_COEF 0.3989422804014327
468void main() {
469#pragma mapbox: initialize highp float weight
470#pragma mapbox: initialize mediump float radius
471vec2 unscaled_extrude=vec2(mod(vec2(a_pos),2.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 tilePos=floor(vec2(a_pos)*0.5);vec3 pos;
472#ifdef PROJECTION_GLOBE_VIEW
473vec3 pos_normal_3=vec3(a_pos_normal_3)/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
474#else
475pos=vec3(tilePos+extrude,elevation(tilePos));
476#endif
477gl_Position=u_matrix*vec4(pos,1);
478#ifdef FOG
479v_fog_pos=fog_position(pos);
480#endif
481}`),heatmapTexture:Ot(`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));glFragColor=color*u_opacity;
482#ifdef OVERDRAW_INSPECTOR
483glFragColor=vec4(0.0);
484#endif
485HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:Ot("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`#include "_prelude_terrain.vertex.glsl"
486in ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;
487#ifdef PROJECTION_GLOBE_VIEW
488uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;
489#endif
490out float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation);
491#ifdef PROJECTION_GLOBE_VIEW
492#ifndef PROJECTED_POS_ON_VIEWPORT
493vec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);
494#endif
495#endif
496vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
4970.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}`),collisionCircle:Ot("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);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);glFragColor=color*alpha*opacity_t;}",`in vec2 a_pos_2f;in float a_radius;in ivec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd  =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz  /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
498mix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
4990.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Ot("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",`#include "_prelude_terrain.vertex.glsl"
500in ivec2 a_pos;
501#ifdef PROJECTION_GLOBE_VIEW
502in ivec4 a_pos_3;
503#endif
504out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0;
505#ifdef PROJECTION_GLOBE_VIEW
506gl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);
507#else
508gl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);
509#endif
510}`),elevatedStructuresDepth:Ot("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:Ot(`#ifdef DEPTH_RECONSTRUCTION
511in float v_height;
512#endif
513void main() {
514#ifdef DEPTH_RECONSTRUCTION
515if (v_height >=0.0)
516discard;
517#else
518#ifdef FEATURE_CUTOUT
519apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x);
520#endif
521#endif
522glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;
523#ifdef DEPTH_RECONSTRUCTION
524out float v_height;
525#endif
526void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);
527#ifdef DEPTH_RECONSTRUCTION
528if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;
529#endif
530gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`),elevatedStructures:Ot(`#include "_prelude_fog.fragment.glsl"
531#include "_prelude_lighting.glsl"
532#include "_prelude_shadow.fragment.glsl"
533in vec3 v_normal;in float v_height;
534#ifdef RENDER_SHADOWS
535in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;
536#endif
537vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
537vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)
538{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;
539#pragma mapbox: define highp vec4 structure_color
540void main() {
541#pragma mapbox: initialize highp vec4 structure_color
542vec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);
543#ifdef FEATURE_CUTOUT
544cutout_factors=get_cutout_factors(gl_FragCoord);
545#endif
546#ifdef LIGHTING_3D_MODE
547vec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);
548#ifdef RENDER_SHADOWS
549float light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light);
550#else
551color=apply_lighting(color,transformed_normal);
552#endif
553color=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}
554#endif
555#ifdef FOG
556color=fog_apply(color,v_fog_pos);
557#endif
558vec4 out_color=vec4(color,1.0);
559#ifdef INDICATOR_CUTOUT
560out_color=applyCutout(out_color,v_height);
561#endif
562#ifdef FEATURE_CUTOUT
563out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
564#endif
565glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
566#include "_prelude_shadow.vertex.glsl"
567in ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;
568#ifdef RENDER_SHADOWS
569uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;
570#endif
571#pragma mapbox: define highp vec4 structure_color
572void main() {
573#pragma mapbox: initialize highp vec4 structure_color
574v_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1);
575#ifdef RENDER_SHADOWS
576vec3 shd_pos0=pos;vec3 shd_pos1=pos;
577#ifdef NORMAL_OFFSET
578vec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
579#endif
580v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
581#endif
582#ifdef FOG
583v_fog_pos=fog_position(vec2(a_pos));
584#endif
585}`),fill:Ot(`#include "_prelude_fog.fragment.glsl"
586#include "_prelude_lighting.glsl"
587#include "_prelude_shadow.fragment.glsl"
588#pragma mapbox: define highp vec4 color
589#pragma mapbox: define lowp float opacity
590uniform float u_emissive_strength;
591#ifdef RENDER_SHADOWS
592uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
593#endif
594#ifdef ELEVATED_ROADS
595in highp float v_road_z_offset;
596#endif
597#ifdef INDICATOR_CUTOUT
598in highp float v_z_offset;
599#endif
600void main() {
601#pragma mapbox: initialize highp vec4 color
602#pragma mapbox: initialize lowp float opacity
603vec2 cutout_factors=vec2(0.0);
604#ifdef FEATURE_CUTOUT
605cutout_factors=get_cutout_factors(gl_FragCoord);
606#endif
607vec4 out_color=color;
608#ifdef LIGHTING_3D_MODE
609out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
610#ifdef RENDER_SHADOWS
611float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
612#endif
613#endif
614#ifdef FOG
615out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
616#endif
617out_color*=opacity;
618#ifdef INDICATOR_CUTOUT
619if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}
620#endif
621#ifdef FEATURE_CUTOUT
622out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
623#endif
624glFragColor=out_color;
625#ifdef USE_MRT1
626out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
627#endif
628#ifdef OVERDRAW_INSPECTOR
629glFragColor=vec4(1.0);
630#endif
631HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
632#include "_prelude_shadow.vertex.glsl"
633in ivec2 a_pos;
634#ifdef ELEVATED_ROADS
635in float a_road_z_offset;out highp float v_road_z_offset;
636#endif
637#ifdef RENDER_SHADOWS
638uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
639#endif
640#ifdef INDICATOR_CUTOUT
641out highp float v_z_offset;
642#endif
643uniform mat4 u_matrix;
644#pragma mapbox: define highp vec4 color
645#pragma mapbox: define lowp float opacity
646#pragma mapbox: define highp float z_offset
647void main() {
648#pragma mapbox: initialize highp vec4 color
649#pragma mapbox: initialize lowp float opacity
650#pragma mapbox: initialize highp float z_offset
651#ifdef ELEVATED_ROADS
652z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
653#endif
654float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
655#ifdef RENDER_SHADOWS
656vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
657#ifdef NORMAL_OFFSET
658vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
659#endif
660v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
661#endif
662#ifdef FOG
663v_fog_pos=fog_position(vec2(a_pos));
664#endif
665#ifdef INDICATOR_CUTOUT
666v_z_offset=z_offset;
667#endif
668}`),fillOutline:Ot(`#include "_prelude_fog.fragment.glsl"
669#include "_prelude_lighting.glsl"
670#include "_prelude_shadow.fragment.glsl"
671in highp vec2 v_pos;uniform float u_emissive_strength;
672#ifdef RENDER_SHADOWS
673uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
674#endif
675#pragma mapbox: define highp vec4 outline_color
676#pragma mapbox: define lowp float opacity
677void main() {
678#pragma mapbox: initialize highp vec4 outline_color
679#pragma mapbox: initialize lowp float opacity
680float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0);
681#ifdef FEATURE_CUTOUT
682cutout_factors=get_cutout_factors(gl_FragCoord);
683#endif
684#ifdef LIGHTING_3D_MODE
685out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
686#ifdef RENDER_SHADOWS
687float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
688#endif
689#endif
690#ifdef FOG
691out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
692#endif
693#ifdef FEATURE_CUTOUT
694out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
695#endif
696glFragColor=out_color*(alpha*opacity);
697#ifdef USE_MRT1
698out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
699#endif
700#ifdef OVERDRAW_INSPECTOR
701glFragColor=vec4(1.0);
702#endif
703HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
704#include "_prelude_shadow.vertex.glsl"
705in ivec2 a_pos;
706#ifdef ELEVATED_ROADS
707in float a_road_z_offset;
708#endif
709#ifdef RENDER_SHADOWS
710uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
711#endif
712uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;
713#pragma mapbox: define highp vec4 outline_color
714#pragma mapbox: define lowp float opacity
715#pragma mapbox: define highp float z_offset
716void main() {
717#pragma mapbox: initialize highp vec4 outline_color
718#pragma mapbox: initialize lowp float opacity
719#pragma mapbox: initialize highp float z_offset
720#ifdef ELEVATED_ROADS
721z_offset+=a_road_z_offset;
722#endif
723float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
724#ifdef FLIP_Y
725v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
726#else
727v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
728#endif
729#ifdef RENDER_SHADOWS
730vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
731#ifdef NORMAL_OFFSET
732vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
733#endif
734v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
735#endif
736#ifdef FOG
737v_fog_pos=fog_position(vec2(a_pos));
738#endif
739}`),fillOutlinePattern:Ot(`#include "_prelude_fog.fragment.glsl"
740#include "_prelude_lighting.glsl"
741#include "_prelude_shadow.fragment.glsl"
742uniform vec2 u_texsize;uniform sampler2D u_image;
743#ifdef FILL_PATTERN_TRANSITION
744uniform float u_pattern_transition;
745#endif
746uniform float u_emissive_strength;
747#ifdef APPLY_LUT_ON_GPU
748uniform highp sampler3D u_lutTexture;
749#endif
750#ifdef RENDER_SHADOWS
751uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
752#endif
753in highp vec2 v_pos;in highp vec2 v_pos_world;
754#pragma mapbox: define lowp float opacity
755#pragma mapbox: define lowp uvec4 pattern
756#ifdef FILL_PATTERN_TRANSITION
757#pragma mapbox: define mediump uvec4 pattern_b
758#endif
759void main() {
760#pragma mapbox: initialize lowp float opacity
761#pragma mapbox: initialize mediump uvec4 pattern
762#ifdef FILL_PATTERN_TRANSITION
763#pragma mapbox: initialize mediump uvec4 pattern_b
764#endif
765vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
766#ifdef APPLY_LUT_ON_GPU
767out_color=applyLUT(u_lutTexture,out_color);
768#endif
769#ifdef FILL_PATTERN_TRANSITION
770vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
771#endif
772vec2 cutout_factors=vec2(0.0);
773#ifdef FEATURE_CUTOUT
774cutout_factors=get_cutout_factors(gl_FragCoord);
775#endif
776#ifdef LIGHTING_3D_MODE
777out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
778#ifdef RENDER_SHADOWS
779float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
780#endif
781#endif
782#ifdef FEATURE_CUTOUT
783out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
784#endif
785#ifdef FOG
786out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
787#endif
788glFragColor=out_color*(alpha*opacity);
789#ifdef USE_MRT1
790out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
791#endif
792#ifdef OVERDRAW_INSPECTOR
793glFragColor=vec4(1.0);
794#endif
795HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
796#include "_prelude_shadow.vertex.glsl"
797uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;
798#ifdef ELEVATED_ROADS
799in float a_road_z_offset;
800#endif
801#ifdef RENDER_SHADOWS
802uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
803#endif
804out highp vec2 v_pos;out highp vec2 v_pos_world;
805#pragma mapbox: define lowp float opacity
806#pragma mapbox: define lowp uvec4 pattern
807#ifdef FILL_PATTERN_TRANSITION
808#pragma mapbox: define mediump uvec4 pattern_b
809#endif
810#pragma mapbox: define lowp float pixel_ratio
811#pragma mapbox: define highp float z_offset
812void main() {
813#pragma mapbox: initialize lowp float opacity
814#pragma mapbox: initialize mediump uvec4 pattern
815#ifdef FILL_PATTERN_TRANSITION
816#pragma mapbox: initialize mediump uvec4 pattern_b
817#endif
818#pragma mapbox: initialize lowp float pixel_ratio
819#pragma mapbox: initialize highp float z_offset
820vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);
821#ifdef ELEVATED_ROADS
822z_offset+=a_road_z_offset;
823#endif
824float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);
825#ifdef FLIP_Y
826v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
827#else
828v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
829#endif
830#ifdef RENDER_SHADOWS
831vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);
832#ifdef NORMAL_OFFSET
833vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
834#endif
835v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
836#endif
837#ifdef FOG
838v_fog_pos=fog_position(pos);
839#endif
840}`),fillPattern:Ot(`#include "_prelude_fog.fragment.glsl"
841#include "_prelude_lighting.glsl"
842#include "_prelude_shadow.fragment.glsl"
843uniform vec2 u_texsize;uniform sampler2D u_image;
844#ifdef FILL_PATTERN_TRANSITION
845uniform float u_pattern_transition;
846#endif
847in highp vec2 v_pos;uniform float u_emissive_strength;
848#ifdef RENDER_SHADOWS
849uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
850#endif
851#ifdef ELEVATED_ROADS
852in highp float v_road_z_offset;
853#endif
854#ifdef APPLY_LUT_ON_GPU
855uniform highp sampler3D u_lutTexture;
856#endif
857#pragma mapbox: define lowp float opacity
858#pragma mapbox: define lowp uvec4 pattern
859#ifdef FILL_PATTERN_TRANSITION
860#pragma mapbox: define mediump uvec4 pattern_b
861#endif
862void main() {
863#pragma mapbox: initialize lowp float opacity
864#pragma mapbox: initialize mediump uvec4 pattern
865#ifdef FILL_PATTERN_TRANSITION
866#pragma mapbox: initialize mediump uvec4 pattern_b
867#endif
868vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
869#ifdef APPLY_LUT_ON_GPU
870out_color=applyLUT(u_lutTexture,out_color);
871#endif
872#ifdef FILL_PATTERN_TRANSITION
873vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
874#endif
875vec2 cutout_factors=vec2(0.0);
876#ifdef FEATURE_CUTOUT
877cutout_factors=get_cutout_factors(gl_FragCoord);
878#endif
879#ifdef LIGHTING_3D_MODE
880out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
881#ifdef RENDER_SHADOWS
882float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);
883#ifdef ELEVATED_ROADS
884out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
885#else
886out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
887#endif
888#endif
889#endif
890#ifdef FEATURE_CUTOUT
891out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
892#endif
893#ifdef FOG
894out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
895#endif
896glFragColor=out_color*opacity;
897#ifdef USE_MRT1
898out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
899#endif
900#ifdef OVERDRAW_INSPECTOR
901glFragColor=vec4(1.0);
902#endif
903HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
904#include "_prelude_shadow.vertex.glsl"
905uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;
906#ifdef ELEVATED_ROADS
907in float a_road_z_offset;out highp float v_road_z_offset;
908#endif
909#ifdef RENDER_SHADOWS
910uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp floa
910t v_depth;
911#endif
912out highp vec2 v_pos;
913#pragma mapbox: define lowp float opacity
914#pragma mapbox: define lowp uvec4 pattern
915#ifdef FILL_PATTERN_TRANSITION
916#pragma mapbox: define mediump uvec4 pattern_b
917#endif
918#pragma mapbox: define lowp float pixel_ratio
919#pragma mapbox: define highp float z_offset
920void main() {
921#pragma mapbox: initialize lowp float opacity
922#pragma mapbox: initialize mediump uvec4 pattern
923#pragma mapbox: initialize lowp float pixel_ratio
924#pragma mapbox: initialize highp float z_offset
925#ifdef FILL_PATTERN_TRANSITION
926#pragma mapbox: initialize mediump uvec4 pattern_b
927#endif
928vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;
929#ifdef ELEVATED_ROADS
930z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
931#endif
932float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);
933#ifdef RENDER_SHADOWS
934vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);
935#ifdef NORMAL_OFFSET
936vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
937#endif
938v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
939#endif
940#ifdef FOG
941v_fog_pos=fog_position(pos);
942#endif
943}`),lineBlendComposite:Ot(`uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos;
944#define ADDITIVE 1
945void main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}highp float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);highp float n=density/max(u_max_density,0.001);highp float t=sqrt(n/(n+1.0));glFragColor=vec4(avgColor*t,t);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);}
946#ifdef OVERDRAW_INSPECTOR
947glFragColor=vec4(0.0);
948#endif
949HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),lineBlendReduce:Ot("uniform highp sampler2D u_image;uniform vec2 u_texel_size;uniform bool u_first_pass;in vec2 v_pos;void main() {vec2 o=u_texel_size*0.5;vec4 s0=texture(u_image,v_pos+vec2(-o.x,-o.y));vec4 s1=texture(u_image,v_pos+vec2( o.x,-o.y));vec4 s2=texture(u_image,v_pos+vec2(-o.x, o.y));vec4 s3=texture(u_image,v_pos+vec2( o.x, o.y));float r0; float g0;float r1; float g1;float r2; float g2;float r3; float g3;if (u_first_pass) {float a0=s0.a;float a1=s1.a;float a2=s2.a;float a3=s3.a;r0=a0; g0=a0 > 0.0 ? 1.0 : 0.0;r1=a1; g1=a1 > 0.0 ? 1.0 : 0.0;r2=a2; g2=a2 > 0.0 ? 1.0 : 0.0;r3=a3; g3=a3 > 0.0 ? 1.0 : 0.0;} else {r0=s0.r; g0=s0.g;r1=s1.r; g1=s1.g;r2=s2.r; g2=s2.g;r3=s3.r; g3=s3.g;}glFragColor=vec4((r0+r1+r2+r3)*0.25,(g0+g1+g2+g3)*0.25,0.0,0.0);}","in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:Ot(`#include "_prelude_fog.fragment.glsl"
950#include "_prelude_shadow.fragment.glsl"
951#include "_prelude_lighting.glsl"
952in vec4 v_color;in vec4 v_flat;
953#ifdef RENDER_SHADOWS
954in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
955#endif
956uniform lowp float u_opacity;
957#ifdef RENDER_FRONT_CUTOFF
958in float v_front_cutoff_opacity;
959#endif
960#ifdef INDICATOR_CUTOUT
961#ifdef FEATURE_CUTOUT
962in vec4 v_ground_roof;
963#endif
964#endif
965#ifdef FAUX_AO
966uniform lowp vec2 u_ao;in vec2 v_ao;
967#endif
968#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
969in vec4 v_roof_color;
970#endif
971#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
972in highp vec3 v_normal;
973#endif
974uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;
975#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
976in float v_flood_radius;in float v_has_floodlight;
977#endif
978in float v_height;
979#pragma mapbox: define highp float emissive_strength
980void main() {
981#pragma mapbox: initialize highp float emissive_strength
982#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
983vec3 normal=normalize(v_normal);
984#endif
985float z;vec4 color=v_color;
986#ifdef ZERO_ROOF_RADIUS
987z=float(normal.z > 0.00001);
988#ifdef LIGHTING_3D_MODE
989normal=mix(normal,vec3(0.0,0.0,1.0),z);
990#else
991color=mix(v_color,v_roof_color,z);
992#endif
993#endif
994float h=max(0.0,v_height);float ao_shade=1.0;
995#ifdef FAUX_AO
996float intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0
996),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;
997#ifdef ZERO_ROOF_RADIUS
998concave*=(1.0-z);
999#endif
1000float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);
1001#ifdef LIGHTING_3D_MODE
1002#ifdef FLOOD_LIGHT
1003color.rgb*=mix(ao_shade,1.0,v_has_floodlight);
1004#else
1005color.rgb*=ao_shade;
1006#endif
1007#else
1008color.rgb*=ao_shade;
1009#endif
1010#endif
1011#ifdef LIGHTING_3D_MODE
1012float flood_radiance=0.0;
1013#ifdef FLOOD_LIGHT
1014flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;
1015#endif
1016#ifdef RENDER_SHADOWS
1017#ifdef FLOOD_LIGHT
1018float ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);
1019#else
1020float shadowed_lighting_factor;
1021#ifdef RENDER_CUTOFF
1022shadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}
1023#else
1024shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
1025#endif
1026color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);
1027#endif
1028#else
1029color.rgb=apply_lighting(color.rgb,normal);
1030#ifdef FLOOD_LIGHT
1031color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);
1032#endif
1033#endif
1034color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;
1035#endif
1036#ifdef FOG
1037color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));
1038#endif
1039#ifdef INDICATOR_CUTOUT
1040#ifdef FEATURE_CUTOUT
1041{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}
1042#else
1043color=applyCutout(color,h);
1044#endif
1045#endif
1046#ifdef RENDER_FRONT_CUTOFF
1047if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}
1048#endif
1049#ifdef FEATURE_CUTOUT
1050color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);
1051#endif
1052glFragColor=color;
1053#ifdef OVERDRAW_INSPECTOR
1054glFragColor=vec4(1.0);
1055#endif
1056HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1057#include "_prelude_terrain.vertex.glsl"
1058#include "_prelude_shadow.vertex.glsl"
1059#include "_prelude_lighting.glsl"
1060#include "_prelude_material_table.vertex.glsl"
1061uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed;
1062#if defined(HAS_CENTROID) || defined(TERRAIN)
1063in uvec2 a_centroid_pos;
1064#endif
1065#ifdef RENDER_WALL_MODE
1066in ivec4 a_join_normal_inside;
1067#endif
1068#ifdef PROJECTION_GLOBE_VIEW
1069in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
1070#endif
1071#ifdef TERRAIN
1072uniform int u_height_type;uniform int u_base_type;
1073#endif
1074uniform highp float u_vertical_scale;
1075#ifdef RENDER_FRONT_CUTOFF
1076uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;
1077#endif
1078out vec4 v_color;out vec4 v_flat;
1079#ifdef RENDER_SHADOWS
1080uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;
1081#endif
1082#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
1083out vec4 v_roof_color;
1084#endif
1085#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
1086out highp vec3 v_normal;
1087#endif
1088#ifdef FAUX_AO
1089uniform lowp vec2 u_ao;out vec2 v_ao;
1090#endif
1091#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
1092out float v_flood_radius;out float v_has_floodlight;
1093#endif
1094out float v_height;
1095#ifdef INDICATOR_CUTOUT
1096#ifdef FEATURE_CUTOUT
1097out vec4 v_ground_roof;
1098#endif
1099#endif
1100vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
1101#pragma mapbox: define highp float base
1102#pragma mapbox: define highp float height
1103#pragma mapbox: define highp vec4 color
1104#pragma mapbox: define highp float flood_light_wall_radius
1105#pragma mapbox: define highp float line_width
1106#pragma mapbox: define highp float emissive_strength
1107void main() {DECLARE_MATERIAL_TABLE_INFO
1108#pragma mapbox: initialize highp float base
1109#pragma mapbox: initialize highp float height
1110#pragma mapbox: initialize highp vec4 color
1111#pragma mapbox: initialize highp float flood_light_wall_radius
1112#pragma mapbox: initialize highp float line_width
1113#pragma mapbox: initialize highp float emissive_strength
1114base*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));
1115#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
1116v_normal=normal;
1117#endif
1118base=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0);
1119#if defined(HAS_CENTROID) || defined(TERRAIN)
1120centroid_pos=vec2(a_centroid_pos);
1121#endif
1122float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;
1123#ifdef TERRAIN
1124bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;
1125#else
1126h=t > 0.0 ? height : base;
1127#endif
1128pos=vec3(pos_nx.xy,h);
1129#ifdef PROJECTION_GLOBE_VIEW
1130float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
1131#endif
1132float cutoff=1.0;vec3 scaled_pos=pos;
1133#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
1134vec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}}
1135#endif
1136#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
1137vec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);
1138#endif
1139#ifdef RENDER_CUTOFF
1140#ifdef CLIP_ZERO_TO_ONE
1141cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);
1142#else
1143cutoff=cutoff_opacity(u_cutoff_params,ground.z);
1144#endif
1145if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.0;vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);
1146#endif
1147float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));
1148#ifdef RENDER_FRONT_CUTOFF
1149v_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));
1149float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}
1150#endif
1151#ifdef RENDER_WALL_MODE
1152vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5;
1153#endif
1154gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;
1155#ifdef RENDER_SHADOWS
1156vec3 shd_pos0=pos;vec3 shd_pos1=pos;
1157#ifdef NORMAL_OFFSET
1158vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
1159#endif
1160v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);
1161#endif
1162float NdotL=0.0;float colorvalue=0.0;
1163#ifndef LIGHTING_3D_MODE
1164colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(
1165(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
1166#endif
1167#ifdef FAUX_AO
1168float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
1169#ifdef TERRAIN
1170top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(ce
1170ntroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
1171#endif
1172v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);
1173#ifdef PROJECTION_GLOBE_VIEW
1174top_height+=u_height_lift;
1175#endif
1176gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
1177#endif
1178#ifdef LIGHTING_3D_MODE
1179#ifdef FLOOD_LIGHT
1180float is_wall=1.0-float(t > 0.0 && top_up_ny_start.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;
1181#endif
1182v_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);
1183#else
1184v_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;
1185#endif
1186#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
1187float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;
1188#endif
1189#ifdef FOG
1190v_fog_pos=fog_position(pos);
1191#endif
1192#ifdef INDICATOR_CUTOUT
1193#ifdef FEATURE_CUTOUT
1194vec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w);
1195#endif
1196#endif
1197}`),fillExtrusionDepth:Ot("void main() {}",`#include "_prelude_terrain.vertex.glsl"
1198#include "_prelude_material_table.vertex.glsl"
1199uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;
1200#ifdef TERRAIN
1201uniform int u_height_type;uniform int u_base_type;
1202#endif
1203in ivec4 a_pos_normal_ed;
1204#if defined(HAS_CENTROID) || defined(TERRAIN)
1205in uvec2 a_centroid_pos;
1206#endif
1207#ifdef RENDER_WALL_MODE
1208in ivec4 a_join_normal_inside;
1209#endif
1210#pragma mapbox: define highp float base
1211#pragma mapbox: define highp float height
1212#pragma mapbox: define highp float line_width
1213#pragma mapbox: define highp vec4 color
1214void main() {DECLARE_MATERIAL_TABLE_INFO
1215#pragma mapbox: initialize highp float base
1216#pragma mapbox: initialize highp float height
1217#pragma mapbox: initialize highp float line_width
1218#pragma mapbox: initialize highp vec4 color
1219base*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
1220#if defined(HAS_CENTROID) || defined(TERRAIN)
1221centroid_pos=vec2(a_centroid_pos);
1222#endif
1223vec3 pos;
1224#ifdef TERRAIN
1225bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);
1226#else
1227pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
1228#endif
1229#ifdef RENDER_WALL_MODE
1230vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5;
1231#endif
1232float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}`),fillExtrusionPattern:Ot(`#include "_prelude_fog.fragment.glsl"
1233#include "_prelude_lighting.glsl"
1234uniform vec2 u_texsize;uniform sampler2D u_image;
1235#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1236uniform float u_pattern_transition;
1237#endif
1238#ifdef FAUX_AO
1239uniform lowp vec2 u_ao;in vec3 v_ao;
1240#endif
1241#ifdef LIGHTING_3D_MODE
1242in vec3 v_normal;
1243#endif
1244#ifdef APPLY_LUT_ON_GPU
1245uniform highp sampler3D u_lutTexture;
1246#endif
1247in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;
1248#pragma mapbox: define highp float base
1249#pragma mapbox: define highp float height
1250#pragma mapbox: define mediump uvec4 pattern
1251#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1252#pragma mapbox: define mediump uvec4 pattern_b
1253#endif
1254#pragma mapbox: define highp float pixel_ratio
1255void main() {
1256#pragma mapbox: initialize highp float base
1257#pragma mapbox: initialize highp float height
1258#pragma mapbox: initialize mediump uvec4 pattern
1259#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1260#pragma mapbox: initialize mediump uvec4 pattern_b
1261#endif
1262#pragma mapbox: initialize highp float pixel_ratio
1263vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
1264#ifdef APPLY_LUT_ON_GPU
1265out_color=applyLUT(u_lutTexture,out_color);
1266#endif
1267#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1268vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
1269#endif
1270#ifdef LIGHTING_3D_MODE
1271out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;
1272#else
1273out_color=out_color*v_lighting;
1274#endif
1275#ifdef FAUX_AO
1276float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0
1276),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;
1277#endif
1278#ifdef FOG
1279out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
1280#endif
1281#ifdef INDICATOR_CUTOUT
1282out_color=applyCutout(out_color,height);
1283#endif
1284glFragColor=out_color;
1285#ifdef OVERDRAW_INSPECTOR
1286glFragColor=vec4(1.0);
1287#endif
1288HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1289#include "_prelude_terrain.vertex.glsl"
1290#include "_prelude_lighting.glsl"
1291#include "_prelude_material_table.vertex.glsl"
1292uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in ivec4 a_pos_normal_ed;
1293#if defined(HAS_CENTROID) || defined(TERRAIN)
1294in uvec2 a_centroid_pos;
1295#endif
1296#ifdef RENDER_WALL_MODE
1297in ivec4 a_join_normal_inside;
1298#endif
1299#ifdef PROJECTION_GLOBE_VIEW
1300in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
1301#endif
1302#ifdef TERRAIN
1303uniform int u_height_type;uniform int u_base_type;
1304#endif
1305out highp vec2 v_pos;out vec4 v_lighting;
1306#ifdef FAUX_AO
1307uniform lowp vec2 u_ao;out vec3 v_ao;
1308#endif
1309#ifdef LIGHTING_3D_MODE
1310out vec3 v_normal;
1311#endif
1312#pragma mapbox: define highp float base
1313#pragma mapbox: define highp float height
1314#pragma mapbox: define highp vec4 color
1315#pragma mapbox: define mediump uvec4 pattern
1316#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1317#pragma mapbox: define mediump uvec4 pattern_b
1318#endif
1319#pragma mapbox: define highp float pixel_ratio
1320#pragma mapbox: define highp float line_width
1321void main() {DECLARE_MATERIAL_TABLE_INFO
1322#pragma mapbox: initialize highp float base
1323#pragma mapbox: initialize highp float height
1324#pragma mapbox: initialize highp vec4 color
1325#pragma mapbox: initialize mediump uvec4 pattern
1326#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1327#pragma mapbox: initialize mediump uvec4 pattern_b
1328#endif
1329#pragma mapbox: initialize highp float pixel_ratio
1330#pragma mapbox: initialize highp float line_width
1331vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(a_pos_normal_ed.w);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
1332#if defined(HAS_CENTROID) || defined(TERRAIN)
1333centroid_pos=vec2(a_centroid_pos);
1334#endif
1335float ele=0.0;float h=z;vec3 p;float c_ele;
1336#ifdef TERRAIN
1337bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);
1338#else
1339p=vec3(pos_nx.xy,z);
1340#endif
1341#ifdef PROJECTION_GLOBE_VIEW
1342float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
1343#endif
1344#ifdef RENDER_WALL_MODE
1345vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5;
1346#endif
1347float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
1348? pos_nx.xy
1349: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;
1350#ifdef LIGHTING_3D_MODE
1351NdotL=calculate_NdotL(normal);
1352#else
1353NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
1354#endif
1355if (normal.y !=0.0) {float r=0.84;
1356#ifndef LIGHTING_3D_MODE
1357r=mix(0.7,0.98,1.0-u_lightintensity);
1358#endif
1359NdotL*=(
1360(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
1361#ifdef FAUX_AO
1362float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
1363#ifdef TERRAIN
1364top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
1365#endif
1366v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);
1367#ifdef PROJECTION_GLOBE_VIEW
1368top_height+=u_height_lift;
1369#endif
1370gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
1371#endif
1372#ifdef LIGHTING_3D_MODE
1373v_normal=normal;
1374#else
1375v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
1376#endif
1377#ifdef FOG
1378v_fog_pos=fog_position(p);
1379#endif
1380}`),groundShadow:Ot(`#include "_prelude_shadow.fragment.glsl"
1381precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
1382#ifdef FOG
1383in float v_fog_opacity;
1384#endif
1385void main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);
1386#ifdef RENDER_CUTOFF
1387shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));
1388#endif
1389#ifdef FOG
1390shadow=mix(shadow,vec3(1.0),v_fog_opacity);
1391#endif
1392#ifdef INDICATOR_CUTOUT
1393shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);
1394#endif
1395#ifdef FEATURE_CUTOUT
1396shadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y);
1397#endif
1398glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl"
1399uniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;
1400#ifdef FOG
1401out float v_fog_opacity;
1402#endif
1403void main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);
1404#ifdef FOG
1405v_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);
1406#endif
1407}`),fillExtrusionGroundEffect:Ot(`uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;
1408#ifdef SDF_SUBPASS
1409in highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}
1410#ifdef FOG
1411in highp float v_fog;
1412#endif
1413#endif
1414void main() {
1415#ifdef CLEAR_SUBPASS
1416vec4 color=vec4(1.0);
1417#ifdef CLEAR_FROM_TEXTURE
1418color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));
1419#endif
1420glFragColor=color;
1421#else
1422#ifdef SDF_SUBPASS
1423highp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;
1424#ifdef FOG
1425fog=v_fog;
1426#endif
1427#ifdef RENDER_CUTOFF
1428fog*=v_cutoff_opacity;
1429#endif
1430glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));
1431#else
1432#ifdef USE_MRT1
1433out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);
1434#else
1435vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);
1436#ifdef OVERDRAW_INSPECTOR
1437color=vec4(1.0);
1438#endif
1439glFragColor=color;
1440#endif
1441#endif
1442HANDLE_WIREFRAME_DEBUG;
1443#endif
1444}`,`#include "_prelude_fog.vertex.glsl"
1445in highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;
1446#ifdef SDF_SUBPASS
1447out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;
1448#ifdef FOG
1449out highp float v_fog;
1450#endif
1451#endif
1452uniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;
1453#pragma mapbox: define highp float flood_light_ground_radius
1454const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {
1455#pragma mapbox: initialize highp float flood_light_ground_radius
1456vec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=float(a_angular_offset_factor)/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;
1457#ifdef SDF_SUBPASS
1458v_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);
1459#ifdef FOG
1460v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);
1461#endif
1462#endif
1463float hidden_by_landmark=0.0;
1464#ifdef HAS_CENTROID
1465hidden_by_landmark=float(a_hidden_by_landmark);
1466#endif
1467float isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));
1468#ifdef RENDER_CUTOFF
1469v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
1470#endif
1471}`),hillshadePrepare:Ot(`precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));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(
1472(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
1473)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(
1474deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in ivec2 a_pos;in uvec2 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=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:Ot(`#include "_prelude_fog.fragment.glsl"
1475#include "_prelude_lighting.glsl"
1476uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;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_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;
1477#ifdef LIGHTING_3D_MODE
1478glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);
1479#endif
1480#ifdef FOG
1481glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));
1482#endif
1483#ifdef USE_MRT1
1484out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1485#endif
1486#ifdef OVERDRAW_INSPECTOR
1487glFragColor=vec4(1.0);
1488#endif
1489HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1490uniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0;
1491#ifdef FOG
1492v_fog_pos=fog_position(vec2(a_pos));
1493#endif
1494}`),line:Ot(`#include "_prelude_fog.fragment.glsl"
1495#include "_prelude_lighting.glsl"
1496#include "_prelude_shadow.fragment.glsl"
1497uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;
1497uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;uniform bool u_clip_to_tile_borders;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;in vec2 v_tile_pos;
1498#ifdef ELEVATED_ROADS
1499in highp float v_road_z_offset;
1500#endif
1501#ifdef VARIABLE_LINE_WIDTH
1502in float stub_side;
1503#endif
1504#ifdef RENDER_LINE_DASH
1505uniform sampler2D u_dash_image;in vec2 v_tex;
1506#endif
1507#ifdef DEBUG_ELEVATION_ID
1508in vec3 v_elevation_id_col;
1509#endif
1510#ifdef RENDER_LINE_GRADIENT
1511uniform sampler2D u_gradient_image;
1512#endif
1513#ifdef INDICATOR_CUTOUT
1514in highp float v_z_offset;
1515#endif
1516#ifdef RENDER_SHADOWS
1517uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
1518#endif
1519float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
1520#pragma mapbox: define highp vec4 color
1521#pragma mapbox: define lowp float floorwidth
1522#pragma mapbox: define mediump uvec4 dash
1523#pragma mapbox: define lowp float blur
1524#pragma mapbox: define lowp float opacity
1525#pragma mapbox: define mediump float side_z_offset
1526#pragma mapbox: define lowp float border_width
1527#pragma mapbox: define lowp vec4 border_color
1528#pragma mapbox: define lowp float emissive_strength
1529float linearstep(float edge0,float edge1,float x) {return  clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
1530#pragma mapbox: initialize highp vec4 color
1531#pragma mapbox: initialize lowp float floorwidth
1532#pragma mapbox: initialize mediump uvec4 dash
1533#pragma mapbox: initialize lowp float blur
1534#pragma mapbox: initialize lowp float opacity
1535#pragma mapbox: initialize mediump float side_z_offset
1536#pragma mapbox: initialize lowp float border_width
1537#pragma mapbox: initialize lowp vec4 border_color
1538#pragma mapbox: initialize lowp float emissive_strength
1539float dist=length(v_normal)*v_width2_dilute.x;
1540#ifdef VARIABLE_LINE_WIDTH
1541blur=mix(blur,0.0,stub_side);
1542#endif
1543float diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);
1544#ifdef VARIABLE_LINE_WIDTH
1545alpha=mix(alpha,1.0,stub_side);
1546#endif
1547alpha=side_z_offset > 0.0 ? 1.0-alpha : alpha;
1548#ifdef RENDER_LINE_DASH
1549float sdfdist=texture(u_dash_image,v_tex).r;
1549float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);
1550#endif
1551highp vec4 out_color;
1552#ifdef RENDER_LINE_GRADIENT
1553out_color=texture(u_gradient_image,v_uv.xy);
1554#else
1555out_color=color;
1556#endif
1557float trim_alpha=1.0;
1558#ifdef RENDER_LINE_TRIM_OFFSET
1559highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;
1560#ifdef RENDER_LINE_GRADIENT
1561gradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);
1562#endif
1563highp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}
1564#endif
1565if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}
1566#ifdef RENDER_LINE_BORDER
1567#ifndef VARIABLE_LINE_WIDTH
1568float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}out_color*=v_width2_dilute.w;}
1569#endif
1570#endif
1571vec2 cutout_factors=vec2(0.0);
1572#ifdef FEATURE_CUTOUT
1573cutout_factors=get_cutout_factors(gl_FragCoord);
1574#endif
1575#ifdef LIGHTING_3D_MODE
1576out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
1577#ifdef RENDER_SHADOWS
1578float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;
1579#ifdef ELEVATED_ROADS
1580out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
1581#else
1582out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
1583#endif
1584#endif
1585#endif
1586#ifdef FOG
1587out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
1588#endif
1589out_color*=(alpha*diluted_opacity);
1590#ifdef INDICATOR_CUTOUT
1591out_color=applyCutout(out_color,v_z_offset);
1592#endif
1593#ifdef FEATURE_CUTOUT
1594out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
1595#endif
1596#ifdef LINE_BLEND_ADDITIVE
1597{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);}
1598#else
1599#ifdef LINE_BLEND_MULTIPLY
1600glFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);
1601#else
1602glFragColor=out_color;
1603#endif
1604#endif
1605#ifdef DUAL_SOURCE_BLENDING
1606glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
1607#else
1608#ifdef USE_MRT1
1609out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1610#endif
1611#endif
1612#ifdef OVERDRAW_INSPECTOR
1613glFragColor=vec4(1.0);
1614#endif
1615#ifdef DEBUG_ELEVATION_ID
1616glFragColor=vec4(v_elevation_id_col,1.0);
1617#endif
1618if (u_clip_to_tile_borders) {if (v_tile_pos.x > 1.0 || v_tile_pos.y > 1.0 || v_tile_pos.x < 0.0 || v_tile_pos.y < 0.0) {discard;}}HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1619#include "_prelude_shadow.vertex.glsl"
1620#include "_prelude_terrain.vertex.glsl"
1621#define EXTRUDE_SCALE 0.015873016
1622in ivec2 a_pos_normal;in uvec4 a_data;
1623#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)
1624in vec3 a_z_offset_width;
1625#endif
1626#ifdef DEBUG_ELEVATION_ID
1627in vec3 a_elevation_id_col;
1628#endif
1629#ifdef DEBUG_ELEVATION_ID
1630out vec3 v_elevation_id_col;
1631#endif
1632#ifdef ELEVATION_GROUND_SCALE
1633in float a_elevation_ground_scale;
1634#endif
1635#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)
1636in highp vec3 a_packed;
1637#endif
1638#ifdef RENDER_LINE_DASH
1639in float a_linesofar;
1640#endif
1641uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_z_offset;uniform highp float u_floor_width_scale;
1642#ifdef RENDER_LINE_CURVE
1643uniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;
1644#endif
1645#ifdef ELEVATED
1646uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
1647#ifdef ELEVATION_REFERENCE_SEA
1648return 0.0;
1649#else
1650return elevation(apos);
1651#endif
1652}
1653#endif
1654out vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv;out vec2 v_tile_pos;
1655#ifdef ELEVATED_ROADS
1656out highp float v_road_z_offset;
1657#endif
1658#ifdef VARIABLE_LINE_WIDTH
1659out float stub_side;
1660#endif
1661#ifdef RENDER_LINE_DASH
1662uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;
1663#endif
1664#ifdef RENDER_LINE_GRADIENT
1665uniform float u_image_height;
1666#endif
1667#ifdef INDICATOR_CUTOUT
1668out highp float v_z_offset;
1669#endif
1670#ifdef RENDER_SHADOWS
1671uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
1672#endif
1673#pragma mapbox: define highp vec4 color
1674#pragma mapbox: define lowp float floorwidth
1675#pragma mapbox: define mediump uvec4 dash
1676#pragma mapbox: define lowp float blur
1677#pragma mapbox: define lowp float opacity
1678#pragma mapbox: define mediump float gapwidth
1679#pragma mapbox: define lowp float offset
1680#pragma mapbox: define mediump float width
1681#pragma mapbox: define mediump float side_z_offset
1682#pragma mapbox: define lowp float border_width
1683#pragma mapbox: define lowp vec4 border_color
1684#pragma mapbox: define lowp float emissive_strength
1685#ifdef RENDER_LINE_CURVE
1686vec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2
1686=t*t;float t3=t2*t;return 0.5*(
16872.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3
1688);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(
1689(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2
1690);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}
1691#endif
1692void main() {
1693#pragma mapbox: initialize highp vec4 color
1694#pragma mapbox: initialize lowp float floorwidth
1695#pragma mapbox: initialize mediump uvec4 dash
1696#pragma mapbox: initialize lowp float blur
1697#pragma mapbox: initialize lowp float opacity
1698#pragma mapbox: initialize mediump float gapwidth
1699#pragma mapbox: initialize lowp float offset
1700#pragma mapbox: initialize mediump float width
1701#pragma mapbox: initialize mediump float side_z_offset
1702#pragma mapbox: initialize lowp float border_width
1703#pragma mapbox: initialize lowp vec4 border_color
1704#pragma mapbox: initialize lowp float emissive_strength
1705float a_z_offset=u_z_offset;
1706#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1707a_z_offset+=a_z_offset_width.x;
1708#endif
1709#ifdef DEBUG_ELEVATION_ID
1710v_elevation_id_col=a_elevation_id_col;
1711#endif
1712highp float line_progress=0.0;
1713#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)
1714line_progress=a_packed[2];
1715#endif
1716float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;
1717#ifdef RENDER_LINE_CURVE
1718CurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;
1719#endif
1720gapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;
1721#ifdef VARIABLE_LINE_WIDTH
1722float left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;
1723#else
1724halfwidth=(u_width_scale*width)/2.0;
1725#endif
1726float 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*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;
1726vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
1727#ifdef ELEVATED_ROADS
1728v_road_z_offset=a_z_offset;v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,a_z_offset,1.0);
1729#else
1730#ifdef ELEVATED
1731vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;
1732#ifdef ELEVATION_GROUND_SCALE
1733scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);
1734#endif
1735#ifdef CROSS_SLOPE_VERTICAL
1736float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);
1737#else
1738#ifdef CROSS_SLOPE_HORIZONTAL
1739float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;
1740#else
1741float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;
1742#endif
1743#endif
1744v_tile_pos=offset_pos;gl_Position=u_matrix*vec4(v_tile_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);
1745#else
1746v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0);
1747#endif
1748#endif
1749#ifndef ELEVATED
1750#ifndef VARIABLE_LINE_WIDTH
1751#ifndef RENDER_TO_TEXTURE
1752float base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else if (gapwidth > 0.0) {float visible_ratio=(halfwidth+ANTIALIASING)/outset;vec2 visible_screen_width=screen_width*visible_ratio;float max_visible_component=max(visible_screen_width.x,visible_screen_width.y);dilute_scale=min(1.0,max_visible_component/min_pixel);}else
1753{
1754#ifdef RENDER_LINE_BORDER
1755float border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);
1756#endif
1757}}
1758#endif
1759#endif
1760v_tile_pos=(v_tile_pos+extrude)/EXTENT;
1761#ifdef ELEVATED_ROADS
1762gl_Position=gl_Position+projected_extrude;
1763#else
1764gl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);
1765#endif
1766#endif
1767#ifdef ELEVATED_ROADS
1768#ifdef RENDER_SHADOWS
1769vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
1770#ifdef NORMAL_OFFSET
1771vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
1772#endif
1773v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
1774#endif
1775#endif
1776#ifndef RENDER_TO_TEXTURE
1777float epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));
1778#else
1779v_gamma_scale=1.0;
1780#endif
1781#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
1782highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];
1783#ifdef RENDER_LINE_GRADIENT
1784highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);
1785#else
1786v_uv=vec3(a_uv_x,0.0,line_progress);
1787#endif
1788#endif
1789#ifdef RENDER_LINE_DASH
1790vec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y);
1791#endif
1792v_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);
1793#ifdef FOG
1794v_fog_pos=fog_position(pos);
1795#endif
1796#ifdef INDICATOR_CUTOUT
1797v_z_offset=a_z_offset;
1798#endif
1799}`),linePattern:Ot(`#include "_prelude_fog.fragment.glsl"
1800#include "_prelude_lighting.glsl"
1801#include "_prelude_shadow.fragment.glsl"
1802uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;
1802uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;
1803#ifdef APPLY_LUT_ON_GPU
1804uniform highp sampler3D u_lutTexture;
1805#endif
1806#ifdef LINE_PATTERN_TRANSITION
1807uniform float u_pattern_transition;
1808#endif
1809in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;
1810#ifdef RENDER_LINE_TRIM_OFFSET
1811in highp vec3 v_uv;
1812#endif
1813#ifdef ELEVATED_ROADS
1814in highp float v_road_z_offset;
1815#endif
1816#ifdef LINE_JOIN_NONE
1817in vec2 v_pattern_data;
1818#endif
1819#ifdef INDICATOR_CUTOUT
1820in highp float v_z_offset;
1821#endif
1822#ifdef RENDER_SHADOWS
1823uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
1824#endif
1825#pragma mapbox: define mediump uvec4 pattern
1826#ifdef LINE_PATTERN_TRANSITION
1827#pragma mapbox: define mediump uvec4 pattern_b
1828#endif
1829#pragma mapbox: define mediump float pixel_ratio
1830#pragma mapbox: define mediump float blur
1831#pragma mapbox: define mediump float opacity
1832#pragma mapbox: define lowp float emissive_strength
1833void main() {
1834#pragma mapbox: initialize mediump uvec4 pattern
1835#ifdef LINE_PATTERN_TRANSITION
1836#pragma mapbox: initialize mediump uvec4 pattern_b
1837#endif
1838#pragma mapbox: initialize mediump float pixel_ratio
1839#pragma mapbox: initialize mediump float blur
1840#pragma mapbox: initialize mediump float opacity
1841#pragma mapbox: initialize lowp float emissive_strength
1842vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);
1843#ifdef APPLY_LUT_ON_GPU
1844color=applyLUT(u_lutTexture,color);
1845#endif
1846#ifdef LINE_PATTERN_TRANSITION
1847vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
1848#endif
1849#ifdef RENDER_LINE_TRIM_OFFSET
1850highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}
1851#endif
1852#ifdef LINE_JOIN_NONE
1853highp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}
1854#endif
1855#ifdef LIGHTING_3D_MODE
1856color=apply_lighting_with_emission_ground(color,emissive_strength);
1857#ifdef RENDER_SHADOWS
1858float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);
1859#ifdef ELEVATED_ROADS
1860color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
1861#else
1862color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
1863#endif
1864#endif
1865#endif
1866#ifdef FOG
1867color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
1868#endif
1869color*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}
1870#ifdef INDICATOR_CUTOUT
1871color=applyCutout(color,v_z_offset);
1872#endif
1873glFragColor=color;
1874#ifdef DUAL_SOURCE_BLENDING
1875glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
1876#else
1877#ifdef USE_MRT1
1878out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1879#endif
1880#endif
1881#ifdef OVERDRAW_INSPECTOR
1882glFragColor=vec4(1.0);
1883#endif
1884HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1885#include "_prelude_shadow.vertex.glsl"
1886#include "_prelude_terrain.vertex.glsl"
1887#define scale 0.015873016
1888in ivec2 a_pos_normal;in uvec4 a_data;
1889#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1890in vec3 a_z_offset_width;
1891#endif
1892#ifdef ELEVATION_GROUND_SCALE
1893in float a_elevation_ground_scale;
1894#endif
1895#ifdef RENDER_LINE_TRIM_OFFSET
1896in highp vec3 a_packed;
1897#endif
1898in highp float a_linesofar;
1899#ifdef LINE_JOIN_NONE
1900in highp vec3 a_pattern_data;out vec2 v_pattern_data;
1901#endif
1902#ifdef INDICATOR_CUTOUT
1903out highp float v_z_offset;
1904#endif
1905uniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;
1906#ifdef ELEVATED
1907uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
1908#ifdef ELEVATION_REFERENCE_SEA
1909return 0.0;
1910#else
1911return elevation(apos);
1912#endif
1913}
1914#endif
1915out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;
1916#ifdef RENDER_LINE_TRIM_OFFSET
1917out highp vec3 v_uv;
1918#endif
1919#ifdef ELEVATED_ROADS
1920out highp float v_road_z_offset;
1921#endif
1922#ifdef RENDER_SHADOWS
1923uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
1924#endif
1925#pragma mapbox: define mediump float blur
1926#pragma mapbox: define mediump float opacity
1927#pragma mapbox: define mediump float offset
1928#pragma mapbox: define mediump float gapwidth
1929#pragma mapbox: define mediump float width
1930#pragma mapbox: define mediump float floorwidth
1931#pragma mapbox: define mediump uvec4 pattern
1932#ifdef LINE_PATTERN_TRANSITION
1933#pragma mapbox: define mediump uvec4 pattern_b
1934#endif
1935#pragma mapbox: define mediump float pixel_ratio
1936#pragma mapbox: define lowp float emissive_strength
1937void main() {
1938#pragma mapbox: initialize mediump float blur
1939#pragma mapbox: initialize mediump float opacity
1940#pragma mapbox: initialize mediump float offset
1941#pragma mapbox: initialize mediump float gapwidth
1942#pragma mapbox: initialize mediump float width
1943#pragma mapbox: initialize mediump float floorwidth
1944#pragma mapbox: initialize mediump uvec4 pattern
1945#ifdef LINE_PATTERN_TRANSITION
1946#pragma mapbox: initialize mediump uvec4 pattern_b
1947#endif
1948#pragma mapbox: initialize mediump float pixel_ratio
1949#pragma mapbox: initialize lowp float emissive_strength
1950float a_z_offset;
1951#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1952a_z_offset=a_z_offset_width.x;
1953#endif
1954float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;
1954vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
1955#ifdef ELEVATED_ROADS
1956v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;
1957#else
1958#ifdef ELEVATED
1959vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;
1960#ifdef ELEVATION_GROUND_SCALE
1961scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);
1962#endif
1963#ifdef CROSS_SLOPE_VERTICAL
1964float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);
1965#else
1966#ifdef CROSS_SLOPE_HORIZONTAL
1967float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;
1968#else
1969float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;
1970#endif
1971#endif
1972gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);
1973#else
1974gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);
1975#endif
1976#endif
1977#ifdef ELEVATED_ROADS
1978#ifdef RENDER_SHADOWS
1979vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
1980#ifdef NORMAL_OFFSET
1981vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
1982#endif
1983v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
1984#endif
1985#endif
1986#ifndef RENDER_TO_TEXTURE
1987float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));
1988#else
1989v_gamma_scale=1.0;
1990#endif
1991#ifdef RENDER_LINE_TRIM_OFFSET
1992highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);
1993#endif
1994v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);
1995#ifdef LINE_JOIN_NONE
1996v_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);
1997#endif
1998#ifdef FOG
1999v_fog_pos=fog_position(pos);
2000#endif
2001#ifdef INDICATOR_CUTOUT
2002v_z_offset=a_z_offset;
2003#endif
2004}`),raster:Ot(`#include "_prelude_fog.fragment.glsl"
2005#include "_prelude_lighting.glsl"
2006#include "_prelude_raster_array.glsl"
2007uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;
2008#ifdef PROJECTION_GLOBE_VIEW
2009in float v_split_fade;
2010#endif
2011uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;
2012#ifndef RASTER_ARRAY
2013uniform highp sampler2D u_image0;uniform sampler2D u_image1;
2014#endif
2015#ifdef RASTER_COLOR
2016uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;
2017#endif
2018void main() {vec4 color0,color1,color;vec2 value;
2019#ifdef RASTER_COLOR
2020#ifdef RASTER_ARRAY
2021#ifdef RASTER_ARRAY_LINEAR
2022value=mix(
2023raTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t
2024);
2025#else
2026value=mix(
2027raTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t
2028);
2029#endif
2030if (value.y > 0.0) value.x/=value.y;
2031#else
2032color=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);
2033#endif
2034color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;
2035#else
2036color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);
2037#endif
2038color.a*=u_opacity;
2039#ifdef GLOBE_POLES
2040color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);
2041#endif
2042vec3 rgb=color.rgb;rgb=vec3(
2043dot(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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
2044#ifdef LIGHTING_3D_MODE
2045out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;
2046#endif
2047#ifdef FOG
2048highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));
2049#endif
2050glFragColor=vec4(out_color*color.a,color.a);
2051#ifdef PROJECTION_GLOBE_VIEW
2052glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));
2053#endif
2054#ifdef RENDER_CUTOFF
2055glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);
2056#endif
2057#ifdef OVERDRAW_INSPECTOR
2058glFragColor=vec4(1.0);
2059#endif
2060#ifdef USE_MRT1
2061out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
2062#endif
2063HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2064#include "_prelude_terrain.vertex.glsl"
2065uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;
2066#ifdef ELEVATED
2067uniform lowp float u_zbias_factor;
2068#endif
2069#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
2070#ifdef GLOBE_POLES
2071in vec3 a_globe_pos;in vec2 a_uv;
2072#else
2073in ivec2 a_pos;in uvec2 a_texture_pos;
2074#endif
2075out vec2 v_pos0;out vec2 v_pos1;out float v_depth;
2076#ifdef PROJECTION_GLOBE_VIEW
2077out float v_split_fade;
2078#endif
2079void main() {vec2 uv;
2080#ifdef GLOBE_POLES
2081vec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;
2082#ifdef ELEVATION_REFERENCE_GROUND
2083ele+=elevation(uv*EXTENT);
2084#endif
2085globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);
2086#ifdef FOG
2087v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);
2088#endif
2089#else
2090vec4 world_pos;
2091#ifdef PROJECTION_GLOBE_VIEW
2092vec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);  
2093float tiles=u_grid_matrix[0][2];
2093if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}float ele=u_raster_elevation;
2094#ifdef ELEVATION_REFERENCE_GROUND
2095ele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;
2096#endif
2097vec4 merc_world_pos=vec4(0.0);   
2098v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
2099#ifdef FOG
2100v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
2101#endif
2102#else
2103float ele=0.0;vec2 decodedPos=vec2(a_pos);
2104#ifdef ELEVATION_REFERENCE_GROUND
2105vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;
2106#else
2107uv=vec2(a_texture_pos)/8192.0;
2108#endif
2109world_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);
2110#ifdef FOG
2111v_fog_pos=fog_position(decodedPos);
2112#endif
2113#endif
2114float w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;
2115#endif
2116v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;
2117#ifdef ELEVATED
2118float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);
2119#endif
2120#ifdef RENDER_CUTOFF
2121v_depth=gl_Position.z;
2122#endif
2123}`),symbol:Ot(`#include "_prelude_lighting.glsl"
2124#include "_prelude_shadow.fragment.glsl"
2125#define SDF_PX 8.0
2126#define SDF 1.0
2127#define ICON 0.0
2128uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;
2129#ifdef ICON_TRANSITION
2130uniform float u_icon_transition;
2131#endif
2132#ifdef COLOR_ADJUSTMENT
2133uniform mat4 u_color_adj_mat;
2134#endif
2135#ifdef INDICATOR_CUTOUT
2136in highp float v_z_offset;
2137#else
2138#ifdef RENDER_SHADOWS
2139in highp float v_z_offset;
2140#endif
2141#endif
2142in vec2 v_tex_a;
2143#ifdef ICON_TRANSITION
2144in vec2 v_tex_b;
2145#endif
2146in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;
2147#ifdef RENDER_TEXT_AND_SYMBOL
2148in float is_sdf;in vec2 v_tex_a_icon;
2149#endif
2150#ifdef RENDER_SHADOWS
2151uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
2152#endif
2153#ifdef APPLY_LUT_ON_GPU
2154uniform highp sampler3D u_lutTexture;
2155#endif
2156#ifdef USE_PAINT_PROPERTIES_UBO
2157in lowp float v_opacity;
2158#ifdef RENDER_SDF
2159in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur;
2160#endif
2161#ifdef LIGHTING_3D_MODE
2162in lowp float v_emissive_strength;
2163#endif
2164#else
2165#pragma mapbox: define highp vec4 fill_color
2166#pragma mapbox: define highp vec4 halo_color
2167#pragma mapbox: define lowp float opacity
2168#pragma mapbox: define lowp float halo_width
2169#pragma mapbox: define lowp float halo_blur
2170#pragma mapbox: define lowp float emissive_strength
2171#endif
2172void main() {
2173#ifdef USE_PAINT_PROPERTIES_UBO
2174lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0;
2175#ifdef RENDER_SDF
2176fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur;
2177#endif
2178lowp float emissive_strength=0.0;
2179#ifdef LIGHTING_3D_MODE
2180emissive_strength=v_emissive_strength;
2181#endif
2182#else
2183#pragma mapbox: initialize highp vec4 fill_color
2184#pragma mapbox: initialize highp vec4 halo_color
2185#pragma mapbox: initialize lowp float opacity
2186#pragma mapbox: initialize lowp float halo_width
2187#pragma mapbox: initialize lowp float halo_blur
2188#pragma mapbox: initialize lowp float emissive_strength
2189#endif
2190vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];
2191#ifdef RENDER_TEXT_AND_SYMBOL
2192if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;
2192glFragColor=texture(u_texture_icon,tex_icon)*alpha;
2193#ifdef OVERDRAW_INSPECTOR
2194glFragColor=vec4(1.0);
2195#endif
2196return;}
2197#endif
2198vec2 cutout_factors=vec2(0.0);
2199#ifdef FEATURE_CUTOUT
2200cutout_factors=get_cutout_factors(gl_FragCoord);
2201#endif
2202#ifdef RENDER_SDF
2203float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;
2204#else
2205#ifdef ICON_TRANSITION
2206vec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);
2207#else
2208out_color=texture(u_texture,v_tex_a);
2209#endif
2210#ifdef APPLY_LUT_ON_GPU
2211out_color=applyLUT(u_lutTexture,out_color);
2212#endif
2213#ifdef COLOR_ADJUSTMENT
2214out_color=u_color_adj_mat*out_color;
2215#endif
2216#endif
2217out_color*=opacity*fade_opacity;
2218#ifdef LIGHTING_3D_MODE
2219out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
2220#ifdef RENDER_SHADOWS
2221float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);
2222#ifdef TERRAIN
2223out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
2224#else
2225out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
2226#endif
2227#endif
2228#endif
2229#ifdef INDICATOR_CUTOUT
2230out_color=applyCutout(out_color,v_z_offset);
2231#endif
2232#ifdef FEATURE_CUTOUT
2233out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
2234#endif
2235glFragColor=out_color;
2236#ifdef OVERDRAW_INSPECTOR
2237glFragColor=vec4(1.0);
2238#endif
2239HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
2240#include "_prelude_shadow.vertex.glsl"
2241#define USING_APPEARANCE 1.0
2242in ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;
2243#ifdef Z_OFFSET
2244in float a_auto_z_offset;
2245#endif
2246#ifdef PROJECTION_GLOBE_VIEW
2247in ivec4 a_globe_anchor;in vec3 a_globe_normal;
2248#endif
2249#ifdef ICON_TRANSITION
2250in uvec2 a_texb;
2251#endif
2252#ifdef OCCLUSION_QUERIES
2253in float a_occlusion_query_opacity;
2254#endif
2255#ifdef ELEVATED_ROADS
2256in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;
2257#endif
2258#ifdef INDICATOR_CUTOUT
2259out highp float v_z_offset;
2260#else
2261#ifdef RENDER_SHADOWS
2262out highp float v_z_offset;
2263#endif
2264#endif
2265uniform 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_matrix;uniform mat4 u_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;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 vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;
2266#ifdef PROJECTION_GLOBE_VIEW
2267uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
2268#endif
2269out vec2 v_tex_a;
2270#ifdef ICON_TRANSITION
2271out vec2 v_tex_b;
2272#endif
2273out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;
2274#ifdef RENDER_TEXT_AND_SYMBOL
2275out float is_sdf;out vec2 v_tex_a_icon;
2276#endif
2277#ifdef RENDER_SHADOWS
2278uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;
2279#endif
2280#ifdef USE_PAINT_PROPERTIES_UBO
2281#ifndef MAX_UBO_SIZE_VEC4
2282#define MAX_UBO_SIZE_VEC4 1024u
2283#endif
2284#define SPP_HEADER_SIZE_VEC4 3u
2285#define DWORDS_PER_VEC4 4u
2286struct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform float u_zoom;uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform highp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity;
2287#ifdef RENDER_SDF
2288out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur;
2289#endif
2290#ifdef LIGHTING_3D_MODE
2291out lowp float v_emissive_strength;
2292#endif
2293PropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask=u_spp_header.header[0][0];uint zoomDependentMask=u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color       =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3]);header.halo_np_color       =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0]);header.opacity             =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1]);header.halo_width          =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2]);header.halo_blur           =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3]);header.emissive_strength   =getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0]);header.occlusion_opacity   =getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1]);header.z_offset            =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2]);header.translate           =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3]);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :
2294(index==1u) ? v.y :
2295(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x :
2296(index==1u) ? v.y :
2297(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,u_zoom);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {vec2 minVal=slot.xy;vec2 maxVal=slot.zw;return mix(minVal,maxVal,u_zoom);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,u_zoom);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color       =header.fill_np_color.isDataDriven     ? readColorProperty(header.fill_np_color,sizeVec4)     : u_spp_fill_np_color;props.halo_np_color       =header.halo_np_color.isDataDriven     ? readColorProperty(header.halo_np_color,sizeVec4)     : u_spp_halo_np_color;props.opacity             =header.opacity.isDataDriven           ? readFloatProperty(header.opacity,sizeVec4)           : u_spp_opacity;props.halo_width          =header.halo_width.isDataDriven        ? readFloatProperty(header.halo_width,sizeVec4)        : u_spp_halo_width;props.halo_blur           =header.halo_blur.isDataDriven         ? readFloatProperty(header.halo_blur,sizeVec4)         : u_spp_halo_blur;props.emissive_strength   =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity   =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset            =header.z_offset.isDataDriven          ? readFloatProperty(header.z_offset,sizeVec4)          : u_spp_z_offset;props.translate           =header.translate.isDataDriven         ? readVec2Property(header.translate,sizeVec4)          : vec2(0.0);return props;}
2298#else
2299#pragma mapbox: define highp vec4 fill_color
2300#pragma mapbox: define highp vec4 halo_color
2301#pragma mapbox: define lowp float opacity
2302#pragma mapbox: define lowp float halo_width
2303#pragma mapbox: define lowp float halo_blur
2304#pragma mapbox: define lowp float emissive_strength
2305#pragma mapbox: define lowp float occlusion_opacity
2306#pragma mapbox: define highp float z_offset
2307#endif
2308vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {
2309#ifdef USE_PAINT_PROPERTIES_UBO
2310SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;
2311#ifdef RENDER_SDF
2312v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur;
2313#endif
2314#ifdef LIGHTING_3D_MODE
2315v_emissive_strength=paint_properties.emissive_strength;
2316#endif
2317lowp float occlusion_opacity=paint_properties.occlusion_opacity;highp float z_offset=paint_properties.z_offset;
2318#else
2319#pragma mapbox: initialize highp vec4 fill_color
2320#pragma mapbox: initialize highp vec4 halo_color
2321#pragma mapbox: initialize lowp float opacity
2322#pragma mapbox: initialize lowp float halo_width
2323#pragma mapbox: initialize lowp float halo_blur
2324#pragma mapbox: initialize lowp float emissive_strength
2325#pragma mapbox: initialize lowp float occlusion_opacity
2326#pragma mapbox: initialize highp float z_offset
2327#endif
2328vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);
2329#ifdef Z_OFFSET
2330e+=a_auto_z_offset;
2331#endif
2332vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;
2333#ifdef PROJECTION_GLOBE_VIEW
2334mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
2335#else
2336world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
2337#endif
2338vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
2339camera_to_anchor_distance/u_camera_to_center_distance :
2340u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
23410.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;
2342#ifdef PROJECTION_GLOBE_VIEW
2343vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);
2343offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;
2344#else
2345offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;
2346#endif
2347vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
2348#ifdef PROJECTION_GLOBE_VIEW
2349#ifdef PROJECTED_POS_ON_VIEWPORT
2350projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);
2351#else
2352vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);    
2353#endif
2354#else
2355projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
2356#endif
2357highp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
2358#ifdef TERRAIN
2359#ifdef PITCH_WITH_MAP_TERRAIN
2360vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
2361#endif
2362#endif
2363#ifdef Z_OFFSET
2364z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;
2365#else
2366z+=u_pitch_with_map ? z_offset : 0.0;
2367#endif
2368float occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));
2369#ifdef DEPTH_OCCLUSION
2370float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;
2371#endif
2372#ifdef OCCLUSION_QUERIES
2373float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;
2374#endif
2375#ifdef Z_TEST_OCCLUSION
2376out_fade_opacity*=occlusion_opacity;
2377#endif
2378float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;
2379#ifdef PROJECTION_GLOBE_VIEW
2380vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;
2381#else
2382#ifdef ELEVATED_ROADS
2383vec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;
2384#else
2385pos=vec3(projected_pos.xy/projected_pos.w+offset,z);
2386#endif
2387#endif
2388gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);
2389#ifdef USE_PAINT_PROPERTIES_UBO
2390{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(
2391u_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y
2392);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}
2393#endif
2394float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;
2395#ifdef RENDER_TEXT_AND_SYMBOL
2396is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;
2397#endif
2398#ifdef ICON_TRANSITION
2399v_tex_b=vec2(a_texb)/u_texsize;
2400#endif
2401#ifdef RENDER_SHADOWS
2402vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;
2403#ifdef NORMAL_OFFSET
2404vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
2405#endif
2406v_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;
2407#endif
2408#ifdef INDICATOR_CUTOUT
2409v_z_offset=e;
2410#else
2411#ifdef RENDER_SHADOWS
2412v_z_offset=e;
2413#endif
2414#endif
2415}`),terrainRaster:Ot(`#include "_prelude_fog.fragment.glsl"
2416#include "_prelude_shadow.fragment.glsl"
2417#include "_prelude_lighting.glsl"
2418uniform sampler2D u_image0;
2419#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2420uniform sampler2D u_image1;uniform float u_emissive_texture_available;
2421#endif
2422in vec2 v_pos0;
2423#ifdef FOG
2424in float v_fog_opacity;
2425#endif
2426#ifdef RENDER_SHADOWS
2427in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
2428#endif
2429uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;
2430#ifdef LIGHTING_3D_MODE
2431const vec3 normal=vec3(0.0,0.0,1.0);
2432#ifdef RENDER_SHADOWS
2433float cutoffOpacity=1.0;
2434#ifdef RENDER_CUTOFF
2435cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);
2436#endif
2437#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2438float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;
2439#else
2440float lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));
2441#endif
2442#else
2443float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);
2444#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2445float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;
2446#endif
2447#endif
2448#else
2449color=image_color;
2450#endif
2451#ifdef FOG
2452#ifdef ZERO_EXAGGERATION
2453color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
2454#else
2455color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
2456#endif
2457#endif
2458glFragColor=color;
2459#ifdef OVERDRAW_INSPECTOR
2460glFragColor=vec4(1.0);
2461#endif
2462HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2463#include "_prelude_terrain.vertex.glsl"
2464uniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;
2465#ifdef FOG
2466out float v_fog_opacity;
2467#endif
2468#ifdef RENDER_SHADOWS
2469uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;
2470#endif
2471void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
2472#ifdef FOG
2473#ifdef ZERO_EXAGGERATION
2474v_fog_pos=fog_position(decodedPos);
2475#else
2476v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
2477#endif
2478#endif
2479#ifdef RENDER_SHADOWS
2480vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);
2481#endif
2482}`),terrainDepth:Ot("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl"
2483uniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:Ot(`#include "_prelude_fog.fragment.glsl"
2484in lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
2485cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(e
2485nd-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;
2486#ifdef FOG
2487sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
2488#endif
2489sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);
2490#ifdef OVERDRAW_INSPECTOR
2491glFragColor=vec4(1.0);
2492#endif
2493}`,nd),skyboxGradient:Ot(`#include "_prelude_fog.fragment.glsl"
2494in highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));
2495#ifdef FOG
2496color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
2497#endif
2498color*=u_opacity;glFragColor=color;
2499#ifdef OVERDRAW_INSPECTOR
2500glFragColor=vec4(1.0);
2501#endif
2502}`,nd),skyboxCapture:Ot
vendor: 3,792 bytes, lines 2502-2513
2502(`
2503in highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float;
2504#define BETA_R                  vec3(5.5e-6,13.0e-6,22.4e-6)
2505#define BETA_M                  vec3(21e-6,21e-6,21e-6)
2506#define MIE_G                   0.76
2507#define DENSITY_HEIGHT_SCALE_R  8000.0
2508#define DENSITY_HEIGHT_SCALE_M  1200.0
2509#define PLANET_RADIUS           6360e3
2510#define ATMOSPHERE_RADIUS       6420e3
2511#define SAMPLE_STEPS            10
2512#define DENSITY_STEPS           4
2513float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}`,"in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globe
2513Raster:Ot(`#include "_prelude_fog.fragment.glsl"
2514#include "_prelude_lighting.glsl"
2515uniform sampler2D u_image0;
2516#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2517uniform sampler2D u_image1;uniform float u_emissive_texture_available;
2518#endif
2519uniform float u_far_z_cutoff;in vec2 v_pos0;
2520#ifndef FOG
2521uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;
2522#endif
2523void main() {vec4 color;
2524#ifdef CUSTOM_ANTIALIASING
2525highp vec2 uv=gl_FragCoord.xy/u_viewport;
2526#ifdef FLIP_Y
2527uv.y=1.0-uv.y;
2528#endif
2529highp vec3 ray_dir=mix(
2530mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);
2531#ifdef LIGHTING_3D_MODE
2532#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2533float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);
2534#else
2535raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);
2536#endif
2537#else
2538color=vec4(raster.rgb*antialias,raster.a*antialias);
2539#endif
2540#else
2541color=texture(u_image0,v_pos0);
2542#ifdef LIGHTING_3D_MODE
2543#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2544float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;
2545#else
2546color=apply_lighting_ground(color);
2547#endif
2548#endif
2549#endif
2550#ifdef FOG
2551color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
2552#endif
2553color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;
2554#ifdef OVERDRAW_INSPECTOR
2555glFragColor=vec4(1.0);
2556#endif
2557HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2558#include "_prelude_terrain.vertex.glsl"
2559uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;
2560#ifdef GLOBE_POLES
2561in vec3 a_globe_pos;in vec2 a_uv;
2562#else
2563in ivec2 a_pos;
2564#endif
2565out vec2 v_pos0;void main() {
2566#ifdef GLOBE_POLES
2567vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
2568#else
2569float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
2570#endif
2571v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
2572#ifdef GLOBE_POLES
2573vec3 up_vector=globe_derived_up_vector;
2574#else
2575vec3 up_vector=elevationVector(tile_pos);
2576#endif
2577float height=elevation(tile_pos);globe_pos+=up_vector*height;
2578#ifndef GLOBE_POLES
2579globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
2580#endif
2581#ifdef GLOBE_POLES
2582vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
2583#else
2584vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
2585#endif
2586gl_Position=u_proj_matrix*interpolated_pos;
2587#ifdef FOG
2588v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
2589#endif
2590}`),globeAtmosphere:Ot(`#include "_prelude_fog.fragment.glsl"
2591uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;
2592#ifdef PROJECTION_GLOBE_VIEW
2593globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {
2594#ifdef ALPHA_PASS
2595glFragColor=vec4(0,0,0,0);return;
2596#else
2597#ifdef NATIVE
2598glFragColor=vec4(1,1,1,1);
2599#else
2600glFragColor=vec4(0,0,0,1);
2601#endif
2602return;
2603#endif
2604}
2605#endif
2606highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
26070.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;
2608#ifdef PROJECTION_GLOBE_VIEW
2609highp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?
2610PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);
2611#else
2612horizon_angle=horizon_angle_mercator;
2613#endif
2614horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;
2614vec3 color_stop_2=u_space_color.rgb;
2615#ifdef ALPHA_PASS
2616float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);
2617#else
2618vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t);
2619#endif
2620}`,`in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(
2621mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(
2622mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`),model:Ot(`#include "_prelude_fog.fragment.glsl"
2623#include "_prelude_shadow.fragment.glsl"
2624#include "_prelude_lighting.glsl"
2625uniform float u_opacity;
2626#ifdef DITHERED_DISCARD
2627uniform float u_dithered_discard_threshold;
2628#endif
2629uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;
2630#ifdef RENDER_SHADOWS
2631in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;
2632#endif
2633#ifdef OCCLUSION_TEXTURE_TRANSFORM
2634uniform vec4 u_occlusionTextureTransform;
2635#endif
2636#pragma mapbox: define-attribute highp vec3 normal_3f
2637#pragma mapbox: define-attribute highp vec3 color_3f
2638#pragma mapbox: define-attribute highp vec4 color_4f
2639#pragma mapbox: define-attribute highp vec2 uv_2f
2640#pragma mapbox: initialize-attribute highp vec3 normal_3f
2641#pragma mapbox: initialize-attribute highp vec3 color_3f
2642#pragma mapbox: initialize-attribute highp vec4 color_4f
2643#pragma mapbox: initialize-attribute highp vec2 uv_2f
2644#ifdef HAS_ATTRIBUTE_a_pbr
2645in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;
2646#endif
2647#ifdef HAS_TEXTURE_u_baseColorTexture
2648uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;
2649#endif
2650#ifdef HAS_TEXTURE_u_metallicRoughnessTexture
2651uniform sampler2D u_metallicRoughnessTexture;
2652#endif
2653#ifdef HAS_TEXTURE_u_occlusionTexture
2654uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;
2655#endif
2656#ifdef HAS_TEXTURE_u_normalTexture
2657uniform sampler2D u_normalTexture;
2658#endif
2659#ifdef HAS_TEXTURE_u_emissionTexture
2660uniform sampler2D u_emissionTexture;
2661#endif
2662#ifdef APPLY_LUT_ON_GPU
2663uniform highp sampler3D u_lutTexture;
2664#endif
2665#ifdef TERRAIN_FRAGMENT_OCCLUSION
2666in highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;
2667#ifdef DEPTH_D24
2668highp float unpack_depth(highp float depth) {return  depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}
2669#else
2670highp float unpack_depth_rgba(highp vec4 rgba_depth)
2671{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}
2672#endif
2673bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;
2674#ifdef FLIP_Y
2675coord.y=1.0-coord.y;
2676#endif
2677#ifdef DEPTH_D24
2678highp float depth=unpack_depth(texture(u_depthTexture,coord).r);
2679#else
2680highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));
2681#endif
2682return v_depth > depth+0.0005;}
2683#endif
2684#define saturate(_x) clamp(_x,0.,1.)
2685vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)
2686{
2687#ifdef LIGHTING_3D_MODE
2688vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;
2689#ifdef RENDER_SHADOWS
2690lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
2691#else
2692lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));
2693#endif
2694return apply_lighting(albedo,transformed_normal,lighting_factor);
2695#else
2696vec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-light
2696Color),vec3(1.0));return c3;
2697#endif
2698}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;
2699#ifdef HAS_ATTRIBUTE_a_color_3f
2700albedo*=vec4(color_3f,1.0);
2701#endif
2702#ifdef HAS_ATTRIBUTE_a_pbr
2703#else
2704#ifdef HAS_ATTRIBUTE_a_color_4f
2705albedo*=color_4f;
2706#endif
2707#endif
2708#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)
2709vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}
2710#ifdef UNPREMULT_TEXTURE_IN_SHADER
2711texColor=vec4(unpremultiplyColor(texColor),1.0);
2712#endif
2713if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}
2714#endif
2715vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);
2716#ifdef APPLY_LUT_ON_GPU
2717color=applyLUT(u_lutTexture,color);
2718#endif
2719return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {
2720#ifdef HAS_TEXTURE_u_normalTexture
2721highp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;
2722#ifdef FLIP_Y
2723T=-T;B=-B;
2724#endif
2725highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;
2726#else
2727return mat3(1.0);
2728#endif
2729}highp vec3 getNormal(){highp vec3 n;
2730#ifdef HAS_ATTRIBUTE_a_normal_3f
2731n=normalize(normal_3f);
2732#else
2733highp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));
2734#ifdef FLIP_Y
2735n=normalize(cross(fdx,fdy));
2736#else
2737n=normalize(cross(fdx,fdy))*-1.0;
2738#endif
2739#endif
2740#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2741vec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);
2742#endif
2743return n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;
2744#ifdef HAS_ATTRIBUTE_a_pbr
2745mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;
2746#endif
2747#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2748vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;
2749#endif
2750const float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)
2751{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)
2752{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)
2753{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)
2754{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)
2755{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)
2756{
2757#ifdef LIGHTING_3D_MODE
2758return mat.diffuseColor;
2759#else
2760return mat.diffuseColor/PI;
2761#endif
2762}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)
2763{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)
2764{vec3 env_light=vec3(0.65,0.65,0.65);
2765#ifdef LIGHTING_3D_MODE
2766float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;
2767#endif
2768vec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)
2769{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;
2770#ifdef RENDER_SHADOWS
2771lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
2772#else
2773lighting_factor=NdotL;
2774#endif
2775vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*light
2775Color;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;
2776#if !defined(LIGHTING_3D_MODE)
2777const vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);
2778#endif
2779color*=intensityFactor;return color;}void main() {
2780#ifdef TERRAIN_FRAGMENT_OCCLUSION
2781if (isOccluded()) {discard;}
2782#endif
2783vec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;
2784#ifdef LIGHTING_3D_MODE
2785lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;
2786#endif
2787vec4 finalColor;
2788#ifdef DIFFUSE_SHADED
2789vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);
2790#ifdef HAS_TEXTURE_u_occlusionTexture
2791float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;
2792#endif
2793finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;
2794#else
2795Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;
2796#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2797#ifdef OCCLUSION_TEXTURE_TRANSFORM
2798vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;
2799#else
2800vec2 uv=uv_2f;
2801#endif
2802ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;
2803#endif
2804vec4 emissive=u_emissiveFactor;
2805#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2806emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);
2807#endif
2808#ifdef APPLY_LUT_ON_GPU
2809float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;
2810#endif
2811color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;
2812#ifdef HAS_ATTRIBUTE_a_pbr
2813float resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;
2814#ifdef APPLY_LUT_ON_GPU
2815color_mix=applyLUT(u_lutTexture,color_mix);
2816#endif
2817color=mix(color,color_mix,min(1.0,resEmission));
2818#ifdef HAS_ATTRIBUTE_a_color_4f
2819float distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.
2819y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);
2820#endif
2821#endif
2822vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);
2823#endif
2824#ifdef DITHERED_DISCARD
2825if (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}
2826#endif
2827#ifdef FOG
2828finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));
2829#endif
2830#ifdef RENDER_CUTOFF
2831finalColor*=v_cutoff_opacity;
2832#endif
2833#ifdef INDICATOR_CUTOUT
2834finalColor=applyCutout(finalColor,v_position_height.w);
2835#endif
2836#ifdef FEATURE_CUTOUT
2837finalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);
2838#endif
2839glFragColor=finalColor;
2840#ifdef OVERDRAW_INSPECTOR
2841glFragColor=vec4(1.0);
2842#endif
2843HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2844#include "_prelude_shadow.vertex.glsl"
2845in vec3 a_pos_3f;
2846#pragma mapbox: define-attribute highp vec3 normal_3f
2847#pragma mapbox: define-attribute highp vec2 uv_2f
2848#pragma mapbox: define-attribute highp vec3 color_3f
2849#pragma mapbox: define-attribute highp vec4 color_4f
2850#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr
2851#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength
2852uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;
2853#ifdef INSTANCED_ARRAYS
2854in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
2855#else
2856uniform highp mat4 u_normal_matrix;
2857#endif
2858#ifdef RENDER_SHADOWS
2859uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;
2860#endif
2861out vec4 v_position_height;out lowp vec4 v_color_mix;
2862#ifdef TERRAIN_FRAGMENT_OCCLUSION
2863out highp float v_depth;
2864#endif
2865#ifdef HAS_ATTRIBUTE_a_pbr
2866out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;
2867#endif
2868vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
2869#pragma mapbox: initialize-attribute highp vec3 normal_3f
2870#pragma mapbox: initialize-attribute highp vec2 uv_2f
2871#pragma mapbox: initialize-attribute highp vec3 color_3f
2872#pragma mapbox: initialize-attribute highp vec4 color_4f
2873#pragma mapbox: initialize-attribute-custom highp uvec4 pbr
2874#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength
2875highp mat4 normal_matrix;
2876#ifdef INSTANCED_ARRAYS
2877normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
2878#else
2879normal_matrix=u_normal_matrix;
2880#endif
2881vec3 local_pos;mat3 rs;
2882#ifdef MODEL_POSITION_ON_GPU
2883vec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;
2884#else
2885local_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);
2886#endif
2887v_position_height.w=a_pos_3f.z;
2888#ifdef HAS_ATTRIBUTE_a_pbr
2889vec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(float(pbr.z));vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;
2890#endif
2891#ifdef FOG
2892v_fog_pos=fog_position(local_pos);
2893#endif
2894#ifdef RENDER_CUTOFF
2895v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
2896#endif
2897#ifdef TERRAIN_FRAGMENT_OCCLUSION
2898v_depth=gl_Position.z/gl_Position.w;
2899#ifdef CLIP_ZERO_TO_ONE
2900v_depth=-1.0+2.0*v_depth; 
2901#endif
2902#endif
2903#ifdef HAS_ATTRIBUTE_a_normal_3f
2904#ifdef MODEL_POSITION_ON_GPU
2905float x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);
2906#else
2907normal_3f=vec3(normal_matrix*vec4(normal_3f,0));
2908#endif
2909#endif
2910#ifdef HAS_ATTRIBUTE_a_pbr
2911#ifdef HAS_ATTRIBUTE_a_color_4f
2912v_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);
2913#endif
2914#endif
2915#ifdef RENDER_SHADOWS
2916vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);
2917#ifdef NORMAL_OFFSET
2918#ifdef HAS_ATTRIBUTE_a_normal_3f
2919#ifdef MODEL_POSITION_ON_GPU
2920vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
2921#else
2922vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
2923#endif
2924#endif
2925#endif
2926v_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;
2927#endif
2928}`),modelDepth:Ot("void main() {}",`in vec3 a_pos_3f;uniform mat4 u_matrix;
2929#ifdef MODEL_POSITION_ON_GPU
2930#ifdef INSTANCED_ARRAYS
2931in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
2932#else
2933uniform highp mat4 u_instance;
2934#endif
2935uniform highp mat4 u_node_matrix;
2936#endif
2937void main() {
2938#ifdef MODEL_POSITION_ON_GPU
2939highp mat4 instance;
2940#ifdef INSTANCED_ARRAYS
2941instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
2942#else
2943instance=u_instance;
2944#endif
2945vec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;
2945rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);
2946#else
2947gl_Position=u_matrix*vec4(a_pos_3f,1);
2948#endif
2949}`),stars:Ot(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)
2950{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}`,`
2951in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}`),occlusion:Ot("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl"
2952in highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;
2953#ifdef TERRAIN
2954float e=elevation(world_pos.xy);world_pos.z+=e;
2955#endif
2956vec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}`)};function Rs(a,t){let o=a.split(`
2957`);for(let c of o){if(c=c.trimStart(),c[0]!=="#"||!c.includes("if")||c.startsWith("#endif"))continue;let d=c.match(ad);if(d)for(let m of d)Sf.has(m)||t.add(m)}}function Vu(a){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(a)}function Ot(a,t){let o=new Set,c=[],d=[];a=a.replace(Fu,(_,y)=>(d.push(y),"")),t=t.replace(Fu,(_,y)=>(c.push(y),""));let m=new Set(Ic);Rs(a,m),Rs(t,m);for(let _ of[...c,...d])Ds[_]||(Ds[_]=new Set,Rs(Ac[_],Ds[_])),m=new Set([...m,...Ds[_]]);return{fragmentSource:a=a.replace(Bu,(_,y,v,T,E)=>(o.add(E),y==="define"?`
2958#ifndef HAS_UNIFORM_u_${E}
2959${Vu(T)?"flat ":""}in ${v} ${T} ${E};
2960#else
2961uniform ${v} ${T} u_${E};
2962#endif
2963`:y==="initialize"?`
2964#ifdef HAS_UNIFORM_u_${E}
2965    ${v} ${T} ${E} = u_${E};
2966#endif
2967`:y==="define-attribute"?`
2968#ifdef HAS_ATTRIBUTE_a_${E}
2969    in ${v} ${T} ${E};
2970#endif
2971`:y==="initialize-attribute"?"":void 0)),vertexSource:t=t.replace(Bu,(_,y,v,T,E)=>{let P=`MATERIAL_ATTRIBUTE_OFFSET_${E}`,A=T==="float"?"vec2":T,D=`GET_ATTRIBUTE_${A}(a_${E}, materialInfo, ${P})`,z=E.includes("color")?"color":A;return y==="define-attribute-vertex-shader-only"?`
2972#ifdef HAS_ATTRIBUTE_a_${E}
2973in ${v} ${T} a_${E};
2974#endif
2975`:o.has(E)?y==="define"?`
2976#ifndef HAS_UNIFORM_u_${E}
2977uniform lowp float u_${E}_t;
2978    #if !defined(${P})
2979        in ${v} ${A} a_${E};
2980    #endif
2981${Vu(T)?"flat ":""}out ${v} ${T} ${E};
2982#else
2983uniform ${v} ${T} u_${E};
2984#endif
2985`:y==="initialize"?z==="vec4"||z==="uvec4"?`
2986#ifndef HAS_UNIFORM_u_${E}
2987    ${E} = a_${E};
2988#else
2989    ${v} ${T} ${E} = u_${E};
2990#endif
2991`:`
2992#if !defined(HAS_UNIFORM_u_${E})
2993    #ifdef ${P}
2994        ${E} = unpack_mix_${z}(${D}, u_${E}_t);
2995    #else
2996        ${E} = unpack_mix_${z}(a_${E}, u_${E}_t);
2997    #endif
2998#else
2999    ${v} ${T} ${E} = u_${E};
3000#endif
3001`:y==="define-attribute"?`
3002#ifdef HAS_ATTRIBUTE_a_${E}
3003    in ${v} ${T} a_${E};
3004    out ${v} ${T} ${E};
3005#endif
3006`:y==="initialize-attribute"?`
3007#ifdef HAS_ATTRIBUTE_a_${E}
3008    ${E} = a_${E};
3009#endif
3010`:void 0:y==="define"?`
3011#ifndef HAS_UNIFORM_u_${E}
3012uniform lowp float u_${E}_t;
3013    #if !defined(${P})
3014        in ${v} ${A} a_${E};
3015    #endif
3016#else
3017uniform ${v} ${T} u_${E};
3018#endif
3019`:y==="define-instanced"?z==="mat4"?`
3020#ifdef INSTANCED_ARRAYS
3021in vec4 a_${E}0;
3022in vec4 a_${E}1;
3023in vec4 a_${E}2;
3024in vec4 a_${E}3;
3025#else
3026uniform ${v} ${T} u_${E};
3027#endif
3028`:`
3029#ifdef INSTANCED_ARRAYS
3030in ${v} ${A} a_${E};
3031#else
3032uniform ${v} ${T} u_${E};
3033#endif
3034`:y==="initialize-attribute-custom"?`
3035#ifdef HAS_ATTRIBUTE_a_${E}
3036    ${v} ${T} ${E} = a_${E};
3037#endif
3038`:z==="vec4"||z==="uvec4"?`
3039#ifndef HAS_UNIFORM_u_${E}
3040    #ifdef ${P}
3041        ${v} ${T} ${E} = ${D};
3042    #else
3043        ${v} ${T} ${E} = a_${E};
3044    #endif
3045#else
3046    ${v} ${T} ${E} = u_${E};
3047#endif
3048`:`
3049#ifndef HAS_UNIFORM_u_${E}
3050    #ifdef ${P}
3051        ${v} ${T} ${E} = unpack_mix_${z}(${D}, u_${E}_t);
3052    #else
3053        ${v} ${T} ${E} = unpack_mix_${z}(a_${E}, u_${E}_t);
3054    #endif
3055#else
3056    ${v} ${T} ${E} = u_${E};
3057#endif
3058`}),usedDefines:m,vertexIncludes:c,fragmentIncludes:d}}class ju{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(t,o,c,d,m,_,y,v){this.context=t;let T=this.boundPaintVertexBuffers.length!==d.length;for(let P=0;!T&&P<d.length;P++)this.boundPaintVertexBuffers[P]!==d[P]&&(T=!0);let E=this.boundDynamicVertexBuffers.length!==y.length;for(let P=0;!E&&P<y.length;P++)this.boundDynamicVertexBuffers[P]!==y[P]&&(E=!0);if(!this.vao||this.boundProgram!==o||this.boundLayoutVertexBuffer!==c||T||E||this.boundIndexBuffer!==m||this.boundVertexOffset!==_)this.freshBind(o,c,d,m,_,y,v);else{t.bindVertexArrayOES.set(this.vao);for(let P of y)P&&(P.bind(),v&&P.instanceCount&&P.setVertexAttribDivisor(t.gl,o,v));m&&m.dynamicDraw&&m.bind()}}freshBind(t,o,c,d,m,_,y){let v=this.context,T=v.gl;this.vao&&this.destroy(),this.vao=v.gl.createVertexArray(),v.bindVertexArrayOES.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=c,this.boundIndexBuffer=d,this.boundVertexOffset=m,this.boundDynamicVertexBuffers=_,o.enableAttributes(T,t),o.bind(),o.setVertexAttribPointers(T,t,m);for(let E of c)E.enableAttributes(T,t),E.bind(),E.setVertexAttribPointers(T,t,m);for(let E of _)E&&(E.enableAttributes(T,t),E.bind(),E.setVertexAttribPointers(T,t,m),y&&E.instanceCount&&E.setVertexAttribDivisor(T,t,y));d&&d.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function cd(a,t){let o=Math.pow(2,t.canonical.z),c=t.canonical.y;return[new h.ad(0,c/o).toLngLat().lat,new h.ad(0,(c+1)/o).toLngLat().lat]}function ud(a,t,o,c,d,m,_){let y=a.context,v=y.gl,T=o.hillshadeFBO;if(!T)return;a.prepareDrawTile();let E=a.isTileAffectedByFog(t),P=[];a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&P.push("USE_MRT1");let A=a.getOrCreateProgram("hillshade",{overrideFog:E,defines:P});y.activeTexture.set(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,T.colorAttachment0.get());let D=((N,q,Z,G)=>{let re=Z.paint.get("hillshade-shadow-color"),te=Z.paint.get("hillshade-shadow-color-use-theme").
3058constantOr("default")==="none",se=Z.paint.get("hillshade-highlight-color"),K=Z.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",J=Z.paint.get("hillshade-accent-color"),oe=Z.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",ue=Z.paint.get("hillshade-emissive-strength"),de=h.am(Z.paint.get("hillshade-illumination-direction"));if(Z.paint.get("hillshade-illumination-anchor")==="viewport")de-=N.transform.angle;else if(N.style&&N.style.enable3dLights()&&N.style.directionalLight){let ve=N.style.directionalLight.properties.get("direction"),Fe=h.cT(ve.x,ve.y,ve.z);de=h.am(Fe[1])}let be=!N.options.moving;return{u_matrix:G||N.transform.calculateProjMatrix(q.tileID.toUnwrapped(),be),u_image:0,u_latrange:cd(0,q.tileID),u_light:[Z.paint.get("hillshade-exaggeration"),de],u_shadow:re.toPremultipliedRenderColor(te?null:Z.lut),u_highlight:se.toPremultipliedRenderColor(K?null:Z.lut),u_emissive_strength:ue,u_accent:J.toPremultipliedRenderColor(oe?null:Z.lut)}})(a,o,c,a.terrain?t.projMatrix:null);a.uploadCommonUniforms(y,A,t.toUnwrapped());let{tileBoundsBuffer:z,tileBoundsIndexBuffer:O,tileBoundsSegments:k}=a.getTileBoundsBuffers(o);A.draw(a,v.TRIANGLES,d,m,_,pt.disabled,D,c.id,z,O,k)}function Mc(a,t,o){if(!t.needsDEMTextureUpload)return;let c=a.context,d=c.gl;c.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||a.getTileTexture(o.stride);let m=o.getPixels();t.demTexture?t.demTexture.update(m,{premultiply:!1}):t.demTexture=new h.T(c,m,d.R32F,{premultiply:!1}),t.needsDEMTextureUpload=!1}function hd(a,t,o){let c=a.context,d=c.gl;if(!t.dem)return;let m=t.dem;if(c.activeTexture.set(d.TEXTURE1),Mc(a,t,m),!t.demTexture)return;t.demTexture.bind(d.NEAREST,d.CLAMP_TO_EDGE);let _=m.dim;c.activeTexture.set(d.TEXTURE0);let y=t.hillshadeFBO;if(!y){let A=new h.T(c,{width:_,height:_,data:null},d.RGBA8);A.bind(d.LINEAR,d.CLAMP_TO_EDGE),y=t.hillshadeFBO=c.createFramebuffer(_,_,1,"renderbuffer"),y.colorAttachment0.set(A.texture)}c.bindFramebuffer.set(y.framebuffer),c.viewport.set([0,0,_,_]);let{tileBoundsBuffer:v,tileBoundsIndexBuffer:T,tileBoundsSegments:E}=a.getMercatorTileBoundsBuffers(),P=[];a.linearFloatFilteringSupported()&&P.push("TERRAIN_DEM_FLOAT_FORMAT"),a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&P.push("USE_MRT1"),a.getOrCreateProgram("hillshadePrepare",{defines:P}).draw(a,d.TRIANGLES,nt.disabled,yt.disabled,_t.unblended,pt.disabled,((A,D)=>{let z=D.stride,O=h.bd();return h.bX(O,0,h.ak,-h.ak,0,0,1),h.bB(O,O,[0,-h.ak,0]),{u_matrix:O,u_image:1,u_dimension:[z,z],u_zoom:A.overscaledZ}})(t.tileID,m),o.id,v,T,E),t.needsHillshadePrepare=!1}class Si{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Ef extends Si{getDefault(){return h.C.transparent.toNonPremultipliedRenderColor(null)}set(t){let o=this.current;(t.r!==o.r||t.g!==o.g||t.b!==o.b||t.a!==o.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class xl extends Si{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Z_ extends Si{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class W_ extends Si{getDefault(){return[!0,!0,!0,!0]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||t[3]!==o[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class X_ extends Si{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Y_ extends Si{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class J_ extends Si{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let o=this.current;(t.func!==o.func||t.ref!==o.ref||t.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class K_ extends Si{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class dd extends Si{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=t,this.dirty=!1}}class pd extends Si{getDefault(){return[0,1]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class fd extends Si{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=t,this.dirty=!1}}class vl extends Si{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class If extends Si{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.BLEND):o.disable(o.BLEND),this.current=t,this.dirty=!1}}class Af extends Si{getDefault(){let t=this.gl;return[t.ONE,t.ZERO,t.ONE,t.ZERO]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||t[3]!==o[3]||this.dirty)&&(this.gl.blendFuncSeparate(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Mf extends Si{getDefault(){return h.C.transparent.toNonPremultipliedRenderColor(null)}set(t){let o=this.current;(t.r!==o.r||t.g!==o.g||t.b!==o.b||t.a!==o.a||this.dirty)&&(this.gl.blendColor
vendor: 4,746 bytes, line 3058
3058(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class md extends Si{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(t,t),this.current=t,this.dirty=!1)}}class Ls extends Si{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;t?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=t,this.dirty=!1}}class Gu extends Si{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Hu extends Si{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}let Cf=class extends Si{getDefault(){return null}set(a){(a!==this.current||this.dirty)&&(this.gl.useProgram(a),this.current=a,this.dirty=!1)}};class zs extends Si{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class _d extends Si{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let o=this.current;(t[0]!==o[0]||t[1]!==o[1]||t[2]!==o[2]||t[3]!==o[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class $u extends Si{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Pf extends Si{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Df extends Si{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindTexture(o.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class gd extends Si{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class yd extends Si{getDefault(){return null}set(t){let o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Q_ extends Si{getDefault(){return null}set(t){this.gl&&(t!==this.current||this.dirty)&&(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}}class Rf extends Si{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class Cc extends Si{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class eg extends Si{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class xd extends Si{constructor(t,o){super(t),this.context=t,this.parent=o}getDefault(){return null}}class Pc extends xd{constructor(t,o,c=0){super(t,o),this.attachmentPoint=t.gl.COLOR_ATTACHMENT0+c}setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachmentPoint,o.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Lf extends xd{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class vd extends xd{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachment(),o.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class qu extends Lf{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}let Pa=(a,t,o,c)=>({u_matrix:a,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:o,u_emissive_texture_available:c}),Dc=(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k)=>({u_proj_matrix:Float32Array.from(a),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(c),u_merc_matrix:o,u_zoom_transition:d,u_merc_center:m,u_image0:0,u_image1:1,u_frustum_tl:_,u_frustum_tr:y,u_frustum_br:v,u_frustum_bl:T,u_globe_pos:E,u_globe_radius:P,u_viewport:A,u_grid_matrix:k?Float32Array.from(k):new Float32Array(9),u_skirt_height:D,u_far_z_cutoff:z,u_emissive_texture_available:O});function bl(a,t){return a!=null&&t!=null&&!(!a.hasData()||!t.hasData())&&a.demTexture!=null&&t.demTexture!=null&&a.tileID.key!==t.tileID.key}let Da=new class{constructor(){this.operations={}}newMorphing(a,t,o,c,d){if(a in this.operations){let m=this.operations[a];m.to.tileID.key!==o.tileID.key&&(m.queued=o)}else this.operations[a]={startTime:c,phase:0,duration:d,from:t,to:o,queued:null}}
3058getMorphValuesForProxy(a){if(!(a in this.operations))return null;let t=this.operations[a];return{from:t.from,to:t.to,phase:t.phase}}update(a){for(let t in this.operations){let o=this.operations[t];for(o.phase=(a-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,a)){delete this.operations[t];break}}}_nextOp(a,t){return!!a.queued&&(a.from=a.to,a.to=a.queued,a.queued=null,a.phase=0,a.startTime=t,!0)}_validOp(a){return a.from.hasData()&&a.to.hasData()}};function Rc(a,t,o){if(t===0)return 0;let c=t<1&&o===514?.25/t:1;return 6*Math.pow(1.5,22-a)*Math.max(t,1)*c}function Zu(a,t){let o=1<<a.z;return!t&&(a.x===0||a.x===o-1)||a.y===0||a.y===o-1}function Ra(a,t){if(!a.style||!a.style.enable3dLights())return;let o=a.context,c=o.gl;o.activeTexture.set(c.TEXTURE1),t?t.bind(c.LINEAR,c.CLAMP_TO_EDGE):a.emptyTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE)}let wl=a=>({u_matrix:a});function Qe(a,t,o,c,d){if(d>0){let m=h.o.now(),_=(m-a.timeAdded)/d,y=t?(m-t.timeAdded)/d:-1,v=o.getSource(),T=c.coveringZoomLevel({tileSize:v.tileSize,roundZoom:v.roundZoom}),E=!t||Math.abs(t.tileID.overscaledZ-T)>Math.abs(a.tileID.overscaledZ-T),P=E&&a.refreshedUponExpiration?1:h.aB(E?_:1-y,0,1);return t?{opacity:1,mix:1-P,isFading:_<1}:{opacity:P,mix:0,isFading:_<1}}return{opacity:1,mix:0,isFading:!1}}class zf extends on{constructor(t){let o={type:"raster-dem",maxzoom:Math.ceil(t.transform.maxZoom)},c=$h("mock-dem",o,t.style.dispatcher,t.style);super("mock-dem",c,null),c.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,o){t.state="loaded",o(null)}}class Os extends on{constructor(t){let o=$h("proxy",{type:"geojson",maxzoom:Math.ceil(t.transform.maxZoom)},t.style.dispatcher,t.style);super("proxy",o,null),o.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,o,c){if(t.freezeTileCoverage)return;this.transform=t;let d=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((m,_)=>{if(m[_.key]="",!this._tiles[_.key]){let y=new h.b3(_,this._source.tileSize*_.overscaleFactor(),t.tileZoom,void 0,void 0,this._source.worldview);y.state="loaded",this._tiles[_.key]=y}return m},{});for(let m in this._tiles)m in d||(this.freeFBO(m),this._tiles[m].unloadVectorData(),delete this._tiles[m])}freeFBO(t){let o=this.proxyCachedFBO[t];if(o!==void 0){let c=Object.values(o);this.renderCachePool.push(...c),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach(t=>t.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class es extends h.aU{constructor(t,o,c){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=o,this.projMatrix=c}}class bd extends h.bx{constructor(t,o){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};let[c,d,m]=function(){let v=new h.dE,T=new h.dF,E=131;v.reserve(17161),T.reserve(33800);let P=h.ak/128,A=h.ak+P/2,D=A+P;for(let O=-P;O<D;O+=P)for(let k=-P;k<D;k+=P){let N=k<0||k>A||O<0||O>A?24575:0,q=h.aB(Math.round(k),0,h.ak),Z=h.aB(Math.round(O),0,h.ak);v.emplaceBack(q+N,Z)}let z=(O,k)=>{let N=k*E+O;T.emplaceBack(N+1,N,N+E),T.emplaceBack(N+E,N+E+1,N+1)};for(let O=1;O<129;O++)for(let k=1;k<129;k++)z(k,O);return[0,129].forEach(O=>{for(let k=0;k<130;k++)z(k,O),z(O,k)}),[v,T,32768]}(),_=t.context;this.gridBuffer=_.createVertexBuffer(c,h.dA.members),this.gridIndexBuffer=_.createIndexBuffer(d),this.gridSegments=h.dB.simpleSegment(0,0,c.length,d.length),this.gridNoSkirtSegments=h.dB.simpleSegment(0,0,c.length,m),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Os(o.map),this.orthoMatrix=h.bd(),h.bX(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,h.ak,0,h.ak,0,1);let y=_.gl;this._overlapStencilMode=new yt({func:y.GEQUAL,mask:255},0,255,y.KEEP,y.KEEP,y.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new zf(o.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),this._style=t,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,o,c){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);let d=t.terrain.properties,m=t.terrain.drapeRenderMode===0,_=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=h.o.now();let y=t.terrain&&t.terrain.scope,v=d.get("source"),T=m?this._mockSourceCache:t.getSourceCache(v,y);if(!T)return void h.w(`Couldn't find terrain source "${v}".`);if(this.sourceCache=T,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=_?this.calculateExaggeration(o):d.get("exaggeration"),!o.projection.requiresDraping&&_&&this._exaggeration===0)return void this._disable();this.enabled=!0;let E=()=>{this.sourceCache.used&&h.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
3059This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);let P=this.getScaledDemTileSize();this.sourceCache.update(o,P,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,E(),this._initializing=!0),E(),o.updateElevation(!0,c),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0,this._previousZoom=
3059o.zoom}else this._disable()}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);let o=this._previousCameraAltitude,c=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=c;let d=o!=null?c-o:Number.MAX_VALUE;if(Math.abs(d)<2)return this._exaggeration;let m=t.zoom,_=this._style.terrain;if(!this._previousUpdateTimestamp)return _.getExaggeration(m);let y=m-this._previousZoom,v=this._previousUpdateTimestamp,T=m;this._evaluationZoom!=null&&(T=this._evaluationZoom,Math.abs(m-T)>.5&&(y=.5*(m-T+y)),y*d<0&&(T+=y)),this._evaluationZoom=T;let E=_.getExaggeration(T),P=E===_.getExaggeration(Math.max(0,T-.1));if(P&&Math.abs(E-this._exaggeration)<.01)return E;let A=Math.min(.1,.00375*(this._updateTimestamp-v));return(P||E<.1||Math.abs(y)<1e-4)&&(A=Math.min(.2,4*A)),h.aj(this._exaggeration,E,A)}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(t){t.dataType==="source"&&t.coord?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):t.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(let t in this._style._mergedSourceCaches)this._style._mergedSourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(t=>t.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){let t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;let o=this.proxySourceCache,c=this.painter.transform;this._initializing&&(this._initializing=c._centerAltitude===0&&this.getAtPointOrZero(h.ad.fromLngLat(c.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);let d=this.proxyCoords=o.getIds().map(v=>{let T=o.getTileByID(v).tileID;return T.projMatrix=c.calculateProjMatrix(T.toUnwrapped()),T});(function(v,T){let E=T.transform.pointCoordinate(T.transform.getCameraPoint()),P=new h.P(E.x,E.y);v.sort((A,D)=>{if(D.overscaledZ-A.overscaledZ)return D.overscaledZ-A.overscaledZ;let z=new h.P(A.canonical.x+(1<<A.canonical.z)*A.wrap,A.canonical.y),O=new h.P(D.canonical.x+(1<<D.canonical.z)*D.wrap,D.canonical.y),k=P.mult(1<<A.canonical.z);return k.x-=.5,k.y-=.5,k.distSqr(z)-k.distSqr(O)})})(d,this.painter);let m=this.proxyToSource||{};this.proxyToSource={},d.forEach(v=>{this.proxyToSource[v.key]={}}),this.terrainTileForTile={};let _=this._style._mergedSourceCaches;for(let v in _){let T=_[v];if(!T.used||(T!==this.sourceCache&&this.resetTileLookupCache(T.id),this._setupProxiedCoordsForOrtho(T,t[v],m),T.usedForTerrain))continue;let E=t[v];(T.getSource().reparseOverscaled||T._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(E)}this.proxiedCoords[o.id]=d.map(v=>new es(v,v.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(m),this.renderingToTexture=!1;let y={};this._visibleDemTiles=[];for(let v of this.proxyCoords){let T=this.terrainTileForTile[v.key];if(!T)continue;let E=T.tileID.key;E in y||(this._visibleDemTiles.push(T),y[E]=E)}}_assignTerrainTiles(t){this._initializing||t.forEach(o=>{if(this.terrainTileForTile[o.key])return;let c=this._findTileCoveringTileID(o,this.sourceCache);c&&(this.terrainTileForTile[o.key]=c)})}_prepareDEMTextures(){let t=this.painter.context,o=t.gl;for(let c in this.terrainTileForTile){let d=this.terrainTileForTile[c],m=d.dem;!m||d.demTexture&&!d.needsDEMTextureUpload||(t.activeTexture.set(o.TEXTURE1),Mc(this.painter,d,m))}}_prepareDemTileUniforms(t,o,c,d){if(!o||o.demTexture==null)return!1;let m=t.tileID.canonical,_=Math.pow(2,o.tileID.canonical.z-m.z),y=d||"";return c[`u_dem_tl${y}`]=[m.x*_%1,m.y*_%1],c[`u_dem_scale${y}`]=_,!0}
3059get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let t=0,o=this._visibleDemTiles.reduce((c,d)=>{if(!d.dem)return c;let m=d.dem.tree.minimums[0];return m>0&&t++,c+m},0);return t?o/t:0}_updateEmptyDEMTexture(){let t=this.painter.context,o=t.gl;t.activeTexture.set(o.TEXTURE2);let c=this._getLoadedAreaMinimum(),d=new h.dC({width:1,height:1},new Float32Array([c]));this._emptyDEMTextureDirty=!1;let m=this._emptyDEMTexture;return m?m.update(d,{premultiply:!1}):m=this._emptyDEMTexture=new h.T(t,d,o.R32F,{premultiply:!1}),m}setupElevationDraw(t,o,c){let d=this.painter.context,m=d.gl,_={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};_.u_exaggeration=this.exaggeration();let y=null,v=null,T=1;if(c&&c.morphing&&this._useVertexMorphing){let D=c.morphing.srcDemTile,z=c.morphing.dstDemTile;T=c.morphing.phase,D&&z&&(this._prepareDemTileUniforms(t,D,_,"_prev")&&(v=D),this._prepareDemTileUniforms(t,z,_)&&(y=z))}let E=D=>D&&D.demTexture&&this.painter.linearFloatFilteringSupported()?m.LINEAR:m.NEAREST,P=null;var A;if(this.enabled?v&&y?(P=y.demTexture,d.activeTexture.set(m.TEXTURE4),v.demTexture.bind(E(v),m.CLAMP_TO_EDGE),_.u_dem_lerp=T):(y=this.terrainTileForTile[t.tileID.key],P=this._prepareDemTileUniforms(t,y,_)?y.demTexture:this.emptyDEMTexture):P=this.emptyDEMTexture,d.activeTexture.set(m.TEXTURE2),P&&(_.u_dem_size=(A=P).size[0]===1?1:A.size[0]-2,P.bind(E(y),m.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(c&&c.useDepthForOcclusion,o,_),
3059c&&c.useMeterToDem&&y){let D=(1<<y.tileID.canonical.z)*h.bY(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;_.u_meter_to_dem=D}if(c&&c.labelPlaneMatrixInv&&(_.u_label_plane_matrix_inv=c.labelPlaneMatrixInv),o.setTerrainUniformValues(d,_),this.painter.transform.projection.name==="globe"){let D=this.globeUniformValues(this.painter.transform,t.tileID.canonical,c&&c.useDenormalizedUpVectorScale);o.setGlobeUniformValues(d,D)}}globeUniformValues(t,o,c){let d=t.projection;return{u_tile_tl_up:d.upVector(o,0,0),u_tile_tr_up:d.upVector(o,h.ak,0),u_tile_br_up:d.upVector(o,h.ak,h.ak),u_tile_bl_up:d.upVector(o,0,h.ak),u_tile_up_scale:c?h.dD(1):d.upVectorScale(o,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){let o=this.painter,c=this.painter.context;t.length!==0&&(c.bindFramebuffer.set(null),c.viewport.set([0,0,o.width,o.height]),o.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(d,m,_,y,v){if(d.transform.projection.name==="globe")(function(T,E,P,A,D){let z=T.context,O=z.gl,k,N,q=T.transform,Z=h.ds(T,z,q),G=(be,ve)=>{if(N===ve)return;let Fe=[];ve===1&&Fe.push("TERRAIN_VERTEX_MORPHING"),Fe.push("PROJECTION_GLOBE_VIEW"),Z&&Fe.push("CUSTOM_ANTIALIASING");let pe=T.isTileAffectedByFog(be);k=T.getOrCreateProgram("globeRaster",{defines:Fe,overrideFog:pe}),N=ve},re=T.colorModeForRenderPass(),te=new nt(O.LEQUAL,nt.ReadWrite,T.depthRangeFor3D);Da.update(D);let se=h.dt(q),K=[h.aG(q.center.lng),h.aJ(q.center.lat)],J=T.globeSharedBuffers,oe=[q.width*h.o.devicePixelRatio,q.height*h.o.devicePixelRatio],ue=Float32Array.from(q.globeMatrix),de={useDenormalizedUpVectorScale:!0};{let be=T.transform,ve=Rc(be.zoom,E.exaggeration(),E.sourceCache._source.tileSize);N=-1;let Fe=O.TRIANGLES;for(let pe of A){let Ee=P.getTile(pe),fe=yt.disabled,Pe=E.prevTerrainTileForTile[pe.key],Ce=E.terrainTileForTile[pe.key];bl(Pe,Ce)&&Da.newMorphing(pe.key,Pe,Ce,D,250),Ra(T,Ee.emissiveTexture),z.activeTexture.set(O.TEXTURE0),Ee.texture&&Ee.texture.bind(O.LINEAR,O.CLAMP_TO_EDGE);let Re=Da.getMorphValuesForProxy(pe.key),Ye=Re?1:0;Re&&Object.assign(de,{morphing:{srcDemTile:Re.from,dstDemTile:Re.to,phase:h.dr(Re.phase)}});let He=h.du(pe.canonical),je=h.dv(He.getCenter().lat),Ue=h.dw(pe.canonical,He,je,be.worldSize/be._pixelsPerMercatorPixel),lt=h.dx(h.dy(pe.canonical)),st=T.emissiveMode==="mrt-fallback"?1:0,et=Dc(be.expandedFarZProjMatrix,ue,se,lt,h.ai(be.zoom),K,be.frustumCorners.TL,be.frustumCorners.TR,be.frustumCorners.BR,be.frustumCorners.BL,be.globeCenterInViewSpace,be.globeRadius,oe,ve,be._farZ,st,Ue);if(G(pe,Ye),k&&(E.setupElevationDraw(Ee,k,de),T.uploadCommonUniforms(z,k,pe.toUnwrapped()),J)){let[it,ht,vt]=J.getGridBuffers(je,ve!==0);k.draw(T,Fe,te,fe,re,pt.backCCW,et,"globe_raster",it,ht,vt)}}}if(J&&(T.renderDefaultNorthPole||T.renderDefaultSouthPole)){let be=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Z&&be.push("CUSTOM_ANTIALIASING"),k=T.getOrCreateProgram("globeRaster",{defines:be});for(let ve of A){let{x:Fe,y:pe,z:Ee}=ve.canonical,fe=pe===0,Pe=pe===(1<<Ee)-1,[Ce,Re,Ye,He]=J.getPoleBuffers(Ee,!1);if(He&&(fe||Pe)){let je=P.getTile(ve);Ra(T,je.emissiveTexture),z.activeTexture.set(O.TEXTURE0),je.texture&&je.texture.bind(O.LINEAR,O.CLAMP_TO_EDGE);let Ue=h.dz(Ee,Fe,q),lt=h.dx(h.dy(ve.canonical)),st=T.emissiveMode==="mrt-fallback"?1:0,et=(it,ht)=>it.draw(T,O.TRIANGLES,te,yt.disabled,re,pt.disabled,Dc(q.expandedFarZProjMatrix,Ue,Ue,lt,0,K,q.frustumCorners.TL,q.frustumCorners.TR,q.frustumCorners.BR,q.frustumCorners.BL,q.globeCenterInViewSpace,q.globeRadius,oe,0,q._farZ,st),"globe_pole_raster",ht,Ye,He);E.setupElevationDraw(je,k,de),T.uploadCommonUniforms(z,k,ve.toUnwrapped()),fe&&T.renderDefaultNorthPole&&et(k,Ce),Pe&&T.renderDefaultSouthPole&&(Ue=h.cE(h.bd(),Ue,[1,-1,1]),et(k,Re))}}}})(d,m,_,y,v);else{let T=d.context,E=T.gl,P,A,D=d.shadowRenderer,z=Ps(d,d.longestCutoffRange),O=re=>{if(A===re)return;let te=[];re===1&&te.push("TERRAIN_VERTEX_MORPHING"),z.shouldRenderCutoff&&te.push("RENDER_CUTOFF"),D&&(te.push("RENDER_SHADOWS"),D.useNormalOffset&&te.push("NORMAL_OFFSET")),P=d.getOrCreateProgram("terrainRaster",{defines:te}),A=re},k=d.colorModeForRenderPass(),N=new nt(E.LEQUAL,nt.ReadWrite,d.depthRangeFor3D);Da.update(v);let q=d.transform,Z=Rc(q.zoom,m.exaggeration(),m.sourceCache._source.tileSize),G=[0,0,0];if(D){let re=d.style.directionalLight,te=d.style.ambientLight;re&&te&&(G=Ia(d.style,re,te))}{A=-1;let re=E.TRIANGLES,[te,se]=[m.gridIndexBuffer,m.gridSegments];for(let K of y){let J=_.getTile(K),oe=yt.disabled,ue=m.prevTerrainTileForTile[K.key],de=m.terrainTileForTile[K.key];bl(ue,de)&&Da.newMorphing(K.key,ue,de,v,250),Ra(d,J.emissiveTexture),T.activeTexture.set(E.TEXTURE0),J.texture&&J.texture.bind(E.LINEAR,E.CLAMP_TO_EDGE);let be=Da.getMorphValuesForProxy(K.key),ve=be?1:0,Fe;be&&(Fe={morphing:{srcDemTile:be.from,dstDemTile:be.to,phase:h.dr(be.phase)}});let pe=d.emissiveMode==="mrt-fallback"?1:0,Ee=Pa(K.projMatrix,Zu(K.canonical,q.renderWorldCopies)?Z/10:Z,G,pe);if(O(ve),!P)continue;m.setupElevationDraw(J,P,Fe);let fe=K.toUnwrapped();D&&D.setupShadows(fe,P),d.uploadCommonUniforms(T,P,fe,null,z),P.draw(d,re,N,oe,k,pt.backCCW,Ee,"terrain_raster",m.gridBuffer,te,se)}}}}(o,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,o.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(this._drapedRenderBatches.length===0)return t+1;this.renderingToTexture=!0;let o=this.painter,c=this.painter.context,d=this.proxySourceCache,m=this.proxiedCoords[d.id],_=this._drapedRenderBatches.shift(),y=o.style.order,v=[];this._updateFBOs(o.emissiveMode==="mrt-fallback");let T=0;for(let E of m){let P=d.getTileByID(E.proxyTileKey),A=d.proxyCachedFBO[E.key]?d.proxyCachedFBO[E.key][t]:void 0,D=A!==void 0?d.renderCache[A]:this.pool[T++],z=A!==void 0;if(P.texture=D.tex,P.emissiveTexture=D.emissiveTex,z&&!D.dirty){v.push(P.tileID);continue}c.bindFramebuffer.set(D.fb.framebuffer);let O=c.gl,k;O.drawBuffers(o.emissiveMode==="mrt-fallback"?[O.COLOR_ATTACHMENT0,O.COLOR_ATTACHMENT1]:[O.COLOR_ATTACHMENT0]),this.renderedToTile=!1,D.dirty&&(c.clear({color:h.C.transparent,stencil:0}),D.dirty=!1);for(let N=_.start;N<=_.end;++N){let q=o.style._mergedLayers[y[N]];if(q.isHidden(o.transform.zoom))continue;let Z=o.style.getLayerSourceCache(q),G=Z?this.proxyToSource[E.key][Z.id]:[E];if(!G)continue;let re=G;
3059c.viewport.set([0,0,D.fb.width,D.fb.height]),k!==(Z?Z.id:null)&&(this._setupStencil(D,G,q,Z),k=Z?Z.id:null),o.renderLayer(o,Z,q,re)}if(O.drawBuffers([O.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(let N of this._pendingGroundEffectLayers){let q=o.style._mergedLayers[y[N]];if(q.isHidden(o.transform.zoom))continue;let Z=o.style.getLayerSourceCache(q),G=Z?this.proxyToSource[E.key][Z.id]:[E];if(!G)continue;let re=G;c.viewport.set([0,0,D.fb.width,D.fb.height]),k!==(Z?Z.id:null)&&(this._setupStencil(D,G,q,Z),k=Z?Z.id:null),o.renderLayer(o,Z,q,re)}this.renderedToTile?(D.dirty=!0,v.push(P.tileID)):z||--T,T===5&&(T=0,this.renderToBackBuffer(v))}return this.renderToBackBuffer(v),this.renderingToTexture=!1,c.bindFramebuffer.set(null),c.viewport.set([0,0,o.width,o.height]),_.end+1}postRender(){}isLayerOrderingCorrect(t){let o=t.order.length,c=-1,d=o;for(let m=0;m<o;++m)this._style.isLayerDraped(t._mergedLayers[t.order[m]])?c=Math.max(c,m):d=Math.min(d,m);return d>c}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{t=Math.min(t,o.dem.tree.minimums[0])}),t===0?t:(t-30)*this._exaggeration}raycast(t,o,c){if(!this._visibleDemTiles)return null;let d=this._visibleDemTiles.filter(m=>m.dem).map(m=>{let _=m.tileID,y=1<<_.overscaledZ,{x:v,y:T}=_.canonical,E=v/y,P=(v+1)/y,A=T/y,D=(T+1)/y;return{minx:E,miny:A,maxx:P,maxy:D,t:m.dem.tree.raycastRoot(E,A,P,D,t,o,c),tile:m}});d.sort((m,_)=>(m.t!==null?m.t:Number.MAX_VALUE)-(_.t!==null?_.t:Number.MAX_VALUE));for(let m of d){if(m.t==null)return null;let _=m.tile.dem.tree.raycast(m.minx,m.miny,m.maxx,m.maxy,t,o,c);if(_!=null)return _}return null}_createFBO(){let t=this.painter.context,o=t.gl,c=this.drapeBufferSize;t.activeTexture.set(o.TEXTURE0);let d=new h.T(t,{width:c[0],height:c[1],data:null},o.RGBA8);d.bind(o.LINEAR,o.CLAMP_TO_EDGE);let m=t.createFramebuffer(c[0],c[1],1,null),_;return m.colorAttachment0.set(d.texture),this._emissiveTexture&&(_=new h.T(t,{width:c[0],height:c[1],data:null},o.R8),_.bind(o.LINEAR,o.CLAMP_TO_EDGE),m.createColorAttachment(t,1),m.colorAttachment1.set(_.texture)),m.depthAttachment=new qu(t,m.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,c[0],c[1]),this._stencilRef=0,m.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):m.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:m,tex:d,emissiveTex:_,dirty:!1}}_updateFBOs(t){if(this._emissiveTexture!==t){for(let o of this.pool)this._updateFBO(o,t);for(let o of this.proxySourceCache.renderCache)this._updateFBO(o,t);this._emissiveTexture=t}}_updateFBO(t,o){let c=t.fb,d=this.painter.context,m=d.gl,_=this.drapeBufferSize;if(o){let y=new h.T(d,{width:_[0],height:_[1],data:null},m.R8);y.bind(m.LINEAR,m.CLAMP_TO_EDGE),t.emissiveTex=y,c.createColorAttachment(d,1),c.colorAttachment1.set(y.texture)}else t.emissiveTex=void 0,c.removeColorAttachment(d,1);t.dirty=!0}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.hasLightTransitions())return!0;for(let t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t].hasTransition())return!0;return this._style.order.some(t=>{let o=this._style._mergedLayers[t],c=o.isHidden(this.painter.transform.zoom);return o.type==="hillshade"||o.type==="custom"?!c&&o.shouldRedrape():!c&&o.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(let c of this._style.getSources())if(c instanceof gu){t=!0;break}if(!t)return;let o={};for(let c=0;c<this._style.order.length;++c){let d=this._style._mergedLayers[this._style.order[c]],m=this._style.getLayerSourceCache(d);if(!m||o[m.id]||d.isHidden(this.painter.transform.zoom)||d.type!=="line")continue;let _=d.widthExpression(),y=d.emissiveStrengthExpression();if(_ instanceof h.ac||y instanceof h.ac){o[m.id]=!0;for(let v of this.proxyCoords){let T=this.proxyToSource[v.key][m.id];if(T)for(let E of T)this._clearRenderCacheForTile(m.id,E)}}}}_clearRasterLayersFromRenderCache(){let t=!1;for(let c in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[c]._source instanceof fc){t=!0;break}if(!t)return;let o={};for(let c=0;c<this._style.order.length;++c){let d=this._style._mergedLayers[this._style.order[c]],m=this._style.getLayerSourceCache(d);if(!m||o[m.id]||d.isHidden(this.painter.transform.zoom)||d.type!=="raster")continue;let _=d.paint.get("raster-fade-duration");for(let y of this.proxyCoords){let v=this.proxyToSource[y.key][m.id];if(v)for(let T of v){let E=Qe(m.getTile(T),m.findLoadedParent(T,0),m,this.painter.transform,_);(E.opacity!==1||E.mix!==0)&&this._clearRenderCacheForTile(m.id,T)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();let t=this._style.order,o=t.length;if(o===0)return;let c=[];this._pendingGroundEffectLayers=[];let d,m=0,_=this._style._mergedLayers[t[m]];for(;!this._style.isLayerDraped(_)&&_.isHidden(this.painter.transform.zoom)&&++m<o;)_=this._style._mergedLayers[t[m]];for(;m<o;++m){let y=this._style._mergedLayers[t[m]];y.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(y)?d===void 0&&(d=m):(y.t
3059ype==="fill-extrusion"&&this._pendingGroundEffectLayers.push(m),d!==void 0&&(c.push({start:d,end:m-1}),d=void 0)))}if(d!==void 0&&c.push({start:d,end:m-1}),c.length!==0){let y=c.at(-1);this._pendingGroundEffectLayers.every(v=>v>y.end)||h.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=c}_setupRenderCache(t){let o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){let _=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let y=0;y<_.length;++y){let v=Object.values(_[y]);o.renderCachePool.push(...v)}}return}this._clearRasterLayersFromRenderCache();let c=this.proxyCoords,d=this._tilesDirty;for(let _=c.length-1;_>=0;_--){let y=c[_];if(o.getTileByID(y.key),o.proxyCachedFBO[y.key]!==void 0){let v=t[y.key],T=this.proxyToSource[y.key],E=0;for(let P in T){let A=T[P],D=v[P];if(!D||D.length!==A.length||A.some((z,O)=>z!==D[O]||d[P]&&Object.hasOwn(d[P],z.key))){E=-1;break}++E}for(let P in o.proxyCachedFBO[y.key])o.renderCache[o.proxyCachedFBO[y.key][P]].dirty=E<0||E!==Object.values(v).length}}let m=[...this._drapedRenderBatches];m.sort((_,y)=>y.end-y.start-(_.end-_.start));for(let _ of m)for(let y of c){if(o.proxyCachedFBO[y.key])continue;let v=o.renderCachePool.pop();v===void 0&&o.renderCache.length<50&&(v=o.renderCache.length,o.renderCache.push(this._createFBO())),v!==void 0&&(o.proxyCachedFBO[y.key]={},o.proxyCachedFBO[y.key][_.start]=v,o.renderCache[v].dirty=!0)}this._tilesDirty={}}_setupStencil(t,o,c,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));let m=this.painter.context,_=m.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let y;if(c.isTileClipped())y=o.length,this._overlapStencilMode.test={func:_.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(o[0].overscaledZ>o.at(-1).overscaledZ))return void(this._overlapStencilType=!1);y=1,this._overlapStencilMode.test={func:_.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+y>255&&(m.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=y,this._overlapStencilMode.ref=this._stencilRef,c.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):yt.disabled}_renderTileClippingMasks(t,o){let c=this.painter,d=this.painter.context,m=d.gl;c._tileClippingMaskIDs={},d.setColorMode(_t.disabled),d.setDepthMode(nt.disabled);let _=c.getOrCreateProgram("clippingMask");for(let y of t){let v=c._tileClippingMaskIDs[y.key]=--o;_.draw(c,m.TRIANGLES,nt.disabled,new yt({func:m.ALWAYS,mask:0},v,255,m.KEEP,m.KEEP,m.REPLACE),_t.disabled,pt.disabled,wl(y.projMatrix),"$clipping",c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}}pointCoordinate(t){let o=this.painter.transform;if(t.x<0||t.x>o.width||t.y<0||t.y>o.height)return null;let c=[t.x,t.y,1,1];h.aD(c,c,o.pixelMatrixInverse),h.cw(c,c,1/c[3]),c[0]/=o.worldSize,c[1]/=o.worldSize;let d=o._camera.position,m=h.bY(1,o.center.lat),_=[d[0],d[1],d[2]/m,0],y=h.cZ([],c.slice(0,3),_);h.ax(y,y);let v=this.raycast(_,y,this._exaggeration);return v!==null&&v?(h.bi(_,_,y,v),_[3]=_[2],_[2]*=m,_):null}_setupProxiedCoordsForOrtho(t,o,c){if(t.getSource()instanceof h.aY)return this._setupProxiedCoordsForImageSource(t,o,c);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};let d=this.proxiedCoords[t.id]=[],m=this.proxyCoords;for(let v=0;v<m.length;v++){let T=m[v],E=this._findTileCoveringTileID(T,t);if(E){let P=this._createProxiedId(T,E,c[T.key]&&c[T.key][t.id]);d.push(P),this.proxyToSource[T.key][t.id]=[P]}}let _=!1,y=new Set;for(let v=0;v<o.length;v++){let T=t.getTile(o[v]);if(!T||!T.hasData())continue;let E=this._findTileCoveringTileID(T.tileID,this.proxySourceCache);
3059if(E&&E.tileID.canonical.z!==T.tileID.canonical.z){let P=this.proxyToSource[E.tileID.key][t.id],A=this._createProxiedId(E.tileID,T,c[E.tileID.key]&&c[E.tileID.key][t.id]);P?P.splice(P.length-1,0,A):this.proxyToSource[E.tileID.key][t.id]=[A];let D=this.proxyToSource[E.tileID.key][t.id];y.has(D)||y.add(D),d.push(A),_=!0}}if(this._sourceTilesOverlap[t.id]=_,_)for(let v of y)v.sort((T,E)=>E.overscaledZ-T.overscaledZ)}_setupProxiedCoordsForImageSource(t,o,c){if(!t.getSource().loaded())return;let d=this.proxiedCoords[t.id]=[],m=this.proxyCoords,_=t.getSource(),y=_.tileID;if(!y)return;let v=new h.P(y.x,y.y)._div(1<<y.z),T=_.coordinates.map(h.ad.fromLngLat).reduce((P,A)=>(P.min.x=Math.min(P.min.x,A.x-v.x),P.min.y=Math.min(P.min.y,A.y-v.y),P.max.x=Math.max(P.max.x,A.x-v.x),P.max.y=Math.max(P.max.y,A.y-v.y),P),{min:new h.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new h.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),E=(P,A)=>{let D=P.wrap+P.canonical.x/(1<<P.canonical.z),z=P.canonical.y/(1<<P.canonical.z),O=h.ak/(1<<P.canonical.z),k=A.wrap+A.canonical.x/(1<<A.canonical.z),N=A.canonical.y/(1<<A.canonical.z);return D+O<k+T.min.x||D>k+T.max.x||z+O<N+T.min.y||z>N+T.max.y};for(let P=0;P<m.length;P++){let A=m[P];for(let D=0;D<o.length;D++){let z=t.getTile(o[D]);if(!z||!z.hasData()||E(A,z.tileID))continue;let O=this._createProxiedId(A,z,c[A.key]&&c[A.key][t.id]),k=this.proxyToSource[A.key][t.id];k?k.push(O):this.proxyToSource[A.key][t.id]=[O],d.push(O)}}}_createProxiedId(t,o,c){let d=this.orthoMatrix;if(c){let m=c.find(_=>_.key===o.tileID.key);if(m)return m}if(o.tileID.key!==t.key){let m=t.canonical.z-o.tileID.canonical.z,_,y,v;d=h.bd();let T=o.tileID.wrap-t.wrap<<t.overscaledZ;m>0?(_=h.ak>>m,y=_*((o.tileID.canonical.x<<m)-t.canonical.x+T),v=_*((o.tileID.canonical.y<<m)-t.canonical.y)):(_=h.ak<<-m,y=h.ak*(o.tileID.canonical.x-(t.canonical.x+T<<-m)),v=h.ak*(o.tileID.canonical.y-(t.canonical.y<<-m))),h.bX(d,0,_,0,_,0,1),h.bB(d,d,[y,v,0])}return new es(o.tileID,t.key,d)}_findTileCoveringTileID(t,o){let c=o.getTile(t);if(c&&c.hasData())return c;let d=this._findCoveringTileCache[o.id],m=d[t.key];if(c=m?o.getTileByID(m):null,c&&c.hasData()||m===null)return c;let _=c?c.tileID:t,y=_.overscaledZ,v=o.getSource().minzoom,T=[];if(!m){let P=o.getSource().maxzoom;if(t.canonical.z>=P){let A=t.canonical.z-P;o.getSource().reparseOverscaled?(y=Math.max(t.canonical.z+2,o.transform.tileZoom),_=new h.aU(y,t.wrap,P,t.canonical.x>>A,t.canonical.y>>A)):A!==0&&(y=P,_=new h.aU(y,t.wrap,P,t.canonical.x>>A,t.canonical.y>>A))}_.key!==t.key&&(T.push(_.key),c=o.getTile(_))}let E=P=>{T.forEach(A=>{d[A]=P}),T.length=0};for(y-=1;y>=v&&(!c||!c.hasData());y--){c&&E(c.tileID.key);let P=_.calculateScaledKey(y);if(c=o.getTileByID(P),c&&c.hasData())break;let A=d[P];if(A===null)break;A===void 0?T.push(P):c=o.getTileByID(A)}return E(c?c.tileID.key:null),c&&c.hasData()?c:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,o){let c=this._tilesDirty[t];c||(c=this._tilesDirty[t]={}),c[o.key]=!0}}function Of(a,t,o){let c=function(y,v,T){let E=h.bk(v,y),P=h.bk(T,[.2126,.7152,.0722]),A=(z,O,k)=>(1-k)*z+k*O,D=A(1-.3*Math.min(P,1),1,Math.min(E+1,1));return A(.92,1,Math.asin(h.aB(v[2],-1,1))/Math.PI+.5)*D}(a,[0,0,1],t),d=[0,0,0];h.bN(d,o.slice(0,3),c);let m=[0,0,0];h.bN(m,t.slice(0,3),a[2]);let _=[0,0,0];return h.cX(_,d,m),h.c_(_)}let Ff=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Bf=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class wd{static cacheKey(t,o,c,d){let m=[o];d&&m.push(d.cacheKey);for(let _ of c)(typeof _=="string"&&_.includes(" ")||t.usedDefines.has(_))&&m.push(_);return m.join("/")}constructor(t,o,c,d,m,_,y=!1){let v=t.gl;this.program=v.createProgram(),this._context=t,this._fixedUniformsFn=m,this._pending=!0,this._precompiled=y,this.attributes={},this.configuration=d,this.name=o,this.fixedDefines=[..._],y?t._compileStats.precompiled++:t._compileStats.onDemand++;let T=`#version 300 es
3060${(d?d.defines():[]).concat(_.map(k=>`#define ${k}`)).join(`
3061`)}`,E=[T,Nu];for(let k of c.fragmentIncludes)E.push(Ac[k]);E.push(c.fragmentSource);let P=E.join(`
3062`),A=[T,q_];
3062for(let k of c.vertexIncludes)A.push(Ac[k]);this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&c.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&A.push("uniform int u_instanceID;"),A.push(c.vertexSource);let D=A.join(`
3063`);this.forceManualRenderingForInstanceIDShaders&&(D=D.replaceAll("gl_InstanceID","u_instanceID"));let z=v.createShader(v.FRAGMENT_SHADER);if(v.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);v.shaderSource(z,P),v.compileShader(z),v.attachShader(this.program,z);let O=v.createShader(v.VERTEX_SHADER);if(v.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);v.shaderSource(O,D),v.compileShader(O),v.attachShader(this.program,O),v.linkProgram(this.program),this._fragmentShader=z,this._vertexShader=O,t.extParallelShaderCompile?t._pendingPrograms.add(this):this._finalize()}_finalize(){if(!this._pending)return;this._pending=!1;let t=this._context,o=t.gl;t._pendingPrograms.delete(this);let c=h.o.now(),d=o.getProgramParameter(this.program,o.LINK_STATUS),m=h.o.now()-c,_=t._compileStats;if(_.totalStallMs+=m,m>_.maxStallMs&&(_.maxStallMs=m),m>1){_.framesMissed+=Math.floor(60*m/1e3);let T=this.fixedDefines.join(",");_.stalls.push({name:`${this.name}${T?"/":""}${T}`,ms:m,timestamp:c})}if(this._fragmentShader&&(d||h.w(`Fragment shader '${this.name}': ${o.getShaderInfoLog(this._fragmentShader)}`),o.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(d||h.w(`Vertex shader '${this.name}': ${o.getShaderInfoLog(this._vertexShader)}`),o.deleteShader(this._vertexShader),this._vertexShader=null),!d)return h.w(`Failed to link program '${this.name}': ${o.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(T=>({u_instanceID:new h.b$(T)}))(t));let y=this.fixedDefines,v=this.name;(y.includes("TERRAIN")||y.includes("ELEVATED")||v.includes("symbol")||v.includes("circle"))&&(this.terrainUniforms=(T=>({u_dem:new h.b$(T),u_dem_prev:new h.b$(T),u_dem_tl:new h.c2(T),u_dem_scale:new h.c1(T),u_dem_tl_prev:new h.c2(T),u_dem_scale_prev:new h.c1(T),u_dem_size:new h.c1(T),u_dem_lerp:new h.c1(T),u_exaggeration:new h.c1(T),u_depth:new h.b$(T),u_depth_size_inv:new h.c2(T),u_depth_range_unpack:new h.c2(T),u_occluder_half_size:new h.c1(T),u_occlusion_depth_offset:new h.c1(T),u_meter_to_dem:new h.c1(T),u_label_plane_matrix_inv:new h.c3(T)}))(t)),y.includes("GLOBE")&&(this.globeUniforms=(T=>({u_tile_tl_up:new h.c0(T),u_tile_tr_up:new h.c0(T),u_tile_br_up:new h.c0(T),u_tile_bl_up:new h.c0(T),u_tile_up_scale:new h.c1(T)}))(t)),y.includes("FOG")&&(this.fogUniforms=(T=>({u_fog_matrix:new h.c3(T),u_fog_range:new h.c2(T),u_fog_color:new h.cS(T),u_fog_horizon_blend:new h.c1(T),u_fog_vertical_limit:new h.c2(T),u_fog_temporal_offset:new h.c1(T),u_frustum_tl:new h.c0(T),u_frustum_tr:new h.c0(T),u_frustum_br:new h.c0(T),u_frustum_bl:new h.c0(T),u_globe_pos:new h.c0(T),u_globe_radius:new h.c1(T),u_globe_transition:new h.c1(T),u_is_globe:new h.b$(T),u_viewport:new h.c2(T)}))(t)),y.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(T=>({u_cutoff_params:new h.cS(T)}))(t)),y.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(T=>({u_lighting_ambient_color:new h.c0(T),u_lighting_directional_dir:new h.c0(T),u_lighting_directional_color:new h.c0(T),u_ground_radiance:new h.c0(T)}))(t)),y.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(T=>({u_light_matrix_0:new h.c3(T),u_light_matrix_1:new h.c3(T),u_fade_range:new h.c2(T),u_shadow_normal_offset:new h.c0(T),u_shadow_intensity:new h.c1(T),u_shadow_texel_size:new h.c1(T),u_shadow_map_resolution:new h.c1(T),u_shadow_direction:new h.c0(T),u_shadow_bias:new h.c0(T),u_shadowmap_0:new h.b$(T),u_shadowmap_1:new h.b$(T)}))(t))}maybeFinalize(){if(!this._pending)return;let t=this._context.extParallelShaderCompile;t&&!this._context.gl.getProgramParameter(this.program,t.COMPLETION_STATUS_KHR
3063)||this._finalize()}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms())}getAttributeLocation(t,o){this._ensureReady();let c=this.attributes[o];return c===void 0&&(c=this.attributes[o]=t.getAttribLocation(this.program,o)),c}setTerrainUniformValues(t,o){if(this._ensureReady(),!this.terrainUniforms)return;let c=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d]&&c[d].set(this.program,d,o[d])}}setGlobeUniformValues(t,o){if(this._ensureReady(),!this.globeUniforms)return;let c=this.globeUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d]&&c[d].set(this.program,d,o[d])}}setFogUniformValues(t,o){if(this._ensureReady(),!this.fogUniforms)return;let c=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d].set(this.program,d,o[d])}}setCutoffUniformValues(t,o){if(this._ensureReady(),!this.cutoffUniforms)return;let c=this.cutoffUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d].set(this.program,d,o[d])}}setLightsUniformValues(t,o){if(this._ensureReady(),!this.lightsUniforms)return;let c=this.lightsUniforms;if(!this.failedToCreate){t.program.set(this.program);for(let d in o)c[d].set(this.program,d,o[d])}}setShadowUniformValues(t,o){if(this._ensureReady(),this.failedToCreate||!this.shadowUniforms)return;let c=this.shadowUniforms;t.program.set(this.program);for(let d in o)c[d].set(this.program,d,o[d])}_drawDebugWireframe(t,o,c,d,m,_,y,v,T,E){let P=t.options.wireframe;if(P.terrain===!1&&P.layers2D===!1&&P.layers3D===!1)return;let A=t.context;if(!(!(!P.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!P.layers2D||t._terrain&&t._terrain.renderingToTexture||!Ff.includes(this.name))||!(!P.layers3D||!Bf.includes(this.name))))return;let D=A.gl,z=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,m,A);if(!z)return;let O=[...this.fixedDefines,"DEBUG_WIREFRAME"],k=t.getOrCreateProgram(this.name,{config:this.configuration,defines:O});k._ensureReady(),A.program.set(k.program);let N=(G,re,te)=>{if(re[G]&&te[G])for(let se in re[G])te[G][se]&&te[G][se].set(te.program,se,re[G][se].current)};T&&T.setUniforms(k.program,A,k.binderUniforms,y,{zoom:v}),N("fixedUniforms",this,k),N("terrainUniforms",this,k),N("globeUniforms",this,k),N("fogUniforms",this,k),N("lightsUniforms",this,k),N("shadowUniforms",this,k),z.bind(),A.setColorMode(new _t([D.ONE,D.ONE_MINUS_SRC_ALPHA,D.ZERO,D.ONE],h.C.transparent,[!0,!0,!0,!1])),A.setDepthMode(new nt(o.func===D.LESS?D.LEQUAL:o.func,nt.ReadOnly,o.range)),A.setStencilMode(yt.disabled);let q=3*_.primitiveLength*2,Z=3*_.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){let G=E||1;for(let re=0;re<G;++re)k.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",re),D.drawElements(D.LINES,q,D.UNSIGNED_SHORT,Z)}else E&&E>1?D.drawElementsInstanced(D.LINES,q,D.UNSIGNED_SHORT,Z,E):D.drawElements(D.LINES,q,D.UNSIGNED_SHORT,Z);m.bind(),A.program.set(this.program),A.setDepthMode(o),A.setStencilMode(c),A.setColorMode(d)}checkUniforms(t,o,c){if(this.fixedDefines.includes(o)){for(let d of Object.keys(c))if(!c[d].initialized)throw new Error(`Program '${this.name}', from draw '${t}': uniform ${d} not set but required by ${o} being defined`)}}draw(t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k){let N=t.context,q=N.gl;if(this._ensureReady(),this.failedToCreate)return;N.program.set(this.program),N.setDepthMode(c),N.setStencilMode(d),N.setColorMode(m),N.setCullFace(_);for(let[K,J]of this.fixedUniformsEntries)J.set(this.program,K,y[K]);z&&z.setUniforms(this.program,N,this.binderUniforms,A,{zoom:D});let Z={[q.POINTS]:1,[q.LINES]:2,[q.TRIANGLES]:3,[q.LINE_STRIP]:1}[o];this.checkUniforms(v,"RENDER_SHADOWS",this.shadowUniforms);let G=O||[],re=z?z.getPaintVertexBuffers():[],te=o===q.TRIANGLES&&E,se=k&&k>0?1:void 0;for(let K of P.get()){let J=K.vaos||(K.vaos={});if((J[v]||(J[v]=new ju)).bind(N,this,T,re,E,K.vertexOffset,G,se),this.forceManualRenderingForInstanceIDShaders){let oe=k||1;for(let ue=0;ue<oe;++ue)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",ue),E?q.drawElements(o,K.primitiveLength*Z,q.UNSIGNED_SHORT,K.primitiveOffset*Z*2):q.drawArrays(o,K.vertexOffset,K.vertexLength)}else k&&k>1?q.drawElementsInstanced(o,K.primitiveLength*Z,q.UNSIGNED_SHORT,K.primitiveOffset*Z*2,k):E?q.drawElements(o,K.primitiveLength*Z,q.UNSIGNED_SHORT,K.primitiveOffset*Z*2):q.drawArrays(o,K.vertexOffset,K.vertexLength);te&&this._drawDebugWireframe(t,c,d,m,E,K,A,D,z,k)}}}
3063function Td(a,t,o=0){let c=Math.pow(2,t.tileID.overscaledZ),d=t.tileSize*Math.pow(2,a.transform.tileZoom)/c,m=d*(t.tileID.canonical.x+t.tileID.wrap*c),_=d*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/h.az(t,1,a.transform.tileZoom),u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_],u_pattern_transition:o}}let La={terrain:0,flat:1},Sd=h.bd(),Lc=(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k,N,q=[0,0,1])=>{let Z=t.style.light,G=Z.properties.get("position"),re=[G.x,G.y,G.z],te=h.dH();Z.properties.get("anchor")==="viewport"&&(h.dI(te,-t.transform.angle),h.dJ(re,re,te));let se=Z.properties.get("color").toPremultipliedRenderColor(null),K=t.transform,J={u_matrix:a,u_lightpos:re,u_lightintensity:Z.properties.get("intensity"),u_lightcolor:[se.r,se.g,se.b],u_vertical_gradient:+o,u_opacity:c,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Sd,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:La[T],u_base_type:La[E],u_ao:d,u_edge_radius:m,u_width_scale:_,u_flood_light_color:z,u_vertical_scale:O,u_flood_light_intensity:k,u_ground_shadow_factor:N,u_front_cutoff_params:q};return K.projection.name==="globe"&&(J.u_tile_id=[y.canonical.x,y.canonical.y,1<<y.canonical.z],J.u_zoom_transition=P,J.u_inv_rot_matrix=D,J.u_merc_center=A,J.u_up_dir=K.projection.upVector(new h.cp(0,0,0),A[0]*h.ak,A[1]*h.ak),J.u_height_lift=v),J},kf=(a,t,o,c,d,m)=>({u_matrix:a,u_edge_radius:t,u_width_scale:o,u_vertical_scale:c,u_height_type:La[d],u_base_type:La[m]}),Nf=(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k,N)=>{let q=Lc(a,t,o,c,d,m,_,y,T,E,P,A,D,z,O,k,1,[0,0,0]),Z={u_height_factor:-Math.pow(2,y.overscaledZ)/v.tileSize/8};return Object.assign(q,Td(t,v,N),Z)},Ed=(a,t,o)=>({u_matrix:a,u_emissive_strength:t,u_ground_shadow_factor:o}),Id=(a,t,o,c,d,m=0)=>Object.assign(Ed(a,t,d),Td(o,c,m)),Uf=(a,t,o,c)=>({u_matrix:a,u_world:o,u_emissive_strength:t,u_ground_shadow_factor:c}),Vf=(a,t,o,c,d,m,_=0)=>Object.assign(Id(a,t,o,c,m,_),{u_world:d}),Ad=(a,t)=>({u_matrix:a,u_depth_bias:t}),Md=(a,t)=>({u_matrix:a,u_ground_shadow_factor:t}),zc=(a,t,o,c,d)=>({u_matrix:a,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:o,u_height_scale:c,u_reset_depth:d}),jf=(a,t,o)=>({u_image:a,u_texel_size:t,u_first_pass:o?1:0}),Gf=(a,t,o,c,d,m,_,y)=>{let v=h.ak/m.tileSize;return{u_matrix:a,u_inv_rot_matrix:t,u_camera_to_center_distance:o.getCameraToCenterDistance(y),u_extrude_scale:[o.pixelsToGLUnits[0]/v,o.pixelsToGLUnits[1]/v],u_zoom_transition:c,u_tile_id:_,u_merc_center:d}},Hf=(a,t,o,c)=>({u_matrix:a,u_inv_matrix:t,u_camera_to_center_distance:o.getCameraToCenterDistance(c),u_viewport_size:[o.width,o.height]}),Oc=(a,t,o=1)=>({u_matrix:a,u_color:t,u_overlay:0,u_overlay_scale:o}),$f=h.bd(),Cd=(a,t,o,c,d,m,_)=>{let y=a.transform,v=y.projection.name==="globe",T=v?h.dK(y.zoom,t.canonical)*y._pixelsPerMercatorPixel:h.az(o,1,m),E={u_matrix:t.projMatrix,u_extrude_scale:T,u_intensity:_,u_inv_rot_matrix:$f,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(v){E.u_inv_rot_matrix=c,E.u_merc_center=d,E.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],E.u_zoom_transition=h.ai(y.zoom);let P=d[0]*h.ak,A=d[1]*h.ak;E.u_up_dir=y.projection.upVector(new h.cp(0,0,0),P,A)}return E};function Pd(a,[t,o,c,d],[m,_]){if(m===_)return[0,0,0,0];let y=255*(a-1)/(a*(_-m));return[t*y,o*y,c*y,d*y]}function Wu(a,t,[o,c]){return o===c?0:.5/a+(t-o)*(a-1)/(a*(c-o))}function Dd(a){let t=a.terrain?a.terrain.exaggeration():1;var o;return(a.transform.pitch<15?.07*(1-(o=h.aB((14-a.transform.zoom)/5,0,1)))+.7*o:.07)*t}let Xu=(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k,N,q,Z,G,re)=>({u_matrix:t,u_normalize_matrix:o,u_globe_matrix:c,u_merc_matrix:d,u_grid_matrix:m,u_tl_parent:_,u_scale_parent:E,u_fade_t:P.mix,u_opacity:P.opacity*A.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:A.paint.get("raster-brightness-min"),u_brightness_high:A.paint.get("raster-brightness-max"),u_saturation_factor:h.dM(A.paint.get("raster-saturation")),u_contrast_factor:h.dL(A.paint.get("raster-contrast")),u_spin_weights:tg(A.paint.get("raster-hue-rotate")),u_perspective_transform:D,u_raster_elevation:z,u_zoom_transition:y,u_merc_center:v,u_cutoff_params:T,u_colorization_mix:Pd(h.dN,k,q),u_colorization_offset:Wu(h.dN,N,q),u_color_ramp:O,u_texture_offset:[G/(Z+2*G),Z/(Z+2*G)],u_texture_res:[Z+2*G,Z+2*G],u_emissive_strength:re,u_zbias_factor:Dd(a)});function tg(a){a*=Math.PI/180;let t=Math.sin(a),o=Math.cos(a);return[(2*o+1)/3,(-Math.sqrt(3)*t-o+1)/3,(Math.sqrt(3)*t-o+1)/3]}
3063let qf=h.bd(),Zf=(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k,N,q,Z,G,re,te,se)=>{let K=d.transform,J={u_is_size_zoom_constant:+(a==="constant"||a==="source"),u_is_size_feature_constant:+(a==="constant"||a==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:K.getCameraToCenterDistance(q),u_rotate_symbol:+o,u_aspect_ratio:K.width/K.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:m,u_label_plane_matrix:_,u_coord_matrix:y,u_is_text:+T,u_elevation_from_sea:v?1:0,u_pitch_with_map:+c,u_texsize:E,u_texsize_icon:P,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:qf,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:qf,u_up_vector:[0,-1,0],u_color_adj_mat:re,u_icon_transition:te||0,u_gamma_scale:c?d.transform.getCameraToCenterDistance(q)*Math.cos(d.terrain?0:d.transform._pitch):1,u_device_pixel_ratio:h.o.devicePixelRatio,u_is_halo:1,u_scale_factor:se||1,u_ground_shadow_factor:Z,u_inv_matrix:h.ba(h.bd(),_),u_normal_scale:G,u_lutTexture:10,u_zoom:K.zoom
3063-Math.floor(K.zoom),u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0]};return q.name==="globe"&&(J.u_tile_id=[D.canonical.x,D.canonical.y,1<<D.canonical.z],J.u_zoom_transition=z,J.u_inv_rot_matrix=k,J.u_merc_center=O,J.u_camera_forward=K._camera.forward(),J.u_ecef_origin=h.dO(K.globeMatrix,D.toUnwrapped()),J.u_tile_matrix=K.globeMatrix,J.u_up_vector=N),J},Yu=(a,t,o,c)=>({u_matrix:a,u_emissive_strength:t,u_opacity:o,u_color:c}),Wf=(a,t,o,c,d,m,_,y,v)=>Object.assign(function(T,E,P,A,D,z){let{width:O,height:k}=A.imageManager.getPixelSize(E),N=Math.pow(2,z.tileID.overscaledZ),q=z.tileSize*Math.pow(2,A.transform.tileZoom)/N,Z=q*(z.tileID.canonical.x+z.tileID.wrap*N),G=q*z.tileID.canonical.y;return{u_image:0,u_pattern_tl:P.tl,u_pattern_br:P.br,u_texsize:[O,k],u_pattern_size:P.displaySize,u_pattern_units_to_pixels:D?[A.transform.width,-1*A.transform.height]:[1/h.az(z,1,A.transform.tileZoom),1/h.az(z,1,A.transform.tileZoom)],u_pixel_coord_upper:[Z>>16,G>>16],u_pixel_coord_lower:[65535&Z,65535&G]}}(0,m,_,c,y,v),{u_matrix:a,u_emissive_strength:t,u_opacity:o}),Ju=new Float32Array(h.bA([])),Rd=(a,t,o,c,d,m,_,y,v,T,E,P,A,D=[0,0,0],z,O,k,N=1)=>{let q=d.style.light,Z=q.properties.get("position"),G=[-Z.x,-Z.y,Z.z],re=h.dH();q.properties.get("anchor")==="viewport"&&(h.dI(re,-d.transform.angle),h.dJ(G,G,re));let te=E.alphaMode==="MASK",se=q.properties.get("color").toNonPremultipliedRenderColor(null),K=A.paint.get("model-ambient-occlusion-intensity"),J=A.paint.get("model-color").constantOr(h.C.white).toNonPremultipliedRenderColor(null);return J.a=A.paint.get("model-color-mix-intensity").constantOr(0),k&&(J.r=k[0],J.g=k[1],J.b=k[2],J.a=k[3]),O&&(J.r=O.color.r,J.g=O.color.g,J.b=O.color.b,J.a=O.colorMix,P=O.emissionStrength,m*=O.opacity),{u_matrix:a,u_lighting_matrix:t,u_normal_matrix:o,u_node_matrix:c||Ju,u_lightpos:G,u_lightintensity:q.properties.get("intensity"),u_lightcolor:[se.r,se.g,se.b],u_camera_pos:D,u_opacity:m,u_baseTextureIsAlpha:0,u_alphaMask:+te,u_alphaCutoff:E.alphaCutoff,u_baseColorFactor:_.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:y.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:v,u_roughnessFactor:T,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:J.toArray01(),u_aoIntensity:K,u_emissive_strength:P,u_occlusionTextureTransform:z||[0,0,0,0],u_dithered_discard_threshold:N}},Ld=(a,t=Ju,o=Ju)=>({u_matrix:a,u_instance:t,u_node_matrix:o}),ig={fillExtrusion:a=>({u_matrix:new h.c3(a),u_lightpos:new h.c0(a),u_lightintensity:new h.c1(a),u_lightcolor:new h.c0(a),u_vertical_gradient:new h.c1(a),u_opacity:new h.c1(a),u_edge_radius:new h.c1(a),u_width_scale:new h.c1(a),u_ao:new h.c2(a),u_height_type:new h.b$(a),u_base_type:new h.b$(a),u_tile_id:new h.c0(a),u_zoom_transition:new h.c1(a),u_inv_rot_matrix:new h.c3(a),u_merc_center:new h.c2(a),u_up_dir:new h.c0(a),u_height_lift:new h.c1(a),u_flood_light_color:new h.c0(a),u_vertical_scale:new h.c1(a),u_flood_light_intensity:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_front_cutoff_params:new h.c0(a)}),fillExtrusionDepth:a=>({u_matrix:new h.c3(a),u_edge_radius:new h.c1(a),u_width_scale:new h.c1(a),u_vertical_scale:new h.c1(a),u_height_type:new h.b$(a),u_base_type:new h.b$(a)}),fillExtrusionPattern:a=>({u_matrix:new h.c3(a),u_lightpos:new h.c0(a),u_lightintensity:new h.c1(a),u_lightcolor:new h.c0(a),u_vertical_gradient:new h.c1(a),u_height_factor:new h.c1(a),u_edge_radius:new h.c1(a),u_width_scale:new h.c1(a),u_ao:new h.c2(a),u_height_type:new h.b$(a),u_base_type:new h.b$(a),u_tile_id:new h.c0(a),u_zoom_transition:new h.c1(a),u_inv_rot_matrix:new h.c3(a),u_merc_center:new h.c2(a),u_up_dir:new h.c0(a),u_height_lift:new h.c1(a),u_image:new h.b$(a),u_texsize:new h.c2(a),u_pixel_coord_upper:new h.c2(a),u_pixel_coord_lower:new h.c2(a),u_tile_units_to_pixels:new h.c1(a),u_opacity:new h.c1(a),u_pattern_transition:new h.c1(a)}),fillExtrusionGroundEffect:a=>({u_matrix:new h.c3(a),u_opacity:new h.c1(a),u_ao_pass:new h.c1(a),u_meter_to_tile:new h.c1(a),u_ao:new h.c2(a),u_flood_light_intensity:new h.c1(a),u_flood_light_color:new h.c0(a),u_attenuation:new h.c1(a),u_edge_radius:new h.c1(a),u_fb:new h.b$(a),u_fb_size:new h.c1(a),u_dynamic_offset:new h.c1(a)}),fill:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_ground_shadow_factor:new h.c0(a)}),fillPattern:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_image:new h.b$(a),u_texsize:new h.c2(a),u_pixel_coord_upper:new h.c2(a),u_pixel_coord_lower:new h.c2(a),u_tile_units_to_pixels:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_pattern_transition:new h.c1(a)}),fillOutline:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_world:new h.c2(a),u_ground_shadow_factor:new h.c0(a)}),fillOutlinePattern:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_world:new h.c2(a),u_image:new h.b$(a),u_texsize:new h.c2(a),u_pixel_coord_upper:new h.c2(a),u_pixel_coord_lower:new h.c2(a),u_tile_units_to_pixels:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_pattern_transition:new h.c1(a)}),lineBlendComposite:a=>({u_image:new h.b$(a),u_opacity:new h.c1(a),u_blend_mode:new h.b$(a),u_max_density:new h.c1(a)}),lineBlendReduce:a=>({u_image:new h.b$(a),u_texel_size:new h.c2(a),u_first_pass:new h.b$(a)}),elevatedStructuresDepth:a=>({u_matrix:new h.c3(a),u_depth_bias:new h.c1(a)}),elevatedStructures:a=>({u_matrix:new h.c3(a),u_ground_shadow_factor:new h.c0(a)}),elevatedStructuresDepthReconstruct:a=>({u_matrix:new h.c3(a),u_camera_pos:new h.c0(a),u_depth_bias:new h.c1(a),u_height_scale:new h.c1(a),u_reset_depth:new h.c1(a)}),circle:h.dR,collisionBox:a=>({u_matrix:new h.c3(a),u_inv_rot_matrix:new h.c3(a),u_camera_to_center_distance:new h.c1(a),u_extrude_scale:new h.c2(a),u_zoom_transition:new h.c1(a),u_merc_center:new h.c2(a),u_tile_id:new h.c0(a)}),collisionCircle:a=>({u_matrix:new h.c3(a),u_inv_matrix:new h.c3(a),u_camera_to_center_distance:new h.c1(a),u_viewport_size:new h.c2(a)}
3063),debug:a=>({u_color:new h.dp(a),u_matrix:new h.c3(a),u_overlay:new h.b$(a),u_overlay_scale:new h.c1(a)}),clippingMask:a=>({u_matrix:new h.c3(a)}),heatmap:a=>({u_extrude_scale:new h.c1(a),u_intensity:new h.c1(a),u_matrix:new h.c3(a),u_inv_rot_matrix:new h.c3(a),u_merc_center:new h.c2(a),u_tile_id:new h.c0(a),u_zoom_transition:new h.c1(a),u_up_dir:new h.c0(a)}),heatmapTexture:a=>({u_image:new h.b$(a),u_color_ramp:new h.b$(a),u_opacity:new h.c1(a)}),hillshade:a=>({u_matrix:new h.c3(a),u_image:new h.b$(a),u_latrange:new h.c2(a),u_light:new h.c2(a),u_shadow:new h.dp(a),u_highlight:new h.dp(a),u_emissive_strength:new h.c1(a),u_accent:new h.dp(a)}),hillshadePrepare:a=>({u_matrix:new h.c3(a),u_image:new h.b$(a),u_dimension:new h.c2(a),u_zoom:new h.c1(a)}),line:h.dQ,linePattern:h.dP,raster:a=>({u_matrix:new h.c3(a),u_normalize_matrix:new h.c3(a),u_globe_matrix:new h.c3(a),u_merc_matrix:new h.c3(a),u_grid_matrix:new h.dq(a),u_tl_parent:new h.c2(a),u_scale_parent:new h.c1(a),u_fade_t:new h.c1(a),u_opacity:new h.c1(a),u_image0:new h.b$(a),u_image1:new h.b$(a),u_brightness_low:new h.c1(a),u_brightness_high:new h.c1(a),u_saturation_factor:new h.c1(a),u_contrast_factor:new h.c1(a),u_spin_weights:new h.c0(a),u_perspective_transform:new h.c2(a),u_raster_elevation:new h.c1(a),u_zoom_transition:new h.c1(a),u_merc_center:new h.c2(a),u_cutoff_params:new h.cS(a),u_colorization_mix:new h.cS(a),u_colorization_offset:new h.c1(a),u_color_ramp:new h.b$(a),u_texture_offset:new h.c2(a),u_texture_res:new h.c2(a),u_emissive_strength:new h.c1(a),u_zbias_factor:new h.c1(a)}),symbol:a=>({u_is_size_zoom_constant:new h.b$(a),u_is_size_feature_constant:new h.b$(a),u_size_t:new h.c1(a),u_size:new h.c1(a),u_camera_to_center_distance:new h.c1(a),u_rotate_symbol:new h.b$(a),u_aspect_ratio:new h.c1(a),u_fade_change:new h.c1(a),u_matrix:new h.c3(a),u_label_plane_matrix:new h.c3(a),u_coord_matrix:new h.c3(a),u_is_text:new h.b$(a),u_elevation_from_sea:new h.b$(a),u_pitch_with_map:new h.b$(a),u_texsize:new h.c2(a),u_texsize_icon:new h.c2(a),u_texture:new h.b$(a),u_texture_icon:new h.b$(a),u_gamma_scale:new h.c1(a),u_device_pixel_ratio:new h.c1(a),u_tile_id:new h.c0(a),u_zoom_transition:new h.c1(a),u_inv_rot_matrix:new h.c3(a),u_merc_center:new h.c2(a),u_camera_forward:new h.c0(a),u_tile_matrix:new h.c3(a),u_up_vector:new h.c0(a),u_ecef_origin:new h.c0(a),u_is_halo:new h.b$(a),u_icon_transition:new h.c1(a),u_color_adj_mat:new h.c3(a),u_scale_factor:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_inv_matrix:new h.c3(a),u_normal_scale:new h.c1(a),u_lutTexture:new h.b$(a),u_zoom:new h.c1(a),u_spp_fill_np_color:new h.cS(a),u_spp_halo_np_color:new h.cS(a),u_spp_opacity:new h.c1(a),u_spp_halo_width:new h.c1(a),u_spp_halo_blur:new h.c1(a),u_spp_emissive_strength:new h.c1(a),u_spp_occlusion_opacity:new h.c1(a),u_spp_z_offset:new h.c1(a),u_spp_translate_rotation:new h.c2(a)}),background:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_opacity:new h.c1(a),u_color:new h.dp(a)}),backgroundPattern:a=>({u_matrix:new h.c3(a),u_emissive_strength:new h.c1(a),u_opacity:new h.c1(a),u_image:new h.b$(a),u_pattern_tl:new h.c2(a),u_pattern_br:new h.c2(a),u_texsize:new h.c2(a),u_pattern_size:new h.c2(a),u_pixel_coord_upper:new h.c2(a),u_pixel_coord_lower:new h.c2(a),u_pattern_units_to_pixels:new h.c2(a)}),terrainRaster:a=>({u_matrix:new h.c3(a),u_image0:new h.b$(a),u_image1:new h.b$(a),u_skirt_height:new h.c1(a),u_ground_shadow_factor:new h.c0(a),u_emissive_texture_available:new h.c1(a)}),skybox:a=>({u_matrix:new h.c3(a),u_sun_direction:new h.c0(a),u_cubemap:new h.b$(a),u_opacity:new h.c1(a),u_temporal_offset:new h.c1(a)}),skyboxGradient:a=>({u_matrix:new h.c3(a),u_color_ramp:new h.b$(a),u_center_direction:new h.c0(a),u_radius:new h.c1(a),u_opacity:new h.c1(a),u_temporal_offset:new h.c1(a)}),skyboxCapture:a=>({u_matrix_3f:new h.dq(a),u_sun_direction:new h.c0(a),u_sun_intensity:new h.c1(a),u_color_tint_r:new h.cS(a),u_color_tint_m:new h.cS(a),u_luminance:new h.c1(a)}),globeRaster:a=>({u_proj_matrix:new h.c3(a),u_globe_matrix:new h.c3(a),u_normalize_matrix:new h.c3(a),u_merc_matrix:new h.c3(a),u_zoom_transition:new h.c1(a),u_merc_center:new h.c2(a),u_image0:new h.b$(a),u_image1:new h.b$(a),u_grid_matrix:new h.dq(a),u_skirt_height:new h.c1(a),u_far_z_cutoff:new h.c1(a),u_frustum_tl:new h.c0(a),u_frustum_tr:new h.c0(a),u_frustum_br:new h.c0(a),u_frustum_bl:new h.c0(a),u_globe_pos:new h.c0(a),u_globe_radius:new h.c1(a),u_viewport:new h.c2(a),u_emissive_texture_available:new h.c1(a)}),globeAtmosphere:a=>({u_frustum_tl:new h.c0(a),u_frustum_tr:new h.c0(a),u_frustum_br:new h.c0(a),u_frustum_bl:new h.c0(a),u_horizon:new h.c1(a),u_transition:new h.c1(a),u_fadeout_range:new h.c1(a),u_atmosphere_fog_color:new h.cS(a),u_high_color:new h.cS(a),u_space_color:new h.cS(a),u_temporal_offset:new h.c1(a),u_horizon_angle:new h.c1(a)}),model:a=>({u_matrix:new h.c3(a),u_lighting_matrix:new h.c3(a),u_normal_matrix:new h.c3(a),u_node_matrix:new h.c3(a),u_lightpos:new h.c0(a),u_lightintensity:new h.c1(a),u_lightcolor:new h.c0(a),u_camera_pos:new h.c0(a),u_opacity:new h.c1(a),u_baseColorFactor:new h.cS(a),u_emissiveFactor:new h.cS(a),u_metallicFactor:new h.c1(a),u_roughnessFactor:new h.c1(a),u_baseTextureIsAlpha:new h.b$(a),u_alph
3063aMask:new h.b$(a),u_alphaCutoff:new h.c1(a),u_baseColorTexture:new h.b$(a),u_metallicRoughnessTexture:new h.b$(a),u_normalTexture:new h.b$(a),u_occlusionTexture:new h.b$(a),u_emissionTexture:new h.b$(a),u_lutTexture:new h.b$(a),u_color_mix:new h.cS(a),u_aoIntensity:new h.c1(a),u_emissive_strength:new h.c1(a),u_occlusionTextureTransform:new h.cS(a),u_dithered_discard_threshold:new h.c1(a)}),modelDepth:a=>({u_matrix:new h.c3(a),u_instance:new h.c3(a),u_node_matrix:new h.c3(a)}),groundShadow:a=>({u_matrix:new h.c3(a),u_ground_shadow_factor:new h.c0(a)}),stars:a=>({u_matrix:new h.c3(a),u_up:new h.c0(a),u_right:new h.c0(a),u_intensity_multiplier:new h.c1(a)}),occlusion:a=>({u_matrix:new h.c3(a),u_anchorPos:new h.c0(a),u_screenSizePx:new h.c2(a),u_occluderSizePx:new h.c2(a),u_color:new h.cS(a)})};class Fs{constructor(t,o,c,d){this.id=Fs.uniqueIdxCounter,Fs.uniqueIdxCounter++,this.context=t;let m=t.gl;this.buffer=m.createBuffer(),this.dynamicDraw=!!c,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),m.bufferData(m.ELEMENT_ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.STATIC_DRAW),this.dynamicDraw||d||o.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){this.id=Fs.uniqueIdxCounter,Fs.uniqueIdxCounter++;let o=this.context.gl;this.context.unbindVAO(),this.bind(),o.bufferSubData(o.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Fs.uniqueIdxCounter=0;let Ar={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class zd{constructor(t,o,c,d,m,_){this.length=o.length,this.attributes=c,this.itemSize=o.bytesPerElement,this.dynamicDraw=d,this.instanceCount=_,this.context=t;let y=t.gl;this.buffer=y.createBuffer(),t.bindVertexBuffer.set(this.buffer),y.bufferData(y.ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?y.DYNAMIC_DRAW:y.STATIC_DRAW),this.dynamicDraw||m||o.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){let o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,o){for(let c of this.attributes){let d=o.getAttributeLocation(t,c.name);d!==-1&&t.enableVertexAttribArray(d)}}setVertexAttribPointers(t,o,c){for(let d of this.attributes){let m=o.getAttributeLocation(t,d.name);if(m!==-1){let _=d.offset+this.itemSize*(c||0);d.type==="Float32"?t.vertexAttribPointer(m,d.components,t.FLOAT,!1,this.itemSize,_):t.vertexAttribIPointer(m,d.components,t[Ar[d.type]],this.itemSize,_)}}}setVertexAttribDivisor(t,o,c){for(let d=0;d<this.attributes.length;d++){let m=o.getAttributeLocation(t,this.attributes[d].name);m!==-1&&this.instanceCount&&this.instanceCount>0&&t.vertexAttribDivisor(m,c)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class En{constructor(t,o,c,d,m){this.context=t,this.width=o,this.height=c;let _=this.framebuffer=t.gl.createFramebuffer();d>0&&(this.colorAttachment0=new Pc(t,_,0)),d>1&&(this.colorAttachment1=new Pc(t,_,1)),m&&(this.depthAttachmentType=m,this.depthAttachment=m==="renderbuffer"?new Lf(t,_):new vd(t,_))}static createWithTexture(t,o,c,d,m){let _=t.gl;if(t.activeTexture.set(_.TEXTURE1),t.viewport.set([0,0,c,d]),o&&o.width===c&&o.height===d)return _.bindTexture(_.TEXTURE_2D,o.colorAttachment0.get()),t.bindFramebuffer.set(o.framebuffer),o;o&&o.destroy();let y=t.extRenderToTextureHalfFloat||t.extColorBufferFloat?t.gl.RGBA16F:t.gl.RGBA8,v=new h.T(t,{width:c,height:d,data:null},y);v.bind(_.LINEAR,_.CLAMP_TO_EDGE);let T=t.createFramebuffer(c,d,1,null);if(T.format=y,T.colorAttachment0.set(v.texture),m){let E=t.createRenderbuffer(_.DEPTH24_STENCIL8,c,d);t.bindFramebuffer.set(T.framebuffer),_.framebufferRenderbuffer(_.FRAMEBUFFER,_.DEPTH_STENCIL_ATTACHMENT,_.RENDERBUFFER,E),T._stencilRbo=E}return T}createColorAttachment(t,o){o===0?this.colorAttachment0=new Pc(t,this.framebuffer,0):o===1&&(this.colorAttachment1=new Pc(t,this.framebuffer,1))}removeColorAttachment(t,o){let c=this.context.gl,d;o===0?(d=this.colorAttachment0.get(),this.colorAttachment0=void 0):o===1&&(
3063d=this.colorAttachment1.get(),this.colorAttachment1=void 0),d&&c.deleteTexture(d)}destroy(){let t=this.context.gl;if(this.colorAttachment0){let o=this.colorAttachment0.get();o&&t.deleteTexture(o)}if(this.colorAttachment1){let o=this.colorAttachment1.get();o&&t.deleteTexture(o)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){let o=this.depthAttachment.get();o&&t.deleteRenderbuffer(o)}else{let o=this.depthAttachment.get();o&&t.deleteTexture(o)}this._stencilRbo&&(t.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),t.deleteFramebuffer(this.framebuffer)}}class Bs{constructor(t,o){this.gl=t,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new Ef(this),this.clearDepth=new xl(this),this.clearStencil=new Z_(this),this.colorMask=new W_(this),this.depthMask=new X_(this),this.stencilMask=new Y_(this),this.stencilFunc=new J_(this),this.stencilOp=new K_(this),this.stencilTest=new dd(this),this.depthRange=new pd(this),this.depthTest=new fd(this),this.depthFunc=new vl(this),this.blend=new If(this),this.blendFunc=new Af(this),this.blendColor=new Mf(this),this.blendEquation=new md(this),this.cullFace=new Ls(this),this.cullFaceSide=new Gu(this),this.frontFace=new Hu(this),this.program=new Cf(this),this.activeTexture=new zs(this),this.viewport=new _d(this),this.bindFramebuffer=new $u(this),this.bindRenderbuffer=new Pf(this),this.bindTexture=new Df(this),this.bindVertexBuffer=new gd(this),this.bindElementBuffer=new yd(this),this.bindVertexArrayOES=new Q_(this),this.pixelStoreUnpack=new Rf(this),this.pixelStoreUnpackPremultiplyAlpha=new Cc(this),this.pixelStoreUnpackFlipY=new eg(this),this.options=o?Object.assign({},o):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=t.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=t.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=t.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=o&&!!o.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.disableSymbolUBO=o&&!!o.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=t.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=t.getExtension("EXT_color_buffer_float"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(t.getParameter(t.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=t.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=t.getExtension("KHR_parallel_shader_compile")}sweepPendingPrograms(){if(this._pendingPrograms.size!==0)for(let t of this._pendingPrograms)t.maybeFinalize()}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.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,o,c){return new Fs(this,t,o,c)}createVertexBuffer(t,o,c,d,m){return new zd(this,t,o,c,d,m)}createRenderbuffer(t,o,c){let d=this.gl,m=d.createRenderbuffer();return this.bindRenderbuffer.set(m),d.renderbufferStorage(d.RENDERBUFFER,t,o,c),this.bindRenderbuffer.set(null),m}createFramebuffer(t,o,c,d){return new En(this,t,o,c,d)}clear({color:t,depth:o,stencil:c,colorMask:d}){let m=this.gl,_=0;t&&(_|=m.COLOR_BUFFER_BIT,this.clearColor.set(t.toNonPremultipliedRenderColor(null)),this.colorMask.set(d||[!0,!0,!0,!0])),o!==void 0&&(_|=m.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(o),this.depthMask.set(!0)),c!==void 0&&(_|=m.STENCIL_BUFFER_BIT,this.clearStencil.set(c),this.stencilMask.set(255)),m.clear(_)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){h.b9(t.blendFunction,_t.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let Fc;function Ku(a,t,o,c,d,m,_){let y=a.context,v=y.gl,T=a.transform,E=[h.aG(T.center.lng),h.aJ(T.center.lat)],P=o.layout.get("symbol-placement"),A=o.layout.get("text-variable-anchor"),D=o.layout.get("icon-rotation-alignment")==="map",z=o.layout.get("text-rotation-alignment")==="map",O=P!=="point",k=[],N=0,q=0;for(let K=0;K<c.length;K++){let J=c[K],oe=t.getTile(J),ue=oe.getBucket(o);if(!ue)continue;let de=ue.getProjection().createInversionMatrix(T,J.canonical),be=[],ve=dr(J,ue,T),Fe=!_&&D&&O,pe=_&&z&&O,Ee=A&&ue.hasTextData(),fe=ue.hasIconTextFit()&&Ee&&ue.hasIconData(),Pe=Fe||pe||_&&Ee||fe,Ce=ue.projection.name==="globe",Re=Ce?h.ai(T.zoom):0;Ce&&(be.push("PROJECTION_GLOBE_VIEW"),Pe&&be.push("PROJECTED_POS_ON_VIEWPORT"));let Ye=a.getOrCreateProgram("collisionBox",{defines:be}),He=ve;d[0]===0&&d[1]===0||(He=a.translatePosMatrix(ve,oe,d,m));let je=_?ue.textCollisionBox:ue.iconCollisionBox,Ue=ue.collisionCircleArray;
3063if(Ue.length>0){let st=h.bd(),et=He;h.cB(st,ue.placementInvProjMatrix,T.glCoordMatrix),h.cB(st,st,ue.placementViewportMatrix),k.push({circleArray:Ue,circleOffset:q,transform:et,invTransform:st,projection:ue.getProjection()}),N+=Ue.length/4,q=N}if(!je)continue;a.terrain&&a.terrain.setupElevationDraw(oe,Ye);let lt=Ce?[J.canonical.x,J.canonical.y,1<<J.canonical.z]:[0,0,0];Ye.draw(a,v.LINES,nt.disabled,yt.disabled,a.colorModeForRenderPass(),pt.disabled,Gf(He,de,T,Re,E,oe,lt,ue.getProjection()),o.id,je.layoutVertexBuffer,je.indexBuffer,je.segments,null,T.zoom,null,[je.collisionVertexBuffer,je.collisionVertexBufferExt])}if(!_||!k.length)return;let Z=a.getOrCreateProgram("collisionCircle"),G=new h.dS;G.resize(4*N),G._trim();let re=0;for(let K of k)for(let J=0;J<K.circleArray.length/4;J++){let oe=4*J,ue=K.circleArray[oe+0],de=K.circleArray[oe+1],be=K.circleArray[oe+2],ve=K.circleArray[oe+3];G.emplace(re++,ue,de,be,ve,0),G.emplace(re++,ue,de,be,ve,1),G.emplace(re++,ue,de,be,ve,2),G.emplace(re++,ue,de,be,ve,3)}(!Fc||Fc.length<2*N)&&(Fc=function(K){let J=2*K,oe=new h.dF;oe.resize(J),oe._trim();for(let ue=0;ue<J;ue++){let de=6*ue;oe.uint16[de+0]=4*ue+0,oe.uint16[de+1]=4*ue+1,oe.uint16[de+2]=4*ue+2,oe.uint16[de+3]=4*ue+2,oe.uint16[de+4]=4*ue+3,oe.uint16[de+5]=4*ue+0}return oe}(N));let te=y.createIndexBuffer(Fc,!0),se=y.createVertexBuffer(G,h.dT.members,!0);for(let K of k){let J=Hf(K.transform,K.invTransform,T,K.projection);Z.draw(a,v.TRIANGLES,nt.disabled,yt.disabled,a.colorModeForRenderPass(),pt.disabled,J,o.id,se,te,h.dB.simpleSegment(0,2*K.circleOffset,K.circleArray.length,K.circleArray.length/2),null,T.zoom)}se.destroy(),te.destroy()}let Tl=h.bd();function Qu(a){let t=a._camera.getWorldToCamera(a.worldSize,1),o=h.aC([],t,a.globeMatrix);h.ba(o,o);let c=[0,0,0],d=[0,1,0,0];return h.aD(d,d,o),c[0]=d[0],c[1]=d[1],c[2]=d[2],h.ax(c,c),c}function Xf({width:a,height:t,anchor:o,textOffset:c,textScale:d},m){let{horizontalAlign:_,verticalAlign:y}=h.bJ(o),v=-(_-.5)*a,T=-(y-.5)*t,E=h.bK(o,c);return new h.P((v/d+E[0])*m,(T/d+E[1])*m)}function ts(a,t,o,c,d,m,_,y,v,T){let E=a.text.placedSymbolArray,P=a.text.dynamicLayoutVertexArray,A=a.icon.dynamicLayoutVertexArray,D={},z=a.getProjection(),O=Tu(_,z,d),k=d.elevation,N=z.upVectorScale(_.canonical,d.center.lat,d.worldSize).metersToTile;P.clear();for(let q=0;q<E.length;q++){let Z=E.get(q),{tileAnchorX:G,tileAnchorY:re,numGlyphs:te}=Z,se=Z.hidden||!Z.crossTileID||a.allowVerticalPlacement&&!Z.placedOrientation?null:c[Z.crossTileID];if(se){let K=0,J=0,oe=0,ue=a.elevationType==="road";if(k||ue){let Ce=ue?a.getElevationFeatureForText(q):null,Re=h.bx.getAtTileOffset(_,new h.P(G,re),k,Ce),[Ye,He,je]=z.upVector(_.canonical,G,re);K=Re*Ye*N,J=Re*He*N,oe=Re*je*N}let[de,be,ve,Fe]=kr(Z.projectedAnchorX+K,Z.projectedAnchorY+J,Z.projectedAnchorZ+oe,o?O:m),pe=io(d.getCameraToCenterDistance(z),Fe),Ee=h.bn(a.textSizeData,v,Z)*pe/h.bC;o&&(Ee*=a.tilePixelRatio/y);let fe=Xf(se,Ee);o?({x:de,y:be,z:ve}=z.projectTilePoint(G+fe.x,re+fe.y,_.canonical),[de,be,ve]=kr(de+K,be+J,ve+oe,m)):(t&&fe._rotate(-d.angle),de+=fe.x,be+=fe.y,ve=0);let Pe=a.allowVerticalPlacement&&Z.placedOrientation===h.bm.vertical?Math.PI/2:0;for(let Ce=0;Ce<te;Ce++)h.bp(P,de,be,ve,Pe);T&&Z.associatedIconIndex>=0&&(D[Z.associatedIconIndex]={x:de,y:be,z:ve,angle:Pe})}else Sr(te,P)}if(T){A.clear();let q=a.icon.placedSymbolArray;for(let Z=0;Z<q.length;Z++){let G=q.get(Z),{numGlyphs:re}=G,te=D[Z];if(G.hidden||!te)Sr(re,A);else{let{x:se,y:K,z:J,angle:oe}=te;for(let ue=0;ue<re;ue++)h.bp(A,se,K,J,oe)}}a.icon.dynamicLayoutVertexBuffer.updateData(A)}a.text.dynamicLayoutVertexBuffer.updateData(P)}function Od(a,t,o,c,d,m,_={}){let y=o.paint.get("icon-translate"),v=o.paint.get("text-translate"),T=o.paint.get("icon-translate-anchor"),E=o.paint.get("text-translate-anchor"),P=o.layout.get("icon-rotation-alignment"),A=o.layout.get("text-rotation-alignment"),D=o.layout.get("icon-pitch-alignment"),z=o.layout.get("text-pitch-alignment"),O=o.layout.get("icon-keep-upright"),k=o.layout.get("text-keep-upright"),N=o.paint.get("icon-color-saturation"),q=o.paint.get("icon-color-contrast"),Z=o.paint.get("icon-color-brightness-min"),G=o.paint.get("icon-color-brightness-max"),re=o.layout.get("symbol-elevation-reference")==="sea",te=o.layout.get("icon-image-use-theme")==="none",se=a.context,K=se.gl,J=a.transform,oe=P==="map",ue=A==="map",de=D==="map",be=z==="map",ve=o.layout.get("symbol-sort-key").constantOr(1)!==void 0,Fe=!1,pe=a.depthModeForSublayer(0,nt.ReadOnly),Ee=new nt(a.context.gl.LEQUAL,nt.ReadOnly,a.depthRangeFor3D),fe=[h.aG(J.center.lng),h.aJ(J.center.lat)],Pe=o.layout.get("text-variable-anchor"),Ce=J.projection.name==="globe",Re=[],Ye=[0,-1,0];for(let He of c){let je=t.getTile(He),Ue=je.getBucket(o);if(!Ue||Ue.projection.name==="mercator"&&Ce||Ue.fullyClipped)continue;let lt=Ue.projection.name==="globe",st=lt?h.ai(J.zoom):0,et=Tu(He,Ue.getProjection(),J),it=J.calculatePixelsToTileUnitsMatrix(je),ht=Pe&&Ue.hasTextData(),vt=Ue.hasIconTextFit()&&ht&&Ue.hasIconData(),gt
3063=Ue.getProjection().createInversionMatrix(J,He.canonical),Et=(1<<je.tileID.canonical.z)*h.ak/a.transform.worldSize,xt=ti=>{let wt=[0,0,0];if(ti){let yi=a.style.directionalLight,fi=a.style.ambientLight;yi&&fi&&(wt=Ia(a.style,yi,fi))}return wt},kt=ti=>{if(a.context.disableSymbolUBO)return;ti.push("USE_PAINT_PROPERTIES_UBO");let wt=Math.floor(a.context.maxUniformBlockSize/4),yi=Math.floor(wt/4);ti.push(`MAX_UBO_SIZE_VEC4 ${yi}u`)},Tt=ti=>{J.depthOcclusionForSymbolsAndCircles&&(o.hasOcclusionOpacityProperties||a.terrain)&&(ti.push("DEPTH_D24"),ti.push("DEPTH_OCCLUSION"))},Vt=ti=>{o.lut&&!te&&(o.lut.texture||(o.lut.texture=new h.dU(a.context,o.lut.image,[o.lut.image.height,o.lut.image.height,o.lut.image.height],se.gl.RGBA8)),se.activeTexture.set(se.gl.TEXTURE0+10),o.lut.texture&&o.lut.texture.bind(se.gl.LINEAR,se.gl.CLAMP_TO_EDGE),ti.push("APPLY_LUT_ON_GPU"))},qt=()=>{let ti=oe&&o.layout.get("symbol-placement")!=="point",wt=[];Tt(wt),Vt(wt);let yi=ti||vt,fi=Ue.elevationType==="road",Ui=a.shadowRenderer,Nt=fi&&de&&!!Ui&&Ui.enabled,Ji=xt(Nt),Vn=fi&&de&&!a.terrain?Ee:pe,pn=o.paint.get("icon-image-cross-fade");a.terrainRenderModeElevated()&&de&&wt.push("PITCH_WITH_MAP_TERRAIN"),lt&&(wt.push("PROJECTION_GLOBE_VIEW"),yi&&wt.push("PROJECTED_POS_ON_VIEWPORT")),pn>0&&Ue.hasAnySecondaryIcon&&wt.push("ICON_TRANSITION"),!Ue.icon.zOffsetVertexBuffer||fi&&a.terrain||wt.push("Z_OFFSET"),N===0&&q===0&&Z===0&&G===1||wt.push("COLOR_ADJUSTMENT"),Ue.sdfIcons&&wt.push("RENDER_SDF"),Nt&&wt.push("RENDER_SHADOWS","NORMAL_OFFSET"),fi&&de&&!a.terrain&&Ue.icon.orientationVertexBuffer&&wt.push("ELEVATED_ROADS"),kt(wt);let In=se.disableSymbolUBO?Ue.icon.programConfigurations.get(o.id):null,cn=a.getOrCreateProgram("symbol",{config:In,defines:wt}),cr=je.imageAtlasTexture?je.imageAtlasTexture.size:[0,0],tr=Ue.iconSizeData,zi=h.bl(tr,J.zoom),Vi=de||!J.isOrthographic,Ii=Tr(et,je.tileID.canonical,de,oe,J,Ue.getProjection(),it),ii=an(et,je.tileID.canonical,de,oe,J,Ue.getProjection(),it),si=Ue.icon.uboBinder&&Ue.icon.uboBinder.cachedHeader&&256&Ue.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:y,Ki=a.translatePosMatrix(ii,je,si,T,!0),vn=a.translatePosMatrix(et,je,si,T),ki=yi?Tl:Ii,bn=oe&&!de&&!ti,Zr=Ye;!Ce&&!J.mercatorFromTransition||oe||(Zr=Qu(J));let ur=lt?Zr:Ye,lo=o.getColorAdjustmentMatrix(N,q,Z,G),cs=Zf(tr.kind,zi,bn,de,a,vn,ki,Ki,re,!1,cr,[0,0],0,He,st,fe,gt,ur,Ue.getProjection(),Ji,Et,lo,pn,null),us=je.imageAtlasTexture?je.imageAtlasTexture:null,Eo=o.layout.get("icon-size").constantOr(0)!==1||Ue.iconsNeedLinear,Jc=Ue.sdfIcons||a.options.rotating||a.options.zooming||Eo||Vi?K.LINEAR:K.NEAREST,Zs=Ue.sdfIcons&&o.paint.get("icon-halo-width").constantOr(1)!==0,Va=a.terrain&&de&&ti?h.ba(h.bd(),Ii):Tl;if(ti&&Ue.icon){let hp=h.bx.getAtTileOffsetFunc(He,J.center.lat,J.worldSize,Ue.getProjection()),Kc=bo(et,je.tileID.canonical,de,oe,J,Ue.getProjection(),it),Pm=o.layout.get("icon-size-scale-range"),Dm=h.aB(a.scaleFactor,Pm[0],Pm[1]);gc(Ue,et,a,!1,Kc,ii,de,O,hp,He,Dm)}return{program:cn,buffers:Ue.icon,uniformValues:cs,atlasTexture:us,atlasTextureIcon:null,atlasInterpolation:Jc,atlasInterpolationIcon:null,isSDF:Ue.sdfIcons,hasHalo:Zs,depthMode:Vn,tile:je,renderWithShadows:Nt,labelPlaneMatrixInv:Va}},bi=()=>{let ti=ue&&o.layout.get("symbol-placement")!=="point",wt=[],yi=ti||Pe||vt,fi=Ue.elevationType==="road",Ui=a.shadowRenderer,Nt=fi&&be&&!!Ui&&Ui.enabled,Ji=xt(Nt),Vn=fi&&be&&!a.terrain?Ee:pe;a.terrainRenderModeElevated()&&be&&wt.push("PITCH_WITH_MAP_TERRAIN"),lt&&(wt.push("PROJECTION_GLOBE_VIEW"),yi&&wt.push("PROJECTED_POS_ON_VIEWPORT")),!Ue.text.zOffsetVertexBuffer||fi&&a.terrain||wt.push("Z_OFFSET"),Ue.iconsInText&&wt.push("RENDER_TEXT_AND_SYMBOL"),wt.push("RENDER_SDF"),Nt&&wt.push("RENDER_SHADOWS","NORMAL_OFFSET"),fi&&be&&!a.terrain&&Ue.text.orientationVertexBuffer&&wt.push("ELEVATED_ROADS"),Tt(wt),kt(wt);let pn=se.disableSymbolUBO?Ue.text.programConfigurations.get(o.id):null,In=a.getOrCreateProgram("symbol",{config:pn,defines:wt}),cn,cr=[0,0],tr=null,zi=Ue.textSizeData;Ue.iconsInText&&(cr=je.imageAtlasTexture?je.imageAtlasTexture.size:[0,0],tr=je.imageAtlasTexture?je.imageAtlasTexture:null,cn=be||!J.isOrthographic||a.options.rotating||a.options.zooming||zi.kind==="composite"||zi.kind==="camera"?K.LINEAR:K.NEAREST);let Vi=je.glyphAtlasTexture?je.glyphAtlasTexture.size:[0,0],Ii=o.layout.get("text-size-scale-range"),ii=h.aB(a.scaleFactor,Ii[0],Ii[1]),si=h.bl(zi,J.zoom,ii),Ki=Tr(et,je.tileID.canonical,be,ue,J,Ue.getProjection(),it),vn=an(et,je.tileID.canonical,be,ue,J,Ue.getProjection(),it),ki=Ue.text.uboBinder&&Ue.text.uboBinder.cachedHeader&&256&Ue.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:v,bn=a.translatePosMatrix(vn,je,ki,E,!0),Zr=a.translatePosMatrix(et,je,ki,E),ur=yi?Tl:Ki,lo=ue&&!be&&!ti,cs=Ye;!Ce&&!J.mercatorFromTransition||ue||(cs=Qu(J));let us=Zf(zi.kind,si,lo,be,a,Zr,ur,bn,re,!0,Vi,cr,0,He,st,fe,gt,lt?cs:Ye,Ue.getProjection(),Ji,Et,null,null,ii),Eo=je.glyphAtlasTexture?je.glyphAtlasTexture:null,Jc=K.LINEAR,Zs=o.paint.get("text-halo-width").constantOr(1)!==0,Va=a.terrain&&be&&ti?h.ba(h.bd(),Ki):Tl;if(ti&&Ue.text){let hp=h.bx.getAtTileOffsetFunc(He,J.center.lat,J.worldSize,Ue.getProjection()),Kc=bo(et,je.tileID.canonical,be,ue,J,Ue.getProjection(),it);gc(Ue,et,a,!0,Kc,vn,be,k,hp,He,ii)}return{program:In,buffers:Ue.text,uniformValues:us,atlasTexture:Eo,atlasTextureIcon:tr,atlasInterpolation:Jc,atlasInterpolationIcon:cn,isSDF:!0,hasHalo:Zs,depthMode:Vn,tile:je,renderWithShadows:Nt,labelPlaneMatr
3063ixInv:Va}},li=Ue.icon.segments.get().length,Xt=Ue.text.segments.get().length,At=li&&!_.onlyText?qt():null,Ct=Xt&&!_.onlyIcons?bi():null,ci=o.paint.get("icon-opacity").constantOr(1),Li=o.paint.get("text-opacity").constantOr(1);if(ve&&Ue.canOverlap){Fe=!0;let ti=ci&&!_.onlyText?Ue.icon.segments.get():[],wt=Li&&!_.onlyIcons?Ue.text.segments.get():[];for(let yi of ti)Re.push({segments:new h.dB([yi]),sortKey:yi.sortKey,state:At});for(let yi of wt)Re.push({segments:new h.dB([yi]),sortKey:yi.sortKey,state:Ct})}else _.onlyText||Re.push({segments:ci?Ue.icon.segments:new h.dB([]),sortKey:0,state:At}),_.onlyIcons||Re.push({segments:Li?Ue.text.segments:new h.dB([]),sortKey:0,state:Ct})}Fe&&Re.sort((He,je)=>He.sortKey-je.sortKey);for(let He of Re){let je=He.state;if(je)if(a.terrain?a.terrain.setupElevationDraw(je.tile,je.program,{useDepthForOcclusion:J.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:je.labelPlaneMatrixInv}):a.setupDepthForOcclusion(J.depthOcclusionForSymbolsAndCircles,je.program),se.activeTexture.set(K.TEXTURE0),je.atlasTexture&&je.atlasTexture.bind(je.atlasInterpolation,K.CLAMP_TO_EDGE,!0),je.atlasTextureIcon&&(se.activeTexture.set(K.TEXTURE1),je.atlasTextureIcon&&je.atlasTextureIcon.bind(je.atlasInterpolationIcon,K.CLAMP_TO_EDGE,!0)),je.renderWithShadows&&a.shadowRenderer.setupShadows(je.tile.tileID.toUnwrapped(),je.program,"vector-tile"),a.uploadCommonLightUniforms(a.context,je.program),je.hasHalo){let Ue=je.uniformValues;Ue.u_is_halo=1,Jt(je.buffers,He.segments,o,a,je.program,je.depthMode,d,m,Ue,2),Ue.u_is_halo=0}else{if(je.isSDF){let Ue=je.uniformValues;je.hasHalo&&(Ue.u_is_halo=1,Jt(je.buffers,He.segments,o,a,je.program,je.depthMode,d,m,Ue,1)),Ue.u_is_halo=0}Jt(je.buffers,He.segments,o,a,je.program,je.depthMode,d,m,je.uniformValues,1)}}}function Jt(a,t,o,c,d,m,_,y,v,T){let E=c.context,P=E.gl,A=[a.dynamicLayoutVertexBuffer,a.opacityVertexBuffer,a.iconTransitioningVertexBuffer,a.globeExtVertexBuffer,a.zOffsetVertexBuffer,a.orientationVertexBuffer];a.featureIdBuffer&&A.push(a.featureIdBuffer);let D=a.uboBinder?null:a.programConfigurations.get(o.id);if(a.uboBinder){a.uboBinder.layer=o;let k=c.transform.zoom,N=c.style.getBrightness?c.style.getBrightness():null,q=a.uboBinder.getConstantUniformValues(k,N);v.u_spp_fill_np_color=q.fill_np_color,v.u_spp_halo_np_color=q.halo_np_color,v.u_spp_opacity=q.opacity,v.u_spp_halo_width=q.halo_width,v.u_spp_halo_blur=q.halo_blur,v.u_spp_emissive_strength=q.emissive_strength,v.u_spp_occlusion_opacity=q.occlusion_opacity,v.u_spp_z_offset=q.z_offset;let Z=o.paint.get(a.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),G=a.uboBinder.cachedHeader&&256&a.uboBinder.cachedHeader.dataDrivenMask&&Z==="map"?c.transform.angle:0;v.u_spp_translate_rotation=[Math.cos(G),Math.sin(G)]}let{batchIndices:z,batchSegments:O}=a.getBatchGrouping(t);for(let k of z){let N=O.get(k);a.uboBinder&&a.uboBinder.bind(E,d.program,k),d.draw(c,P.TRIANGLES,m,_,y,pt.disabled,v,o.id,a.layoutVertexBuffer,a.indexBuffer,N,o.paint,c.transform.zoom,D,A,T)}}function Sl(a,t,o,c,d,m){let _=o.paint.get("line-width"),y=o.paint.get("line-emissive-strength").isConstant(),v=o.paint.get("line-emissive-strength").constantOr(0),T=o.paint.get("line-occlusion-opacity"),E=o.layout.get("line-elevation-reference"),P=o.layout.get("line-width-unit")==="meters",A=E==="sea",D=!(!a.terrain||!a.terrain.enabled),z=a.context,O=z.gl;if(o.hasElevatedBuckets&&a.transform.projection.name==="globe")return;let k=o.layout.get("line-cross-slope"),N=k!==void 0,q=k<1,Z=d||a.colorModeForDrapableLayerRenderPass(y?v:null),G=a.terrain&&a.terrain.renderingToTexture||m,re=G?1:h.o.devicePixelRatio,te=o.paint.get("line-dasharray"),se=te.constantOr(1),K=o.layout.get("line-cap"),J=te.constantOr(null),oe=K.constantOr(null),ue=o.paint.get("line-pattern"),de=ue.constantOr(1),be=o.paint.get("line-pattern-cross-fade"),ve=ue.constantOr(null),Fe=o.paint.get("line-opacity").constantOr(1),pe=!de&&Fe!==1||a.depthOcclusion&&T>0&&T<1,Ee=o.paint.get("line-gradient"),fe=de?"linePattern":"line",Pe=h.dX(o),Ce;if(G&&a.terrain&&a.terrain.clipOrMaskOverlapStencilType()&&(pe=!1),T!==0&&a.depthOcclusion){let Ue=
3063o.paint._values["line-opacity"];Ue&&Ue.value&&Ue.value.kind==="constant"?Ce=Ue.value:h.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`)}_.value.kind!=="constant"&&_.value.isLineProgressConstant===!1&&Pe.push("VARIABLE_LINE_WIDTH"),a._debugParams.showElevationIdDebug&&Pe.push("DEBUG_ELEVATION_ID"),G&&(a.emissiveMode!=="dual-source-blending"||y?a.emissiveMode==="mrt-fallback"&&Pe.push("USE_MRT1"):Pe.push("DUAL_SOURCE_BLENDING"));let Re={},Ye=(Ue,lt,st,et,it,ht)=>{for(let vt of Ue){let gt=t.getTile(vt);if(de&&!gt.patternsLoaded())continue;let Et=gt.getBucket(o);if(!Et||Et.elevationType!=="none"&&!it||Et.elevationType==="none"&&it)continue;a.prepareDrawTile();let xt=[...lt],kt=a.shadowRenderer,Tt=Et.elevationType==="road"&&!!kt&&kt.enabled,Vt=[0,0,0];if(Tt){let Nt=a.style.directionalLight,Ji=a.style.ambientLight;Nt&&Ji&&(Vt=Ia(a.style,Nt,Ji)),xt.push("RENDER_SHADOWS","NORMAL_OFFSET")}let qt=Et.programConfigurations.get(o.id),bi=!1;if(ve&&gt.imageAtlas){let Nt=h.dY.from(ve),Ji=Nt.getPrimary().scaleSelf(re).toString(),Vn=gt.imageAtlas.patternPositions.get(Ji),pn=Nt.getSecondary(),In=pn?gt.imageAtlas.patternPositions.get(pn.scaleSelf(re).toString()):null;bi=!!Vn&&!!In,Vn&&qt.setConstantPatternPositions(Vn,In)}be>0&&(bi||qt.getPatternTransitionVertexBuffer("line-pattern"))&&xt.push("LINE_PATTERN_TRANSITION"),Et.elevationGroundScaleVertexBuffer&&xt.push("ELEVATION_GROUND_SCALE");let li=a.isTileAffectedByFog(vt),Xt=a.getOrCreateProgram(fe,{config:qt,defines:xt,overrideFog:li});if(!de&&J&&oe&&gt.lineAtlas){let Nt=gt.lineAtlas.getDash(J,oe);Nt&&qt.setConstantPatternPositions(Nt)}Tt&&kt.setupShadows(gt.tileID.toUnwrapped(),Xt,"vector-tile");let[At,Ct]=o.paint.get("line-trim-offset");(oe==="round"||oe==="square")&&At!==Ct&&(At===0&&(At-=1),Ct===1&&(Ct+=1));let ci=G?vt.projMatrix:null,Li=P?1/Et.tileToMeter/h.az(gt,1,a.transform.zoom):1,ti=P?1/Et.tileToMeter/h.az(gt,1,Math.floor(a.transform.zoom)):1,wt=se?o.paint._values["line-floorwidth"]:null,yi;if(wt&&wt.value.kind==="constant"){let Nt=Et.zoom;Nt in Re||(Re[Nt]=Math.max(.01,o.widthExpression().evaluate({zoom:Nt}))),yi=wt.value.value;let Ji=Math.floor(a.transform.zoom);wt.value.value=Re[Nt]*Math.pow(2,Ji-gt.tileID.overscaledZ)}let fi=de?h.dZ(a,gt,o,ci,re,Li,ti,[At,Ct],Vt,be):h.d_(a,gt,o,ci,Et.lineClipsArray.length,re,Li,ti,[At,Ct],Vt);if(Ee){let Nt=Et.gradients[o.id],Ji=Nt.texture;if(o.gradientVersion!==Nt.version){let Vn=256;if(o.stepInterpolant){let pn=t.getSource().maxzoom,In=vt.canonical.z===pn?Math.ceil(1<<a.transform.maxZoom-vt.canonical.z):1;Vn=h.aB(h.d$(Et.maxLineLength/h.ak*1024*In),256,z.maxTextureSize)}Nt.gradient=h.e0({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:Vn,image:Nt.gradient||void 0,clips:Et.lineClipsArray}),Nt.texture?Nt.texture.update(Nt.gradient):Nt.texture=new h.T(z,Nt.gradient,O.RGBA8),Nt.version=o.gradientVersion,Ji=Nt.texture}z.activeTexture.set(O.TEXTURE1),Ji.bind(o.stepInterpolant?O.NEAREST:O.LINEAR,O.CLAMP_TO_EDGE)}se&&(z.activeTexture.set(O.TEXTURE0),gt.lineAtlasTexture&&gt.lineAtlasTexture.bind(O.LINEAR,O.REPEAT),qt.updatePaintBuffers()),de&&(z.activeTexture.set(O.TEXTURE0),gt.imageAtlasTexture&&gt.imageAtlasTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE),qt.updatePaintBuffers()),it&&a.terrain.setupElevationDraw(gt,Xt),a.uploadCommonUniforms(z,Xt,vt.toUnwrapped());let Ui=Nt=>{Ce!=null&&(Ce.value=Fe*T),Xt.draw(a,O.TRIANGLES,st,Nt,Z,pt.disabled,fi,o.id,Et.layoutVertexBuffer,Et.indexBuffer,Et.segments,o.paint,a.transform.zoom,qt,[Et.layoutVertexBuffer2,Et.patternVertexBuffer,Et.zOffsetVertexBuffer,Et.elevationIdColVertexBuffer,Et.elevationGroundScaleVertexBuffer]),Ce!=null&&(Ce.value=Fe)};if(pe&&!it){let Nt=a.stencilModeForClipping(vt).ref;Nt===0&&G&&z.clear({stencil:0});let Ji={func:O.EQUAL,mask:255};
3063fi.u_alpha_discard_threshold=.8,Ui(new yt(Ji,Nt,255,O.KEEP,O.KEEP,O.INVERT)),fi.u_alpha_discard_threshold=0,Ui(new yt(Ji,Nt,255,O.KEEP,O.KEEP,O.KEEP))}else fi.u_alpha_discard_threshold=pe&&it&&ht?.8:0,Ui(it?et:a.stencilModeForClipping(vt));yi!==void 0&&(wt.value.value=yi)}},He=a.depthModeForSublayer(0,nt.ReadOnly),je=new nt(a.depthOcclusion?O.GREATER:O.LEQUAL,nt.ReadOnly,a.depthRangeFor3D);if(o.hasNonElevatedBuckets){let Ue=!G&&a.terrain;T!==0&&Ue?h.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`):Ue?h.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${o.id}.`):Ye(c,Pe,He,yt.disabled,!1,!0)}if(o.hasElevatedBuckets){E==="hd-road-markup"?D||(He=je,Pe.push("ELEVATED_ROADS")):(Pe.push("ELEVATED"),He=je,N&&Pe.push(q?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),A&&Pe.push("ELEVATION_REFERENCE_SEA"));let Ue=pe?a.stencilModeFor3D():yt.disabled;a.forceTerrainMode=!0,Ye(c,Pe,He,Ue,!0,!0),pe&&Ye(c,Pe,He,Ue,!0,!1),a.forceTerrainMode=!1}pe&&(a.resetStencilClippingMasks(),G&&z.clear({stencil:0})),T===0||a.depthOcclusion||G||a.layersWithOcclusionOpacity.push(a.currentLayer)}class eh{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null)}}class Yf{constructor(t){this.pbo=t.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0}destroy(t){this.sync&&(t.deleteSync(this.sync),this.sync=null),t.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null)}}let Bc={additive:{clearColor:new h.C(0,0,0,0),colorMode:_t.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new h.C(1,1,1,1),colorMode:_t.multiply,compositeUniformValue:0}};function kc(a){return!(!a.extRenderToTextureHalfFloat&&!a.extColorBufferFloat)}function Nc(a,t){return a==="additive"&&kc(t)?_t.additiveAlphaWeightedUnboundedAlpha:Bc[a].colorMode}function ks(a,t,o){let c=a.context,d=c.gl,m=o.width,_=o.height,y=o.colorAttachment0.get();t.lineBlendDensityReadback||(t.lineBlendDensityReadback=new Yf(d));let v=t.lineBlendDensityReadback,T=0,E=!0;for(;m>1||_>1;){let D=Math.max(1,Math.floor(m/2)),z=Math.max(1,Math.floor(_/2)),O=T===0?"fboA":"fboB";v[O]=En.createWithTexture(c,v[O],D,z,!1);let k=v[O];c.bindFramebuffer.set(k.framebuffer),c.viewport.set([0,0,D,z]),c.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,y),a.getOrCreateProgram("lineBlendReduce").draw(a,d.TRIANGLES,nt.disabled,yt.disabled,_t.unblended,pt.disabled,jf(0,[1/m,1/_],E),t.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments,t.paint,a.transform.zoom),m=D,_=z,y=k.colorAttachment0.get(),T=1-T,E=!1}let P=kc(c),A=P?16:4;v.sync&&(d.deleteSync(v.sync),v.sync=null),d.bindBuffer(d.PIXEL_PACK_BUFFER,v.pbo),d.bufferData(d.PIXEL_PACK_BUFFER,A,d.STREAM_READ),d.readPixels(0,0,1,1,d.RGBA,P?d.FLOAT:d.UNSIGNED_BYTE,0),d.bindBuffer(d.PIXEL_PACK_BUFFER,null),v.sync=d.fenceSync(d.SYNC_GPU_COMMANDS_COMPLETE,0),c.viewport.set([0,0,a.width,a.height])}function is(a,t,o){if(!kc(a.context))return;let c=t.lineBlendDensityReadback;c&&c.sync?(function(d,m,_){if(d.sync&&m.getSyncParameter(d.sync,m.SYNC_STATUS)===m.SIGNALED){if(m.deleteSync(d.sync),d.sync=null,m.bindBuffer(m.PIXEL_PACK_BUFFER,d.pbo),kc(_)){let y=new Float32Array(4);m.getBufferSubData(m.PIXEL_PACK_BUFFER,0,y);let v=y[1];d.maxDensity=Math.max(2*(v>0?y[0]/v:0),1)}else d.maxDensity=1;m.bindBuffer(m.PIXEL_PACK_BUFFER,null)}}(c,a.context.gl,a.context),c.sync||(ks(a,t,o),a.style.map.triggerRepaint())):(ks(a,t,o),a.style.map.triggerRepaint())}function qe(a,t,o,c,d,m){let _=a.context,y=_.gl,v=o==="additive"?1:t.paint.get("line-opacity").constantOr(1),T=o==="additive"?function(P,A){let D=A.paint.get("line-blend-additive-clamp");if(D>0)return D;let z=A.lineBlendDensityReadback;return z&&z.maxDensity!==0?z.maxDensity:null}(0,t):1;if(T===null)return;_.bindFramebuffer.set(d),m&&_.viewport.set([0,0,m[0],m[1]]),_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,c.colorAttachment0.get());let E=Nc(o,a.context);a.getOrCreateProgram("lineBlendComposite").draw(a,y.TRIANGLES,nt.disabled,yt.disabled,E,pt.disabled,((P,A,D,z)=>({u_image:0,u_opacity:A,u_blend_mode:D,u_max_density:z}))(0,v,Bc[o].compositeUniformValue,T),t.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments,t.paint,a.transform.zoom)}function Ze(a,t){let o=1<<a.canonical.z,c=(t.x*o-a.canonical.x-a.wrap*o)*h.ak,d=(t.y*o-a.canonical.y)*h.ak,m=h.e1(t.z,t.y);return h.cU(c,d,m)}function za(a,t,o,c,d){if(!o.layout||o.layout.get("fill-elevation-reference")==="none"||o.paint.get("fill-opacity").constantOr(1)===0)return;
3063let m=a.context.gl,_=new nt(a.context.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D),y=new nt(a.context.gl.GREATER,nt.ReadWrite,a.depthRangeFor3D),v=function(D){let z=.01;return D.isOrthographic&&(z=h.aj(1e-4,z,h.cP(D.pitch>=Ro?1:D.pitch/Ro))),2*z}(a.transform),T=a.transform.getFreeCameraOptions().position,E="elevatedStructuresDepthReconstruct",P=a.getOrCreateProgram(E,{defines:["DEPTH_RECONSTRUCTION"]}),A=a.getOrCreateProgram(E);for(let D of c){let z=t.getTile(D),O=z.getBucket(o);if(!O)continue;let k=O.elevatedStructures;if(!k||!k.depthSegments)continue;let N=O.elevationBufferData.heightRange,q=Ze(D.toUnwrapped(),T),Z=a.translatePosMatrix(D.projMatrix,z,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor")),G,re,te,se;if(d==="initialize"){if(!N||N.min>=1||k.depthSegments.segments[0].primitiveLength===0)continue;G=zc(Z,q,v,1,0),re=_,te=k.depthSegments,se=P}else if(d==="reset"){if(!N||N.min>=0||k.maskSegments.segments[0].primitiveLength===0)continue;G=zc(Z,q,0,0,1),re=y,te=k.maskSegments,se=P}else if(d==="geometry"){if(k.depthSegments.segments[0].primitiveLength===0)continue;G=zc(Z,q,v,1,0),re=_,te=k.depthSegments,se=A}se.draw(a,m.TRIANGLES,re,yt.disabled,_t.disabled,pt.disabled,G,o.id,k.vertexBuffer,k.indexBuffer,te,o.paint,a.transform.zoom)}}function Ti(a,t,o,c){let{painter:d,sourceCache:m,layer:_,coords:y,colorMode:v,elevationType:T,terrainEnabled:E,pass:P}=a,A=d.context.gl,D=_.paint.get("fill-pattern"),z=_.paint.get("fill-pattern-cross-fade"),O=D.constantOr(null),k=T;T!=="road"||t&&!E||(k="none");let N=k==="road",q=a.painter.shadowRenderer,Z=N&&!!q&&q.enabled,G=new nt(d.context.gl.LEQUAL,nt.ReadOnly,d.depthRangeFor3D),re=[0,0,0];if(Z){let J=d.style.directionalLight,oe=d.style.ambientLight;J&&oe&&(re=Ia(d.style,J,oe))}let te=D&&D.constantOr(1),se=d.terrain&&d.terrain.renderingToTexture,K=(J,oe)=>{let ue,de,be,ve,Fe;oe?(ue=te&&!_.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",be=A.LINES):(ue=te?"fillPattern":"fill",be=A.TRIANGLES);for(let pe of y){let Ee=m.getTile(pe);if(te&&!Ee.patternsLoaded())continue;let fe=Ee.getBucket(_);if(!fe)continue;let Pe=t?fe.elevationBufferData:fe.bufferData;if(Pe.isEmpty())continue;d.prepareDrawTile();let Ce=Pe.programConfigurations.get(_.id),Re=d.isTileAffectedByFog(pe),Ye=[],He=[];N&&(Ye.push("ELEVATED_ROADS"),He.push(Pe.elevatedLayoutVertexBuffer)),Z&&Ye.push("RENDER_SHADOWS","NORMAL_OFFSET"),se&&o&&Ye.push("USE_MRT1"),te&&(d.context.activeTexture.set(A.TEXTURE0),Ee.imageAtlasTexture&&Ee.imageAtlasTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE),Ce.updatePaintBuffers());let je=!1;if(O&&Ee.imageAtlas){let it=Ee.imageAtlas,ht=h.dY.from(O),vt=ht.getPrimary().scaleSelf(h.o.devicePixelRatio).toString(),gt=ht.getSecondary(),Et=it.patternPositions.get(vt),xt=gt?it.patternPositions.get(gt.scaleSelf(h.o.devicePixelRatio).toString()):null;je=!!Et&&!!xt,Et&&Ce.setConstantPatternPositions(Et,xt)}z>0&&(je||Ce.getPatternTransitionVertexBuffer("fill-pattern"))&&Ye.push("FILL_PATTERN_TRANSITION");let Ue=d.getOrCreateProgram(ue,{config:Ce,overrideFog:Re,defines:Ye}),lt=d.translatePosMatrix(pe.projMatrix,Ee,_.paint.get("fill-translate"),_.paint.get("fill-translate-anchor"));Z&&q.setupShadows(Ee.tileID.toUnwrapped(),Ue,"vector-tile");let st=_.paint.get("fill-emissive-strength");if(oe){ve=Pe.lineIndexBuffer,Fe=Pe.lineSegments;let it=d.terrain&&d.terrain.renderingToTexture?d.terrain.drapeBufferSize:[A.drawingBufferWidth,A.drawingBufferHeight];de=ue==="fillOutlinePattern"&&te?Vf(lt,st,d,Ee,it,re,z):Uf(lt,st,it,re)}else ve=Pe.indexBuffer,Fe=Pe.triangleSegments,de=te?Id(lt,st,d,Ee,re,z):Ed(lt,st,re);d.uploadCommonUniforms(d.context,Ue,pe.toUnwrapped());let et=J;(T==="road"&&!E||T==="offset")&&(et=G),Ue.draw(d,be,et,c||d.stencilModeForClipping(pe),v,pt.disabled,de,_.id,Pe.layoutVertexBuffer,ve,Fe,_.paint,d.transform.zoom,Ce,He)}};d.renderPass===P&&K(d.depthModeForSublayer(1,d.renderPass==="opaque"?nt.ReadWrite:nt.ReadOnly),!1),k==="none"&&d.renderPass==="translucent"&&_.paint.get("fill-antialias")&&K(d.depthModeForSublayer(_.getPaintProperty("fill-outline-color")?2:0,nt.ReadOnly),!0)}let he=new Float32Array(16);function Uc(a,t,o,c,d,m,_,y){o.resetLayerRenderingStats(a);let v=a.context,T=v.gl,E=a.transform,P=o.paint.get("fill-extrusion-pattern"),A=o.paint.get("fill-extrusion-pattern-cross-fade"),D=P.constantOr(null),z=P.constantOr(1),O=o.paint.get("fill-extrusion-opacity"),k=a.style.enable3dLights(),N=o.paint.get(k&&!z?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),q=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),N],Z=o.layout.get("fill-extrusion-edge-radius"),G=Z>0&&!o.paint.get("fill-extrusion-rounded-roof"),re=G?0:Z,te=E.projection.name==="globe"?h.e4():0,se=E.projection.name==="globe",K=se?h.ai(E.zoom):0,J=[h.aG(E.center.lng),h.aJ(E.center.lat)],oe=o.paint.get("fill-extrusion-flood-light-color-use-theme").
3063constantOr("default")==="none",ue=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(oe?null:o.lut).toArray01().slice(0,3),de=o.paint.get("fill-extrusion-flood-light-intensity"),be=o.paint.get("fill-extrusion-vertical-scale"),ve=o.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Fe=o.paint.get("fill-extrusion-height-alignment"),pe=o.paint.get("fill-extrusion-base-alignment"),Ee=Ps(a,o.paint.get("fill-extrusion-cutoff-fade-range")),fe=o.paint.get("fill-extrusion-front-cutoff"),Pe=jc(E.pitch,fe,!!a.terrain),Ce=Pe[2]<1;Ce&&(a.maxFrontCutoffRawStart=Math.max(a.maxFrontCutoffRawStart,fe[0]));let Re=[],Ye;se&&Re.push("PROJECTION_GLOBE_VIEW"),q[0]>0&&Re.push("FAUX_AO"),G&&Re.push("ZERO_ROOF_RADIUS"),y&&Re.push("HAS_CENTROID"),de>0&&Re.push("FLOOD_LIGHT"),Ee.shouldRenderCutoff&&Re.push("RENDER_CUTOFF"),Ce&&Re.push("RENDER_FRONT_CUTOFF"),ve&&Re.push("RENDER_WALL_MODE");let He=a.renderPass==="shadow",je=a.shadowRenderer,Ue=He&&!!je,lt=He?pt.disabled:pt.backCCW;a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!0);let st=[0,0,0];if(je){let ht=a.style.directionalLight,vt=a.style.ambientLight;ht&&vt&&(st=Ia(a.style,ht,vt)),He||(Re.push("RENDER_SHADOWS"),je.useNormalOffset&&Re.push("NORMAL_OFFSET")),Ye=Re.concat(["SHADOWS_SINGLE_CASCADE"])}
3063let et=Ue?"fillExtrusionDepth":z?"fillExtrusionPattern":"fillExtrusion",it=o.getLayerRenderingStats();for(let ht of c){let vt=t.getTile(ht),gt=vt.getBucket(o);if(!gt||gt.projection.name!==E.projection.name)continue;let Et=!1;je&&(Et=je.getMaxCascadeForTile(ht.toUnwrapped())===0);let xt=a.isTileAffectedByFog(ht),kt=gt.programConfigurations.get(o.id),Tt=!1;if(D&&vt.imageAtlas){let Ct=vt.imageAtlas,ci=h.dY.from(D),Li=ci.getPrimary().scaleSelf(h.o.devicePixelRatio).toString(),ti=ci.getSecondary(),wt=Ct.patternPositions.get(Li),yi=ti?Ct.patternPositions.get(ti.scaleSelf(h.o.devicePixelRatio).toString()):null;Tt=!!wt&&!!yi,wt&&kt.setConstantPatternPositions(wt,yi)}A>0&&(Tt||kt.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Re.push("FILL_EXTRUSION_PATTERN_TRANSITION");let Vt=a.getOrCreateProgram(et,{config:kt,defines:Et?Ye:Re,overrideFog:xt});if(a.terrain&&a.terrain.setupElevationDraw(vt,Vt,{useMeterToDem:!0}),!gt.centroidVertexBuffer){let Ct=Vt.getAttributeLocation(T,"a_centroid_pos");Ct!==-1&&T.vertexAttribI4ui(Ct,0,0,0,0)}!He&&je&&je.setupShadows(vt.tileID.toUnwrapped(),Vt,"vector-tile"),z&&(a.context.activeTexture.set(T.TEXTURE0),vt.imageAtlasTexture&&vt.imageAtlasTexture.bind(T.LINEAR,T.CLAMP_TO_EDGE),kt.updatePaintBuffers());let qt=o.paint.get("fill-extrusion-vertical-gradient"),bi=1/gt.tileToMeter,li;if(He&&je){if(Qf(vt.tileID,gt.maxHeight,a))continue;let Ct=je.calculateShadowPassMatrixFromTile(vt.tileID.toUnwrapped());li=kf(Ct,re,bi,be,Fe,pe)}else{let Ct=a.translatePosMatrix(ht.expandedProjMatrix,vt,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),ci=E.projection.createInversionMatrix(E,ht.canonical);li=z?Nf(Ct,a,qt,O,q,re,bi,ht,vt,te,Fe,pe,K,J,ci,ue,be,A):Lc(Ct,a,qt,O,q,re,bi,ht,te,Fe,pe,K,J,ci,ue,be,de,st,Pe)}a.uploadCommonUniforms(v,Vt,ht.toUnwrapped(),null,Ee);let Xt=gt.segments;if(E.projection.name==="mercator"&&!He&&(Xt=gt.getVisibleSegments(vt.tileID,a.terrain,a.transform.getFrustum(0)),!Xt.get().length))continue;if(it)if(He)for(let Ct of Xt.get())it.numRenderedVerticesInShadowPass+=Ct.primitiveLength;else for(let Ct of Xt.get())it.numRenderedVerticesInTransparentPass+=Ct.primitiveLength;let At=[];(a.terrain||y)&&At.push(gt.centroidVertexBuffer),se&&At.push(gt.layoutVertexExtBuffer),ve&&At.push(gt.wallVertexBuffer),Vt.draw(a,v.gl.TRIANGLES,d,m,_,lt,li,o.id,gt.layoutVertexBuffer,gt.indexBuffer,Xt,o.paint,a.transform.zoom,kt,At)}a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!1)}class Vc{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function jc(a,t,o){if(!(t[2]<1)||o)return[0,0,1];let c=180*a/Math.PI;if(c<15)return[-.5,t[1],t[2]];let d=Math.min(1,Math.max(0,(c-15)/5)),m=d*d*(3-2*d);return[-.5*(1-m)+t[0]*m,t[1],t[2]]}function oo(a,t,o,c,d,m,_,y,v,T,E,P,A,D,z,O,k,N,q,Z,G){let re=t.context,te=re.gl,se=t.transform,K=t.transform.zoom,J=[],oe=a.translate,ue=a.translateAnchor,de=a.edgeRadius,be=Ps(t,a.cutoffFadeRange);E==="clear"?(J.push("CLEAR_SUBPASS"),Z&&(J.push("CLEAR_FROM_TEXTURE"),re.activeTexture.set(te.TEXTURE0),Z.bind(te.LINEAR,te.CLAMP_TO_EDGE))):E==="sdf"?J.push("SDF_SUBPASS"):E==="emissive"&&(J.push("USE_MRT1"),re.activeTexture.set(te.TEXTURE0),Z.bind(te.LINEAR,te.CLAMP_TO_EDGE)),N&&J.push("HAS_CENTROID"),be.shouldRenderCutoff&&J.push("RENDER_CUTOFF");let ve=(Fe,pe,Ee,fe,Pe)=>{let Ce=J;pe.groundRadiusBuffer!=null&&(Ce=J.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));let Re=pe.programConfigurations.get(c.id),Ye=t.isTileAffectedByFog(Fe),He=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:Re,defines:Ce,overrideFog:Ye}),je=((lt,st,et,it,ht,vt,gt,Et,xt,kt,Tt)=>({u_matrix:st,u_opacity:et,u_ao_pass:it?1:0,u_meter_to_tile:ht,u_ao:vt,u_flood_light_intensity:gt,u_flood_light_color:Et,u_attenuation:xt,u_edge_radius:kt,u_fb:0,u_fb_size:Tt,u_dynamic_offset:1}))(0,fe,P,T,Pe,[A,D*Pe],z,O,k,K>=17?0:de*Pe,Z?Z.size[0]:0),Ue=[];N&&Ue.push(pe.hiddenByLandmarkVertexBuffer),pe.groundRadiusBuffer!=null&&Ue.push(pe.groundRadiusBuffer),t.uploadCommonUniforms(re,He,Fe.toUnwrapped(),null,be),He.draw(t,re.gl.TRIANGLES,m,_,y,v,je,c.id,pe.vertexBuffer,pe.indexBuffer,Ee,c.paint,K,Re,Ue)};for(let Fe of d){let pe=o.getTile(Fe),Ee=pe.getBucket(c);if(!Ee||Ee.projection.name!==se.projection.name||!Ee.groundEffect||Ee.groundEffect&&!Ee.groundEffect.hasData())continue;let fe=Ee.groundEffect,Pe=1/Ee.tileToMeter;{let Ce=t.translatePosMatrix(Fe.projMatrix,pe,oe,ue),Re=fe.getDefaultSegment();ve(Fe,fe,Re,Ce,Pe)}if(q)for(let Ce=0;Ce<4;Ce++){let Re=h.e2[Ce](Fe),Ye=o.getTile(Re);
3063if(!Ye)continue;let He=Ye.getBucket(c);if(!He||He.projection.name!==se.projection.name||!He.groundEffect||He.groundEffect&&!He.groundEffect.hasData())continue;let je=He.groundEffect,Ue,lt;Ce===0?(Ue=[-h.ak,0,0],lt=1):Ce===1?(Ue=[h.ak,0,0],lt=0):Ce===2?(Ue=[0,-h.ak,0],lt=3):(Ue=[0,h.ak,0],lt=2);let st=je.regionSegments[lt];st&&(h.bB(he,Fe.projMatrix,Ue),ve(Fe,je,st,t.translatePosMatrix(he,pe,oe,ue),Pe))}}}function Jf(a,t,o,c,d,m,_){c.centroidVertexArray.length===0&&c.createCentroidsBuffer();let y=m?m.findDEMTileFor(o):null;if(!(y&&y.dem||_))return;m&&y&&y.dem&&c.selfDEMTileTimestamp!==y.dem._timestamp&&(c.borderDoneWithNeighborZ=[-1,-1,-1,-1],c.selfDEMTileTimestamp=y.dem._timestamp);let v=(N,q)=>{(N.flags|q.flags)&h.e5?(N.flags|=h.e5,q.flags|=h.e5):(N.flags&=~h.e5,q.flags&=~h.e5)},T=N=>new h.P(Math.ceil((N+h.e6)*h.e7),0),E=(N,q,Z)=>{let G=Math.ceil((N+h.e6)*h.e7),re=Math.floor(Math.max(0,Math.min(h.ak-1,Z))/4);return new h.P(G,re<<5|(3&q)<<3|7)},P=N=>{let q=t.getSource().minzoom,Z=re=>{let te=t.getTileByID(re);if(te&&te.hasData())return te.getBucket(d)},G=[0,-1,1];for(let re of G){if(N.overscaledZ+re<q)continue;let te=Z(N.calculateScaledKey(N.overscaledZ+re));if(te)return te}},A=[0,0,0],D=(N,q)=>(A[0]=Math.min(N.min.y,q.min.y),A[1]=Math.max(N.max.y,q.max.y),A[2]=h.ak-q.min.x>N.max.x?q.min.x-h.ak:N.max.x,A),z=(N,q)=>(A[0]=Math.min(N.min.x,q.min.x),A[1]=Math.max(N.max.x,q.max.x),A[2]=h.ak-q.min.y>N.max.y?q.min.y-h.ak:N.max.y,A),O=[(N,q)=>D(N,q),(N,q)=>D(q,N),(N,q)=>z(N,q),(N,q)=>z(q,N)],k=(N,q,Z,G,re,te,se)=>{if(!m)return 0;let K=[[te?Z:N,te?N:Z,0],[te?Z:q,te?q:Z,0]],J=se<0?h.ak+se:se,oe=[te?J:(N+q)/2,te?(N+q)/2:J,0];return Z===0&&se<0||Z!==0&&se>0?m.getForTilePoints(re,[oe],!0,G):K.push(oe),m.getForTilePoints(o,K,!0,y),Math.max(K[0][2],K[1][2],oe[2])/m.exaggeration()};for(let N=0;N<4;N++){let q=c.borderFeatureIndices[N];if(q.length===0)continue;let Z=h.e2[N](o),G=P(Z);if(!(G&&G instanceof h.e3))continue;let re=m?m.findDEMTileFor(Z):null;if(!(re&&re.dem||_)||(m&&re&&re.dem&&c.borderDEMTileTimestamp[N]!==re.dem._timestamp&&(c.borderDoneWithNeighborZ[N]=-1,c.borderDEMTileTimestamp[N]=re.dem._timestamp),c.borderDoneWithNeighborZ[N]===G.canonical.z))continue;G.centroidVertexArray.length===0&&G.createCentroidsBuffer();let te=(N<2?1:5)-N,se=G.borderDoneWithNeighborZ[te]!==c.canonical.z,K=G.borderFeatureIndices[te],J=0;if(c.canonical.z!==G.canonical.z){for(let be of q)c.showCentroid(c.featuresOnBorder[be]);if(se)for(let be of K)G.showCentroid(G.featuresOnBorder[be]);c.borderDoneWithNeighborZ[N]=G.canonical.z,G.borderDoneWithNeighborZ[te]=c.canonical.z;continue}let oe=new Map,ue=new Set,de=new Set;for(let be=0;be<K.length;be++){let ve=G.featuresOnBorder[K[be]];ve.buildingId!==void 0&&oe.set(ve.buildingId,be)}for(let be of q){let ve=c.featuresOnBorder[be],Fe=c.centroidData.get(ve.centroidDataIndex);if(ve.buildingId===void 0)continue;let pe=oe.get(ve.buildingId);if(pe===void 0)continue;let Ee=G.featuresOnBorder[K[pe]],fe=G.centroidData.get(Ee.centroidDataIndex);ue.add(be),de.add(pe),_&&v(Fe,fe);let Pe=Fe.groupCentroidPos.x!==0||Fe.groupCentroidPos.y!==0?Fe.groupCentroidPos:ve.centroid(),Ce=fe.groupCentroidPos.x!==0||fe.groupCentroidPos.y!==0?fe.groupCentroidPos:Ee.centroid(),Re=N<2?Math.round((Pe.y+Ce.y)/2):Math.round((Pe.x+Ce.x)/2),Ye=ve.intersectsCount()>1||Ee.intersectsCount()>1;{let He=0;if(re&&re.dem&&!Ye){let je=O[N](Fe,fe),Ue=N%2?h.ak-1:0;He=k(je[0],Math.min(h.ak-1,je[1]),Ue,re,Z,N<2,je[2])}Fe.centroidXY=E(He,N,Re),fe.centroidXY=E(He,te,Re)}if(c.writeCentroidToBuffer(Fe),G.writeCentroidToBuffer(fe),ve.buildingId!==void 0){for(let He of c.centroidData)He.buildingId===ve.buildingId&&He!==Fe&&(He.centroidXY=Fe.centroidXY,c.writeCentroidToBuffer(He));for(let He of G.centroidData)He.buildingId===ve.buildingId&&He!==fe&&(He.centroidXY=fe.centroidXY,G.writeCentroidToBuffer(He))}}for(let be of q){if(ue.has(be))continue;let ve=c.featuresOnBorder[be],Fe=c.centroidData.get(ve.centroidDataIndex),pe=ve.borders[N],Ee;for(;J<K.length;){if(de.has(J)){J++;continue}Ee=G.featuresOnBorder[K[J]];let fe=Ee.borders[te];if(fe[1]>pe[0]+3||fe[0]>pe[0]-3)break;G.showCentroid(Ee),J++}if(Ee&&J<K.length){let fe=J,Pe=0;for(;;)if(de.has(J)){if(++J===K.length)break;Ee=G.featuresOnBorder[K[J]]}else{if(Ee.borders[te][0]>pe[1]-3||(Pe++,++J===K.length))break;Ee=G.featuresOnBorder[K[J]]}for(;fe<K.length&&de.has(fe);)fe++;if(fe>=K.length){c.showCentroid(ve);continue}Ee=G.featuresOnBorder[K[fe]];let Ce=!1;if(Pe>=1){let He=Ee.borders[te];Math.abs(pe[0]-He[0])<3&&Math.abs(pe[1]-He[1])<3&&(Pe=1,Ce=!0,J=fe+1)}else if(Pe===0){c.showCentroid(ve);continue}let Re=G.centroidData.get(Ee.centroidDataIndex);_&&Ce&&v(Fe,Re);let Ye=ve.intersectsCount()>1||Ee.intersectsCount()>1;
3063if(Pe>1)J=fe,Fe.centroidXY=Re.centroidXY=new h.P(0,0);else if(re&&re.dem&&!Ye){let He=O[N](Fe,Re),je=N%2?h.ak-1:0,Ue=k(He[0],Math.min(h.ak-1,He[1]),je,re,Z,N<2,He[2]);Fe.centroidXY=Re.centroidXY=T(Ue)}else Ye?Fe.centroidXY=Re.centroidXY=new h.P(0,0):(Fe.centroidXY=c.encodeBorderCentroid(ve),Re.centroidXY=G.encodeBorderCentroid(Ee));c.writeCentroidToBuffer(Fe),G.writeCentroidToBuffer(Re)}else c.showCentroid(ve)}c.borderDoneWithNeighborZ[N]=G.canonical.z,G.borderDoneWithNeighborZ[te]=c.canonical.z}(c.needsCentroidUpdate||!c.centroidVertexBuffer&&c.centroidVertexArray.length!==0)&&c.uploadCentroid(a)}let Kf=[1,0,0],El=[0,1,0],ng=[0,0,1];function Qf(a,t,o){let c=o.transform,d=o.shadowRenderer;if(!d)return!0;let m=o.frameCounter,_=o.currentShadowCascade,y=o._shadowCullCache;if(!y||y.frame!==m||y.cascade!==_){let N=c.tileSize*d._cascades[_].scale,q=c.scaleZoom(N),Z=d.shadowDirection,G=[Z[0],Z[1],-Z[2]],re=[Kf,El,ng,G,[G[0],0,G[2]],[0,G[1],G[2]]];y={frame:m,cascade:_,cameraFrustum:h.cn.fromInvProjectionMatrix(c.invProjMatrix,c.worldSize,q,c.projection.name!=="globe"),edges:re,shadowDir:G,ws:N,zoom:q},o._shadowCullCache=y}let{cameraFrustum:v,edges:T,shadowDir:E,ws:P,zoom:A}=y,D=t;if(c.elevation){let N=c.elevation.getMinMaxForTile(a);N&&(D+=N.max)}D/=h.e8(c.center.lat,A);let z=d.computeSimplifiedTileShadowVolume(a.toUnwrapped(),D,P,E);if(!z)return!1;let{vertices:O,planes:k}=z;return v.intersectsPrecise(O,k,T)===0||d.getCurrentCascadeFrustum().intersectsPrecise(O,k,T)===0}let em=(a,t,o,c,d,m,_,y,v,T=[0,0,1])=>({u_matrix:a,u_normal_matrix:t,u_opacity:o,u_faux_facade_ao_intensity:c,u_camera_pos:d,u_tile_to_meter:m,u_facade_emissive_chance:_,u_flood_light_color:y,u_flood_light_intensity:v,u_front_cutoff_params:T}),th=a=>({u_matrix:a}),Fd=a=>({u_matrix:a}),Bd=new Float32Array(16),Oa=new Float32Array(16);function Fa(a){let{painter:t,source:o,layer:c,coords:d}=a,m=a.defines,_=t.context,y=t.renderPass==="shadow",v=t.renderPass==="light-beam",T=t.shadowRenderer,E=h.e8(t.transform.center.lat,t.transform.zoom),P=Ps(t,c.paint.get("building-cutoff-fade-range"));P.shouldRenderCutoff&&(m=m.concat("RENDER_CUTOFF"));let A=c.paint.get("building-front-cutoff"),D=A[2]<1&&!t.terrain,z=jc(t.transform.pitch,A,!!t.terrain);D&&(m=m.concat("RENDER_FRONT_CUTOFF"),t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,A[0])),a.floodLightIntensity>0&&(m=m.concat("FLOOD_LIGHT"));for(let O of d){let k=o.getTile(O),N=k.getBucket(c);if(!N)continue;T&&T.getMaxCascadeForTile(O.toUnwrapped())===0&&(m=m.concat("SHADOWS_SINGLE_CASCADE"));let q=N.programConfigurations.get(c.id),Z,G,re=t.translatePosMatrix(O.expandedProjMatrix,k,[0,0],"map");h.cE(Bd,re,[1,1,a.verticalScale]);let te=Bd,se;if(y&&T){if(Qf(k.tileID,N.maxHeight*E,t))continue;let J=T.calculateShadowPassMatrixFromTile(k.tileID.toUnwrapped());h.cE(J,J,[1,1,a.verticalScale]),se=Fd(J),Z=G=t.getOrCreateProgram("buildingDepth",{config:q,defines:m,overrideFog:!1})}else if(v)Z=G=t.getOrCreateProgram("buildingBloom",{config:q,defines:m,overrideFog:!1}),se=th(te);else{let J=t.transform.calculatePosMatrix(O.toUnwrapped(),t.transform.worldSize);h.cE(J,J,[1,1,a.verticalScale]),h.cE(Oa,J,[1,-1,1/E]),h.ba(Oa,Oa),h.e9(Oa,Oa);let oe=Oa,ue=t.transform.getFreeCameraOptions().position,de=1<<O.canonical.z;if(se=em(te,oe,a.opacity,a.facadeAOIntensity,[((ue.x-O.wrap)*de-O.canonical.x)*h.ak,(ue.y*de-O.canonical.y)*h.ak,ue.z*de*h.ak],N.tileToMeter,a.facadeEmissiveChance,a.floodLightColor,a.floodLightIntensity,z),G=t.getOrCreateProgram("building",{config:q,defines:m,overrideFog:!1}),a.depthOnly===!0)Z=G;else{let be=m.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);Z=t.getOrCreateProgram("building",{config:q,defines:be,overrideFog:!1})}T&&(T.setupShadowsFromMatrix(J,G,!0),Z!==G&&T.setupShadowsFromMatrix(J,Z,!0))}let K=(J,oe)=>{if(v){let ue=J.entranceBloom;oe.draw(t,_.gl.TRIANGLES,a.depthMode,yt.disabled,a.blendMode,pt.disabled,se,c.id,ue.layoutVertexBuffer,ue.indexBuffer,ue.segmentsBucket,c.paint,t.transform.zoom,q,[ue.layoutAttenuationBuffer,ue.layoutColorBuffer])}else{let ue=J.segmentsBucket,de=[J.layoutNormalBuffer,J.layoutCentroidBuffer,J.layoutColorBuffer,J.layoutFloodLightDataBuffer];J.layoutFacadePaintBuffer&&(de=de.concat([J.layoutFacadeDataBuffer,J.layoutFacadeVerticalRangeBuffer,J.layoutFacadePaintBuffer])),oe.draw(t,_.gl.TRIANGLES,a.depthMode,yt.disabled,a.blendMode,y?pt.disabled:pt.backCW,se,c.id,J.layoutVertexBuffer,J.indexBuffer,ue,c.paint,t.transform.zoom,q,de)}};t.uploadCommonUniforms(_,G,O.toUnwrapped(),null,P),N.buildingWithoutFacade&&K(N.buildingWithoutFacade,G),N.buildingWithFacade&&(Z!==G&&t.uploadCommonUniforms(_,Z,O.toUnwrapped(),null,P),K(N.buildingWithFacade,Z))}}
3063function Il(a,t,o,c,d,m,_,y,v,T,E,P,A,D){let z=a.context.gl,O=a.depthModeForSublayer(1,nt.ReadOnly,z.LEQUAL,!0),k=.1*(1-(N=E))+3*N;var N;let q=a._showOverdrawInspector,Z=P,G=new Vc;q||oo(G,a,t,o,c,O,new yt({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),new _t([z.ONE,z.ONE,z.ONE,z.ONE],h.C.transparent,[!1,!1,!1,!0],z.MIN),pt.disabled,d,"sdf",m,_,y,v,T,k,Z,!1,void 0);{let re=q?yt.disabled:new yt({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),te=q?a.colorModeForRenderPass():new _t([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],h.C.transparent,[!0,!0,!0,!0]);oo(G,a,t,o,c,O,re,te,pt.disabled,d,"color",m,_,y,v,T,k,Z,!1,void 0)}}let Ns=.05,tm=(a,t,o,c,d,m,_,y,v,T,E,P)=>({u_matrix:a,u_normalize_matrix:t,u_globe_matrix:o,u_merc_matrix:c,u_grid_matrix:d,u_tl_parent:m,u_scale_parent:T,u_fade_t:E.mix,u_opacity:E.opacity,u_image0:0,u_image1:1,u_raster_elevation:P,u_zoom_transition:_,u_merc_center:y,u_cutoff_params:v}),im=(a,t,o,c,d,m,_,y,v,T)=>({u_particle_texture:a,u_particle_texture_side_len:t,u_tile_offset:o,u_velocity:c,u_color_ramp:m,u_velocity_res:d,u_max_speed:_,u_uv_offset:y,u_data_scale:[255*v[0],255*v[1]],u_data_offset:T,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ns,Ns]}),nm=(a,t,o,c,d,m,_,y,v,T)=>({u_particle_texture:a,u_particle_texture_side_len:t,u_velocity:o,u_velocity_res:c,u_max_speed:d,u_speed_factor:m,u_reset_rate:_,u_rand_seed:Math.random(),u_uv_offset:y,u_data_scale:[255*v[0],255*v[1]],u_data_offset:T,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ns,Ns]});var rm=h.ea([{name:"a_index",type:"Int16",components:1}]);class om{constructor(t,o,c,d){let m={width:c[0],height:c[1],data:null},_=t.gl;this.targetColorTexture=new h.T(t,m,_.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new h.T(t,m,_.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(o,d),this.lastInvalidatedAt=0}updateParticleTexture(t,o){if(this.particleTextureDimension===o.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());let c=this.context.gl,d=o.width*o.height;this.particleTexture0=new h.T(this.context,o,c.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new h.T(this.context,o,c.RGBA8,{premultiply:!1,useMipmap:!1});let m=new h.eb;m.reserve(d);for(let _=0;_<d;_++)m.emplaceBack(_);this.particleIndexBuffer=this.context.createVertexBuffer(m,rm.members,!0),this.particleSegment=h.dB.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=o.width}update(t){return!(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=h.o.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function rg(a,t,o){if(!a)return null;let c=t.getTextureDescriptor(a,o,!0);if(!c)return null;let{texture:d,mix:m,offset:_,tileSize:y,buffer:v,format:T}=c;if(!d||!T)return null;let E=!1;return T==="uint32"&&(E=!0,m[3]=0,m=Pd(h.ec,m,[0,o.paint.get("raster-particle-max-speed")]),_=Wu(h.ec,_,[0,o.paint.get("raster-particle-max-speed")])),{texture:d,textureOffset:[v/(y+2*v),y/(y+2*v)],tileSize:y,scalarData:E,scale:m,offset:_,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[T]]}}function sm(a){let t=a._nearZ,o=a.projection.farthestPixelDistance(a),c=o-t,d=.2*a.height,m=t+d;return[t,o,(m-d-t)/c,(m-t)/c]}var am=`#ifdef RASTER_ARRAY
3064uniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}
3065#endif
3066uniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}`;Ac["_prelude_raster_particle.glsl"]||(Ac["_prelude_raster_particle.glsl"]=am);var or={building:Ot(`#include "_prelude_fog.fragment.glsl"
3067#include "_prelude_shadow.fragment.glsl"
3068#include "_prelude_lighting.glsl"
3069const float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;
3070#ifdef RENDER_FRONT_CUTOFF
3071in float v_front_cutoff_opacity;
3072#endif
3073#ifdef INDICATOR_CUTOUT
3074#ifdef FEATURE_CUTOUT
3075in vec4 v_ground_roof;
3076#endif
3077#endif
3078#ifdef BUILDING_FAUX_FACADE
3079in lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;
3080#endif
3081#ifdef RENDER_SHADOWS
3082in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
3083#endif
3084#ifdef FLOOD_LIGHT
3085in highp float v_flood_radius;in float v_has_flood_light;
3086#endif
3087uniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}
3088#ifdef BUILDING_FAUX_FACADE
3089highp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;
3090#if 0
3091if (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;
3092#else
3093if (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;
3094#endif
3095return out_color;}
3096#endif
3097vec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;
3098#ifdef BUILDING_FAUX_FACADE
3099if (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}
3100#endif
3101vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;
3102#ifdef RENDER_SHADOWS
3103#ifdef RENDER_CUTOFF
3104shadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}
3105#else
3106shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
3107#endif
3108#else
3109shadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));
3110#endif
3111color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);
3112#ifdef FLOOD_LIGHT
3113float flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);
3114#endif
3115color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);
3116#ifdef FOG
3117color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));
3118#endif
3119color*=u_opacity;
3120#ifdef INDICATOR_CUTOUT
3121#ifdef FEATURE_CUTOUT
3122{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}
3123#else
3124color=applyCutout(color,v_pos.z);
3125#endif
3126#endif
3127#ifdef RENDER_FRONT_CUTOFF
3128if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}
3129#endif
3130#ifdef FEATURE_CUTOUT
3131color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);
3132#endif
3133glFragColor=color;
3134#ifdef DEBUG_SHOW_NORMALS
3135color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;
3136#endif
3137#ifdef OVERDRAW_INSPECTOR
3138glFragColor=vec4(1.0);
3139#endif
3140HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
3141#include "_prelude_shadow.vertex.glsl"
3142in vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;
3143#ifdef FLOOD_LIGHT
3144in int a_flood_light_wall_radius_1i16;
3145#endif
3146#ifdef BUILDING_FAUX_FACADE
3147in uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;
3148#endif
3149uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;
3150#ifdef RENDER_FRONT_CUTOFF
3151uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;
3152#endif
3153#ifdef INDICATOR_CUTOUT
3154#ifdef FEATURE_CUTOUT
3155out vec4 v_ground_roof;
3156#endif
3157#endif
3158out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;
3159#ifdef BUILDING_FAUX_FACADE
3160out lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;
3161#endif
3162#ifdef RENDER_SHADOWS
3163uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;
3164#endif
3165#ifdef FLOOD_LIGHT
3166out highp float v_flood_radius;out float v_has_flood_light;
3167#endif
3168const float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
3169#ifdef BUILDING_FAUX_FACADE
3170mat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}
3171#endif
3172#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive
3173#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive
3174void main() {
3175#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive
3176#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive
3177#ifdef FLOOD_LIGHT
3178v_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);
3179#endif
3180vec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);
3181#ifdef BUILDING_FAUX_FACADE
3182vec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}
3183#endif
3184v_pos=a_pos_3f;
3185#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
3186float halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;
3186vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;
3187#endif
3188#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
3189vec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);
3190#endif
3191#ifdef RENDER_CUTOFF
3192v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;
3193#endif
3194#ifdef RENDER_SHADOWS
3195vec3 shadow_pos=v_pos;
3196#ifdef NORMAL_OFFSET
3197vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();
3198#endif
3199v_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);
3200#endif
3201#ifdef FOG
3202v_fog_pos=fog_position(v_pos);
3203#endif
3204#ifdef RENDER_FRONT_CUTOFF
3205v_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}
3206#endif
3207gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;
3208#ifdef INDICATOR_CUTOUT
3209#ifdef FEATURE_CUTOUT
3210vec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);
3211#endif
3212#endif
3213}`),buildingBloom:Ot(`in vec4 v_color_emissive;
3214#pragma mapbox: define-attribute highp vec4 bloom_attenuation
3215#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
3216float saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;
3217#ifdef HAS_ATTRIBUTE_a_bloom_attenuation
3218float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);
3219#endif
3220#ifdef RENDER_CUTOFF
3221opacity*=v_cutoff_opacity;
3222#endif
3223glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f;
3224#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive
3225#pragma mapbox: define-attribute highp vec4 bloom_attenuation
3226out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
3227#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive
3228#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
3229#ifdef HAS_ATTRIBUTE_a_part_color_emissive
3230vec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);
3231#else
3232v_color_emissive=vec4(1.0);
3233#endif
3234gl_Position=u_matrix*vec4(a_pos_3f,1.0);
3235#ifdef RENDER_CUTOFF
3236v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
3237#endif
3238}`),buildingDepth:Ot("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:Ot(`#include "_prelude_fog.fragment.glsl"
3239#include "_prelude_lighting.glsl"
3240uniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;
3241#ifdef LIGHTING_3D_MODE
3242out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;
3243#endif
3244#ifdef FOG
3245highp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));
3246#endif
3247glFragColor=vec4(out_color*color.a,color.a);
3248#ifdef OVERDRAW_INSPECTOR
3249glFragColor=vec4(1.0);
3250#endif
3251HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
3252uniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;
3253#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
3254in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;
3255#ifdef PROJECTION_GLOBE_VIEW
3256vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;
3257#ifdef FOG
3258v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
3259#endif
3260#else
3261uv=vec2(a_texture_pos)/8192.0;
3261gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);
3262#ifdef FOG
3263v_fog_pos=fog_position(vec2(a_pos));
3264#endif
3265#endif
3266v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:Ot("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",`#include "_prelude_raster_particle.glsl"
3267in int a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(
3268mod(float(a_index),u_particle_texture_side_len),float(a_index)/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:Ot("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Ot(`#include "_prelude_raster_particle.glsl"
3269uniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return  clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(
3270linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)
3271);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),snowParticle:Ot("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}",`
3272in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; 
3273uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; 
3274uniform float u_horizontalOscillationRate; 
3275uniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);
3275simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+
3276localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}`),rainParticle:Ot("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}",`
3277in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; 
3278uniform float u_velocity; 
3279uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; 
3280pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+
3281localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}`),vignette:Ot("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}")};Ot(am,"");let og=h.ea([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),Gc=h.ea([{type:"Float32",name:"a_pos_2f",components:2}]);class sg{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,o){let c=t.getOrCreateProgram("vignette");
3281if(!this.vignetteVx||!this.vignetteIdx){let _=new h.ee,y=new h.dF;_.emplaceBack(-1,-1),_.emplaceBack(1,-1),_.emplaceBack(1,1),_.emplaceBack(-1,1),y.emplaceBack(0,1,2),y.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(_,Gc.members),this.vignetteIdx=t.context.createIndexBuffer(y)}let d=h.dB.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,c);let _={u_vignetteShape:(m={vignetteShape:[o.start,o.range,Math.pow(10,o.fadePower)],vignetteColor:[o.color.r,o.color.g,o.color.b,o.color.a*o.strength]}).vignetteShape,u_vignetteColor:m.vignetteColor};c.draw(t,t.context.gl.TRIANGLES,nt.disabled,yt.disabled,_t.alphaBlended,pt.disabled,_,"vignette",this.vignetteVx,this.vignetteIdx,d)}var m}}class gi{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,o){let c=t.getFreeCameraOptions().position,d=c.toAltitude(),m=c.toLngLat(),_=h.am(m.lng),y=h.am(m.lat),v=t.pixelsPerMeter/o,T=_*h.eg,E=h.eg*Math.log(Math.tan(Math.PI/4+y/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{let P=-this._offsetYPrev+E,A=-this._elevationPrev+d;this._accumulatedOffsetX+=(-this._offsetXPrev+T)*v,this._accumulatedOffsetY+=P*v,this._accumulatedElevation+=A*v,this._offsetXPrev=T,this._offsetYPrev=E,this._elevationPrev=d}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Rt(a,t){return[-(a[0]-Math.floor(a[0]/t)*t),-(a[1]-Math.floor(a[1]/t)*t),-(a[2]-Math.floor(a[2]/t)*t)]}function kd(a){let t=h.ef(1323123451230),o=[];for(let c=0;c<a;++c){let d=2*t()-1,m=2*t()-1,_=2*t()-1;o.push(h.cU(d,m,_))}return o}function Zn(a,t,o,c,d){let m=h.aB((d-o)/(c-o),0,1);return(1-m)*a+m*t}class Us{constructor(t){this._movement=new gi,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new sg,this._ppmScaleFactor=t}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(t,o){let c=t.transform;this._movement.update(c,this._ppmScaleFactor);let d=c.starsProjMatrix,m=h.bP([]);h.bR(m,m,h.am(90)-c._pitch),h.bQ(m,m,-c.angle);let _=h.bV(new Float32Array(16),m),y=new Float32Array([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),v=h.e9([],y),T=h.aC([],v,_),E=Date.now()/1e3;return this._accumulatedTimeFromStart+=(E-this._prevTime)*o,this._prevTime=E,{projectionMatrix:d,modelviewMatrix:T}}}let Ba=h.ea([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]),Lo={building:a=>({u_matrix:new h.c3(a),u_normal_matrix:new h.c3(a),u_opacity:new h.c1(a),u_faux_facade_ao_intensity:new h.c1(a),u_camera_pos:new h.c0(a),u_tile_to_meter:new h.c1(a),u_facade_emissive_chance:new h.c1(a),u_flood_light_color:new h.c0(a),u_flood_light_intensity:new h.c1(a),u_front_cutoff_params:new h.c0(a)}),buildingBloom:a=>({u_matrix:new h.c3(a)}),buildingDepth:a=>({u_matrix:new h.c3(a)}),rasterParticle:a=>({u_matrix:new h.c3(a),u_normalize_matrix:new h.c3(a),u_globe_matrix:new h.c3(a),u_merc_matrix:new h.c3(a),u_grid_matrix:new h.dq(a),u_tl_parent:new h.c2(a),u_scale_parent:new h.c1(a),u_fade_t:new h.c1(a),u_opacity:new h.c1(a),u_image0:new h.b$(a),u_image1:new h.b$(a),u_raster_elevation:new h.c1(a),u_zoom_transition:new h.c1(a),u_merc_center:new h.c2(a),u_cutoff_params:new h.cS(a)}),rasterParticleTexture:a=>({u_texture:new h.b$(a),u_opacity:new h.c1(a)}),rasterParticleDraw:a=>({u_particle_texture:new h.b$(a),u_particle_texture_side_len:new h.c1(a),u_tile_offset:new h.c2(a),u_velocity:new h.b$(a),u_color_ramp:new h.b$(a),u_velocity_res:new h.c2(a),u_max_speed:new h.c1(a),u_uv_offset:new h.c2(a),u_data_scale:new h.c2(a),u_data_offset:new h.c1(a),u_particle_pos_scale:new h.c1(a),u_particle_pos_offset:new h.c2(a)}),rasterParticleUpdate:a=>({u_particle_texture:new h.b$(a),u_particle_texture_side_len:new h.c1(a),u_velocity:new h.b$(a),u_velocity_res:new h.c2(a),u_max_speed:new h.c1(a),u_speed_factor:new h.c1(a),u_reset_rate:new h.c1(a),u_rand_seed:new h.c1(a),u_uv_offset:new h.c2(a),u_data_scale:new h.c2(a),u_data_offset:new h.c1(a),u_particle_pos_scale:new h.c1(a),u_particle_pos_offset:new h.c2(a)}),snowParticle:a=>({u_modelview:new h.c3(a),u_projection:new h.c3(a),u_time:new h.c1(a),u_cam_pos:new h.c0(a),u_velocityConeAperture:new h.c1(a),u_velocity:new h.c1(a),u_horizontalOscillationRadius:new h.c1(a),u_horizontalOscillationRate:new h.c1(a),u_boxSize:new h.c1(a),u_billboardSize:new h.c1(a),u_simpleShapeParameters:new h.c2(a),u_screenSize:new h.c2(a),u_thinningCenterPos:new h.c2(a),u_thinningShape:new h.c0(a),u_thinningAffectedRatio:new h.c1(a),u_thinningParticleOffset:new h.c1(a),u_particleColor:new h.cS(a),u_direction:new h.c0(a)}),rainParticle:a=>({u_modelview:new h.c3(a),u_projection:new h.c3(a),u_time:new h.c1(a),u_cam_pos:new h.c0(a),u_texScreen:new h.b$(a),u_velocityConeAperture:new h.c1(a),u_velocity:new h.c1(a),u_boxSize:new h.c1(a),u_rainDropletSize:new h.c2(a),u_distortionStrength:new h.c1(a),u_rainDirection:new h.c0(a),u_color:new h.cS(a),u_screenSize:new h.c2(a),u_thinningCenterPos:new h.c2(a),u_thinningShape:new h.c0(a),u_thinningAffectedRatio:new h.c1(a),u_thinningParticleOffset:new h.c1(a),u_shapeDirectionalPower:new h.c1(a),u_shapeNormalPower:new h.c1(a),u_mode:new h.c1(a)}),vignette:a=>({u_vignetteShape:new h.c0(a),u_vignetteColor:new h.cS(a)})},so={drawBuilding:function(a,t,o,c){a.currentLayer<a.firstLightBeamLayer&&(a.firstLightBeamLayer=a.currentLayer);let d=o.paint.get("building-ambient-occlusion-ground-intensity"),m=o.paint.get("building-ambient-occlusion-ground-radius"),_=o.paint.get("building-ambient-occlusion-ground-attenuation"),y=o.paint.get("building-opacity");if(y<=0)return;let v=d>0&&m>0,T=!0,E=o.paint.get("building-vertical-scale");if(E<=0)return;a.shadowRenderer||(T=!1);let P=a.conflationActive&&a.style.isLayerClipped(o,t.getSource()),A=a.style.order.indexOf(o.fqid);if(function(D,z,O,k,N,q){for(let Z of q){let G=z.getTile(Z).getBucket(O);G&&(N&&G.updateReplacement(Z,D.replacementSource,k),G.uploadUpdatedIndexBuffer(D.context))}}(a,t,o,A,P,c),function(D,z,O,k){for(let N of k){let q=z.getTile(N).getBucket(O);q&&q.needsEvaluation()&&q.uploadUpdatedColorBuffer(D.context)}}(a,t,o,c),o.resetLayerRenderingStats(a),a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!0),a.renderPass==="shadow"&&a.shadowRenderer){let D=[],z=a.shadowRenderer.getShadowPassDepthMode();Fa({painter:a,source:t,layer:o,coords:c,defines:D,blendMode:_t.disabled,depthMode:z,opacity:y,verticalScale:E,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(a.renderPass==="translucent"){let D=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];T&&(D=D.concat("RENDER_SHADOWS")),a.shadowRenderer&&a.shadowRenderer.useNormalOffset&&(D=D.concat("NORMAL_OFFSET"));let z=o.paint.get("building-facade-emissive-chance"),O=o.paint.get("building-ambient-occlusion-intensity"),k=o.paint.get("building-flood-light-intensity"),N=o.paint.get("building-flood-light-color-use-theme").
3281constantOr("default")==="none",q=o.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(N?null:o.lut).toArray01().slice(0,3),Z=o.paint.get("building-flood-light-ground-attenuation"),G=k>0,re=new nt(a.context.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D);y<1&&Fa({painter:a,source:t,layer:o,coords:c,defines:D,blendMode:_t.disabled,depthMode:re,opacity:y,verticalScale:E,facadeEmissiveChance:z,facadeAOIntensity:O,floodLightIntensity:k,floodLightColor:q,depthOnly:!0});let te=a.colorModeForRenderPass();Fa({painter:a,source:t,layer:o,coords:c,defines:D,blendMode:te,depthMode:re,opacity:y,verticalScale:E,facadeEmissiveChance:z,facadeAOIntensity:O,floodLightIntensity:k,floodLightColor:q});let se=o.paint.get("building-front-cutoff");jc(a.transform.pitch,se,!!a.terrain),v&&Il(a,t,o,c,!0,y,d,m,k,q,_,P),G&&Il(a,t,o,c,!1,y,d,m,k,q,Z,P)}else if(a.renderPass==="light-beam"){let D=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],z=new nt(a.context.gl.LEQUAL,nt.ReadOnly,a.depthRangeFor3D);Fa({painter:a,source:t,layer:o,coords:c,defines:D,blendMode:_t.alphaBlended,depthMode:z,opacity:y,verticalScale:E,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!1),a.resetStencilClippingMasks()},drawRasterParticle:function(a,t,o,c,d,m){a.renderPass==="offscreen"&&function(_,y,v,T){if(!T.length)return;let E=_.context,P=E.gl,A=y.getSource();if(!(A instanceof Ht))return;let D=Math.ceil(Math.sqrt(v.paint.get("raster-particle-count"))),z=v.particlePositionRGBAImage;if(!z||z.width!==D){let Z=function(G){let re=G*G,te=new Uint8Array(4*re),se=.9090909090909091;for(let K=0;K<re;K++){let J=se*(h.ed(2*K+0)+Ns),oe=se*(h.ed(2*K+1)+Ns),ue=255*J%1,de=255*oe%1,be=ue,ve=oe-de/255,Fe=de;te[4*K+0]=255*(J-ue/255),te[4*K+1]=255*be,te[4*K+2]=255*ve,te[4*K+3]=255*Fe}return te}(D);z=v.particlePositionRGBAImage=new h.q({width:D,height:D},Z)}let O=v.particleFramebuffer;O?O.width!==D&&(O.destroy(),O=v.particleFramebuffer=E.createFramebuffer(D,D,1,null)):O=v.particleFramebuffer=E.createFramebuffer(D,D,1,null);let k=[];for(let Z of T){let G=y.getTile(Z);if(!(G instanceof at))continue;let re=rg(G,A,v);if(!re)continue;let te=[G.tileSize,G.tileSize],se=v.tileFramebuffer;se||(se=v.tileFramebuffer=E.createFramebuffer(te[0],te[1],1,null));let K=G.rasterParticleState;K||(K=G.rasterParticleState=new om(E,Z,te,z));let J=K.update(v.lastInvalidatedAt);K.particleTextureDimension!==D&&K.updateParticleTexture(Z,z);let oe=K.targetColorTexture;K.targetColorTexture=K.backgroundColorTexture,K.backgroundColorTexture=oe;let ue=K.particleTexture0;K.particleTexture0=K.particleTexture1,K.particleTexture1=ue,k.push([Z,re,K,J])}if(k.length===0)return;let N=h.o.now(),q=v.previousDrawTimestamp?.001*(N-v.previousDrawTimestamp):.0167;if(v.previousDrawTimestamp=N,v.hasColorMap()){E.activeTexture.set(P.TEXTURE0+2);let Z=v.colorRampTexture;Z||(Z=v.colorRampTexture=new h.T(E,v.colorRamp,P.RGBA8)),Z.bind(P.LINEAR,P.CLAMP_TO_EDGE)}E.bindFramebuffer.set(v.tileFramebuffer.framebuffer),function(Z,G,re){let te=Z.context,se=te.gl,K=G.tileFramebuffer;te.activeTexture.set(se.TEXTURE0);let J={u_texture:0,u_opacity:1.05*(ue=G.paint.get("raster-particle-fade-opacity-factor"))/(ue+.05)},oe=Z.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var ue;for(let de of re){let[,,be,ve]=de;K.colorAttachment0.set(be.targetColorTexture.texture),te.viewport.set([0,0,K.width,K.height]),te.clear({color:h.C.transparent}),ve&&(be.backgroundColorTexture.bind(se.NEAREST,se.CLAMP_TO_EDGE),oe.draw(Z,se.TRIANGLES,nt.disabled,yt.disabled,_t.alphaBlended,pt.disabled,J,G.id,Z.viewportBuffer,Z.quadTriangleIndexBuffer,Z.viewportSegments))}}(_,v,k),function(Z,G,re,te){let se=Z.context,K=se.gl,J=re.tileFramebuffer,oe=Z.transform.projection.name==="globe",ue=re.paint.get("raster-particle-max-speed");for(let de of te){let[be,ve,Fe]=de;se.activeTexture.set(K.TEXTURE0+0),ve.texture.bind(K.LINEAR,K.CLAMP_TO_EDGE),J.colorAttachment0.set(Fe.targetColorTexture.texture);let pe=Z.getOrCreateProgram("rasterParticleDraw",{defines:ve.defines,overrideFog:!1});se.activeTexture.set(K.TEXTURE0+1);let Ee=ve.scalarData?[]:[0,1,2,3].map(Ce=>h.e2[Ce](be));Ee.push(be);let fe=be.canonical.x,Pe=be.canonical.y;for(let Ce of Ee){let Re=G.getTile(oe?Ce.wrapped():Ce);if(!Re)continue;let Ye=Re.rasterParticleState;if(!Ye)continue;let He=Ce.canonical.x+(1<<Ce.canonical.z)*(Ce.wrap-be.wrap),je=Ce.canonical.y;Ye.particleTexture0.bind(K.NEAREST,K.CLAMP_TO_EDGE);let Ue=im(1,Ye.particleTexture0.size[0],[He-fe,je-Pe],0,ve.texture.size,2,ue,ve.textureOffset,ve.scale,ve.offset);pe.draw(Z,K.POINTS,nt.disabled,yt.disabled,_t.alphaBlended,pt.disabled,Ue,re.id,Ye.particleIndexBuffer,void 0,Ye.particleSegment)}}}(_,y,v,k),E.bindFramebuffer.set(v.particleFramebuffer.framebuffer),function(Z,G,re,te){let se=Z.context,K=se.gl,J=G.paint.get("raster-particle-max-speed"),oe=te*G.paint.get("raster-particle-speed-factor")*.15,ue=function(be){return Math.pow(be,6)}(.01+1*G.paint.get("raster-particle-reset-rate-factor")),de=G.particleFramebuffer;se.viewport.set([0,0,de.width,de.height]);for(let be of re){let[,ve,Fe]=be;se.activeTexture.set(K.TEXTURE0+0),ve.texture.bind(K.LINEAR,K.CLAMP_TO_EDGE),se.activeTexture.set(K.TEXTURE0+1);let pe=Fe.particleTexture0;
3281pe.bind(K.NEAREST,K.CLAMP_TO_EDGE);let Ee=nm(1,pe.size[0],0,ve.texture.size,J,oe,ue,ve.textureOffset,ve.scale,ve.offset);de.colorAttachment0.set(Fe.particleTexture1.texture),se.clear({color:h.C.transparent}),Z.getOrCreateProgram("rasterParticleUpdate",{defines:ve.defines}).draw(Z,K.TRIANGLES,nt.disabled,yt.disabled,_t.unblended,pt.disabled,Ee,G.id,Z.viewportBuffer,Z.quadTriangleIndexBuffer,Z.viewportSegments)}}(_,v,k,q)}(a,t,o,c),a.renderPass==="translucent"&&(function(_,y,v,T){let E=_.context,P=E.gl,A=y.getSource().tileSize,D=5*(1-h.ag(h.cx,h.cx+1,_.transform.zoom))*A+v.paint.get("raster-particle-elevation"),z=!_.options.moving,O=_.transform.projection.name==="globe";if(!T.length)return;let[k,N]=_.stencilConfigForOverlap(T),q=[];O&&q.push("PROJECTION_GLOBE_VIEW");let Z=_.stencilModeFor3D();for(let G of N){let re=G.toUnwrapped(),te=y.getTile(G);if(!te.rasterParticleState)continue;let se=te.rasterParticleState,K=100;te.registerFadeDuration(K);let J=y.findLoadedParent(G,0),oe=Qe(te,J,y,_.transform,K),ue,de;_.terrain&&_.terrain.prepareDrawTile(),E.activeTexture.set(P.TEXTURE0),se.targetColorTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),E.activeTexture.set(P.TEXTURE1),J&&J.rasterParticleState?(J.rasterParticleState.targetColorTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ue=Math.pow(2,J.tileID.overscaledZ-te.tileID.overscaledZ),de=[te.tileID.canonical.x*ue%1,te.tileID.canonical.y*ue%1]):se.targetColorTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE);let be=O?_.transform.expandedFarZProjMatrix:_.transform.calculateProjMatrix(re,z),ve=_.transform,Fe=sm(ve),pe=h.du(G.canonical),Ee=h.dv(pe.getCenter().lat),fe,Pe,Ce,Re,Ye;O?(fe=Float32Array.from(h.dx(h.dy(G.canonical))),Pe=Float32Array.from(ve.globeMatrix),Ce=Float32Array.from(h.dt(ve)),Re=[h.aG(ve.center.lng),h.aJ(ve.center.lat)],Ye=Float32Array.from(h.dw(G.canonical,pe,Ee,ve.worldSize/ve._pixelsPerMercatorPixel))):(fe=new Float32Array(16),Pe=new Float32Array(9),Ce=new Float32Array(16),Re=[0,0],Ye=new Float32Array(9));let He=tm(be,fe,Pe,Ce,Ye,de||[0,0],h.ai(_.transform.zoom),Re,Fe,ue||1,oe,D),je=_.isTileAffectedByFog(G),Ue=_.getOrCreateProgram("rasterParticle",{defines:q,overrideFog:je});if(_.uploadCommonUniforms(E,Ue,re),O){let lt=new nt(P.LEQUAL,nt.ReadOnly,_.depthRangeFor3D),st=0,et=_.globeSharedBuffers;if(et){let[it,ht,vt]=et.getGridBuffers(Ee,st!==0);Ue.draw(_,P.TRIANGLES,lt,Z,_t.alphaBlended,_.renderElevatedRasterBackface?pt.frontCCW:pt.backCCW,He,v.id,it,ht,vt)}}else{let lt=_.depthModeForSublayer(0,nt.ReadOnly),st=k[G.overscaledZ],{tileBoundsBuffer:et,tileBoundsIndexBuffer:it,tileBoundsSegments:ht}=_.getTileBoundsBuffers(te);Ue.draw(_,P.TRIANGLES,lt,st,_t.alphaBlended,pt.disabled,He,v.id,et,it,ht)}}_.resetStencilClippingMasks()}(a,t,o,c),a.style.map.triggerRepaint())},prepareRasterParticle:function(a,t,o){let c=t.getSource();if(!(c instanceof Ht&&c.loaded()))return;let d=a.sourceLayer||c.rasterLayerIds&&c.rasterLayerIds[0];if(!d)return;let m=a.paint.get("raster-particle-array-band")||c.getInitialBand(d);if(m==null)return;let _=t.getIds().map(y=>t.getTileByID(y));for(let y of _)y.updateNeeded(a.id,m)&&c.prepareTile(y,d,a.id,m)},Rain:class extends Us{constructor(){super(4.25),this._params={intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(a){let t=a.context;if(!this.particlesVx){let o=kd(this.particlesCount),c=new h.eh,d=new h.dF,m=0,_=h.ef(1323123451230);for(let y=0;y<o.length;++y){let v=o[y],T=[2*_()-1,_(),_(),_()];c.emplaceBack(v[0],v[1],v[2],-1,-1,...T),c.emplaceBack(v[0],v[1],v[2],1,-1,...T),c.emplaceBack(v[0],v[1],v[2],1,1,...T),c.emplaceBack(v[0],v[1],v[2],-1,1,...T),d.emplaceBack(m+0,m+1,m+2),d.emplaceBack(m+0,m+2,m+3),m+=4}this.particlesVx=t.createVertexBuffer(c,og.members),this.particlesIdx=t.createIndexBuffer(d)}}getDrawParams(a){if(!a.style.rain)return null;let t=a.style.rain.state,o=structuredClone(this._params);o.intensity=t.density,o.timeFactor=t.intensity,o.color=structuredClone(t.color),o.screenThinning.intensity=t.centerThinning,o.droplet
3281SizeX=t.dropletSize[0],o.dropletSizeYScale=t.dropletSize[1]/t.dropletSize[0],o.distortionStrength=100*t.distortionStrength;let c=structuredClone(this._vignetteParams);return c.strength=1,c.color=structuredClone(t.vignetteColor),{params:o,vignetteParams:c,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(a){let t=this.getDrawParams(a);if(!t)return;let{params:o,revealParams:c,direction:d,vignetteParams:m}=t,_=a.transform.zoom;if(c.revealStart>_)return;let y=Zn(0,1,c.revealStart,c.revealStart+c.revealRange,_);if(!this.particlesVx||!this.particlesIdx)return;m.strength*=y;let v=this.updateOnRender(a,o.timeFactor),T=a.context,E=T.gl,P=a.transform;this.screenTexture&&this.screenTexture.size[0]===a.width&&this.screenTexture.size[1]===a.height||(this.screenTexture=new h.T(T,{width:a.width,height:a.height,data:null},E.RGBA8)),o.distortionStrength>0&&(T.activeTexture.set(E.TEXTURE0),this.screenTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),E.copyTexSubImage2D(E.TEXTURE_2D,0,0,0,0,0,a.width,a.height));let A=a.getOrCreateProgram("rainParticle");a.uploadCommonUniforms(T,A),T.activeTexture.set(E.TEXTURE0),this.screenTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE);let D=[o.color.r,o.color.g,o.color.b,o.color.a],z=(O,k)=>{let N=Rt(this._movement.getPosition(),O),q=o.dropletSizeX,Z=o.dropletSizeX*o.dropletSizeYScale,G=a.width/2,re=a.height/2,te=Zn(0,o.screenThinning.start,0,1,o.screenThinning.intensity),se=Zn(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),K=Zn(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),J=(oe={modelview:v.modelviewMatrix,projection:v.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:N,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:O,rainDropletSize:[q,Z],distortionStrength:o.distortionStrength,rainDirection:d,color:D,screenSize:[P.width,P.height],thinningCenterPos:[G,re],thinningShape:[te,se,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:K,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:k?0:1},{u_modelview:Float32Array.from(oe.modelview),u_projection:Float32Array.from(oe.projection),u_time:oe.time,u_cam_pos:oe.camPos,u_texScreen:0,u_velocityConeAperture:oe.velocityConeAperture,u_velocity:oe.velocity,u_boxSize:oe.boxSize,u_rainDropletSize:oe.rainDropletSize,u_distortionStrength:oe.distortionStrength,u_rainDirection:oe.rainDirection,u_color:oe.color,u_screenSize:oe.screenSize,u_thinningCenterPos:oe.thinningCenterPos,u_thinningShape:oe.thinningShape,u_thinningAffectedRatio:oe.thinningAffectedRatio,u_thinningParticleOffset:oe.thinningParticleOffset,u_shapeDirectionalPower:oe.shapeDirectionalPower,u_shapeNormalPower:oe.shapeNormalPower,u_mode:oe.mode});var oe;let ue=Math.round(o.intensity*this.particlesCount),de=h.dB.simpleSegment(0,0,4*ue,2*ue);A.draw(a,E.TRIANGLES,nt.disabled,yt.disabled,_t.alphaBlended,pt.disabled,J,"rain_particles",this.particlesVx,this.particlesIdx,de)};o.distortionStrength>0&&z(o.boxSize,!0),z(o.boxSize,!1),this._vignette.draw(a,m)}},Snow:class extends Us{constructor(){super(2.25),this._params={intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3,this._devtoolsFolder=null,this._painter=null}destroy(){super.destroy()}update(a){let t=a.context;if(!this.particlesVx){let o=kd(this.particlesCount),c=new h.ei,d=new h.dF,m=0,_=h.ef(1323123451230);for(let y=0;y<o.length;++y){let v=o[y],T=_(),E=_(),P=_(),A=[y/o.length,T,E,P],D=[_(),_()];c.emplaceBack(v[0],v[1],v[2],-1,-1,...A,...D),c.emplaceBack(v[0],v[1],v[2],1,-1,...A,...D),c.emplaceBack(v[0],v[1],v[2],1,1,...A,...D),c.emplaceBack(v[0],v[1],v[2],-1,1,...A,...D),d.emplaceBack(m+0,m+1,m+2),d.emplaceBack(m+0,m+2,m+3),m
3281+=4}this.particlesVx=t.createVertexBuffer(c,Ba.members),this.particlesIdx=t.createIndexBuffer(d)}}getDrawParams(a){if(!a.style.snow)return null;let t=a.style.snow.state,o=structuredClone(this._params);o.intensity=t.density,o.timeFactor=t.intensity,o.color=structuredClone(t.color),o.screenThinning.intensity=t.centerThinning,o.billboardSize=2.79*t.flakeSize;let c=structuredClone(this._vignetteParams);return c.strength=1,c.color=structuredClone(t.vignetteColor),{params:o,vignetteParams:c,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(t.direction)}}draw(a){let t=this.getDrawParams(a);if(!t)return;let{params:o,revealParams:c,direction:d,vignetteParams:m}=t,_=a.transform.zoom;if(c.revealStart>_)return;let y=Zn(0,1,c.revealStart,c.revealStart+c.revealRange,_);m.strength*=y;let v=this.updateOnRender(a,o.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;let T=a.context,E=T.gl,P=a.transform,A=a.getOrCreateProgram("snowParticle");a.uploadCommonUniforms(T,A),((D,z,O)=>{let k=Rt(this._movement.getPosition(),D),N=P.width/2,q=P.height/2,Z=Zn(0,O.screenThinning.start,0,1,O.screenThinning.intensity),G=Zn(.001,O.screenThinning.range,0,1,O.screenThinning.intensity),re=Zn(0,O.screenThinning.particleOffset,0,1,O.screenThinning.intensity),te=(se={modelview:v.modelviewMatrix,projection:v.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:k,velocityConeAperture:O.velocityConeAperture,velocity:O.velocity,horizontalOscillationRadius:O.horizontalOscillationRadius,horizontalOscillationRate:O.horizontalOscillationRate,boxSize:D,billboardSize:1*O.billboardSize,simpleShapeParameters:[O.shapeFadeStart,O.shapeFadePower],screenSize:[P.width,P.height],thinningCenterPos:[N,q],thinningShape:[Z,G,Math.pow(10,O.screenThinning.fadePower)],thinningAffectedRatio:O.screenThinning.affectedRatio,thinningParticleOffset:re,color:[O.color.r,O.color.g,O.color.b,O.color.a],direction:d},{u_modelview:Float32Array.from(se.modelview),u_projection:Float32Array.from(se.projection),u_time:se.time,u_cam_pos:se.camPos,u_velocityConeAperture:se.velocityConeAperture,u_velocity:se.velocity,u_horizontalOscillationRadius:se.horizontalOscillationRadius,u_horizontalOscillationRate:se.horizontalOscillationRate,u_boxSize:se.boxSize,u_billboardSize:se.billboardSize,u_simpleShapeParameters:se.simpleShapeParameters,u_screenSize:se.screenSize,u_thinningCenterPos:se.thinningCenterPos,u_thinningShape:se.thinningShape,u_thinningAffectedRatio:se.thinningAffectedRatio,u_thinningParticleOffset:se.thinningParticleOffset,u_particleColor:se.color,u_direction:se.direction});var se;let K=Math.round(O.intensity*this.particlesCount),J=h.dB.simpleSegment(0,0,4*K,2*K);this.particlesVx&&this.particlesIdx&&A.draw(a,E.TRIANGLES,nt.disabled,yt.disabled,_t.alphaBlended,pt.disabled,te,"snow_particles",this.particlesVx,this.particlesIdx,J)})(o.boxSize,0,o),this._vignette.draw(a,m)}},shaders:or,programUniforms:Lo};function ih(a){return[a[0]*h.ej,a[1]*h.ej,a[2]*h.ej,0]}function Hc(a,t,o,c,d,m,_,y,v){let T=c.getSource(),E=o.globeSharedBuffers;if(!E)return;let P,A,D;if(t&&(P=c.getTile(t)),T instanceof h.aY?(A=T.texture,D=h.dz(0,0,o.transform)):P&&t&&(A=P.texture,D=h.dz(t.canonical.z,t.canonical.x,o.transform)),!A||!D)return;a||(D=h.cE(h.bd(),D,[1,-1,1]));let z=o.context,O=z.gl,k=d.paint.get("raster-resampling")==="nearest"?O.NEAREST:O.LINEAR,N=o.colorModeForDrapableLayerRenderPass(m),q=_.defines;q.push("GLOBE_POLES");let Z=new nt(O.LEQUAL,nt.ReadWrite,o.depthRangeFor3D),G=o.transform.expandedFarZProjMatrix,re=Float32Array.from(h.dx(h.dy(new h.cp(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),z.activeTexture.set(O.TEXTURE0),A.bind(k,O.CLAMP_TO_EDGE),z.activeTexture.set(O.TEXTURE1),A.bind(k,O.CLAMP_TO_EDGE),"useMipmap"in A&&z.extTextureFilterAnisotropic&&o.transform.pitch>20&&O.texParameterf(O.TEXTURE_2D,z.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,z.extTextureFilterAnisotropicMax);let[te,se,K,J]=t?E.getPoleBuffers(t.canonical.z,!1):E.getPoleBuffers(0,!0),oe=d.paint.get("raster-elevation"),ue;a?(ue=te,o.renderDefaultNorthPole=oe!==0):(ue=se,o.renderDefaultSouthPole=oe!==0);let de=ih(_.mix),be=((Fe,pe,Ee,fe,Pe,Ce,Re,Ye,He,je,Ue,lt,st,et)=>Xu(Fe,pe,Ee,fe,new Float32Array(16),new Float32Array(9),[0,0],Pe,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Re,[0,0],He,2,Ue,lt,st,1,0,et))(o,G,re,D,h.ai(o.transform.zoom),0,d,0,oe,0,de,_.offset,_.range,m),ve=o.getOrCreateProgram("raster",{defines:q});o.uploadCommonUniforms(z,ve,null),ve.draw(o,O.TRIANGLES,Z,v,N,y,be,d.id,ue,K,J)}function Nd(a){if(a.isOrthographic)return[0,0,0,0];let t=a._nearZ,o=a.projection.farthestPixelDistance(a),c=o-t,d=.2*a.height,m=t+d;
3281return[t,o,(m-d-t)/c,(m-t)/c]}function Ud(a,t,o,c){if(a)return t instanceof Ht&&a instanceof at?t.getTextureDescriptor(a,o,!0):{texture:a.texture,mix:ih(c.mix),offset:c.offset,buffer:0,tileSize:1}}let Ur=h.bA(new Float32Array(16)),Vs=new h.C(1,0,0,1),Al=new h.C(0,1,0,1),nh=new h.C(0,0,1,1),Vd=new h.C(1,0,1,1),jd=new h.C(0,1,1,1);function js(a,t,o,c,d,m,_){let y=a.context,v=a.transform,T=y.gl,E=v.projection.name==="globe",P=E?["PROJECTION_GLOBE_VIEW"]:[],A=h.bb(o.projMatrix);if(E&&h.ai(v.zoom)>0){let de=h.ek(o.canonical,v),be=h.el(de);A=h.aC(new Float32Array(16),v.globeMatrix,be),h.aC(A,v.projMatrix,A)}let D=h.bd();D[12]+=2*d/(h.o.devicePixelRatio*v.width),D[13]+=2*m/(h.o.devicePixelRatio*v.height),h.aC(A,D,A);let z=a.getOrCreateProgram("debug",{defines:P}),O=t.getTileByID(o.key);a.terrain&&a.terrain.setupElevationDraw(O,z);let k=nt.disabled,N=yt.disabled,q=a.colorModeForRenderPass(),Z="$debug";y.activeTexture.set(T.TEXTURE0),a.emptyTexture.bind(T.LINEAR,T.CLAMP_TO_EDGE),E?O._makeGlobeTileDebugBuffers(a.context,v):O._makeDebugTileBoundsBuffers(a.context,v.projection);let G=O._tileDebugBuffer||a.debugBuffer,re=O._tileDebugIndexBuffer||a.debugIndexBuffer,te=O._tileDebugSegments||a.debugSegments;if(z.draw(a,T.LINE_STRIP,k,N,q,pt.disabled,Oc(A,c.toPremultipliedRenderColor(null)),Z,G,re,te,null,null,null,[O._globeTileDebugBorderBuffer]),_){let de=O.latestRawTileData,be=Math.floor((de&&de.byteLength||0)/1024),ve=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(ve+=` => ${o.overscaledZ}`),ve+=` ${O.state}`,ve+=` ${be}kb`,function(Fe,pe){Fe.initDebugOverlayCanvas();let Ee=Fe.debugOverlayCanvas,fe=Fe.context.gl,Pe=Fe.debugOverlayCanvas.getContext("2d");Pe.clearRect(0,0,Ee.width,Ee.height),Pe.shadowColor="white",Pe.shadowBlur=2,Pe.lineWidth=1.5,Pe.strokeStyle="white",Pe.textBaseline="top",Pe.font="bold 36px Open Sans, sans-serif",Pe.fillText(pe,5,5),Pe.strokeText(pe,5,5),Fe.debugOverlayTexture.update(Ee),Fe.debugOverlayTexture.bind(fe.LINEAR,fe.CLAMP_TO_EDGE)}(a,ve)}let se=t.getTile(o).tileSize,K=512/Math.min(se,512)*(o.overscaledZ/v.zoom)*.5,J=O._tileDebugTextBuffer||a.debugBuffer,oe=O._tileDebugTextIndexBuffer||a.quadTriangleIndexBuffer,ue=O._tileDebugTextSegments||a.debugSegments;z.draw(a,T.TRIANGLES,k,N,_t.alphaBlended,pt.disabled,Oc(A,h.C.transparent.toPremultipliedRenderColor(null),K),Z,J,oe,ue,null,null,null,[O._globeTileDebugTextBuffer])}function rh(a,t,o,c){Ml(a,0,t+o/2,a.transform.width,o,c)}function Vr(a,t,o,c){Ml(a,t-o/2,0,o,a.transform.height,c)}function Ml(a,t,o,c,d,m){let _=a.context,y=_.gl;y.enable(y.SCISSOR_TEST),y.scissor(t*h.o.devicePixelRatio,o*h.o.devicePixelRatio,c*h.o.devicePixelRatio,d*h.o.devicePixelRatio),_.clear({color:m}),y.disable(y.SCISSOR_TEST)}let oh=h.ea([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Gd}=oh;function zo(a,t,o,c){a.emplaceBack(t,o,c)}class Yi{constructor(t){this.vertexArray=new h.em,this.indices=new h.dF,zo(this.vertexArray,-1,-1,1),zo(this.vertexArray,1,-1,1),zo(this.vertexArray,-1,1,1),zo(this.vertexArray,1,1,1),zo(this.vertexArray,-1,-1,-1),zo(this.vertexArray,1,-1,-1),zo(this.vertexArray,-1,1,-1),zo(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,Gd),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=h.dB.simpleSegment(0,0,36,12)}}function Gs(a,t,o,c,d,m){let _=a.context.gl,y=t.paint.get("sky-atmosphere-color"),v=t.paint.get("sky-atmosphere-halo-color"),T=t.paint.get("sky-atmosphere-sun-intensity"),E=((P,A,D,z,O)=>({u_matrix_3f:P,u_sun_direction:A,u_sun_intensity:D,u_color_tint_r:[z.r,z.g,z.b,z.a],u_color_tint_m:[O.r,O.g,O.b,O.a],u_luminance:5e-5}))(h.ep(h.dH(),c),d,T,y.toPremultipliedRenderColor(null),v.toPremultipliedRenderColor(null));_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+m,t.skyboxTexture,0),o.draw(a,_.TRIANGLES,nt.disabled,yt.disabled,_t.unblended,pt.frontCW,E,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}let Hd=h.ea([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class $d{constructor(t){let o=new h.eq;o.emplaceBack(-1,1,1,0,0),o.emplaceBack(1,1,1,1,0),o.emplaceBack(1,-1,1,1,1),o.emplaceBack(-1,-1,1,0,1);let c=new h.dF;c.emplaceBack(0,1,2),c.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(o,Hd.members),this.indexBuffer=t.createIndexBuffer(c),this.segments=h.dB.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}let ka=h.ea([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_opacity",components:1}]);class qd{constructor(){this.colorModeAlphaBlendedWriteRGB=new _t([1,Ms,1,Ms],h.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new _t([1,0,1,0],h.C.transparent,[!1,!1,!1,!0]),this.params={starsCount:16e3,sizeMultiplier:.15,sizeRange:100,intensityRange:200},this.updateNeeded=!0,this._painter=null,this._devtoolsFolder=null}update(t){this._painter=t;let o=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new $d(o);let c=this.params,d=c.sizeRange,m=c.intensityRange,_=function(P){let A=h.ef(30),D=[];for(let z=0;z<P;
3281++z){let O=2*Math.PI*A(),k=Math.acos(1-2*A())-.5*Math.PI;D.push(h.cU(Math.cos(k)*Math.cos(O),Math.cos(k)*Math.sin(O),Math.sin(k)))}return D}(c.starsCount),y=h.ef(300),v=new h.er,T=new h.dF,E=0;for(let P=0;P<_.length;++P){let A=h.bN([],_[P],200),D=Math.max(0,1+.01*d*(1*y()-.5)),z=Math.max(0,1+.01*m*(1*y()-.5));v.emplaceBack(A[0],A[1],A[2],-1,-1,D,z),v.emplaceBack(A[0],A[1],A[2],1,-1,D,z),v.emplaceBack(A[0],A[1],A[2],1,1,D,z),v.emplaceBack(A[0],A[1],A[2],-1,1,D,z),T.emplaceBack(E+0,E+1,E+2),T.emplaceBack(E+0,E+2,E+3),E+=4}this.starsVx=o.createVertexBuffer(v,ka.members),this.starsIdx=o.createIndexBuffer(T),this.starsSegments=h.dB.simpleSegment(0,0,v.length,T.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy(),this._painter=null}drawAtmosphereGlow(t,o){let c=t.context,d=c.gl,m=t.transform,_=new nt(d.LEQUAL,nt.ReadOnly,[0,1]),y=h.ai(m.zoom),v=t.style.getLut(o.scope),T=o.properties.get("color-use-theme")==="none",E=o.properties.get("color").toNonPremultipliedRenderColor(T?null:v),P=o.properties.get("high-color-use-theme")==="none",A=o.properties.get("high-color").toNonPremultipliedRenderColor(P?null:v),D=o.properties.get("space-color-use-theme")==="none",z=o.properties.get("space-color").toNonPremultipliedRenderColor(D?null:v),O=5e-4,k=h.es(o.properties.get("horizon-blend"),0,1,O,.25),N=h.ds(t,c,m)&&k===O?m.worldSize/(2*Math.PI*1.025)-1:m.globeRadius,q=t.frameCounter/1e3%1,Z=h.af(m.globeCenterInViewSpace),G=Math.sqrt(Math.pow(Z,2)-Math.pow(N,2)),re=Math.acos(G/Z),te=se=>{let K=m.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];se&&K.push("ALPHA_PASS");let J=t.getOrCreateProgram("globeAtmosphere",{defines:K}),oe=((de,be,ve,Fe,pe,Ee,fe,Pe,Ce,Re,Ye,He)=>({u_frustum_tl:de,u_frustum_tr:be,u_frustum_br:ve,u_frustum_bl:Fe,u_horizon:pe,u_transition:Ee,u_fadeout_range:fe,u_atmosphere_fog_color:Pe.toArray01(),u_high_color:Ce.toArray01(),u_space_color:Re.toArray01(),u_temporal_offset:Ye,u_horizon_angle:He}))(m.frustumCorners.TL,m.frustumCorners.TR,m.frustumCorners.BR,m.frustumCorners.BL,m.frustumCorners.horizon,y,k,E,A,z,q,re);t.uploadCommonUniforms(c,J);let ue=this.atmosphereBuffer;ue&&J.draw(t,d.TRIANGLES,_,yt.disabled,se?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,pt.backCW,oe,se?"atmosphere_glow_alpha":"atmosphere_glow",ue.vertexBuffer,ue.indexBuffer,ue.segments)};te(!1),te(!0)}drawStars(t,o){let c=h.aB(o.properties.get("star-intensity"),0,1);if(c===0)return;let d=t.context,m=d.gl,_=t.transform,y=t.getOrCreateProgram("stars"),v=h.bP([]);h.bR(v,v,-_._pitch),h.bQ(v,v,-_.angle),h.bR(v,v,h.am(_._center.lat)),h.et(v,v,-h.am(_._center.lng));let T=h.bV(new Float32Array(16),v),E=h.aC([],_.starsProjMatrix,T),P=h.ep([],T),A=h.eu([],P),D=this.params.sizeMultiplier,z=[0,1,0];h.dJ(z,z,A),h.bN(z,z,D);let O=[1,0,0];h.dJ(O,O,A),h.bN(O,O,D);let k=(N=z,q=O,Z=c,{u_matrix:Float32Array.from(E),u_up:N,u_right:q,u_intensity_multiplier:Z});var N,q,Z;t.uploadCommonUniforms(d,y),this.starsVx&&this.starsIdx&&y.draw(t,m.TRIANGLES,nt.disabled,yt.disabled,this.colorModeAlphaBlendedWriteRGB,pt.disabled,k,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class Zd{constructor(){this.visibleTiles=[]}updateBorders(t,o){let c=[],d=[],m=t._getRenderableCoordinates(!1,!0);for(let v of m){let T=t.getTile(v);if(!T.hasData())continue;let E=T.getBucket(o);E&&(E.isEmpty()||(c.push(v.key),d.push({bucket:E,tileID:v.canonical})))}let _=c.length!==this.visibleTiles.length;if(!_){c.sort();for(let v=0;v<c.length;v++)if(c[v]!==this.visibleTiles[v]){_=!0;break}}if(!_)return;let y=new Set;this.visibleTiles=c,d.sort((v,T)=>v.tileID.z-T.tileID.z||v.tileID.x-T.tileID.x||v.tileID.y-T.tileID.y);for(let v of d){let T=new Array,E=new Array,P=v.bucket;for(let A of P.featuresOnBorder)y.has(A.featureId)?E.push(A.footprintIndex):(y.add(A.featureId),T.push(A.footprintIndex));P.updateFootprintHiddenFlags(T,h.ev,!1),P.updateFootprintHiddenFlags(E,h.ev,!0)}}}let fr=new Float64Array(16),sr=new Float64Array(16),sh=new Float64Array(16),Cl=new Float32Array(16),Pl=[0,0,0];function Dl(a,t,o){let c=o.cameraWorldSizeForFog/o.worldSize;return h.cE(a,o.worldToFogMatrix,[c,c,1]),h.aC(a,a,t),a}function Rl(a,t,o,c,d){let m=o.material,_=c.context,{baseColorTexture:y,metallicRoughnessTexture:v}=m.pbrMetallicRoughness,{normalTexture:T,occlusionTexture:E,emissionTexture:P}=m;function A(z,O,k){if(z&&(a.push(O),_.activeTexture.set(_.gl.TEXTURE0+k),z.gfxTexture)){let{minFilter:N,magFilter:q,wrapS:Z,wrapT:G}=z.sampler;z.gfxTexture.bindExtraParam(N,q,Z,G)}}A(y,"HAS_TEXTURE_u_baseColorTexture",5),A(v,"HAS_TEXTURE_u_metallicRoughnessTexture",6),A(T,"HAS_TEXTURE_u_normalTexture",7),A(E,"HAS_TEXTURE_u_occlusionTexture",8),A(P,"HAS_TEXTURE_u_emissionTexture",9),d&&(d.texture||(d.texture=new h.dU(c.context,d.image,[d.image.height,d.image.height,d.image.height],_.gl.RGBA8)),_.activeTexture.set(_.gl.TEXTURE0+10),d.texture&&d.texture.bind(_.gl.LINEAR,_.gl.CLAMP_TO_EDGE),a.push("APPLY_LUT_ON_GPU")),o.texcoordBuffer&&(a.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(o.texcoordBuffer)),o.colorBuffer&&(a.push(o.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(o.colorBuffer)),o.normalBuffer&&(a.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(o.normalBuffer)),o.pbrBuffer&&(a.push("HAS_ATTRIBUTE_a_pbr"),a.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(o.pbrBuffer)),m.alphaMode!=="OPAQUE"&&m.alphaMode!=="MASK"||a.push("UNPREMULT_TEXTURE_IN_SHADER"),m.defined||a.push("DIFFUSE_SHADED");let D=c.shadowRenderer;D&&(a.push("RENDER_SHADOWS"),D.useNormalOffset&&a.push("NORMAL_OFFSET"))}function Ll(a,t,o,c,d,m){let _=a.modelOpacity,y=t.context,v=new nt(t.context.gl.LEQUAL,a.isLightMesh?nt.ReadOnly:nt.ReadWrite,t.depthRangeFor3D),T=t.transform,E=a.mesh,P=E.material,A=P.pbrMetallicRoughness,D=t.style.fog;t.transform.projection.zAxisUnit==="pixels"?fr.set(a.nodeModelMatrix):h.aC(fr,c.zScaleMatrix,a.nodeModelMatrix),h.aC(fr,c.negCameraPosMatrix,fr),h.ba(sr,fr),h.e9(sr,sr);
3281let z=o.paint.get("model-color-use-theme").constantOr("default")==="none",O=o.paint.get("model-emissive-strength").constantOr(0),k=Rd(a.worldViewProjection,fr,sr,null,t,_,A.baseColorFactor,P.emissiveFactor,A.metallicFactor,A.roughnessFactor,P,O,o,void 0,void 0,a.materialOverride,a.modelColor),N={defines:[]},q=[],Z=t.shadowRenderer;Z&&(Z.useNormalOffset=!1),Rl(N.defines,q,E,t,z?null:o.lut);let G=null;if(D&&(G=Dl(sh,a.nodeModelMatrix,t.transform),T.projection.name!=="globe")){let se=E.aabb.min,K=E.aabb.max,[J,oe]=D.getOpacityForBounds(G,se[0],se[1],K[0],K[1]);N.overrideFog=J>=Ts||oe>=Ts}let re=Ps(t,o.paint.get("model-cutoff-fade-range"));re.shouldRenderCutoff&&N.defines.push("RENDER_CUTOFF");let te=t.getOrCreateProgram("model",N);t.uploadCommonUniforms(y,te,null,G,re),t.renderPass!=="shadow"&&Z&&Z.setupShadowsFromMatrix(a.nodeModelMatrix,te),te.draw(t,y.gl.TRIANGLES,v,d,m,E.material.doubleSided?pt.disabled:pt.backCCW,k,o.id,E.vertexBuffer,E.indexBuffer,E.segments,o.paint,t.transform.zoom,void 0,q)}function Wd(a,t){return a.style._importedAsBasemap?"basemap":t.scope}function $c(a,t,o,c,d,m,_,y,v,T){let E=a.transform,P=!!t.isGeometryBloom&&t.isGeometryBloom;if(P&&a.renderPass==="shadow")return;let A=E.projection.name==="globe"?h.eD(o,E):[...o];h.aC(A,A,t.globalMatrix);let D=h.aC([],c,A);if(t.meshes)for(let z of t.meshes){let O=y.get(z.material.name);if(O&&O.opacity<=0)continue;if(z.material.alphaMode!=="BLEND"){_.push({mesh:z,depth:0,modelIndex:d,worldViewProjection:D,nodeModelMatrix:A,isLightMesh:P,materialOverride:O,modelOpacity:v,modelColor:T,node:t,modelMatrix:o});continue}let k=h.ae([],z.centroid,D);!E.isOrthographic&&k[2]<=0||m.push({mesh:z,depth:k[2],modelIndex:d,worldViewProjection:D,nodeModelMatrix:A,isLightMesh:P,materialOverride:O,modelOpacity:v,modelColor:T,node:t,modelMatrix:o})}if(t.children)for(let z of t.children)$c(a,z,o,c,d,m,_,y,v,T)}function zl(a,t,o,c){let d=o.shadowRenderer;if(!d)return;let m=d.getShadowPassDepthMode(),_=d.calculateShadowPassMatrixFromMatrix(t),y=Ld(_);o.getOrCreateProgram("modelDepth").draw(o,o.context.gl.TRIANGLES,m,yt.disabled,_t.disabled,pt.disabled,y,c.id,a.vertexBuffer,a.indexBuffer,a.segments,c.paint,o.transform.zoom,void 0,void 0)}function Xd(a,t,o,c){let d=function(E,P){if(P.footprintDebugMesh)return P.footprintDebugMesh;if(!P.footprint)return null;let A=E.context,D=P.footprint.vertices,z=P.footprint.indices,O=new h.dE;O.reserve(D.length);for(let oe of D)O.emplaceBack(oe.x,oe.y);let k=new h.dF;k.reserve(z.length);for(let oe=0;oe<z.length;oe+=3)k.emplaceBack(z[oe],z[oe+1],z[oe+2]);let N=A.createVertexBuffer(O,h.dA.members),q=A.createIndexBuffer(k),Z=h.dB.simpleSegment(0,0,D.length,z.length),G=P.id||P.name||"footprint",re,te=parseInt(G,10);re=isNaN(te)?function(oe){let ue=0;for(let de=0;de<oe.length;de++)ue=(ue<<5)-ue+oe.charCodeAt(de)|0;return ue}(G):te;let se=h.ed(re),K=h.ed(re+1),J=h.ed(re+2);return P.footprintDebugMesh={vertexBuffer:N,indexBuffer:q,segments:Z,color:new h.C(se,K,J,.5)},P.footprintDebugMesh}(a,o);if(!d)return;let m=a.context,_=m.gl,y=a.getOrCreateProgram("debug"),v=d.color,T=nt.disabled;m.activeTexture.set(_.TEXTURE0),a.emptyTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),y.draw(a,_.TRIANGLES,T,yt.disabled,_t.alphaBlended,pt.disabled,Oc(c,v.toPremultipliedRenderColor(null)),"$debug",d.vertexBuffer,d.indexBuffer,d.segments)}function lm(a,t,o,c,d,m){for(let _ of d){let y=Object.assign({},c);y.part=_;let v={type:"Unknown",id:t,properties:y},T={orientation:a.paint.get("model-rotation").evaluate(v,o)};m.set(_,T)}}function cm(a,t,o,c,d,m){for(let _ of d){let y=Object.assign({},c);y.part=_;let v={type:"Unknown",id:t,properties:y},T={color:a.paint.get("model-color").evaluate(v,o),colorMix:a.paint.get("model-color-mix-intensity").evaluate(v,o),opacity:a.paint.get("model-opacity").evaluate(v,o),emissionStrength:a.paint.get("model-emissive-strength").evaluate(v,o)};m.set(_,T)}}function Yd(a,t,o,c,d){let m=!1;for(let y of c)y.modelOpacity!==1&&(Ll(y,a,t,d[y.modelIndex],yt.disabled,_t.disabled),m=!0);for(let y of c)Ll(y,a,t,d[y.modelIndex],y.modelOpacity!==1?a.stencilModeFor3D():yt.disabled,a.colorModeForRenderPass());m&&a.resetStencilClippingMasks();let _=_t.additive;for(let y of o)Ll(y,a,t,d[y.modelIndex],yt.disabled,y.isLightMesh?_:a.colorModeForRenderPass())}function um(a,t,o){let c=t.updateZoomBasedPaintProperties(),d=function(m,_,y){let v,T,E,P=m.terrain?m.terrain.exaggeration():0;if(m.terrain&&P>0){let A=m.terrain,D=A.findDEMTileFor(y);D&&D.dem?v=h.eF.create(A,y,D):P=0}if(P===0&&(_.terrainElevationMin=0,_.terrainElevationMax=0),P===_.validForExaggeration&&(P===0||v&&v._demTile&&v._demTile.tileID===_.validForDEMTile.id&&v._dem._timestamp===_.validForDEMTile.timestamp))return!1;for(let A in _.instancesPerModel){let D=_.instancesPerModel[A];for(let z=0;z<D.instancedDataArray.length;++z){let O=(v?P*v.getElevationAt(0|D.instancedDataArray.float32[16*z],0|D.instancedDataArray.float32[16*z+1],!0,!0):0)+D.instancesEvaluatedElevation[z];D.instancedDataArray.float32[16*z+6]=O,T=T?Math.min(_.terrainElevationMin,O):O,E=E?Math.max(_.terrainElevationMax,O):O}}return _.terrainElevationMin=T||0,_.terrainElevationMax=E||0,_.validForExaggeration=P,_.validForDEMTile=v&&v._demTile?{id:v._demTile.tileID,timestamp:v._dem._timestamp}:{id:void 0,timestamp:0},!0}(a,t,o);(c||d)&&(t.uploaded=!1,t.upload(a.context))}let wo={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new h.cY([0,0,0],[h.ak,h.ak,0])};function hm(a,t){let o=1<<a.canonical.z,c=t.getFreeCameraOptions().position,d=t.elevation,m=a.canonical.x/o,_=(a.canonical.x+1)/o,y=a.canonical.y/o,v=(a.canonical.y+1)/o,T=t._centerAltitude;if(d){let D=d.getMinMaxForTile(a);D&&D.max>T&&(T=D.max)}let E=h.aB(c.x,m,_)-c.x,P=h.aB(c.y,y,v)-c.y,A=h.bY(T,t.center.lat)-c.z;return t._zoomFromMercatorZ(Math.sqrt(E*E+P*P+A*A))}function Jd(a,t,o,c,d,m,_){let y=a.context,v=a.renderPass==="shadow",T=a.shadowRenderer,E=v&&T?T.getShadowPassDepthMode():new nt(y.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D),P=a.isTileAffectedByFog(m),A=a.transform.projection.name==="globe";if(o.meshes)for(let D of o.meshes){let z=A?[]:["MODEL_POSITION_ON_GPU"],O=[],k,N,q,Z=!A&&c.instancedDataArray.length>20;Z&&z.push("INSTANCED_ARRAYS");let G=Ps(a,t.paint.get("model-cutoff-fade-range"));if(G.shouldRenderCutoff&&z.push("RENDER_CUTOFF"),v&&T)k=a.getOrCreateProgram("modelDepth",{defines:z}),N=Ld(_.shadowTileMatrix,_.shadowTileMatrix,o.globalMatrix),q=_t.disabled;
3281else{Rl(z,O,D,a,t.paint.get("model-color-use-theme").constantOr("default")==="none"?null:t.lut),k=a.getOrCreateProgram("model",{defines:z,overrideFog:P});let te=D.material,se=te.pbrMetallicRoughness,K=t.paint.get("model-opacity").constantOr(1),J=t.paint.get("model-emissive-strength").constantOr(0);N=Rd(m.expandedProjMatrix,o.globalMatrix,Cl,null,a,K,se.baseColorFactor,te.emissiveFactor,se.metallicFactor,se.roughnessFactor,te,J,t,d),T&&(_.shadowUniformsInitialized?k.setShadowUniformValues(y,T.getShadowUniformValues()):(T.setupShadows(m.toUnwrapped(),k,"model-tile"),_.shadowUniformsInitialized=!0)),q=G.shouldRenderCutoff||K<1||te.alphaMode!=="OPAQUE"?_t.alphaBlended:_t.unblended}a.uploadCommonUniforms(y,k,m.toUnwrapped(),null,G);let re=D.material.doubleSided?pt.disabled:pt.backCCW;if(Z)O.push(c.instancedDataBuffer),k.draw(a,y.gl.TRIANGLES,E,yt.disabled,q,re,N,t.id,D.vertexBuffer,D.indexBuffer,D.segments,t.paint,a.transform.zoom,void 0,O,c.instancedDataArray.length);else{let te=v?"u_instance":"u_normal_matrix";for(let se=0;se<c.instancedDataArray.length;++se)N[te]=new Float32Array(c.instancedDataArray.arrayBuffer,64*se,16),k.draw(a,y.gl.TRIANGLES,E,yt.disabled,q,re,N,t.id,D.vertexBuffer,D.indexBuffer,D.segments,t.paint,a.transform.zoom,void 0,O)}}if(o.children)for(let D of o.children)Jd(a,t,D,c,d,m,_)}let dm=[1,-1,1];function pm(a,t,o,c){let d=a.node;if(d.lodMeshes&&d.lodMeshes.length>0)if(a.targetLod<0)a.targetLod=t>c?1:0;else{let m=o/1e3;a.targetLod=t>c?Math.min(a.targetLod+m,1):Math.max(a.targetLod-m,0)}else a.targetLod=0}function ag(a,t,o,c){if(!o.modelManager)return!0;let d=o.modelManager;if(!o.shadowRenderer)return!0;let m=o.shadowRenderer,_=t.aabb,y=!0,v=a.maxHeight;if(v===0){let E=0;for(let P in a.instancesPerModel){let A=d.getModel(P,c);A?E=Math.max(E,Math.max(Math.max(A.aabb.max[0],A.aabb.max[1]),A.aabb.max[2])):y=!1}v=a.maxScale*E*1.41+a.maxVerticalOffset,y&&(a.maxHeight=v)}_.max[2]=v,_.min[2]+=a.terrainElevationMin,_.max[2]+=a.terrainElevationMax,h.ae(_.min,_.min,t.tileMatrix),h.ae(_.max,_.max,t.tileMatrix);let T=_.intersects(m.getCurrentCascadeFrustum());return o.currentShadowCascade===0&&(a.isInsideFirstShadowMapFrustum=T===2),T===0}function lg(a,t){let o=a.uniformValues.u_cutoff_params[0],c=a.uniformValues.u_cutoff_params[1],d=a.uniformValues.u_cutoff_params[2],m=a.uniformValues.u_cutoff_params[3];return c===o||m===d?1:h.aB(((t-o)/(c-o)-d)/(m-d),0,1)}function cg(a,t,o,c){if(t.pitch<20)return 1;let d=t.getWorldToCameraMatrix();h.aC(d,d,a);let m=h.bw(o.min[0],o.min[1],o.min[2],1),_=h.aD(h.bI(),m,d),y=_,v=_;m[1]=o.max[1],_=h.aD(h.bI(),m,d),y=_[1]<y[1]?_:y,v=_[1]>v[1]?_:v,m[0]=o.max[0],_=h.aD(h.bI(),m,d),y=_[1]<y[1]?_:y,v=_[1]>v[1]?_:v,m[1]=o.min[1],_=h.aD(h.bI(),m,d),y=_[1]<y[1]?_:y,v=_[1]>v[1]?_:v;let T=h.aB(c[0],0,1),E=100*t.pixelsPerMeter*h.aB(c[1],0,1),P=h.aB(c[2],0,1),A=h.eG(h.bI(),y,v,T),D=Math.tan(.5*t.fovX),z=-A[2]*D;if(E===0)return A[1]<-Math.abs(z)?P:1;let O=(-Math.abs(z)-A[1])/E,k=(q,Z,G)=>(1-G)*q+G*Z,N=h.aB(k(1,P,O),P,1);return k(1,N,h.aB((t.pitch-20)/20,0,1))}class pi{}class Ol{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,o,c){{let P=this._storage.get(o.id);if(P)return P.lastUsedFrameIdx=t,P.buf}let d=c.gl,m=d.getBufferParameter(d.ELEMENT_ARRAY_BUFFER,d.BUFFER_SIZE),_=new ArrayBuffer(m),y=new Int16Array(_);d.getBufferSubData(d.ELEMENT_ARRAY_BUFFER,0,new Int16Array(_));let v=new h.eI;for(let P=0;P<m/2;P+=3){let A=y[P],D=y[P+1],z=y[P+2];v.emplaceBack(A,D),v.emplaceBack(D,z),v.emplaceBack(z,A)}let T=c.bindVertexArrayOES.current,E=new pi;return E.buf=new Fs(c,v),E.lastUsedFrameIdx=t,this._storage.set(o.id,E),c.bindVertexArrayOES.set(T),E.buf}update(t){for(let[o,c]of this._storage)t-c.lastUsedFrameIdx>30&&(c.buf.destroy(),this._storage.delete(o))}destroy(){for(let[t,o]of this._storage)o.buf.destroy(),this._storage.delete(t)}}class ug{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}let ah={symbol:function(a,t,o,c,d){if(a.renderPass!=="translucent")return;let m=yt.disabled,_=a.colorModeForRenderPass(),y=o.layout.get("text-variable-anchor"),v=o.layout.get("text-size-scale-range"),T=h.aB(a.scaleFactor,v[0],v[1]);y&&function(A,D,z,O,k,N,q,Z){let G=D.transform,re=k==="map",te=N==="map";for(let se of A){let K=O.getTile(se),J=K.getBucket(z);if(!J||!J.text||!J.text.segments.get().length)continue;let oe=h.bl(J.textSizeData,G.zoom,Z),ue=Tu(se,J.getProjection(),G),de=G.calculatePixelsToTileUnitsMatrix(K),be=Tr(ue,K.tileID.canonical,te,re,G,J.getProjection(),de),ve=J.hasIconTextFit()&&J.hasIconData();
3281oe&&ts(J,re,te,q,G,be,se,Math.pow(2,G.zoom-K.tileID.overscaledZ),oe,ve)}}(c,a,o,t,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),d,T);let E=o.paint.get("icon-opacity").constantOr(1)!==0,P=o.paint.get("text-opacity").constantOr(1)!==0;o.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(E||P)?Od(a,t,o,c,m,_):(E&&Od(a,t,o,c,m,_,{onlyIcons:!0}),P&&Od(a,t,o,c,m,_,{onlyText:!0})),t.map.showCollisionBoxes&&(Ku(a,t,o,c,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),Ku(a,t,o,c,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(a,t,o,c){if(a.renderPass!=="translucent")return;let d=o.paint.get("circle-opacity"),m=o.paint.get("circle-stroke-width"),_=o.paint.get("circle-stroke-opacity"),y=o.layout.get("circle-sort-key").constantOr(1)!==void 0,v=o.paint.get("circle-emissive-strength");if(d.constantOr(1)===0&&(m.constantOr(1)===0||_.constantOr(1)===0))return;let T=a.context,E=T.gl,P=a.transform,A=!(!a.terrain||!a.terrain.enabled),D=o.layout.get("circle-elevation-reference"),z=a.depthModeForSublayer(0,nt.ReadOnly),O=new nt(a.context.gl.LEQUAL,nt.ReadOnly,a.depthRangeFor3D),k=D==="none"||A?z:O,N=yt.disabled,q=a.colorModeForDrapableLayerRenderPass(v),Z=P.projection.name==="globe",G=[h.aG(P.center.lng),h.aJ(P.center.lat)],re=[];for(let se=0;se<c.length;se++){let K=c[se],J=t.getTile(K),oe=J.getBucket(o);if(!oe||oe.projection.name!==P.projection.name)continue;let ue=oe.programConfigurations.get(o.id),de=oe.layoutVertexBuffer,be=oe.globeExtVertexBuffer,ve=oe.indexBuffer,Fe=h.dV(o),pe=[be],Ee=a.isTileAffectedByFog(K);Z&&Fe.push("PROJECTION_GLOBE_VIEW"),Fe.push("DEPTH_D24"),a.terrain&&P.depthOcclusionForSymbolsAndCircles&&Fe.push("DEPTH_OCCLUSION"),oe.hasElevation&&!a.terrain&&(Fe.push("ELEVATED_ROADS"),pe.push(oe.elevatedLayoutVertexBuffer));let fe=a.getOrCreateProgram("circle",{config:ue,defines:Fe,overrideFog:Ee}),Pe=P.projection.createInversionMatrix(P,K.canonical),Ce={programConfiguration:ue,program:fe,layoutVertexBuffer:de,dynamicBuffers:pe,indexBuffer:ve,uniformValues:h.dW(a,K,J,Pe,G,o),tile:J};if(y){let Re=oe.segments.get();for(let Ye of Re)re.push({segments:new h.dB([Ye]),sortKey:Ye.sortKey,state:Ce})}else re.push({segments:oe.segments,sortKey:0,state:Ce})}y&&re.sort((se,K)=>se.sortKey-K.sortKey);let te={useDepthForOcclusion:P.depthOcclusionForSymbolsAndCircles};for(let se of re){let{programConfiguration:K,program:J,layoutVertexBuffer:oe,dynamicBuffers:ue,indexBuffer:de,uniformValues:be,tile:ve}=se.state,Fe=se.segments;a.terrain&&a.terrain.setupElevationDraw(ve,J,te),a.uploadCommonUniforms(T,J,ve.tileID.toUnwrapped()),J.draw(a,E.TRIANGLES,k,N,q,pt.disabled,be,o.id,oe,de,Fe,o.paint,P.zoom,K,ue)}},heatmap:function(a,t,o,c){if(o.paint.get("heatmap-opacity")!==0)if(a.renderPass==="offscreen"){let d=a.context,m=d.gl,_=yt.disabled,y=new _t([m.ONE,m.ONE,m.ONE,m.ONE],h.C.transparent,[!0,!0,!0,!0]),v=a.transform.projection.name==="globe"?.5:.25;o.heatmapFbo=En.createWithTexture(d,o.heatmapFbo,a.width*v,a.height*v),d.clear({color:h.C.transparent});let T=a.transform,E=T.projection.name==="globe",P=E?["PROJECTION_GLOBE_VIEW"]:[],A=E?pt.frontCCW:pt.disabled,D=[h.aG(T.center.lng),h.aJ(T.center.lat)];for(let z=0;z<c.length;z++){let O=c[z];if(t.hasRenderableParent(O))continue;let k=t.getTile(O),N=k.getBucket(o);if(!N||N.projection.name!==T.projection.name)continue;let q=a.isTileAffectedByFog(O),Z=N.programConfigurations.get(o.id),G=a.getOrCreateProgram("heatmap",{config:Z,defines:P,overrideFog:q}),{zoom:re}=a.transform;a.terrain&&a.terrain.setupElevationDraw(k,G),a.uploadCommonUniforms(d,G,O.toUnwrapped());let te=T.projection.createInversionMatrix(T,O.canonical);G.draw(a,m.TRIANGLES,nt.disabled,_,y,A,Cd(a,O,k,te,D,re,o.paint.get("heatmap-intensity")),o.id,N.layoutVertexBuffer,N.indexBuffer,N.segments,o.paint,a.transform.zoom,Z,E?[N.globeExtVertexBuffer]:null)}d.viewport.set([0,0,a.width,a.height])}else a.renderPass==="translucent"&&(a.context.setColorMode(a.colorModeForRenderPass()),function(d,m){let _=d.context,y=_.gl,v=m.heatmapFbo;if(!v)return;_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,v.colorAttachment0.get()),_.activeTexture.set(y.TEXTURE1);let T=m.colorRampTexture;T||(T=m.colorRampTexture=new h.T(_,m.colorRamp,y.RGBA8)),T.bind(y.LINEAR,y.CLAMP_TO_EDGE),d.getOrCreateProgram("heatmapTexture").draw(d,y.TRIANGLES,nt.disabled,yt.disabled,d.colorModeForRenderPass(),pt.disabled,((E,P)=>({u_image:0,u_color_ramp:1,u_opacity:P.paint.get("heatmap-opacity")}))(0,m),m.id,d.viewportBuffer,d.quadTriangleIndexBuffer,d.viewportSegments,m.paint,d.transform.zoom)}(a,o))},line:function(a,t,o,c){let d=o.paint.get("line-opacity"),m=o.paint.get("line-width");if(d.constantOr(1)===0||m.constantOr(1)===0)return;let _=o.paint.get("line-blend-mode"),y=a.terrain&&a.terrain.renderingToTexture;if(_==="default"||a.transform.projection.name==="globe")a.renderPass==="translucent"&&Sl(a,t,o,c);else{if(y)return void function(v,T,E,P,A){if(v.renderPass!=="translucent")return;
3281let D=v.context,z=D.gl,O=v.terrain;if(!O)return;let k=D.bindFramebuffer.current,N=v.emissiveMode==="mrt-fallback",q=O.drapeBufferSize[0],Z=O.drapeBufferSize[1];E.lineBlendFbos||(E.lineBlendFbos=new eh),E.lineBlendFbos.drapeFbo=En.createWithTexture(D,E.lineBlendFbos.drapeFbo,q,Z,!0),N&&z.drawBuffers([z.COLOR_ATTACHMENT0]),D.clear({color:Bc[A].clearColor,depth:1,stencil:0});let G=v.currentStencilSource,re=v._tileClippingMaskIDs,te=v.nextStencilID;v.currentStencilSource=void 0,v._tileClippingMaskIDs={},v.nextStencilID=1;let se=v._terrain;v._terrain=null,v._renderTileClippingMasks(E,T,P),Sl(v,T,E,P,Nc(A,v.context),!0),v._terrain=se,v.currentStencilSource=G,v._tileClippingMaskIDs=re,v.nextStencilID=te,N&&z.drawBuffers([z.COLOR_ATTACHMENT0,z.COLOR_ATTACHMENT1]);let K=O.drapeBufferSize,J=E.lineBlendFbos&&E.lineBlendFbos.drapeFbo;J&&(A==="additive"&&is(v,E,J),qe(v,E,A,J,k,K))}(a,t,o,c,_);if(a.renderPass==="offscreen")return void function(v,T,E,P,A){let D=v.context,z=Math.ceil(v.width),O=Math.ceil(v.height);E.lineBlendFbos||(E.lineBlendFbos=new eh),E.lineBlendFbos.fbo=En.createWithTexture(D,E.lineBlendFbos.fbo,z,O,!0),D.clear({color:Bc[A].clearColor,depth:1,stencil:0});let k=v.currentStencilSource,N=v._tileClippingMaskIDs,q=v.nextStencilID;v.currentStencilSource=void 0,v._tileClippingMaskIDs={},v.nextStencilID=1,v._renderTileClippingMasks(E,T,P);let Z=v.renderPass;v.renderPass="translucent",Sl(v,T,E,P,Nc(A,v.context)),v.renderPass=Z,v.currentStencilSource=k,v._tileClippingMaskIDs=N,v.nextStencilID=q,D.viewport.set([0,0,v.width,v.height]),A==="additive"&&is(v,E,E.lineBlendFbos.fbo)}(a,t,o,c,_);if(a.renderPass==="translucent"){let v=o.lineBlendFbos&&o.lineBlendFbos.fbo;return void(v&&qe(a,o,_,v,null))}}},fill:function(a,t,o,c){let d=o.paint.get("fill-color"),m=o.paint.get("fill-opacity");if(m.constantOr(1)===0)return;let _=o.paint.get("fill-emissive-strength"),y=a.colorModeForDrapableLayerRenderPass(_),v=o.paint.get("fill-pattern"),T=a.opaquePassEnabledForLayer()&&!v.constantOr(1)&&d.constantOr(h.C.transparent).a===1&&m.constantOr(0)===1?"opaque":"translucent",E="none";o.layout.get("fill-elevation-reference")!=="none"?E="road":o.paint.get("fill-z-offset").constantOr(1)!==0&&(E="offset");let P=!(!a.terrain||!a.terrain.enabled),A={painter:a,sourceCache:t,layer:o,coords:c,colorMode:y,elevationType:E,terrainEnabled:P,pass:T};if(a.renderPass==="shadow")return void(a.shadowRenderer&&E==="road"&&!P&&function(z){let{painter:O,sourceCache:k,layer:N,coords:q}=z,Z=O.context.gl,G=z.painter.shadowRenderer;for(let re of q){let te=k.getTile(re),se=te.getBucket(N);if(!se)continue;let K=se.elevatedStructures;if(!K||!K.shadowCasterSegments||K.shadowCasterSegments.segments[0].primitiveLength===0)continue;O.prepareDrawTile();let J=se.bufferData.programConfigurations.get(N.id),oe=O.isTileAffectedByFog(re),ue=O.getOrCreateProgram("elevatedStructuresDepth",{config:J,overrideFog:oe}),de=G.calculateShadowPassMatrixFromTile(te.tileID.toUnwrapped());O.uploadCommonUniforms(O.context,ue,re.toUnwrapped());let be=Ad(de,0);ue.draw(O,Z.TRIANGLES,G.getShadowPassDepthMode(),yt.disabled,_t.disabled,pt.disabled,be,N.id,K.vertexBuffer,K.indexBuffer,K.shadowCasterSegments,N.paint,O.transform.zoom,J)}}(A));let D=a.emissiveMode==="mrt-fallback";if(E!=="offset"){if(Ti(A,!1,D),E==="road"){let z=!P&&a.renderPass==="translucent";z&&za(a,t,o,c,"geometry"),Ti(A,!0,D,yt.disabled),z&&function(O){let{painter:k,sourceCache:N,layer:q,coords:Z,colorMode:G}=O,re=k.context.gl,te=O.painter.shadowRenderer,se=!!te&&te.enabled,K=new nt(k.context.gl.LEQUAL,nt.ReadOnly,k.depthRangeFor3D),J=[0,0,0];if(se){let ue=k.style.directionalLight,de=k.style.ambientLight;ue&&de&&(J=Ia(k.style,ue,de))}let oe=ue=>{for(let de of Z){let be=N.getTile(de),ve=be.getBucket(q);if(!ve)continue;let Fe=ve.elevatedStructures;if(!Fe)continue;let pe,Ee;if(ue?(pe=Fe.renderableBridgeSegments,Ee=Fe.bridgeProgramConfigurations.get(q.id)):(pe=Fe.renderableTunnelSegments,Ee=Fe.tunnelProgramConfigurations.get(q.id)),!pe||pe.segments[0].primitiveLength===0)continue;Ee.updatePaintBuffers(),k.prepareDrawTile();let fe=k.isTileAffectedByFog(de),Pe=[];se&&Pe.push("RENDER_SHADOWS","NORMAL_OFFSET");let Ce=k.getOrCreateProgram("elevatedStructures",{config:Ee,overrideFog:fe,defines:Pe}),Re=k.translatePosMatrix(de.projMatrix,be,q.paint.get("fill-translate"),q.paint.get("fill-translate-anchor"));se&&te.setupShadows(be.tileID.toUnwrapped(),Ce,"vector-tile");let Ye=Md(Re,J);k.uploadCommonUniforms(k.context,Ce,de.toUnwrapped()),Ce.draw(k,re.TRIANGLES,K,yt.disabled,G,pt.backCCW,Ye,q.id,Fe.vertexBuffer,Fe.indexBuffer,pe,q.paint,k.transform.zoom,Ee,[Fe.vertexBufferNormal])}};oe(!0),oe(!1)}(A)}}else Ti(A,!1,D,a.stencilModeFor3D())},"fill-extrusion":function(a,t,o,c){let d=o.paint.get("fill-extrusion-opacity"),m=a.context,_=m.gl,y=a.terrain,v=y&&y.renderingToTexture;if(d===0)return;let T=a.emissiveMode==="mrt-fallback",E=a.conflationActive&&a.style.isLayerClipped(o,t.getSource()),P=a.style.order.indexOf(o.fqid);if(E&&function(A,D,z,O,k){for(let N of O){let q=D.getTile(N).getBucket(z);q&&(q.updateReplacement(N,A.replacementSource,k),q.uploadCentroid(A.context))}}(a,t,o,c,P),y||E)for(let A of c){let D=t.getTile(A).getBucket(o);D&&Jf(a.context,t,A,D,o,y,E)}if(a.renderPass==="shadow"&&a.shadowRenderer){if(y&&d<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof h.ac)return;let A=a.shadowRenderer.getShadowPassDepthMode();Uc(a,t,o,c,A,yt.disabled,_t.disabled,E)}else if(a.renderPass==="translucent"){let A=!o.paint.get("fill-extrusion-pattern").constantOr(1),D=o.paint.get("fill-extrusion-color").constantOr(h.C.white);if(!v&&D.a!==0){let z=new nt(a.context.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D);d===1&&A?Uc(a,t,o,c,z,yt.disabled,_t.unblended,E):(Uc(a,t,o,c,z,yt.disabled,_t.disabled,E),Uc(a,t,o,c,z,a.stencilModeFor3D(),a.colorModeForRenderPass(),E),a.resetStencilClippingMasks())}if(a.style.enable3dLights()&&A&&(!y&&a.transform.projection.name!=="globe"||v)){let z=o.paint.get("fill-extrusion-opacity"),O=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),k=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),N=o.paint.get("fill-extrusion-flood-light-intensity"),q=o.paint.get("fill-extrusion-flood-light-color-use-theme").
3281constantOr("default")==="none",Z=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(q?null:o.lut).toArray01().slice(0,3),G=O>0&&k>0,re=N>0,te=(J,oe,ue)=>(1-ue)*J+ue*oe,se=new Vc;se.translate=o.paint.get("fill-extrusion-translate"),se.translateAnchor=o.paint.get("fill-extrusion-translate-anchor"),se.edgeRadius=o.layout.get("fill-extrusion-edge-radius"),se.cutoffFadeRange=o.paint.get("fill-extrusion-cutoff-fade-range");let K=J=>{let oe=a.depthModeForSublayer(1,nt.ReadOnly,_.LEQUAL,!0),ue=o.paint.get(J?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),de=te(.1,3,ue),be=a._showOverdrawInspector;if(!be){let ve=new yt({func:_.ALWAYS,mask:255},255,255,_.KEEP,_.KEEP,_.REPLACE),Fe=new _t([_.ONE,_.ONE,_.ONE,_.ONE],h.C.transparent,[!1,!1,!1,!0],_.MIN);oo(se,a,t,o,c,oe,ve,Fe,pt.disabled,J,"sdf",z,O,k,N,Z,de,E,!1)}{let ve=be?yt.disabled:new yt({func:_.EQUAL,mask:255},255,255,_.KEEP,_.DECR,_.DECR),Fe=be?a.colorModeForRenderPass():new _t([_.ONE_MINUS_DST_ALPHA,_.DST_ALPHA,_.ONE,_.ONE],h.C.transparent,[!0,!0,!0,!0]);oo(se,a,t,o,c,oe,ve,Fe,pt.disabled,J,"color",z,O,k,N,Z,de,E,!1)}};if(v){let J=()=>{let ue=y.drapeBufferSize[0],de=y.drapeBufferSize[1],be=y.framebufferCopyTexture;return be&&(!be||be.size[0]===ue&&be.size[1]===de)||(be&&be.destroy(),be=y.framebufferCopyTexture=new h.T(m,new h.q({width:ue,height:de}),_.RGBA8)),be.bind(_.LINEAR,_.CLAMP_TO_EDGE),_.copyTexSubImage2D(_.TEXTURE_2D,0,0,0,0,0,ue,de),be},oe=(ue,de,be)=>{let ve=a.depthModeForSublayer(1,nt.ReadOnly,_.LEQUAL,!1),Fe=o.paint.get(ue?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),pe=te(.1,3,Fe);{let Ee=new _t([_.ONE,_.ONE,_.ONE,_.ONE],h.C.transparent,[!1,!1,!1,!0]);oo(se,a,t,o,c,ve,yt.disabled,Ee,pt.disabled,ue,"clear",z,O,k,N,Z,pe,E,de)}{let Ee=new yt({func:_.ALWAYS,mask:255},255,255,_.KEEP,_.KEEP,_.REPLACE),fe=new _t([_.ONE,_.ONE,_.ONE,_.ONE],h.C.transparent,[!1,!1,!1,!0],_.MIN);oo(se,a,t,o,c,ve,Ee,fe,pt.disabled,ue,"sdf",z,O,k,N,Z,pe,E,de)}T&&!ue&&(be=J());{let Ee=ue?_.ZERO:_.ONE_MINUS_DST_ALPHA,fe=new yt({func:_.EQUAL,mask:255},255,255,_.KEEP,_.DECR,_.DECR),Pe=new _t([Ee,_.DST_ALPHA,_.ONE_MINUS_DST_ALPHA,_.ZERO],h.C.transparent,[!0,!0,!0,!0]);oo(se,a,t,o,c,ve,fe,Pe,pt.disabled,ue,"color",z,O,k,N,Z,pe,E,de)}if(!T||ue){let Ee=new _t([_.ONE,_.ONE,_.ONE,ue?_.ZERO:_.ONE],h.C.transparent,[!1,!1,!1,!0],ue?_.FUNC_ADD:_.MAX);oo(se,a,t,o,c,ve,yt.disabled,Ee,pt.disabled,ue,"clear",z,O,k,N,Z,pe,E,de,be)}else{_.drawBuffers([_.NONE,_.COLOR_ATTACHMENT1]);let Ee=new yt({func:_.EQUAL,mask:255},254,255,_.KEEP,_.DECR,_.DECR),fe=new _t([_.ONE,_.ONE,_.ONE,_.ONE],h.C.transparent,[!0,!1,!1,!1],_.MAX);oo(se,a,t,o,c,ve,Ee,fe,pt.disabled,ue,"emissive",z,O,k,N,Z,pe,E,de,be),_.drawBuffers([_.COLOR_ATTACHMENT0])}};if(G||re){let ue;a.prepareDrawTile(),T&&!G||(ue=J()),G&&oe(!0,!1,ue),re&&oe(!1,!0,ue)}}else G&&K(!0),re&&K(!1),(G||re)&&a.resetStencilClippingMasks()}}},hillshade:function(a,t,o,c){if(a.renderPass!=="offscreen"&&a.renderPass!=="translucent"||a.style.disableElevatedTerrain)return;let d=a.context,m=a.terrain&&a.terrain.renderingToTexture,[_,y]=a.renderPass!=="translucent"||m?[{},c]:a.stencilConfigForOverlap(c);for(let v of y){let T=t.getTile(v);if(T.needsHillshadePrepare&&a.renderPass==="offscreen")hd(a,T,o);else if(a.renderPass==="translucent"){let E=a.depthModeForSublayer(0,nt.ReadOnly),P=o.paint.get("hillshade-emissive-strength"),A=a.colorModeForDrapableLayerRenderPass(P),D=m&&a.terrain?a.terrain.stencilModeForRTTOverlap(v):_[v.overscaledZ];ud(a,v,T,o,E,D,A)}}d.viewport.set([0,0,a.width,a.height]),a.resetStencilClippingMasks()},raster:function(a,t,o,c,d,m){if(a.renderPass!=="translucent")return;let _=o.paint.get("raster-opacity");if(_===0)return;let y=a.transform.projection.name==="globe",v=o.paint.get("raster-elevation")!==0,T=v&&y,E=a.terrain&&a.terrain.exaggeration()>0&&v&&o.paint.get("raster-elevation-reference")==="ground",P=!y&&E;if(a.renderElevatedRasterBackface&&!T)return;let A=a.context,D=A.gl,z=t.getSource(),O=function(J,oe,ue,de,be){let ve=oe.paint.get("raster-color"),Fe
3281=J.type==="raster-array",pe=[],Ee=oe.paint.get("raster-resampling"),fe=oe.paint.get("raster-color-mix"),Pe=oe.paint.get("raster-color-range"),Ce=[fe[0],fe[1],fe[2],0],Re=fe[3],Ye=Ee==="nearest"?de.NEAREST:de.LINEAR;if(Fe&&(pe.push("RASTER_ARRAY"),ve||pe.push("RASTER_COLOR"),Ee==="linear"&&pe.push("RASTER_ARRAY_LINEAR"),Ye=de.NEAREST,!Pe&&J.rasterLayers)){let He=J.rasterLayers.find(({id:je})=>je===oe.sourceLayer);He&&He.fields&&He.fields.range&&(Pe=He.fields.range)}if(Pe=Pe||[0,1],ve){pe.push("RASTER_COLOR"),ue.activeTexture.set(de.TEXTURE2),oe.updateColorRamp(Pe);let He=oe.colorRampTexture;He||(He=oe.colorRampTexture=new h.T(ue,oe.colorRamp,de.RGBA8)),He.bind(Ye,de.CLAMP_TO_EDGE)}return be&&pe.push("USE_MRT1"),{mix:Ce,range:Pe,offset:Re,defines:pe,resampling:Ye}}(z,o,A,D,a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback");if(z instanceof h.aY&&!c.length&&!y)return;let k=o.paint.get("raster-emissive-strength"),N=a.colorModeForDrapableLayerRenderPass(k),q=a.terrain&&a.terrain.renderingToTexture,Z=!a.options.moving,G=o.paint.get("raster-resampling")==="nearest"?D.NEAREST:D.LINEAR;if(z instanceof h.aY&&!c.length&&(z.onNorthPole||z.onSouthPole)){let J=v?a.stencilModeFor3D():yt.disabled;return void Hc(!!z.onNorthPole,null,a,t,o,k,O,pt.disabled,J)}if(!c.length)return;let[re,te]=z instanceof h.aY||q?[{},c]:a.stencilConfigForOverlap(c),se=te.at(-1).overscaledZ;T&&O.defines.push("PROJECTION_GLOBE_VIEW"),v&&O.defines.push("RENDER_CUTOFF","ELEVATED"),E&&O.defines.push("ELEVATION_REFERENCE_GROUND");let K=(J,oe,ue)=>{for(let de of J){let be=de.toUnwrapped(),ve=t.getTile(de);if(q&&(!ve||!ve.hasData()))continue;A.activeTexture.set(D.TEXTURE0);let Fe=Ud(ve,z,o,O);if(!Fe||!Fe.texture)continue;let{texture:pe,mix:Ee,offset:fe,tileSize:Pe,buffer:Ce}=Fe,Re,Ye;q?(Re=nt.disabled,Ye=de.projMatrix):v?(Re=new nt(D.LEQUAL,nt.ReadWrite,a.depthRangeFor3D),Ye=y?a.transform.expandedFarZProjMatrix:a.transform.calculateProjMatrix(be,Z)):(Re=a.depthModeForSublayer(de.overscaledZ-se,_===1?nt.ReadWrite:nt.ReadOnly,D.LESS),Ye=a.transform.calculateProjMatrix(be,Z));let He=a.terrain&&q?a.terrain.stencilModeForRTTOverlap(de):re[de.overscaledZ],je=m?0:o.paint.get("raster-fade-duration");ve.registerFadeDuration(je);let Ue=t.findLoadedParent(de,0),lt=Qe(ve,Ue,t,a.transform,je),st,et;!lt.isFading&&ve.refreshedUponExpiration&&(ve.refreshedUponExpiration=!1),a.terrain&&a.terrain.prepareDrawTile(),A.activeTexture.set(D.TEXTURE0),pe.bind(G,D.CLAMP_TO_EDGE),A.activeTexture.set(D.TEXTURE1),Ue?(Ue.texture&&Ue.texture.bind(G,D.CLAMP_TO_EDGE),st=Math.pow(2,Ue.tileID.overscaledZ-ve.tileID.overscaledZ),et=[ve.tileID.canonical.x*st%1,ve.tileID.canonical.y*st%1]):pe.bind(G,D.CLAMP_TO_EDGE),"useMipmap"in pe&&A.extTextureFilterAnisotropic&&a.transform.pitch>20&&D.texParameterf(D.TEXTURE_2D,A.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,A.extTextureFilterAnisotropicMax);let it=a.transform,ht,vt=v?Nd(it):[0,0,0,0],gt,Et,xt,kt,Tt,Vt=0;if(T&&z instanceof h.aY&&z.coordinates.length>3)gt=Float32Array.from(h.dx(h.dy(new h.cp(0,0,0)))),Et=Float32Array.from(it.globeMatrix),xt=Float32Array.from(h.dt(it)),kt=[h.aG(it.center.lng),h.aJ(it.center.lat)],ht=z.elevatedGlobePerspectiveTransform,Tt=z.elevatedGlobeGridMatrix||new Float32Array(9);else if(T){let Xt=h.du(de.canonical);Vt=h.dv(Xt.getCenter().lat),gt=Float32Array.from(h.dx(h.dy(de.canonical))),Et=Float32Array.from(it.globeMatrix),xt=Float32Array.from(h.dt(it)),kt=[h.aG(it.center.lng),h.aJ(it.center.lat)],ht=[0,0],Tt=Float32Array.from(h.dw(de.canonical,Xt,Vt,it.worldSize/it._pixelsPerMercatorPixel))}else ht=z instanceof h.aY?z.perspectiveTransform:[0,0],gt=new Float32Array(16),Et=new Float32Array(9),xt=new Float32Array(16),kt=[0,0],Tt=new Float32Array(9);let qt=Xu(a,Ye,gt,Et,xt,Tt,et||[0,0],h.ai(a.transform.zoom),kt,vt,st||1,lt,o,ht,v?o.paint.get("raster-elevation"):0,2,Ee,fe,O.range,Pe,Ce,k),bi=a.isTileAffectedByFog(de),li=a.getOrCreateProgram("raster",{defines:O.defines,overrideFog:bi});if(a.uploadCommonUniforms(A,li,be),z instanceof h.aY){let Xt=z.elevatedGlobeVertexBuffer,At=z.elevatedGlobeIndexBuffer;
3281if(q||!y)z.boundsBuffer&&z.boundsSegments&&li.draw(a,D.TRIANGLES,Re,yt.disabled,N,pt.disabled,qt,o.id,z.boundsBuffer,a.quadTriangleIndexBuffer,z.boundsSegments);else if(Xt&&At){let Ct=it.zoom<=h.cN?z.elevatedGlobeSegments:z.getSegmentsForLongitude(it.center.lng);Ct&&li.draw(a,D.TRIANGLES,Re,yt.disabled,N,oe,qt,o.id,Xt,At,Ct)}}else if(T){Re=new nt(D.LEQUAL,nt.ReadOnly,a.depthRangeFor3D);let Xt=a.globeSharedBuffers;if(Xt){E&&(a.terrain.setupElevationDraw(ve,li),a.uploadCommonUniforms(A,li,ve.tileID.toUnwrapped()));let[At,Ct,ci]=Xt.getGridBuffers(Vt,!1),Li=li.getAttributeLocation(D,"a_texture_pos");Li!==-1&&D.vertexAttribI4ui(Li,0,0,0,0),li.draw(a,D.TRIANGLES,Re,ue||He,a.colorModeForRenderPass(),oe,qt,o.id,At,Ct,ci)}}else if(P)Re=new nt(D.LEQUAL,nt.ReadWrite,a.depthRangeFor3D),a.terrain.setupElevationDraw(ve,li),a.uploadCommonUniforms(A,li,ve.tileID.toUnwrapped()),it.pitch>20&&li.draw(a,D.TRIANGLES,Re,yt.disabled,_t.disabled,pt.frontCCW,qt,o.id,a.terrain.gridBuffer,a.terrain.gridIndexBuffer,a.terrain.gridSegments),li.draw(a,D.TRIANGLES,Re,He,N,pt.backCCW,qt,o.id,a.terrain.gridBuffer,a.terrain.gridIndexBuffer,a.terrain.gridSegments);else{let{tileBoundsBuffer:Xt,tileBoundsIndexBuffer:At,tileBoundsSegments:Ct}=a.getTileBoundsBuffers(ve);li.draw(a,D.TRIANGLES,Re,He,N,pt.disabled,qt,o.id,Xt,At,Ct)}}if(!(z instanceof h.aY)&&T)for(let de of J){let be=de.canonical.y===(1<<de.canonical.z)-1;de.canonical.y===0&&Hc(!0,de,a,t,o,k,O,oe,ue||yt.disabled),be&&Hc(!1,de,a,t,o,k,O,oe===pt.frontCW?pt.backCW:pt.frontCW,ue||yt.disabled)}};T?K(te,a.renderElevatedRasterBackface?pt.backCW:pt.frontCW,a.stencilModeFor3D()):K(te,pt.disabled,void 0),a.resetStencilClippingMasks()},background:function(a,t,o,c){let d=o.paint.get("background-color"),m=o.paint.get("background-color-use-theme").constantOr("default")==="none",_=o.paint.get("background-opacity"),y=o.paint.get("background-emissive-strength"),v=o.paint.get("background-pitch-alignment")==="viewport";if(_===0)return;let T=a.context,E=T.gl,P=a.transform,A=P.tileSize,D=o.paint.get("background-pattern"),z;if(D!==void 0&&(D===null||(z=a.imageManager.getPattern(h.I.from(D.toString()),o.scope,a.style.getLut(o.scope)),!z)))return;let O=!D&&d.a===1&&_===1&&a.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.renderPass!==O)return;let k=yt.disabled,N=a.depthModeForSublayer(0,O==="opaque"?nt.ReadWrite:nt.ReadOnly),q=a.colorModeForDrapableLayerRenderPass(y),Z=D?"backgroundPattern":"background",G,re=c;re||(G=a.getBackgroundTiles(),re=Object.values(G).map(se=>se.tileID)),D&&(T.activeTexture.set(E.TEXTURE0),a.imageManager.bind(a.context,o.scope));let te=[];if(a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&te.push("USE_MRT1"),v){let se=a.getOrCreateProgram(Z,{overrideFog:!1,overrideRtt:!0,defines:te}),K=Ur,J=new h.aU(0,0,0,0,0),oe=D?Wf(K,y,_,a,0,o.scope,z,v,{tileID:J,tileSize:A}):Yu(K,y,_,d.toPremultipliedRenderColor(m?null:o.lut));return void se.draw(a,E.TRIANGLES,N,k,q,pt.disabled,oe,o.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments)}for(let se of re){let K=a.isTileAffectedByFog(se),J=a.getOrCreateProgram(Z,{overrideFog:K,defines:te}),oe=se.toUnwrapped(),ue=c?se.projMatrix:a.transform.calculateProjMatrix(oe);a.prepareDrawTile();let de=t?t.getTile(se):G?G[se.key]:new h.b3(se,A,P.zoom,a),be=D?Wf(ue,y,_,a,0,o.scope,z,v,{tileID:se,tileSize:A}):Yu(ue,y,_,d.toPremultipliedRenderColor(m?null:o.lut));a.uploadCommonUniforms(T,J,oe);let{tileBoundsBuffer:ve,tileBoundsIndexBuffer:Fe,tileBoundsSegments:pe}=a.getTileBoundsBuffers(de);J.draw(a,E.TRIANGLES,N,k,q,pt.disabled,be,o.id,ve,Fe,pe)}},sky:function(a,t,o){let c=a._atmosphere?h.ai(a.transform.zoom):1,d=o.paint.get("sky-opacity")*c;if(d===0)return;let m=a.context,_=o.paint.get("sky-type"),y=new nt(m.gl.LEQUAL,nt.ReadOnly,[0,1]),v=a.frameCounter/1e3%1;_==="atmosphere"?a.renderPass==="offscreen"?o.needsSkyboxCapture(a)&&(function(T,E){let P=T.context,A=P.gl,D=E.skyboxFbo;if(!D){D=E.skyboxFbo=P.createFramebuffer(32,32,1,null),E.skyboxGeometry=new Yi(P),E.skyboxTexture=P.gl.createTexture(),A.bindTexture(A.TEXTURE_CUBE_MAP,E.skyboxTexture),A.texParameteri(A.TEXTURE_CUBE_MAP,A.TEXTURE_WRAP_S,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_CUBE_MAP,A.TEXTURE_WRAP_T,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_CUBE_MAP,A.TEXTURE_MIN_FILTER,A.LINEAR),A.texParameteri(A.TEXTURE_CUBE_MAP,A.TEXTURE_MAG_FILTER,A.LINEAR);for(let N=0;N<6;++N)A.texImage2D(A.TEXTURE_CUBE_MAP_POSITIVE_X+N,0,A.RGBA,32,32,0,A.RGBA,A.UNSIGNED_BYTE,null)}P.bindFramebuffer.set(D.framebuffer),P.viewport.set([0,0,32,32]);let z=E.getCenter(T,!0),O=T.getOrCreateProgram("skyboxCapture"),k=new Float64Array(16);h.en(k,.5*-Math.PI),Gs(T,E,O,k,z,0),h.en(k,.5*Math.PI),Gs(T,E,O,k,z,1),h.eo(k,.5*-Math.PI),Gs(T,E,O,k,z,2),h.eo(k,.5*Math.PI),Gs(T,E,O,k,z,3),h.bA(k),Gs(T,E,O,k,z,4),h.en(k,Math.PI),Gs(T,E,O,k,z,5),P.viewport.set([0,0,T.width,T.height])}(a,o),o.markSkyboxValid(a)):a.renderPass==="sky"&&function(T,E,P,A,D){let z=T.context,O=z.gl,k=T.transform,N=T.getOrCreateProgram("skybox");z.activeTexture.set(O.TEXTURE0),O.bindTexture(O.TEXTURE_CUBE_MAP,E.skyboxTexture);let q=((Z,G,re,te,se)=>({u_matrix:Z,u_sun_direction:G,u_cubemap:0,u_opacity:te,u_temporal_offset:se}))(k.skyboxMatrix,E.getCenter(T,!1),0,A,D);T.uploadCommonUniforms(z,N),N.draw(T,O.TRIANGLES,P,yt.disabled,T.colorModeForRenderPass(),pt.backCW,q,"skybox",E.skyboxGeometry.vertexBuffer,E.skyboxGeometry.indexBuffer,E.skyboxGeometry.segment)}(a,o,y,d,v):_==="gradient"&&a.renderPass==="sky"&&function(T,E,P,A,D){let z=T.context,O=z.gl,k=T.transform,N=T.getOrCreateProgram("skyboxGradient");E.skyboxGeometry||(E.skyboxGeometry=new Yi(z)),z.activeTexture.set(O.TEXTURE0);let q=E.colorRampTexture;q||(q=E.colorRampTexture=new h.T(z,E.colorRamp,O.RGBA8)),q.bind(O.LINEAR,O.CLAMP_TO_EDGE);let Z=((G,re,te,se,K)=>({u_matrix:G,u_color_ramp:0,u_center_direction:re,u_radius:h.am(te),u_opacity:se,u_temporal_offset:K}))(k.skyboxMatrix,E.getCenter(T,!1),E.paint.get("sky-gradient-radius"),A,D);T.uploadCommonUniforms(z,N),N.draw(T,O.TRIANGLES,P,yt.disabled,T.colorModeForRenderPass(),pt.backCW,Z,"skyboxGradient",E.skyboxGeometry.vertexBuffer,E.skyboxGeometry.indexBuffer,E.skyboxGeometry.segment)}(a,o,y,d,v)},custom:function(a,t,o,c){let d=a.context,m=o.implementation;if(!a.transform.projection.unsupportedLayers||!a.transform.projection.unsupportedLayers.includes("custom")||a.terrain&&(a.terrain.renderingToTexture||a.renderPass==="offscreen")&&o.isDraped(t)){if(a.renderPass==="offscreen"){let _=m.prerender;if(_){if(a.setCustomLayerDefaults(),d.setColorMode(a.colorModeForRenderPass()),a.transform.projection.name==="globe"){let y=a.transform.pointMerc;_.call(m,d.gl,a.transform.customLayerMatrix(),a.transform.getProjection(),a.transform.globeToMercatorMatrix(),h.ai(a.transform.zoom),[y.x,y.y],a.transform.pixelsPerMeterRatio)}else _.call(m,d.gl,a.transform.customLayerMatrix());d.setDirty(),a.setBaseState()}}else if(a.renderPass==="translucent"){if(a.terrain&&a.terrain.renderingToTexture){let y=m.renderToTile;if(y){let v=c[0].canonical,T={x:v.x+c[0].wrap*(m.wrapTileId?0:1<<v.z),y:v.y,z:v.z};d.setDepthMode(nt.disabled),d.setStencilMode(yt.disabled),d.setColorMode(a.colorModeForRenderPass()),a.setCustomLayerDefaults();let E=d.gl;a.emissiveMode==="mrt-fallback"&&E.drawBuffers([E.COLOR_ATTACHMENT0]),y.call(m,d.gl,T),a.emissiveMode==="mrt-fallback"&&E.drawBuffers([E.COLOR_ATTACHMENT0,E.COLOR_ATTACHMENT1]),d.setDirty(),a.setBaseState()}return}a.setCustomLayerDefaults(),d.setColorMode(a.colorModeForRenderPass()),d.setStencilMode(yt.disabled);let _=m.renderingMode==="3d"?new nt(a.context.gl.LEQUAL,nt.ReadWrite,a.depthRangeFor3D):a.depthModeForSublayer(0,nt.ReadOnly);if(d.setDepthMode(_),a.transform.projection.name==="globe"){let y=a.transform.pointMerc;m.render(d.gl,a.transform.customLayerMatrix(),a.transform.getProjection(),a.transform.globeToMercatorMatrix(),h.ai(a.transform.zoom),[y.x,y.y],a.transform.pixelsPerMeterRatio)}else m.render(d.gl,a.transform.customLayerMatrix());d.setDirty(),a.setBaseState(),d.bindFramebuffer.set(null)}}else h.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(a,t,o,c){if(a.renderPass==="opaque")return;let d=o.paint.get("model-opacity").constantOr(1),m=o.paint.get("model-elevation-reference"),_=m==="ground",y=m==="ground";if(d===0)return;let v=o.paint.get("model-cast-shadows");
3281if(a.renderPass==="shadow"&&(!v||a.terrain&&d<.65&&o._transitionablePaint._values["model-opacity"].value.expression instanceof h.ac))return;let T=a.shadowRenderer,E=o.paint.get("model-receive-shadows");T&&(T.useNormalOffset=!0,E||(T.enabled=!1));let P=()=>{T&&(T.useNormalOffset=!0,E||(T.enabled=!0))},A=t.getSource();if(a.renderPass==="light-beam"&&A.type!=="batched-model")return;if(A.type==="vector"||A.type==="geojson")return function(G,re,te,se,K){let J=G.transform,oe=J.projection.name==="globe",ue=J.getFreeCameraOptions().position;if(!G.modelManager)return;let de=G.modelManager;te.modelManager=de;let be=G.shadowRenderer;if(!Object.hasOwn(te._unevaluatedLayout._values,"model-id"))return;let ve=te._unevaluatedLayout._values["model-id"],Fe=Object.assign({},te.layout.get("model-id").parameters),pe=G.style.order.indexOf(te.fqid),Ee=te.paint.get("model-opacity").constantOr(1);for(let fe of se){let Pe=re.getTile(fe).getBucket(te);if(!Pe||Pe.projection.name!==J.projection.name)continue;let Ce=Pe.getModelUris();if(Ce&&!Pe.modelsRequested&&(de.addModelsFromBucket(Ce,K),Pe.modelsRequested=!0),oe)Fe.zoom=fe.overscaledZ;else{let et=hm(fe,J);Fe.zoom=et}let Re=ve.possiblyEvaluate(Fe);if(um(G,Pe,fe),wo.shadowUniformsInitialized=!1,wo.useSingleShadowCascade=!!be&&be.getMaxCascadeForTile(fe.toUnwrapped())===0,G.renderPass==="shadow"&&be){if(G.currentShadowCascade===1&&Pe.isInsideFirstShadowMapFrustum)continue;let et=J.calculatePosMatrix(fe.toUnwrapped(),J.worldSize);if(wo.tileMatrix.set(et),wo.shadowTileMatrix.set(be.calculateShadowPassMatrixFromMatrix(et)),wo.aabb.min=[0,0,0],wo.aabb.max[0]=wo.aabb.max[1]=h.ak,wo.aabb.max[2]=0,ag(Pe,wo,G,te.scope))continue}let Ye=1<<fe.canonical.z,He=[((ue.x-fe.wrap)*Ye-fe.canonical.x)*h.ak,(ue.y*Ye-fe.canonical.y)*h.ak,ue.z*Ye*h.ak];G.conflationActive&&Object.keys(Pe.instancesPerModel).length>0&&G.style.isLayerClipped(te,re.getSource())&&Pe.updateReplacement(fe,G.replacementSource,pe,te.scope)&&(Pe.uploaded=!1,Pe.upload(G.context));let je=0,Ue=new Array,lt=new Array,st=new Array;for(let et in Pe.instancesPerModel){let it=Pe.instancesPerModel[et];it.features.length>0&&!oe&&(et=Re.evaluate(it.features[0].feature,{}));let ht=de.getModel(et,K);if(ht||de.hasURLBeenRequested(et)||Pe.modelUris.includes(et)||(Pe.modelUris.push(et),Pe.modelsRequested=!1),ht&&ht.uploaded)if(oe){let vt=h.bN([],[ue.x,ue.y,ue.z],G.transform.worldSize);h.ew(vt,vt);for(let gt=0;gt<it.instancedDataArray.length;++gt){let Et=[0,0,0],xt=[1,1,1],kt=h.ex(),Tt=it.tileCoordinatesForInstance(gt),Vt=it.transformForInstance(gt);h.ey(xt,Vt),h.ez(kt,Vt),h.eA(Et,kt);let qt=it.translationForInstance(gt),bi=new h.aX(0,0);h.eB(Pe.canonical,bi,Tt.x,Tt.y);let li=h.bd();h.eC(li,ht,G.transform,bi,Et,xt,qt,!0,!1,!1);let Xt=it.colorForInstance(gt),At=h.cK([],vt),Ct=h.e8(bi.lat,G.transform.zoom),ci=h.bT([],[1,1,1/Ct]);st.push({zScaleMatrix:ci,negCameraPosMatrix:At});for(let Li of ht.nodes)$c(G,Li,li,G.transform.expandedFarZProjMatrix,je,Ue,lt,ht.materialOverrides,Ee,Xt);++je}}else for(let vt of ht.nodes)Jd(G,te,vt,it,He,fe,wo)}if(oe)if(G.renderPass==="shadow"){for(let et of lt)zl(et.mesh,et.nodeModelMatrix,G,te);for(let et of Ue)zl(et.mesh,et.nodeModelMatrix,G,te)}else Yd(G,te,Ue,lt,st)}}(a,t,o,c,Wd(a,o)),void P();if(!A.loaded())return;if(A.type==="batched-model")return function(G,re,te,se){te.resetLayerRenderingStats(G);let K=G.context,J=G.transform,oe=G.style.fog,ue=G.shadowRenderer;if(J.projection.name!=="mercator")return void h.w(`Drawing 3D landmark models for ${J.projection.name} projection is not yet implemented`);let de=G.transform.getFreeCameraOptions().position,be=h.bN([],[de.x,de.y,de.z],G.transform.worldSize),ve=h.ew([],be),Fe=h.cK([],ve),pe=h.e8(J.center.lat,J.zoom),Ee=h.bT([],[1,1,1/pe]),fe=te.paint.get("model-opacity").constantOr(1),Pe=new nt(K.gl.LEQUAL,nt.ReadWrite,G.depthRangeFor3D),Ce=new nt(K.gl.LEQUAL,nt.ReadOnly,G.depthRangeFor3D),Re=new h.cY([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),Ye=G.renderPass==="shadow",He=Ye&&ue?ue.getCurrentCascadeFrustum():J.getFrustum(J.scaleZoom(J.worldSize)),je=te.paint.get("model-front-cutoff"),Ue=je[2]<1,lt=Ps(G,te.paint.get("model-cutoff-fade-range")),st=te.getLayerRenderingStats();(function(et,it,ht,vt){let gt=et.terrain?et.terrain.exaggeration():0,Et=et.transform.zoom;for(let xt of vt){let kt=it.getTile(xt).getBucket(ht);kt&&(kt.setFilter(ht.filter),et.conflationActive&&kt.updateReplacement(xt,et.replacementSource),kt.evaluateTransform(et,ht),et.terrain&&gt>0&&kt.elevationUpdate(et.terrain,gt,xt,ht.source),kt.needsReEvaluation(et,Et,ht)&&kt.evaluate(ht))}})(G,re,te,se),function(){let et=new Map,it,ht,vt;Ue?(it=se.length-1,ht=-1,vt=-1):(it=0,ht=se.length,vt=1);let gt=new Float64Array(16),Et=h.cg(),xt=new h.P(0,0);for(let kt=it;kt!==ht;kt+=vt){let Tt=se[kt],Vt=re.getTile(Tt).getBucket(te);if(!Vt||!Vt.uploaded)continue;let qt=!1;ue&&(qt=ue.getMaxCascadeForTile(Tt.toUnwrapped())===0);let bi=J.calculatePosMatrix(Tt.toUnwrapped(),J.worldSize),li=Vt.modelTraits;!Ye&&Ue&&(h.ba(gt,bi),h.ae(Et,be,gt),xt.x=Et[0],xt.y=Et[1]);let Xt=[];Vt.setFilter(te.filter);
3281for(let At of Vt.getNodesInfo()){if(At.hiddenByReplacement||!At.node.meshes)continue;let Ct=At.node,ci=0;G.terrain&&Ct.elevation&&(ci=Ct.elevation*G.terrain.exaggeration());let Li=(()=>{let cn=At.aabb;return Re.min=[...cn.min],Re.max=[...cn.max],Re.min[2]+=ci,Re.max[2]+=ci,h.ae(Re.min,Re.min,bi),h.ae(Re.max,Re.max,bi),Re})(),ti=At.evaluatedScale;if(ti[0]<=1&&ti[1]<=1&&ti[2]<=1&&Li.intersects(He)===0)continue;if(!Ye){let cn=Li.min,cr=Li.max;Pl[0]=.5*(cn[0]+cr[0]),Pl[1]=.5*(cn[1]+cr[1]),Pl[2]=.5*(cn[2]+cr[2]);let tr=h.bh(be,Pl)*pe;pm(At,tr,Math.min(G._debugParams.dt,1e3/30),G._debugParams.lodSwitchDistance)}if(!Ye&&Ue){let cn=.16666666666666666;At.cameraCollisionOpacity=be[0]>Li.min[0]&&be[0]<Li.max[0]&&be[1]>Li.min[1]&&be[1]<Li.max[1]&&be[2]*pe<Li.max[2]&&Ct.footprint&&h.bG(xt,Ct.footprint)?Math.max(At.cameraCollisionOpacity-cn,0):Math.min(1,At.cameraCollisionOpacity+cn)}let wt=[...bi],yi=1/h.cW(Tt.canonical),fi=Ct.anchor?Ct.anchor[0]:0,Ui=Ct.anchor?Ct.anchor[1]:0;h.bB(wt,wt,[fi*(ti[0]-1)+At.evaluatedTranslation[0]*yi,Ui*(ti[1]-1)+At.evaluatedTranslation[1]*yi,ci+At.evaluatedTranslation[2]]),h.c6(ti,h.eE)||h.cE(wt,wt,ti);let Nt=h.aC([],wt,Ct.globalMatrix),Ji=h.aC([],J.expandedFarZProjMatrix,Nt),Vn=h.aC([],J.expandedFarZProjMatrix,wt),pn=h.aD([],[fi,Ui,ci,1],Ji)[2];Ct.hidden=!1;let In=fe;Ye||(Ue&&(In*=At.cameraCollisionOpacity,In*=cg(wt,J,At.aabb,je)),In*=lg(lt,pn)),In!==0?Xt.push({nodeInfo:At,depth:pn,opacity:In,wvpForNode:Ji,wvpForTile:Vn,nodeModelMatrix:Nt,tileModelMatrix:wt}):Ct.hidden=!0}Ye||Xt.sort((At,Ct)=>!Ue||At.opacity===1&&Ct.opacity===1?At.depth<Ct.depth?-1:1:At.opacity===1?-1:Ct.opacity===1?1:At.depth>Ct.depth?-1:1);for(let At of Xt){let Ct=At.nodeInfo,ci=Ct.node;if(G._debugParams.show3DModelFootprints&&ci.footprint){let pn=ci.id||ci.name||"footprint";et.has(pn)||et.set(pn,{node:ci,mvp:At.wvpForTile})}h.aC(fr,Ee,At.tileModelMatrix),h.aC(fr,Fe,fr),h.ba(sr,fr),h.e9(sr,sr),h.cE(sr,sr,dm),h.aC(fr,fr,ci.globalMatrix);let Li=G.renderPass==="light-beam",ti=te.paint.get("model-color-use-theme").constantOr("default")==="none",wt=li&h.eH.HasMapboxMeshFeatures,yi=wt?0:Ct.evaluatedRMEA[0][2],fi=Ct.targetLod,Ui=ci.lodMeshes&&ci.lodMeshes.length>0,Nt=Ui&&fi>0&&fi<1;if(Ye&&Ui&&Math.round(fi)===1)continue;let Ji=Nt?2:1,Vn=Ui&&Math.round(fi)===1;for(let pn=0;pn<Ji;++pn){let In=Nt?pn===1:Vn,cn=In?ci.lodMeshes:ci.meshes,cr=Nt?In?-fi:1-fi:1;for(let tr=0;tr<cn.length;++tr){let zi=cn[tr],Vi=!In&&tr===ci.lightMeshIndex,Ii=At.wvpForNode;if(Vi){if(!Li&&!G.terrain&&G.shadowRenderer){G.currentLayer<G.firstLightBeamLayer&&(G.firstLightBeamLayer=G.currentLayer);continue}Ii=At.wvpForTile}else if(Li)continue;let ii={defines:[]},si=[];if(!Ye&&ue&&(ue.useNormalOffset=!!zi.normalBuffer),Rl(ii.defines,si,zi,G,ti?null:te.lut),wt||ii.defines.push("DIFFUSE_SHADED"),qt&&ii.defines.push("SHADOWS_SINGLE_CASCADE"),st&&(Ye?st.numRenderedVerticesInShadowPass+=zi.vertexArray.length:st.numRenderedVerticesInTransparentPass+=zi.vertexArray.length),Ye){zl(zi,At.nodeModelMatrix,G,te);continue}let Ki=null;if(oe&&(Ki=Dl(sh,At.nodeModelMatrix,G.transform),J.projection.name!=="globe")){let lo=zi.aabb.min,cs=zi.aabb.max,[us,Eo]=oe.getOpacityForBounds(Ki,lo[0],lo[1],cs[0],cs[1]);ii.overrideFog=us>=Ts||Eo>=Ts}let vn=zi.material,ki;vn.occlusionTexture&&vn.occlusionTexture.offsetScale&&(ki=vn.occlusionTexture.offsetScale,ii.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),Nt&&ii.defines.push("DITHERED_DISCARD");let bn=G.getOrCreateProgram("model",ii);!Ye&&ue&&ue.setupShadowsFromMatrix(At.tileModelMatrix,bn,ue.useNormalOffset),G.uploadCommonUniforms(K,bn,null,Ki);let Zr=vn.pbrMetallicRoughness;Zr.metallicFactor=.9,Zr.roughnessFactor=.5;let ur=Rd(Ii,fr,sr,ci.globalMatrix,G,At.opacity,Zr.baseColorFactor,vn.emissiveFactor,Zr.metallicFactor,Zr.roughnessFactor,vn,yi,te,[0,0,0],ki,void 0,void 0,cr);!Vi&&(Ct.hasTranslucentParts||At.opacity<1)&&bn.draw(G,K.gl.TRIANGLES,Pe,yt.disabled,_t.disabled,pt.backCCW,ur,te.id,zi.vertexBuffer,zi.indexBuffer,zi.segments,te.paint,G.transform.zoom,void 0,si),bn.draw(G,K.gl.TRIANGLES,Vi?Ce:Pe,yt.disabled,Vi||At.opacity<1||Ct.hasTranslucentParts?_t.alphaBlended:_t.unblended,pt.backCCW,ur,te.id,zi.vertexBuffer,zi.indexBuffer,zi.segments,te.paint,G.transform.zoom,void 0,si)}}}}if(G._debugParams.show3DModelFootprints&&et.size>
32810){let kt=Array.from(et.keys()).sort();for(let Tt of kt){let{node:Vt,mvp:qt}=et.get(Tt);Xd(G,0,Vt,qt)}}}()}(a,t,o,c),void P();if(A.type!=="model")return;let D=A.getModels(),z=[],O=a.transform.getFreeCameraOptions().position,k=h.bN([],[O.x,O.y,O.z],a.transform.worldSize);h.ew(k,k);let N=[],q=[],Z=0;for(let G of D){let re=t.getFeatureState("",G.id),te={type:"Unknown",id:G.id,properties:G.featureProperties},se=o.paint.get("model-rotation").evaluate(te,re),K=o.paint.get("model-scale").evaluate(te,re),J=o.paint.get("model-translation").evaluate(te,re),oe=o.paint.get("model-opacity").evaluate(te,re);lm(o,G.id,re,G.featureProperties,G.nodeOverrideNames,G.nodeOverrides),cm(o,G.id,re,G.featureProperties,G.materialOverrideNames,G.materialOverrides),G.nodeOverrides.size>0&&G.computeBoundsAndApplyParent(),G.computeModelMatrix(a,se,K,J,y,_,!1);let ue=h.cK([],k),de=h.e8(G.position.lat,a.transform.zoom),be=h.bT([],[1,1,1/de]);z.push({zScaleMatrix:be,negCameraPosMatrix:ue});for(let ve of G.nodes)$c(a,ve,G.matrix,a.transform.expandedFarZProjMatrix,Z,N,q,G.materialOverrides,oe);Z++}if(N.sort((G,re)=>re.depth-G.depth),a.renderPass!=="shadow"){if(a._debugParams.show3DModelFootprints){let G=a.transform.projMatrix,re=new Map,te=(K,J)=>{if(K.footprint){let oe=K.id||K.name||"footprint";if(!re.has(oe)){let ue=h.aC([],G,J);re.set(oe,{node:K,mvp:ue})}}};for(let K of q)te(K.node,K.modelMatrix);for(let K of N)te(K.node,K.modelMatrix);let se=Array.from(re.keys()).sort();for(let K of se){let{node:J,mvp:oe}=re.get(K);Xd(a,0,J,oe)}}Yd(a,o,N,q,z),P()}else{for(let G of q)zl(G.mesh,G.nodeModelMatrix,a,o);for(let G of N)zl(G.mesh,G.nodeModelMatrix,a,o);P()}}},Kd={line:function(a,t,o){if(a.hasElevatedBuckets=!1,a.hasNonElevatedBuckets=!1,a._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||a._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(t){let c=t.getVisibleCoordinates();for(let d of c){let m=t.getTile(d).getBucket(a);if(m&&(m.elevationType!=="none"?a.hasElevatedBuckets=!0:a.hasNonElevatedBuckets=!0,a.hasElevatedBuckets&&a.hasNonElevatedBuckets))break}}}else a.hasNonElevatedBuckets=!0},model:function(a,t,o){let c=t.getSource();if(!c.loaded())return;if(c.type==="vector"||c.type==="geojson")return void(o.modelManager&&o.modelManager.upload(o,Wd(o,a)));if(c.type==="batched-model"||c.type!=="model")return;let d=c.getModels();for(let m of d)m.upload(o.context)},raster:function(a,t,o){let c=t.getSource();if(!(c instanceof Ht&&c.loaded()))return;let d=a.sourceLayer||c.rasterLayerIds&&c.rasterLayerIds[0];if(!d)return;let m=a.paint.get("raster-array-band")||c.getInitialBand(d);if(m==null)return;let _=t.getIds().map(y=>t.getTileByID(y));for(let y of _)y.updateNeeded(a.id,m)&&c.prepareTile(y,d,a.id,m)}},Fl={fill:za},Qd={fill:function(a,t,o,c){if(!o.layout||o.layout.get("fill-elevation-reference")==="none"||o.paint.get("fill-opacity").constantOr(1)===0)return;let d=a.context.gl,m=new nt(d.LEQUAL,nt.ReadOnly,a.depthRangeFor3D),_=new yt({func:d.ALWAYS,mask:255},255,255,d.KEEP,d.KEEP,d.REPLACE),y=a.transform.getFreeCameraOptions().position,v=a.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(let T of c){let E=t.getTile(T),P=E.getBucket(o);if(!P)continue;let A=P.elevatedStructures;if(!A||!A.depthSegments||A.depthSegments.segments[0].primitiveLength===0)continue;let D=Ze(T.toUnwrapped(),y),z=a.translatePosMatrix(T.projMatrix,E,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor")),O=zc(z,D,0,1,0);v.draw(a,d.TRIANGLES,m,_,_t.disabled,pt.disabled,O,o.id,A.vertexBuffer,A.indexBuffer,A.depthSegments,o.paint,a.transform.zoom)}}};class ep{constructor(t,o,c,d,m){this.context=new Bs(t,o),this.transform=c,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._debugParams={averageFPS:0,fpsHistory:[],fpsWindow:30,dt:0,timeStamp:h.o.now(),continousRedraw:!1,enabledLayers:{},buildingsShowNormals:!1,buildingsDrawGroundAO:!0,buildingsDrawShadowPass:!0,buildingsDrawTranslucentPass:!0,showTerrainProxyTiles:!1,terrainSortTilesHiZFirst:!0,terrainDisableRenderCache:!1,forceEnablePrecipitation:!1,overrideSnowParams:!1,snowParamsOverride:null,snowRevealParamsOverride:null,snowVignetteParam
3281sOverride:null,overrideRainParams:!1,rainParamsOverride:null,rainRevealParamsOverride:null,rainVignetteParamsOverride:null,overrideStarsParams:!1,starsParamsOverride:null,show3DModelFootprints:!1,showElevationIdDebug:!1,lodSwitchDistance:3e3},this.occlusionParams=new ug,this.setup(),this.numSublayers=on.maxUnderzooming+on.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new h.eJ,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new yf(this),this._wireframeDebugCache=new Ol,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];let _=new h.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new h.T(this.context,_,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=d,this.maxFrontCutoffRawStart=0,this.worldview=m,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(t,o){let c=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(c||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new bd(this,t));let d=this._terrain;this.transform.elevation=c?d:null,d.update(t,this.transform,o),this.transform.elevation&&!d.enabled&&(this.transform.elevation=null)}_updateFog(t){let o=t.fog;if(!o||this.transform.projection.name==="globe"||o.getOpacity(this.transform.pitch)<1||o.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);let[c,d]=o.getRangeForProjection();if(c>d)return void(this.transform.fogCullDistSq=null);let m=c+.78*(d-c);this.transform.fogCullDistSq=m*m}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(t){t&&!this._terrain&&(this._terrain=new bd(this,this.style)),this._forceTerrainMode=t}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,o){if(this.width=t*h.o.devicePixelRatio,this.height=o*h.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let c of this.style.order)this.style._mergedLayers[c].resize()}setup(){let t=this.context,o=new h.dE;o.emplaceBack(0,0),o.emplaceBack(h.ak,0),o.emplaceBack(0,h.ak),o.emplaceBack(h.ak,h.ak),this.tileExtentBuffer=t.createVertexBuffer(o,h.dA.members),this.tileExtentSegments=h.dB.simpleSegment(0,0,4,2);let c=new h.dE;c.emplaceBack(0,0),c.emplaceBack(h.ak,0),c.emplaceBack(0,h.ak),c.emplaceBack(h.ak,h.ak),this.debugBuffer=t.createVertexBuffer(c,h.dA.members),this.debugSegments=h.dB.simpleSegment(0,0,4,5);let d=new h.dE;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,h.dA.members),this.viewportSegments=h.dB.simpleSegment(0,0,4,2);let m=new h.eK;m.emplaceBack(0,0,0,0),m.emplaceBack(h.ak,0,h.ak,0),m.emplaceBack(0,h.ak,0,h.ak),m.emplaceBack(h.ak,h.ak,h.ak,h.ak),this.mercatorBoundsBuffer=t.createVertexBuffer(m,h.eL.members),this.mercatorBoundsSegments=h.dB.simpleSegment(0,0,4,2);let _=new h.dF;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(_);let y=new h.eM;for(let T of[0,1,3,2,0])y.emplaceBack(T);this.debugIndexBuffer=t.createIndexBuffer(y),this.emptyTexture=new h.T(t,new h.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=h.bd();let v=this.context.gl;this.stencilClearMode=new yt({func:v.ALWAYS,mask:0},0,255,v.ZERO,v.ZERO,v.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){let t=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,t.TRIANGLES,nt.disabled,this.stencilClearMode,_t.disabled,pt.disabled,wl(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,o,c){if(!o||this.currentStencilSource===o.id||!t.isTileClipped()||!c||c.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let y=!1;for(let v of c)if(this._tileClippingMaskIDs[v.key]===void 0){y=!0;break}if(!y)return}this.currentStencilSource=o.id;let d=this.context,m=d.gl;this.nextStencilID+c.length>256&&this.clearStencil(),d.setColorMode(_t.disabled),d.setDepthMode(nt.disabled);let _=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(let y of c){let v=o.getTile(y),T=this._tileClippingMaskIDs[y.key]=this.nextStencilID++,{tileBoundsBuffer:E,tileBoundsIndexBuffer:P,tileBoundsSegments:A}=this.getTileBoundsBuffers(v);_.draw(this,m.TRIANGLES,nt.disabled,new yt({func:m.ALWAYS,mask:0},T,255,m.KEEP,m.KEEP,m.REPLACE),_t.disabled,pt.disabled,wl(y.projMatrix),"$clipping",E,P,A)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,o=this.context.gl;return new yt({func:o.NOTEQUAL,mask:255},t,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);let o=this.context.gl;return new yt({func:o.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(t){let o=this.context.gl,c=t.sort((_,y)=>
3281y.overscaledZ-_.overscaledZ),d=c.at(-1).overscaledZ,m=c[0].overscaledZ-d+1;if(m>1){this.currentStencilSource=void 0,this.nextStencilID+m>256&&this.clearStencil();let _={};for(let y=0;y<m;y++)_[y+d]=new yt({func:o.GEQUAL,mask:255},y+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=m,[_,c]}return[{[d]:yt.disabled},c]}colorModeForRenderPass(){let t=this.context.gl;return this._showOverdrawInspector?new _t([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new h.C(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?_t.unblended:_t.alphaBlended}colorModeForDrapableLayerRenderPass(t){let o=this.context.gl;return this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture&&this.renderPass==="translucent"?t!=null&&this.emissiveMode!=="mrt-fallback"||this.emissiveMode==="constant"?new _t([o.ONE,o.ONE_MINUS_SRC_ALPHA,o.CONSTANT_ALPHA,o.ONE_MINUS_SRC_ALPHA],new h.C(0,0,0,t??0),[!0,!0,!0,!0]):this.emissiveMode==="dual-source-blending"?new _t([o.ONE,o.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,o.ONE_MINUS_SRC_ALPHA],h.C.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(t,o,c,d=!1){if(this.depthOcclusion)return new nt(this.context.gl.GREATER,nt.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!d)return nt.disabled;let m=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new nt(c||this.context.gl.LEQUAL,o,[m,m])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){let t=this.context.gl,o=Math.ceil(this.width),c=Math.ceil(this.height),d=this.context.bindFramebuffer.get(),m=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===o&&this.depthFBO.height===c||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),o!==0&&c!==0&&(this.depthFBO=new En(this.context,o,c,0,"texture"),this.depthTexture=new h.T(this.context,{width:o,height:c,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(d),t.bindTexture(t.TEXTURE_2D,m),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,o,c,0,0,o,c,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current))}render(t,o){this.context.sweepPendingPrograms(),this._wireframeDebugCache.update(this.frameCounter),this.style=t,this.options=o;let c=this.style._mergedLayers,d=!(!this.terrain||!this.terrain.enabled),m=()=>this.style._getOrder(d),_=m(),y=!1,v=!1,T=null,E=0,P=!1;for(let pe of _){let Ee=c[pe];Ee.visibility!=="none"&&(Ee.type==="circle"?y=!0:Ee.type==="building"?(T=Ee,++E):Ee.type==="symbol"&&(Ee.hasOcclusionOpacityProperties?v=!0:y=!0))}this.updateEmissiveMode();let A=_.map(pe=>c[pe]),D=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(h.o.now()),this.imageManager.beginFrame();for(let pe in D){let Ee=D[pe];Ee.used&&(Ee.prepare(this.context),Ee.getSource().usedInConflation&&++E)}let z=!1;for(let pe of A)pe.isHidden(this.transform.zoom)||(pe.type==="clip"&&(z=!0),this.prepareLayer(pe));let O={},k={},N={},q={},Z={};for(let pe in D){let Ee=D[pe];O[pe]=Ee.getVisibleCoordinates(),k[pe]=O[pe].slice().reverse(),N[pe]=Ee.getVisibleCoordinates(!0).reverse(),q[pe]=Ee.getShadowCasterCoordinates(),Z[pe]=Ee.sortCoordinatesByDistance(O[pe])}let G=pe=>{let Ee=this.style.getLayerSourceCache(pe);return Ee&&Ee.used?Ee.getSource():null};if(E||z||this._clippingActiveLastFrame){let pe=[],Ee=[],fe=0;for(let Pe of A)this.isSourceForClippingOrConflation(Pe,G(Pe))&&(pe.push(Pe),Ee.push(fe)),fe++;if(pe&&(z||pe.length>1)||this._clippingActiveLastFrame){z=!1;let Pe=[];for(let Ce=0;Ce<pe.length;Ce++){let Re=pe[Ce],Ye=Ee[Ce],He=this.style.getLayerSourceCache(Re);if(!He||!He.used||!He.getSource().usedInConflation&&Re.type!=="clip"&&Re.type!=="building")continue;let je=h.eN,Ue=h.bE.None,lt=[],st=!0;if(Re.type==="building")je=h.eP;else if(Re.type==="clip")if(je=Ye,Re.isHidden(this.transform.zoom))st=!1;else{if(!Re.layout){st=!1;continue}
3281for(let et of Re.layout.get("clip-layer-types"))Ue|=et==="model"?h.bE.Model:et==="symbol"?h.bE.Symbol:h.bE.FillExtrusion;for(let et of Re.layout.get("clip-layer-scope"))lt.push(h.t(et,Re.scope));z=!0}st&&Pe.push({layer:Re.fqid,cache:He,order:je,clipMask:Ue,clipScope:lt})}this.replacementSource.setSources(Pe),P=!0}}this._clippingActiveLastFrame=z,P||this.replacementSource.clear(),this.conflationActive=P,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let pe=0;pe<A.length;pe++){let Ee=A[pe];if(Ee.visibility==="none")continue;let fe=Ee.cutoffRange();if(this.longestCutoffRange=Math.max(fe,this.longestCutoffRange),fe>0){let Pe=G(Ee);Pe&&(this.minCutoffZoom=Math.max(Pe.minzoom,this.minCutoffZoom)),Ee.minzoom&&(this.minCutoffZoom=Math.max(Ee.minzoom,this.minCutoffZoom))}Ee.is3D(d)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=pe),this._lastOcclusionLayer=pe)}let re=this.style&&this.style.fog;re?(this._fogVisible=re.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=re.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(N),this.opaquePassCutoff=0,_=m(),A=_.map(pe=>c[pe]));let te=this._shadowRenderer;if(te){te.updateShadowParameters(this.transform,this.style.directionalLight);for(let pe in D)for(let Ee of O[pe]){let fe={min:0,max:0};this.terrain&&(fe=this.terrain.getMinMaxForTile(Ee)||fe),te.addShadowReceiver(Ee.toUnwrapped(),fe.min,fe.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new h.eO(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new qd),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let se=!(!this.style||!this.style.snow),K=!(!this.style||!this.style.rain);if(se&&!this._snow&&so.Snow&&(this._snow=new so.Snow),!se&&this._snow&&(this._snow.destroy(),delete this._snow),K&&!this._rain&&so.Rain&&(this._rain=new so.Rain),!K&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),T){this.buildingTileBorderManager||(this.buildingTileBorderManager=new Zd);let pe=this.style.getLayerSourceCache(T);this.buildingTileBorderManager.updateBorders(pe,T)}if(!oa.has(this.context.gl))return;this.renderPass="offscreen";for(let pe of A){let Ee=t.getLayerSourceCache(pe);if(!pe.hasOffscreenPass()||pe.isHidden(this.transform.zoom))continue;let fe=Ee?k[Ee.id]:void 0;(pe.type==="custom"||pe.type==="raster"||pe.type==="raster-particle"||pe.isSky()||fe&&fe.length)&&this.renderLayer(this,Ee,pe,fe)}this.depthRangeFor3D=[0,1-(A.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,q)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let J=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),oe=(()=>{if(o.showOverdrawInspector)return h.C.black;let pe=this.style.fog;if(pe&&this.transform.projection.supportsFog){let Ee=this.style.getLut(pe.scope);if(!J){let fe=pe.properties.get("color-use-theme")==="none",Pe=pe.properties.get("color").toNonPremultipliedRenderColor(fe?null:Ee).toArray01();return new h.C(...Pe)}if(J){let fe=pe.properties.get("space-color-use-theme")==="none",Pe=pe.properties.get("space-color").toNonPremultipliedRenderColor(fe?null:Ee).toArray01();return new h.C(...Pe)}}return h.C.transparent})();if(this.context.clear({color:oe,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&J&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=_.length-1;this.currentLayer>=0;this.currentLayer--){let pe=A[this.currentLayer],Ee=t.getLayerSourceCache(pe);if(pe.isSky())continue;let fe=Ee?(pe.is3D(d)?Z:k)[Ee.id]:void 0;this._renderTileClippingMasks(pe,Ee,fe),this.renderLayer(this,Ee,pe,fe)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&J&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||h.ai(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isH
3281orizonVisible()))for(this.currentLayer=0;this.currentLayer<_.length;this.currentLayer++){let pe=A[this.currentLayer],Ee=t.getLayerSourceCache(pe);pe.isSky()&&this.renderLayer(this,Ee,pe,Ee?k[Ee.id]:void 0)}function ue(pe,Ee){let fe;return Ee&&(fe=(pe.type==="symbol"?N:pe.is3D(d)?Z:k)[Ee.id]),fe}if(this.renderPass="translucent",this.transform.projection.name==="globe"){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<_.length;){let pe=A[this.currentLayer];if(pe.type==="raster"||pe.type==="raster-particle"){let Ee=t.getLayerSourceCache(pe);this.renderLayer(this,Ee,pe,ue(pe,Ee))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let de=te?te.getGroundShadowLayerIndex():-1,be=!1,ve=-1;for(let pe=0;pe<_.length;++pe){let Ee=A[pe];Ee.isHidden(this.transform.zoom)||Ee.is3D(d)&&(ve=pe)}v&&ve===-1&&(y=!0);let Fe=!1;for(;this.currentLayer<_.length;){let pe=A[this.currentLayer],Ee=t.getLayerSourceCache(pe);if(pe.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(pe)){if(pe.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer)}else{if(!Fe&&pe.is3D(d)&&!d){let fe=this.currentLayer,Pe=Ce=>{for(this.currentLayer=0;this.currentLayer<A.length;this.currentLayer++){let Re=A[this.currentLayer];if(Fl[Re.type]){let Ye=this.style.getLayerSourceCache(Re);Fl[Re.type](this,Ye,Re,ue(Re,Ye),Ce)}}};Pe("initialize"),Pe("reset"),this.currentLayer=fe,Fe=!0}if(y&&!be&&this.terrain&&!this.transform.isOrthographic&&(be=!0,this.blitDepth()),v&&ve!==-1&&this.currentLayer===ve+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(pe,Ee,Ee?O[Ee.id]:void 0),this.renderLayer(this,Ee,pe,ue(pe,Ee)),!this.terrain&&te&&this.currentLayer===de){{this.clearStencil(),this.resetStencilClippingMasks();let fe=this.currentLayer;for(this.currentLayer=0;this.currentLayer<A.length;this.currentLayer++){let Pe=A[this.currentLayer];if(Qd[Pe.type]){let Ce=this.style.getLayerSourceCache(Pe);Qd[Pe.type](this,Ce,Pe,ue(Pe,Ce))}}this.currentLayer=fe}if(te.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){let fe=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=fe;this.currentLayer++){let Pe=A[this.currentLayer];if(!Pe.hasLightBeamPass())continue;let Ce=t.getLayerSourceCache(Pe);this.renderLayer(this,Ce,Pe,Ce?k[Ce.id]:void 0)}this.currentLayer=fe,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){let fe=this.currentLayer;this.depthOcclusion=!0;for(let Pe of this.layersWithOcclusionOpacity){this.currentLayer=Pe;let Ce=A[this.currentLayer],Re=t.getLayerSourceCache(Ce),Ye=Re?k[Re.id]:void 0;this.terrain||this._renderTileClippingMasks(Ce,Re,Re?O[Re.id]:void 0),this.renderLayer(this,Re,Ce,Ye)}this.depthOcclusion=!1,this.currentLayer=fe,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let pe=null;A.forEach(Ee=>{let fe=t.getLayerSourceCache(Ee);fe&&!Ee.isHidden(this.transform.zoom)&&fe.getVisibleCoordinates().length&&(!pe||pe.getSource().maxzoom<fe.getSource().maxzoom)&&(pe=fe)}),pe&&this.options.showTileBoundaries&&function(Ee,fe,Pe,Ce,Re,Ye){for(let He=0;He<Pe.length;He++)js(Ee,fe,Pe[He],Ce,0,0,Ye)}(this,pe,pe.getVisibleCoordinates(),h.C.red,0,this.options.showParseStatus)}this.options.showPadding&&function(pe){let Ee=pe.transform.padding;rh(pe,pe.transform.height-(Ee.top||0),3,Vs),rh(pe,Ee.bottom||0,3,Al),Vr(pe,Ee.left||0,3,nh),Vr(pe,pe.transform.width-(Ee.right||0),3,Vd);let fe=pe.transform.centerPoint;(function(Pe,Ce,Re,Ye){Ml(Pe,Ce-1,Re-10,2,20,Ye),Ml(Pe,Ce-10,Re-1,20,2,Ye)})(pe,fe.x,pe.transform.height-fe.y,jd)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveC
3281anvasCopy()),P||(this.conflationActive=!1)}prepareLayer(t){this.gpuTimingStart(t);let{unsupportedLayers:o}=this.transform.projection,c=!o||!o.includes(t.type);if(Kd[t.type]&&(c||this.terrain&&t.type==="custom")){let d=this.style.getLayerSourceCache(t);Kd[t.type](t,d,this)}this.gpuTimingEnd()}renderLayer(t,o,c,d){c.isHidden(this.transform.zoom)||(c.type==="background"||c.type==="sky"||c.type==="custom"||c.type==="model"||c.type==="raster"||c.type==="raster-particle"||d&&d.length)&&(this.id=c.id,this.gpuTimingStart(c),(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes(c.type)||t.terrain&&c.type==="custom")&&c.type!=="clip"&&c.type!=="slot"&&ah[c.type]&&ah[c.type](t,o,c,d,this.style.placement.variableOffsets,this.options.isInitialLoad),ah[c.type]||async function(){await async function(){return Promise.resolve()}(),Object.assign(ah,{building:so.drawBuilding,"raster-particle":so.drawRasterParticle}),Object.assign(Kd,{"raster-particle":so.prepareRasterParticle})}(),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;let o=this.context.extTimerQuery,c=this.context.gl,d=this.gpuTimers[t.id];d||(d=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:c.createQuery()}),d.calls++,c.beginQuery(o.TIME_ELAPSED_EXT,d.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){let t=this.context.extTimerQuery,o=this.context.gl,c=o.createQuery();this.deferredRenderGpuTimeQueries.push(c),o.beginQuery(t.TIME_ELAPSED_EXT,c)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){let t=this.gpuTimers;return this.gpuTimers={},t}collectDeferredRenderGpuQueries(){let t=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],t}queryGpuTimers(t){let o={};for(let c in t){let d=t[c],m=this.context.extTimerQuery,_=m.getQueryParameter(d.query,this.context.gl.QUERY_RESULT)/1e6;
3281m.deleteQueryEXT(d.query),o[c]=_}return o}queryGpuTimeDeferredRender(t){if(!this.options.gpuTimingDeferredRender)return 0;let o=this.context.gl,c=0;for(let d of t)c+=o.getQueryParameter(d,o.QUERY_RESULT)/1e6,o.deleteQuery(d);return c}translatePosMatrix(t,o,c,d,m){if(!c[0]&&!c[1])return t;let _=m?d==="map"?this.transform.angle:0:d==="viewport"?-this.transform.angle:0;if(_){let T=Math.sin(_),E=Math.cos(_);c=[c[0]*E-c[1]*T,c[0]*T+c[1]*E]}let y=[m?c[0]:h.az(o,c[0],this.transform.zoom),m?c[1]:h.az(o,c[1],this.transform.zoom),0],v=new Float32Array(16);return h.bB(v,t,y),v}saveTileTexture(t){if(t.context!==this.context)return;let o=t.size[0],c=this._tileTextures[o];c?c.push(t):this._tileTextures[o]=[t]}getTileTexture(t){let o=this._tileTextures[t];return o&&o.length>0?o.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(t,o,c,d,m){let _=c===void 0?this.terrain&&this.terrain.renderingToTexture:c,y=d===void 0?this.terrainRenderModeElevated():d,v=m===void 0?this.transform.projection.name==="globe":m,T=[];return this.style&&this.style.enable3dLights()&&(t==="globeRaster"||t==="terrainRaster"?(T.push("LIGHTING_3D_MODE"),T.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):_||T.push("LIGHTING_3D_MODE")),y&&(T.push("TERRAIN"),this.linearFloatFilteringSupported()&&T.push("TERRAIN_DEM_FLOAT_FORMAT")),v&&T.push("GLOBE"),!this._fogVisible||_||o!==void 0&&!o||T.push("FOG"),_&&T.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&T.push("OVERDRAW_INSPECTOR"),T}getOrCreateProgram(t,o){this.cache=this.cache||{};let{defines:c,config:d,overrideFog:m,overrideRtt:_,overrideTerrain:y,overrideGlobe:v,precompiled:T}=o||{},E=this.currentGlobalDefines(t,m,_,y,v).concat(c||[]),P=this.getShaderSource(t),A=ig[t]||so.programUniforms[t],D=wd.cacheKey(P,t,E,d);return this.cache[D]||(this.cache[D]=new wd(this.context,t,P,d,A,E,T)),this.cache[D]}getShaderSource(t){return Uu[t]||so.shaders&&so.shaders[t]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new h.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,o){if(this.style.enable3dLights()){let c=this.style.directionalLight,d=this.style.ambientLight;if(c&&d){let m=((_,y,v)=>{let T=_.properties.get("direction"),E=_.properties.get("color-use-theme")==="none",P=_.properties.get("color").toNonPremultipliedRenderColor(E?null:v.getLut(_.scope)).toArray01(),A=_.properties.get("intensity"),D=y.properties.get("color-use-theme")==="none",z=y.properties.get("color").toNonPremultipliedRenderColor(D?null:v.getLut(y.scope)).toArray01(),O=y.properties.get("intensity"),k=[T.x,T.y,T.z],N=h.dG(z,O),q=h.dG(P,A);return{u_lighting_ambient_color:N,u_lighting_directional_dir:k,u_lighting_directional_color:q,u_ground_radiance:Of(k,q,N)}})(c,d,this.style);o.setLightsUniformValues(t,m)}}}uploadCommonUniforms(t,o,c,d,m){if(this.uploadCommonLightUniforms(t,o),this.terrain&&this.terrain.renderingToTexture)return;let _=this.style.fog;if(_){let y=_.getOpacity(this.transform.pitch),v=((T,E,P,A,D,z,O,k,N,q,Z,G)=>{let re=T.transform,te=E.properties.get("color-use-theme")==="none",se=E.properties.get("color").toNonPremultipliedRenderColor(te?null:T.style.getLut(E.scope)).toArray01();se[3]=A;let K=T.frameCounter/1e3%1,[J,oe]=E.properties.get("vertical-range");return{u_fog_matrix:P?re.calculateFogTileMatrix(P):G||T.identityMat,u_fog_range:E.getRangeForProjection(),u_fog_color:se,u_fog_horizon_blend:E.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(J,oe),oe],u_fog_temporal_offset:K,u_frustum_tl:D,u_frustum_tr:z,u_frustum_br:O,u_frustum_bl:k,u_globe_pos:N,u_globe_radius:q,u_viewport:Z,u_globe_transition:h.ai(re.zoom),u_is_globe:+(re.projection.name==="globe")}})(this,_,c,y,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*h.o.devicePixelRatio,this.transform.height*h.o.devicePixelRatio],d);o.setFogUniformValues(t,v)}m&&o.setCutoffUniformValues(t,m.uniformValues)}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){let t=this.canvasCopy();t&&(this.frameCopies.push(t),this.tileLoaded=!1)}canvasCopy(){let t=this.context.gl,o=t.createTexture();return t.bindTexture(t.TEXTURE_2D,o),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;let t=this.style&&this.style.fog;return!!t&&t.getOpacity(this.transform.pitch)!==0}
3281getBackgroundTiles(){let t=this._backgroundTiles,o=this._backgroundTiles={},c=this.transform.coveringTiles({tileSize:512});for(let d of c)o[d.key]=t[d.key]||new h.b3(d,512,this.transform.tileZoom,this,void 0,this.worldview);return o}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(t,o){return!(!t.is3D(!(!this.terrain||!this.terrain.enabled))||t.type!=="clip"&&t.type!=="building"&&(t.minzoom&&t.minzoom>this.transform.zoom||(this.style._clipLayerPresent||t.sourceLayer!=="building"&&t.sourceLayer!=="procedural_buildings")&&(!o||o.type!=="batched-model")))}isTileAffectedByFog(t){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let o=this._cachedTileFogOpacities[t.key];return o||(this._cachedTileFogOpacities[t.key]=o=this.style.fog.getOpacityForTile(t)),o[0]>=Ts||o[1]>=Ts}setupDepthForOcclusion(t,o,c){let d=this.context,m=d.gl,_=!!c;var y;c||(c={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),d.activeTexture.set(m.TEXTURE3),t&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(m.NEAREST,m.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],c.u_depth_range_unpack=[2/((y=this.depthRangeFor3D)[1]-y[0]),-1-2*y[0]/(y[1]-y[0])],c.u_occluder_half_size=.5*this.occlusionParams.occluderSize,c.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(m.NEAREST,m.CLAMP_TO_EDGE),d.activeTexture.set(m.TEXTURE0),_||o.setTerrainUniformValues(d,c)}updateEmissiveMode(){if(this._forceEmissiveMode)return;let t=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=t?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function qc(a,t){let o=!1,c=null,d=()=>{c=null,o&&(a(),c=setTimeout(d,t),o=!1)};return()=>(o=!0,c||d(),c)}let Oo=/(#.+)?$/;class lh{constructor(t){this._hashName=t&&encodeURIComponent(t),h.b0(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=qc(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){let t=this._map;if(!t)return"";let o=ln(t);if(this._hashName){let c=this._hashName,d=!1,m=location.hash.slice(1).split("&").map(_=>{let y=_.split("=")[0];return y===c?(d=!0,`${y}=${o}`):_}).filter(_=>_);return d||m.push(`${c}=${o}`),`#${m.join("&")}`}return`#${o}`}_getCurrentHash(){let t=location.hash.replace("#","");if(this._hashName){let o;return t.split("&").map(c=>c.split("=")).forEach(c=>{c[0]===this._hashName&&(o=c)}),(o&&o[1]||"").split("/")}return t.split("/")}_onHashChange(){let t=this._map;if(!t)return!1;let o=this._getCurrentHash();if(o.length>=3&&!o.some(c=>isNaN(Number(c)))){let c=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(o[3]||0):t.getBearing();return t.jumpTo({center:[+o[2],+o[1]],zoom:+o[0],bearing:c,pitch:+(o[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(Oo,this.getHashString()))}}function ln(a,t){let o=a.getCenter(),c=Math.round(100*a.getZoom())/100,d=Math.ceil((c*Math.LN2+Math.log(512/360/.5))/Math.LN10),m=Math.pow(10,d),_=Math.round(o.lng*m)/m,y=Math.round(o.lat*m)/m,v=a.getBearing(),T=a.getPitch(),E=t?`/${_}/${y}/${c}`:`${c}/${y}/${_}`;return(v||T)&&(E+="/"+Math.round(10*v)/10),T&&(E+=`/${Math.round(T)}`),E}let mr={linearity:.3,easing:h.eQ(0,0,.3,1)},Zc=Object.assign({deceleration:2500,maxSpeed:1400},mr),hg=Object.assign({deceleration:20,maxSpeed:1400},mr),tp=Object.assign({deceleration:1e3,maxSpeed:360},mr),fm=Object.assign({deceleration:1e3,maxSpeed:90},mr);class Wc{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:h.o.now(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,o=h.o.now();for(;t.length>0&&o-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;let o={zoom:0,bearing:0,pitch:0,pan:new h.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:m}of this._inertiaBuffer)o.zoom+=m.zoomDelta||0,o.bearing+=m.bearingDelta||0,o.pitch+=m.pitchDelta||0,m.panDelta&&o.pan._add(m.panDelta),m.around&&(o.around=m.around),m.pinchAround&&(o.pinchAround=m.pinchAround);let c=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,d={};if(o.pan.mag()){let m=kl(o.pan.mag(),c,Object.assign({},Zc,t||{}));d.offset=o.pan.mult(m.amount/o.pan.mag()),d.center=this._map.transform.center,Bl(d,m)}if(o.zoom){let m=kl(o.zoom,c,hg);d.zoom=this._map.transform.zoom+m.amount,Bl(d,m)}if(o.bearing){let m=kl(o.bearing,c,tp);
vendor: 17,585 bytes, line 3281
3281d.bearing=this._map.transform.bearing+h.aB(m.amount,-179,179),Bl(d,m)}if(o.pitch){let m=kl(o.pitch,c,fm);d.pitch=this._map.transform.pitch+m.amount,Bl(d,m)}if(d.zoom||d.bearing){let m=o.pinchAround===void 0?o.around:o.pinchAround;d.around=m?this._map.unproject(m):this._map.getCenter()}return this.clear(),d.noMoveStart=!0,d}}function Bl(a,t){(!a.duration||a.duration<t.duration)&&(a.duration=t.duration,a.easing=t.easing)}function kl(a,t,o){let{maxSpeed:c,linearity:d,deceleration:m}=o,_=h.aB(a*d/(t/1e3),-c,c),y=Math.abs(_)/(m*d);return{easing:o.easing,duration:1e3*y,amount:_*(y/2)}}class ar extends h.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o,c,d={}){let m=$o(o.getCanvasContainer(),c),_=o.unproject(m);super(t,Object.assign({point:m,lngLat:_,originalEvent:c},d)),this._defaultPrevented=!1,this.target=o}}class Na extends h.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o,c){let d=t==="touchend"?c.changedTouches:c.touches,m=ta(o.getCanvasContainer(),d),_=m.map(v=>o.unproject(v)),y=m.reduce((v,T,E,P)=>v.add(T.div(P.length)),new h.P(0,0));super(t,{points:m,point:y,lngLats:_,lngLat:o.unproject(y),originalEvent:c}),this._defaultPrevented=!1}}class Xc extends h.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,o){super("wheel",{originalEvent:o}),this._defaultPrevented=!1}}class ns{constructor(t,o){this._map=t,this._clickTolerance=o.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new Xc(this._map,t))}mousedown(t,o){return this._mousedownPos=o,this._firePreventable(new ar(t.type,this._map,t))}mouseup(t){this._map.fire(new ar(t.type,this._map,t))}preclick(t){let o=new MouseEvent("preclick",t);this._map.fire(new ar(o.type,this._map,o))}click(t,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(t),this._map.fire(new ar(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new ar(t.type,this._map,t))}mouseover(t){this._map.fire(new ar(t.type,this._map,t))}mouseout(t){this._map.fire(new ar(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Na(t.type,this._map,t))}touchmove(t){this._map.fire(new Na(t.type,this._map,t))}touchend(t){this._map.fire(new Na(t.type,this._map,t))}touchcancel(t){this._map.fire(new Na(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Fo{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new ar(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ar("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new ar(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bo{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=o.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,o){this.isEnabled()&&t.shiftKey&&t.button===0&&(Go(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(t,o){if(!this._active)return;let c=o,d=this._startPos,m=this._lastPos;if(!d||!m||m.equals(c)||!this._box&&c.dist(d)<this._clickTolerance)return;this._lastPos=c,this._box||(this._box=Mt("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));let _=Math.min(d.x,c.x),y=Math.max(d.x,c.x),v=Math.min(d.y,c.y),T=Math.max(d.y,c.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${_}px,${v}px)`,this._box.style.width=y-_+"px",this._box.style.height=T-v+"px")})}mouseupWindow(t,o){if(!this._active)return;let c=this._startPos,d=o;if(c&&t.button===0){if(this.reset(),_s(),c.x!==d.x||c.y!==d.y)return this._map.fire(new h.z("boxzoomend",{originalEvent:t})),{cameraAnimation:m=>m.fitScreenCoordinates(c,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),Ho(),delete this._startPos,delete this._lastPos}_fireEvent(t,o){return this._map.fire(new h.z(t,{originalEvent:o}))}}function rs(a,t){let o={};for(let c=0;c<a.length;c++)o[a[c].identifier]=t[c];return o}class To{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,o,c){(this.centroid||c.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=t.timeStamp),c.length===this.numTouches&&(this.centroid=function(d){let m=new h.P(0,0);for(let _ of d)m._add(_);return m.div(d.length)}(o),this.touches=rs(c,o)))}touchmove(t,o,c){if(this.aborted||!this.centroid)return;let d=rs(c,o);for(let m in this.touches){let _=d[m];(!_||_.dist(this.touches[m])>30)&&(this.aborted=!0)}}touchend(t,o,c){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),c.length===0){let d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class ip{constructor(t){this.singleTap=new To(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,o,c){this.singleTap.touchstart(t,o,c)}touchmove(t,o,c){this.singleTap.touchmove(t,o,c)}touchend(t,o,c){let d=this.singleTap.touchend(t,o,c);if(d){let m=t.timeStamp-this.lastTime<500,_=!this.lastTap||this.lastTap.dist(d)<30;if(m&&_||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class dg{constructor(){this._zoomIn=new ip({numTouches:1,numTaps:2}),this._zoomOut=new ip({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,o,c){this._zoomIn.touchstart(t,o,c),this._zoomOut.touchstart(t,o,c)}touchmove(t,o,c){this._zoomIn.touchmove(t,o,c),this._zoomOut.touchmove(t,o,c)}touchend(t,o,c){let d=this._zoomIn.touchend(t,o,c),m=this._zoomOut.touchend(t,o,c);return d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()+1,around:_.unproject(d)},{originalEvent:t})}):m?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()-1,around:_.unproject(m)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}let pg=0,fg=2,mm={[pg]:1,[fg]:2},er={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class Hs{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,o){return!1}_move(t,o){return{}}mousedown(t,o){if(this._lastPoint)return;let c=Kl(t);this._correctButton(t,c)&&(this._lastPoint=o,this._eventButton=c)}mousemoveWindow(t,o){let c=this._lastPoint;if(c){if(t.preventDefault(),this._eventButton!=null&&function(d,m){let _=mm[m];return d.buttons===void 0||(d.buttons&_)!==_}(t,this._eventButton))this.reset();else if(this._moved||!(o.dist(c)<this._clickTolerance))return this._moved=!0,this._lastPoint=o,this._move(c,o)}}mouseupWindow(t){this._lastPoint&&Kl(t)===this._eventButton&&(this._moved&&_s(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class np extends Hs{mousedown(t,o){super.mousedown(t,o),this._lastPoint&&(this._active=!0)}_correctButton(t,o){return o===0&&!t.ctrlKey}_move(t,o){return{around:o,panDelta:o.sub(t)}}}class jr extends Hs{constructor(t){super(t),this._pitchRotateKey=t.pitchRotateKey?er[t.pitchRotateKey]:void 0}_correctButton(t,o){return this._pitchRotateKey?o===0&&t[this._pitchRotateKey]:o===0&&t.ctrlKey||o===2}_move(t,o){let c=.8*(o.x-t.x);if(c)return this._active=!0,{bearingDelta:c}}contextmenu(t){this._pitchRotateKey||t.preventDefault()}}class Gr extends Hs{constructor(t){super(t),this._pitchRotateKey=t.pitchRotateKey?er[t.pitchRotateKey]:void 0}_correctButton(t,o){return this._pitchRotateKey?o===0&&t[this._pitchRotateKey]:o===0&&t.ctrlKey||o===2}_move(t,o){let c=-.5*(o.y-t.y);if(c)return this._active=!0,{pitchDelta:c}}contextmenu(t){this._pitchRotateKey||t.preventDefault()}}class Nl{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),h.b0(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new h.P(0,0)}touchstart(t,o,c){return this._calculateTransform(t,o,c)}touchmove(t,o,c){if(this._active&&!(c.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(c.length===1&&!h.eR())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,o,c)}}touchend(t,o,c){this._calculateTransform(t,o,c),this._active&&c.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,o,c){c.length>0&&(this._active=!0);let d=rs(c,o),m=new h.P(0,0),_=new h.P(0,0),y=0;for(let T in d){let E=d[T],P=this._touches[T];P&&(m._add(E),_._add(E.sub(P)),y++,d[T]=E)}if(this._touches=d,y<this._minTouches||!_.mag())return;let v=_.div(y);return this._sum._add(v),this._sum.mag()<this._clickTolerance?void 0:{around:m.div(y),panDelta:v}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Mt("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class os{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,o,c){return{}}touchstart(t,o,c){this._firstTwoTouches||c.length<2||(this._firstTwoTouches=[c[0].identifier,c[1].identifier],this._start([o[0],o[1]]))}touchmove(t,o,c){let d=this._firstTwoTouches;if(!d)return;t.preventDefault();let[m,_]=d,y=ss(c,o,m),v=ss(c,o,_);if(!y||!v)return;let T=this._aroundCenter?null:y.add(v).div(2);return this._move([y,v],T,t)}touchend(t,o,c){if(!this._firstTwoTouches)return;let[d,m]=this._firstTwoTouches,_=ss(c,o,d),y=ss(c,o,m);_&&y||(this._active&&_s(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function ss(a,t,o){for(let c=0;c<a.length;c++)if(a[c].identifier===o)return t[c]}function ch(a,t){return Math.log2(a/t)}class Kt extends os{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,o){let c=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(ch(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:ch(this._distance,c),pinchAround:o}}}function as(a,t){return 180*a.angleWith(t)/Math.PI}class rp extends os{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,o){let c=this._vector;if(this._vector=t[0].sub(t[1]),c&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:as(this._vector,c),pinchAround:o}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let o=25/(Math.PI*this._minDiameter)*360,c=this._startVector;if(!c)return!1;let d=as(t,c);return Math.abs(d)<o}}function So(a){return Math.abs(a.y)>Math.abs(a.x)}class ko extends os{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,So(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,o,c){let d=this._lastPoints;if(!d)return;let m=t[0].sub(d[0]),_=t[1].sub(d[1]);return this._map._cooperativeGestures&&!h.eR()&&c.touches.length<3||(this._valid=this.gestureBeginsVertically(m,_,c.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(m.y+_.y)/2*-.5})}gestureBeginsVertically(t,o,c){if(this._valid!==void 0)return this._valid;let d=t.mag()>=2,m=o.mag()>=2;if(!d&&!m)return;if(!d||!m)return this._firstMove==null&&(this._firstMove=c),c-this._firstMove<100&&void 0;let _=t.y>0==o.y>0;return So(t)&&So(o)&&_}}let lr={panStep:100,bearingStep:15,pitchStep:10};class Mr{constructor(){let t=lr;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let o=0,c=0,d=0,m=0,_=0;switch(t.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:t.shiftKey?c=-1:(t.preventDefault(),m=-1);break;case 39:t.shiftKey?c=1:(t.preventDefault(),m=1);break;case 38:t.shiftKey?d=1:(t.preventDefault(),_=-1);break;case 40:t.shiftKey?d=-1:(t.preventDefault(),_=1);break;default:return}return this._rotationDisabled&&(c=0,d=0),{cameraAnimation:y=>{let v=y.getZoom();y.easeTo({duration:300,easeId:"keyboardHandler",easing:zn,zoom:o?Math.round(v)+o*(t.shiftKey?2:1):v,bearing:y.getBearing()+c*this._bearingStep,pitch:y.getPitch()+d*this._pitchStep,offset:[-m*this._panStep,-_*this._panStep],center:y.getCenter()},{originalEvent:t})}}}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 zn(a){return a*(2-a)}let uh=4.000244140625,Cr=1/450,_m=/(Mac|iPad)/i;class Ua{constructor(t,o){this._map=t,this._el=t.getCanvasContainer(),this._handler=o,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Cr,h.b0(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||h.eR()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,c=h.o.now(),d=c-(this._lastWheelEventTime||0);this._lastWheelEventTime=c,o!==0&&o%uh===0?this._type="wheel":o!==0&&Math.abs(o)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=o,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(d*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),t.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=t,this._delta-=o,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){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);let o=$o(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:o,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRe
3281nderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let t=this._map.transform;this._type==="wheel"&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);let o=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(this._delta!==0){let T=this._type==="wheel"&&Math.abs(this._delta)>uh?this._wheelZoomRate:this._defaultZoomRate,E=2/(1+Math.exp(-Math.abs(this._delta*T)));this._delta<0&&E!==0&&(E=1/E);let P=o(),A=Math.pow(2,P),D=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):A;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(D*E))),this._type==="wheel"&&(this._startZoom=P,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}let c=typeof this._targetZoom=="number"?this._targetZoom:o(),d=this._startZoom,m=this._easing,_,y=!1;if(this._type==="wheel"&&d&&m){let T=Math.min((h.o.now()-this._lastWheelEventTime)/200,1),E=m(T);_=h.aj(d,c,E),T<1?this._frameId||(this._frameId=!0):y=!0}else _=c,y=!0;this._active=!0,y&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let v=_-o();return v*this._lastDelta<0&&(v=0),{noInertia:!0,needsRenderFrame:!y,zoomDelta:v,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let o=h.eS;if(this._prevEase){let c=this._prevEase,d=(h.o.now()-c.start)/c.duration,m=c.easing(d+.01)-c.easing(d),_=.27/Math.sqrt(m*m+1e-4)*.01,y=Math.sqrt(.0729-_*_);o=h.eQ(_,y,.25,1)}return this._prevEase={start:h.o.now(),duration:t,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=Mt("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=_m.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class gm{constructor(t,o){this._clickZoom=t,this._tapZoom=o}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 Hr{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,o){return t.preventDefault(),{cameraAnimation:c=>{c.easeTo({duration:300,zoom:c.getZoom()+(t.shiftKey?-1:1),around:c.unproject(o)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Wn{constructor(){this._tap=new ip({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,o,c){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?c.length>0&&(this._swipePoint=o[0],this._swipeTouch=c[0].identifier):this._tap.touchstart(t,o,c))}touchmove(t,o,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;let d=o[0],m=d.y-this._swipePoint.y;return this._swipePoint=d,t.preventDefault(),this._active=!0,{zoomDelta:m/128}}}else this._tap.touchmove(t,o,c)}touchend(t,o,c){this._tapTime?this._swipePoint&&c.length===0&&this.reset():this._tap.touchend(t,o,c)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class op{constructor(t,o,c){this._el=t,this._mousePan=o,this._touchPan=c}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class ym{constructor(t,o,c){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=o,this._mousePitch=c}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class sp{constructor(t,o,c,d){this._el=t,this._touchZoom=o,this._touchRotate=c,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-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()}}let hh=a=>a.zoom||a.drag||a.pitch||a.rotate;class ap extends h.z{}class xm{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,o){let c=h.aw([],o,t);
3281this.radius=h.af(c[2]<0?h.eU([],c,this.constants):[c[0],c[1],0])}projectRay(t){h.eU(t,t,this.constants),h.ax(t,t),h.eV(t,t,this.constants);let o=h.bN([],t,this.radius);if(o[2]>0){let c=h.bN([],[0,0,1],h.bk(o,[0,0,1])),d=h.bN([],h.ax([],[o[0],o[1],0]),this.radius),m=h.cX([],o,h.bN([],h.aw([],h.cX([],d,c),o),2));o[0]=m[0],o[1]=m[1]}return o}}function dh(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}class $r{constructor(t,o){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wc(t),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new xm,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(o),h.b0(["handleEvent","handleWindowEvent"],this);let c=this._el;this._listeners=[[c,"touchstart",{passive:!0}],[c,"touchmove",{passive:!1}],[c,"touchend",void 0],[c,"touchcancel",void 0],[c,"mousedown",void 0],[c,"mousemove",void 0],[c,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[c,"mouseover",void 0],[c,"mouseout",void 0],[c,"dblclick",void 0],[c,"click",void 0],[c,"keydown",{capture:!1}],[c,"keyup",void 0],[c,"wheel",{passive:!1}],[c,"contextmenu",void 0],[window,"blur",void 0]];for(let[d,m,_]of this._listeners){let y=d===document?this.handleWindowEvent:this.handleEvent;d.addEventListener(m,y,_)}}destroy(){for(let[t,o,c]of this._listeners){let d=t===document?this.handleWindowEvent:this.handleEvent;t.removeEventListener(o,d,c)}}_addDefaultHandlers(t){let o=this._map,c=o.getCanvasContainer();this._add("mapEvent",new ns(o,t));let d=o.boxZoom=new Bo(o,t);this._add("boxZoom",d);let m=new dg,_=new Hr;o.doubleClickZoom=new gm(_,m),this._add("tapZoom",m),this._add("clickZoom",_);let y=new Wn;this._add("tapDragZoom",y);let v=o.touchPitch=new ko(o);this._add("touchPitch",v);let T=new jr(t),E=new Gr(t);o.dragRotate=new ym(t,T,E),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",E,["mouseRotate"]);let P=new np(t),A=new Nl(o,t);o.dragPan=new op(c,P,A),this._add("mousePan",P),this._add("touchPan",A,["touchZoom","touchRotate"]);let D=new rp,z=new Kt;o.touchZoomRotate=new sp(c,z,D,y),this._add("touchRotate",D,["touchPan","touchZoom"]),this._add("touchZoom",z,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Fo(o));let O=o.scrollZoom=new Ua(o,this);this._add("scrollZoom",O,["mousePan"]);let k=o.keyboard=new Mr;this._add("keyboard",k);for(let N of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[N]&&o[N].enable(t[N])}_add(t,o,c){this._handlers.push({handlerName:t,handler:o,allowed:c}),this._handlersById[t]=o}stop(t){if(!this._updatingCamera){for(let{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[],this._originalZoom=void 0}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!hh(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(t,o,c){for(let d in t)if(!(d===c||o&&o.includes(d)))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){let o=[];for(let c of t)this._el.contains(c.target)&&o.push(c);return o}handleEvent(t,o){this._updatingCamera=!0;let c=t.type==="renderFrame",d=c?void 0:t,m={needsRenderFrame:!1},_={},y={},v=t.touches?this._getMapTouches(t.touches):void 0,T=v?ta(this._el,v):c?void 0:$o(this._el,t);for(let{handlerName:A,handler:D,allowed:z}of this._handlers){if(!D.isEnabled())continue;let O;this._blockedByActive(y,z,A)?D.reset():D[o||t.type]&&(O=D[o||t.type](t,T,v),this.mergeHandlerResult(m,_,O,A,d),O&&O.needsRenderFrame&&this._triggerRenderFrame()),(O||D.isActive())&&(y[A]=D)}let E={};for(let A in this._previousActiveHandlers)y[A]||(E[A]=d);this._previousActiveHandlers=y,(Object.keys(E).length||dh(m))&&(this._changes.push([m,_,E]),this._triggerRe
3281nderFrame()),(Object.keys(y).length||dh(m))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:P}=m;P&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],P(this._map))}mergeHandlerResult(t,o,c,d,m){if(!c)return;Object.assign(t,c);let _={handlerName:d,originalEvent:c.originalEvent||m};c.zoomDelta!==void 0&&(o.zoom=_),c.panDelta!==void 0&&(o.drag=_),c.pitchDelta!==void 0&&(o.pitch=_),c.bearingDelta!==void 0&&(o.rotate=_)}_applyChanges(){let t={},o={},c={};for(let[d,m,_]of this._changes)d.panDelta&&(t.panDelta=(t.panDelta||new h.P(0,0))._add(d.panDelta)),d.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+d.pitchDelta),d.around!==void 0&&(t.around=d.around),d.aroundCoord!==void 0&&(t.aroundCoord=d.aroundCoord),d.pinchAround!==void 0&&(t.pinchAround=d.pinchAround),d.noInertia&&(t.noInertia=d.noInertia),Object.assign(o,m),Object.assign(c,_);this._updateMapTransform(t,o,c),this._changes=[]}_updateMapTransform(t,o,c){let d=this._map,m=d.transform,_=q=>[q.x,q.y,q.z];if((()=>{let q=this._eventsInProgress.drag;return q&&!this._handlersById[q.handlerName].isActive()})()&&!dh(t)){let q=m.zoom;m.cameraElevationReference="sea",this._originalZoom!=null&&m._orthographicProjectionAtLowPitch&&m.projection.name!=="globe"&&m.pitch===0?(m.cameraElevationReference="ground",m.zoom=this._originalZoom):(m.recenterOnTerrain(),m.cameraElevationReference="ground"),q!==m.zoom&&this._map._update(!0)}if(m._isCameraConstrained&&d._stop(!0),!dh(t))return void this._fireEvents(o,c,!0);let{panDelta:y,zoomDelta:v,bearingDelta:T,pitchDelta:E,around:P,aroundCoord:A,pinchAround:D}=t;m._isCameraConstrained&&(v>0&&(v=0),m._isCameraConstrained=!1),D!==void 0&&(P=D),(v||(q=>o[q]&&!this._eventsInProgress[q])("drag"))&&P&&(this._dragOrigin=_(m.pointCoordinate3D(P)),this._originalZoom=m.zoom,this._trackingEllipsoid.setup(m._camera.position,this._dragOrigin)),m.cameraElevationReference="sea",d._stop(!0),P=P||d.transform.centerPoint,T&&(m.bearing+=T),E&&(m.pitch+=E),m._updateCameraState();let z=[0,0,0];if(y)if(m.projection.name==="mercator"){let q=this._trackingEllipsoid.projectRay(m.screenPointToMercatorRay(P).dir),Z=this._trackingEllipsoid.projectRay(m.screenPointToMercatorRay(P.sub(y)).dir);z[0]=Z[0]-q[0],z[1]=Z[1]-q[1]}else{let q=m.pointCoordinate(P);if(m.projection.name==="globe"){y=y.rotate(-m.angle);let Z=m._pixelsPerMercatorPixel/m.worldSize;z[0]=-y.x*h.eT(h.bZ(q.y))*Z,z[1]=-y.y*h.eT(m.center.lat)*Z}else{let Z=m.pointCoordinate(P.sub(y));q&&Z&&(z[0]=Z.x-q.x,z[1]=Z.y-q.y)}}let O=m.zoom,k=[0,0,0];if(v){let q=_(A||m.pointCoordinate3D(P)),Z={dir:h.ax([],h.aw([],q,m._camera.position))};if(Z.dir[2]<0){let G=m.zoomDeltaToMovement(q,v);h.bN(k,Z.dir,G)}}let N=h.cX(z,z,k);m._translateCameraConstrained(N),v&&Math.abs(m.zoom-O)>1e-4&&m.recenterOnTerrain(),m.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(o,c,!0)}_fireEvents(t,o,c){let d=hh(this._eventsInProgress),m=hh(t),_={};for(let E in t){let{originalEvent:P}=t[E];this._eventsInProgress[E]||(_[`${E}start`]=P),this._eventsInProgress[E]=t[E]}!d&&m&&this._fireEvent("movestart",m.originalEvent);for(let E in _)this._fireEvent(E,_[E]);m&&this._fireEvent("move",m.originalEvent);for(let E in t){let{originalEvent:P}=t[E];this._fireEvent(E,P)}let y={},v;for(let E in this._eventsInProgress){let{handlerName:P,originalEvent:A}=this._eventsInProgress[E];this._handlersById[P].isActive()||(delete this._eventsInProgress[E],v=o[P]||A,y[`${E}end`]=v)}for(let E in y)this._fireEvent(E,y[E]);let T=hh(this._eventsInProgress);if(c&&(d||m)&&!T){this._updatingCamera=!0;let E=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),P=A=>A!==0&&-this._bearingSnap<A&&A<this._bearingSnap;E?(P(E.bearing||this._map.getBearing())&&(E.bearing=0),this._map.easeTo(E,{originalEvent:v})):(this._map.fire(new h.z("moveend",{originalEvent:v})),P(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,o){this._map.fire(new h.z(t,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{this._frameId=void 0,this.handleEvent(new ap("renderFrame",{timeStamp:t})),this._applyChanges()})}
3281_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}let qr="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class $s extends h.E{constructor(t,o){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=o.bearingSnap,this._respectPrefersReducedMotion=o.respectPrefersReducedMotion!==!1,h.b0(["_renderFrameCallback"],this)}getCenter(){return new h.aX(this.transform.center.lng,this.transform.center.lat)}setCenter(t,o){return this.jumpTo({center:t},o)}panBy(t,o,c){return t=h.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},o),c)}panTo(t,o,c){return this.easeTo(Object.assign({center:t},o),c)}getZoom(){return this.transform.zoom}setZoom(t,o){return this.jumpTo({zoom:t},o),this}zoomTo(t,o,c){return this.easeTo(Object.assign({zoom:t},o),c)}zoomIn(t,o){return this.zoomTo(this.getZoom()+1,t,o),this}zoomOut(t,o){return this.zoomTo(this.getZoom()-1,t,o),this}getBearing(){return this.transform.bearing}setBearing(t,o){return this.jumpTo({bearing:t},o),this}getPadding(){return this.transform.padding}setPadding(t,o){return this.jumpTo({padding:t},o),this}rotateTo(t,o,c){return this.easeTo(Object.assign({bearing:t},o),c)}resetNorth(t,o){return this.rotateTo(0,Object.assign({duration:1e3},t),o),this}resetNorthPitch(t,o){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},t),o),this}snapToNorth(t,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,o):this}getPitch(){return this.transform.pitch}setPitch(t,o){return this.jumpTo({pitch:t},o),this}cameraForBounds(t,o){t=h.aI.convert(t);let c=o&&o.bearing||0,d=o&&o.pitch||0,m=t.getNorthWest(),_=t.getSouthEast();return this._cameraForBounds(this.transform,m,_,c,d,o)}_extendPadding(t){let o={top:0,right:0,bottom:0,left:0};return t==null?Object.assign({},o,this.transform.padding):typeof t=="number"?{top:t,bottom:t,right:t,left:t}:Object.assign({},o,t)}_extendCameraOptions(t){return(t=Object.assign({offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding=this._extendPadding(t.padding),t}_minimumAABBFrustumDistance(t,o){let c=o.max[0]-o.min[0],d=o.max[1]-o.min[1];return c/d>t.aspect?c/(2*Math.tan(.5*t.fovX)*t.aspect):d/(2*Math.tan(.5*t.fovY)*t.aspect)}_cameraForBoundsOnGlobe(t,o,c,d,m,_){let y=t.clone(),v=this._extendCameraOptions(_);y.bearing=d,y.pitch=m;let T=h.aX.convert(o),E=h.aX.convert(c),P=.5*(T.lat+E.lat),A=.5*(T.lng+E.lng),D=h.eW(P,A),z=h.ax([],D),O=h.ax([],h.bj([],z,[0,1,0])),k=h.bj([],O,z),N=[O[0],O[1],O[2],0,k[0],k[1],k[2],0,z[0],z[1],z[2],0,0,0,0,1],q=[D,h.eW(T.lat,T.lng),h.eW(E.lat,T.lng),h.eW(E.lat,E.lng),h.eW(T.lat,E.lng),h.eW(P,T.lng),h.eW(P,E.lng),h.eW(T.lat,A),h.eW(E.lat,A)],Z=h.cY.fromPoints(q.map(Ce=>[h.bk(O,Ce),h.bk(k,Ce),h.bk(z,Ce)])),G=h.ae([],Z.center,N);h.eX(G)===0&&h.eY(G,0,0,1),h.ax(G,G),h.bN(G,G,h.aE),y.center=h.eZ(G);let re=y.getWorldToCameraMatrix(),te=h.ba(new Float64Array(16),re);Z=h.cY.applyTransform(Z,h.aC([],re,N));let se=this._extendAABB(Z,y,v,d);if(!se)return void h.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Z=se,h.ae(G,G,re);let K=.5*(Z.max[2]-Z.min[2]),J=this._minimumAABBFrustumDistance(y,Z),oe=h.bN([],[0,0,1],K),ue=h.cX(oe,G,oe),de=J+(y.pitch===0?0:h.bh(G,ue)),be=y.globeCenterInViewSpace,ve=h.aw([],G,[be[0],be[1],be[2]]);h.ax(ve,ve),h.bN(ve,ve,de);let Fe=h.cX([],G,ve);h.ae(Fe,Fe,te);let pe=h.eg/h.aE,Ee=h.af(Fe),fe=h.bY(Math.max(Ee*pe-h.eg,Number.EPSILON),0),Pe=Math.min(y.zoomFromMercatorZAdjusted(fe),v.maxZoom);return Pe>.5*(h.cN+h.cx)?(y.setProjection({name:"mercator"}),y.zoom=Pe,this._cameraForBounds(y,o,c,d,m,_)):{center:y.center,zoom:Pe,bearing:d,pitch:m}}_extendAABB(t,o,c,d){let m=.5*((c.padding.left||0)+(c.padding.right||0)),_=.5*((c.padding.top||0)+(c.padding.bottom||0)),y=_,v=m,T=m,E=_,P=o.width-(v+T),A=o.height-(y+E),D=h.aw([],t.max,t.min),z=Math.min(P/D[0],A/D[1]),O=Math.min(o.scaleZoom(o.scale*z),c.maxZoom);if(isNaN(O))return null;let k=o.scale/o.zoomScale(O),N=new h.cY([t.min[0]-v*k,t.min[1]-E*k,t.min[2]],[t.max[0]+T*k,t.max[1]+y*k,t.max[2]]),q=(typeof c.offset.x=="number"&&typeof c.offset.y=="number"?new h.P(c.offset.x,c.offset.y):h.P.convert(c.offset)).rotate(-h.am(d));return N.center[0]-=q.x*k,N.center[1]+=q.y*k,N}queryTerrainElevation(t,o){let c=this.transform.elevation;return c?(o=Object.assign({},{exaggerated:!0},o),c.getAtPoint(h.ad.fromLngLat(t),null,o.exaggerated)):null}_cameraForBounds(t,o,c,d,m,_){if(t.projection.name==="globe")return this._cameraForBoundsOnGlobe(t,o,c,d,m,_);let y=t.clone(),v=this._extendCameraOptions(_);y.bearing=d,y.pitch=m;let T=h.aX.convert(o),E=h.aX.convert(c),P=new h.aX(T.lng,E.lat),A=new h.aX(E.lng,T.lat),D=y.project(T),z=y.project(E),O
3281=this.queryTerrainElevation(T),k=this.queryTerrainElevation(E),N=this.queryTerrainElevation(P),q=this.queryTerrainElevation(A),Z=[[D.x,D.y,Math.min(O||0,k||0,N||0,q||0)],[z.x,z.y,Math.max(O||0,k||0,N||0,q||0)]],G=h.cY.fromPoints(Z),re=y.getWorldToCameraMatrix(),te=h.ba(new Float64Array(16),re);G=h.cY.applyTransform(G,re);let se=this._extendAABB(G,y,v,d);if(!se)return void h.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");G=se;let K=.5*h.aw([],G.max,G.min)[2],J=this._minimumAABBFrustumDistance(y,G),oe=[0,0,1,0];h.aD(oe,oe,re),h.e_(oe,oe);let ue=h.bN([],oe,J+K),de=h.cX([],G.center,ue);h.ae(G.center,G.center,te),h.ae(de,de,te);let be=y.unproject(new h.P(G.center[0],G.center[1])),ve=h.e$(y.projection,be),Fe=Math.pow(2,ve),pe=Math.min(y._zoomFromMercatorZ(de[2]*y.pixelsPerMeter*Fe/y.worldSize),v.maxZoom);return y.mercatorFromTransition&&pe<.5*(h.cN+h.cx)?(y.setProjection({name:"globe"}),y.zoom=pe,this._cameraForBounds(y,o,c,d,m,_)):{center:be,zoom:pe,bearing:d,pitch:m}}fitBounds(t,o,c){let d=this.cameraForBounds(t,o);return this._fitInternal(d,o,c)}fitScreenCoordinates(t,o,c,d,m){let _=h.P.convert(t),y=h.P.convert(o),v=new h.P(Math.min(_.x,y.x),Math.min(_.y,y.y)),T=new h.P(Math.max(_.x,y.x),Math.max(_.y,y.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(_,y))return this;let E=this.transform.pointLocation3D(v),P=this.transform.pointLocation3D(T),A=this.transform.pointLocation3D(new h.P(v.x,T.y)),D=this.transform.pointLocation3D(new h.P(T.x,v.y)),z=[Math.min(E.lng,P.lng,A.lng,D.lng),Math.min(E.lat,P.lat,A.lat,D.lat)],O=[Math.max(E.lng,P.lng,A.lng,D.lng),Math.max(E.lat,P.lat,A.lat,D.lat)],k=d&&d.pitch?d.pitch:this.getPitch(),N=this._cameraForBounds(this.transform,z,O,c,k,d);return this._fitInternal(N,d,m)}_fitInternal(t,o,c){return t?(o=Object.assign(t,o)).linear?this.easeTo(o,c):this.flyTo(o,c):this}jumpTo(t,o){this.stop();let c=t.preloadOnly?this.transform.clone():this.transform,d=!1,m=!1,_=!1;"zoom"in t&&c.zoom!==+t.zoom&&(d=!0,c.zoom=+t.zoom),t.center!==void 0&&(c.center=h.aX.convert(t.center)),"bearing"in t&&c.bearing!==+t.bearing&&(m=!0,c.bearing=+t.bearing),"pitch"in t&&c.pitch!==+t.pitch&&(_=!0,c.pitch=+t.pitch);let y=typeof t.padding=="number"?this._extendPadding(t.padding):t.padding;if(t.padding!=null&&!c.isPaddingEqual(y))if(t.retainPadding===!1){let v=c.clone();v.padding=y,c.setLocationAtPoint(c.center,v.centerPoint)}else c.padding=y;return t.preloadOnly?(this._preloadTiles(c),this):(this.fire(new h.z("movestart",o)).fire(new h.z("move",o)),d&&this.fire(new h.z("zoomstart",o)).fire(new h.z("zoom",o)).fire(new h.z("zoomend",o)),m&&this.fire(new h.z("rotatestart",o)).fire(new h.z("rotate",o)).fire(new h.z("rotateend",o)),_&&this.fire(new h.z("pitchstart",o)).fire(new h.z("pitch",o)).fire(new h.z("pitchend",o)),this.fire(new h.z("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||h.w(qr),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,o){let c=this.transform;if(!c.projection.supportsFreeCamera)return h.w(qr),this;this.stop();let d=c.zoom,m=c.pitch,_=c.bearing;c.setFreeCameraOptions(t);let y=d!==c.zoom,v=m!==c.pitch,T=_!==c.bearing;return this.fire(new h.z("movestart",o)).fire(new h.z("move",o)),y&&this.fire(new h.z("zoomstart",o)).fire(new h.z("zoom",o)).fire(new h.z("zoomend",o)),T&&this.fire(new h.z("rotatestart",o)).fire(new h.z("rotate",o)).fire(new h.z("rotateend",o)),v&&this.fire(new h.z("pitchstart",o)).fire(new h.z("pitch",o)).fire(new h.z("pitchend",o)),this.fire(new h.z("moveend",o)),this}easeTo(t,o){this._stop(!1,t.easeId),((t=Object.assign({offset:[0,0],duration:500,easing:h.eS},t)).animate===!1||this._prefersReducedMotion(t))&&(t.duration=0);let c=this.transform,d=this.getZoom(),m=this.getBearing(),_=this.getPitch(),y=this.getPadding(),v="zoom"in t?+t.zoom:d,T="bearing"in t?this._normalizeBearing(t.bearing,m):m,E="pitch"in t?+t.pitch:_,P=this._extendPadding(t.padding),A=h.P.convert(t.offset),D,z,O;if(c.projection.name==="globe"){let oe=h.ad.fromLngLat(c.center),ue=A.rotate(-c.angle);oe.x+=ue.x/c.worldSize,oe.y+=ue.y/c.worldSize;let de=oe.toLngLat(),be=h.aX.convert(t.center||de);this._normalizeCenter(be),D=c.centerPoint.add(ue),z=new h.P(oe.x,oe.y).mult(c.worldSize),O=new h.P(h.aG(be.lng),h.aJ(be.lat)).mult(c.worldSize).sub(z)}else{D=c.centerPoint.add(A);let oe=c.pointLocation(D),ue=h.aX.convert(t.center||oe);this._normalizeCenter(ue),z=c.project(oe),O=c.project(ue).sub(z)}let k=c.zoomScale(v-d),N,q;t.around&&(N=h.aX.convert(t.around),q=c.locationPoint(N));let Z=this._zooming||v!==d,G=this._rotating||m!==T,re=this._pitching||E!==_,te=!c.isPaddingEqual(P),se=t.retainPadding===!1?c.clone():c,K=oe=>ue=>{if(Z&&(oe.zoom=h.aj(d,v,ue)),G&&(oe.bearing=h.aj(m,T,ue)),re&&(oe.pitch=h.aj(_,E,ue)),te&&(se.interpolatePadding(y,P,ue),D=se.centerPoint.add(A)),N)oe.setLocationAtPoint(N,q);else{let de=oe.zoomScale(oe.zoom-d),be=v>d?Math.min(2,k):Math.max(.5,k),ve=Math.pow(be,1-ue),Fe=oe.unproject(z.add(O.mult(ue*ve)).mult(de));oe.setLocationAtPoint(oe.renderWorldCopies?Fe.wrap():Fe,D)}return t.preloadOnly||this._fireMoveEvents(o),oe};if(t.preloadOnly){let oe=this._emulate(K,t.duration,c);return this._preloadTiles(oe),this}let J={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Z,this._rotating=G,this._pitching=re,this._padding=te,this._easeId=t.easeId,this._prepareEase(o,t.noMoveStart,J),this._ease(K(c),oe=>{c.cameraElevationReference==="sea"&&c.recenterOnTerrain(),this._afterEase(o,oe)},t),this}_prepareEase(t,o,c={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),o||c.moving||this.fire(new h.z("movestart",t)),this._zooming&&!c.zooming&&this.fire(new h.z("zoomstart",t)),this._rotating&&!c.rotating&&this.fire(new h.z("rotatestart",t)),this._pitching&&!c.pitching&&this.fire(new h.z("pitchstart",t))}_fireMoveEvents(t){this.fire(new h.z("move",t)),this._zooming&&this.fire(new h.z("zoom",t)),this._rotating&&this.fire(new h.z("rotate",t)),this._pitching&&this.fire(new h.z("pitch",t))}
3281_afterEase(t,o){if(this._easeId&&o&&this._easeId===o)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";let c=this._zooming,d=this._rotating,m=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,c&&this.fire(new h.z("zoomend",t)),d&&this.fire(new h.z("rotateend",t)),m&&this.fire(new h.z("pitchend",t)),this.fire(new h.z("moveend",t))}flyTo(t,o){if(this._prefersReducedMotion(t)){let Ce=h.aK(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Ce,o)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:h.eS},t);let c=this.transform,d=this.getZoom(),m=this.getBearing(),_=this.getPitch(),y=this.getPadding(),v="zoom"in t?h.aB(+t.zoom,c.minZoom,c.maxZoom):d,T="bearing"in t?this._normalizeBearing(t.bearing,m):m,E="pitch"in t?+t.pitch:_,P=this._extendPadding(t.padding),A=c.zoomScale(v-d),D=h.P.convert(t.offset),z=c.centerPoint.add(D),O=c.pointLocation(z),k=h.aX.convert(t.center||O);this._normalizeCenter(k);let N=c.project(O),q=c.project(k).sub(N),Z=t.curve,G=Math.max(c.width,c.height),re=G/A,te=q.mag();if("minZoom"in t){let Ce=h.aB(Math.min(t.minZoom,d,v),c.minZoom,c.maxZoom),Re=G/c.zoomScale(Ce-d);Z=Math.sqrt(Re/te*2)}let se=Z*Z;function K(Ce){let Re=(re*re-G*G+(Ce?-1:1)*se*se*te*te)/(2*(Ce?re:G)*se*te);return Math.log(Math.sqrt(Re*Re+1)-Re)}function J(Ce){return(Math.exp(Ce)-Math.exp(-Ce))/2}function oe(Ce){return(Math.exp(Ce)+Math.exp(-Ce))/2}let ue=K(0),de=function(Ce){return oe(ue)/oe(ue+Z*Ce)},be=function(Ce){return G*((oe(ue)*(J(Re=ue+Z*Ce)/oe(Re))-J(ue))/se)/te;var Re},ve=(K(1)-ue)/Z;
3281if(Math.abs(te)<1e-6||!isFinite(ve)){if(Math.abs(G-re)<1e-6)return this.easeTo(t,o);let Ce=re<G?-1:1;ve=Math.abs(Math.log(re/G))/Z,be=function(){return 0},de=function(Re){return Math.exp(Ce*Z*Re)}}t.duration="duration"in t?+t.duration:1e3*ve/("screenSpeed"in t?+t.screenSpeed/Z:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);let Fe=m!==T,pe=E!==_,Ee=!c.isPaddingEqual(P),fe=t.retainPadding===!1?c.clone():c,Pe=Ce=>Re=>{let Ye=Re*ve,He=1/de(Ye);Ce.zoom=Re===1?v:d+Ce.scaleZoom(He),Fe&&(Ce.bearing=h.aj(m,T,Re)),pe&&(Ce.pitch=h.aj(_,E,Re)),Ee&&(fe.interpolatePadding(y,P,Re),z=fe.centerPoint.add(D));let je=Re===1?k:Ce.unproject(N.add(q.mult(be(Ye))).mult(He));return Ce.setLocationAtPoint(Ce.renderWorldCopies?je.wrap():je,z),Ce._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(o),Ce};if(t.preloadOnly){let Ce=this._emulate(Pe,t.duration,c);return this._preloadTiles(Ce),this}return this._zooming=!0,this._rotating=Fe,this._pitching=pe,this._padding=Ee,this._prepareEase(o,!1),this._ease(Pe(c),()=>this._afterEase(o),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(t){}_cancelRenderFrame(t){}_stop(t,o){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){let c=this._onEaseEnd;this._onEaseEnd=void 0,c.call(this,o)}if(!t){let c=this.handlers;c&&c.stop(!1)}return this}_ease(t,o,c){c.animate===!1||c.duration===0?(t(1),o()):(this._easeStart=h.o.now(),this._easeOptions=c,this._onEaseFrame=t,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){let t=Math.min((h.o.now()-this._easeStart)/this._easeOptions.duration,1),o=this._onEaseFrame;o&&o(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,o){t=h.bv(t,-180,180);let c=Math.abs(t-o);return Math.abs(t-360-o)<c&&(t-=360),Math.abs(t+360-o)<c&&(t+=360),t}_normalizeCenter(t){let o=this.transform;
3281if(o.maxBounds||o.projection.name!=="globe"&&!o.renderWorldCopies)return;let c=t.lng-o.center.lng;t.lng+=c>180?-360:c<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&h.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(t,o,c){let d=Math.ceil(15*o/1e3),m=[],_=t(c.clone());for(let y=0;y<=d;y++){let v=_(y/d);m.push(v.clone())}return m}_preloadTiles(t,o){}}let mg=/^(https?:|mailto:)/i;class vm{constructor(t={}){this.options=t,h.b0(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){let o=this.options&&this.options.compact,c=t._getUIString("AttributionControl.ToggleAttribution");this._map=t,this._container=Mt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=Mt("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",c);let d=Mt("span","mapboxgl-ctrl-icon",this._compactButton);return d.setAttribute("aria-hidden","true"),d.setAttribute("title",c),this._innerContainer=Mt("div","mapboxgl-ctrl-attrib-inner",this._container),o&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),o===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));let o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||h.g.ACCESS_TOKEN}];if(t){let c=o.reduce((d,m,_)=>(m.value&&(d+=`${m.key}=${m.value}${_<o.length-1?"&":""}`),d),"?");t.href=`${h.g.FEEDBACK_URL}/${c}#${ln(this._map,!0)}`,t.rel="noopener nofollow"}}_updateData(t){!t||(t.dataType!=="source"||t.sourceDataType!=="metadata"&&t.sourceDataType!=="visibility")&&t.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){let d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}let o=this._map.style._mergedSourceCaches;for(let d in o){let m=o[d];if(m.used){let _=m.getSource();_.attribution&&!t.includes(_.attribution)&&t.push(_.attribution)}}t.sort((d,m)=>d.length-m.length),t=t.filter((d,m)=>{for(let _=m+1;_<t.length;_++)if(t[_].includes(d))return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));let c=t.map(d=>function(m){let _=new DOMParser().parseFromString(m,"text/html");return Array.from(_.body.querySelectorAll("*")).reverse().forEach(y=>{let v=y.textContent||"";if(y.tagName!=="A")return void y.replaceWith(...y.childNodes);let T=y.getAttribute("href");if(!T||!mg.test(T))return void y.replaceWith(_.createTextNode(v));let E=_.createElement("a");E.href=T,E.textContent=v,E.rel="noopener nofollow";let P=y.getAttribute("class");P&&(E.className=P),y.replaceWith(E)}),_.body.innerHTML}(d)).join(" | ");c!==this._attribHTML&&(this._attribHTML=c,t.length?(this._innerContainer.innerHTML=c,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class bm{constructor(){h.b0(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=Mt("div","mapboxgl-ctrl");let o=Mt("a","mapboxgl-ctrl-logo");return o.target="_blank",o.rel="noopener nofollow",o.href="https://www.mapbox.com/",o.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),o.setAttribute("rel","noopener nofollow"),this._container.appendChild(o),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&t.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;let t=this._map.style._sourceCaches;if(Object.entries(t).length===0)return!0;for(let o in t){let c=t[o].getSource();if(Object.hasOwn(c,"mapbox_logo")&&!c.mapbox_logo)return!1}return!0}_updateCompact(){let t=this._container.children;if(t.length){let o=t[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class wm{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let o=++this._id;return this._queue.push({callback:t,id:o,cancelled:!1}),o}remove(t){let o=this._currentlyRunning,c=o?this._queue.concat(o):this._queue;
3281for(let d of c)if(d.id===t)return void(d.cancelled=!0)}run(t=0){let o=this._currentlyRunning=this._queue;this._queue=[];for(let c of o)if(!c.cancelled&&(c.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class lp{constructor(t){this.jumpTo(t)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;let o=h.dr((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,o,c){this._start=this.getValue(o),this._end=t,this._startTime=o,this._endTime=o+c}}let _g={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class qs extends h.z{constructor(t,o,c,d){let{point:m,lngLat:_,originalEvent:y,target:v}=t;super(t.type,{point:m,lngLat:_,originalEvent:y,target:v}),this.preventDefault=()=>{t.preventDefault()},this.id=o,this.interaction=c,this.feature=d}}class Tm{constructor(t){this.map=t,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(t,o){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);let c=o.filter,d=o.type;c&&this.filters.set(t,h.dj(c)),d==="mouseover"&&(d="mouseenter"),d==="mouseout"&&(d="mouseleave");let m=this.interactionsByType.get(d)||new Map;d==="mouseenter"||d==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,o)):m.size===0&&this.map.on(d,this.handleType),m.size===0&&this.interactionsByType.set(d,m),m.set(t,o),this.typeById.set(t,d)}get(t){let o=this.typeById.get(t);if(!o)return;let c=this.interactionsByType.get(o);return c?c.get(t):void 0}remove(t){let o=this.typeById.get(t);if(!o)return;this.typeById.delete(t),this.filters.delete(t);let c=this.interactionsByType.get(o);c&&(c.delete(t),o==="mouseenter"||o==="mouseleave"?(this.delegatedInteractions.delete(t),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):c.size===0&&this.map.off(o,this.handleType))}queryTargets(t,o){let c=[];for(let[d,m]of o)m.target&&c.push({targetId:d,target:m.target,filter:this.filters.get(d)});return this.map.style.queryRenderedTargets(t,c,this.map.transform)}handleMove(t){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;let o=this.queryTargets(t.point,Array.from(this.delegatedInteractions).reverse());o.length&&(t.type="mouseenter",this.handleType(t,o));let c=new Map;for(let[d,{feature:m}]of this.prevHoveredFeatures)this.hoveredFeatures.has(d)||c.set(m.id,m);c.size&&(t.type="mouseleave",this.handleType(t,Array.from(c.values())))}handleOut(t){let o=Array.from(this.hoveredFeatures.values()).map(({feature:c})=>c);o.length&&(t.type="mouseleave",this.handleType(t,o)),this.hoveredFeatures.clear()}handleType(t,o){let c=t.type==="mouseenter";if(c&&!this.interactionsByType.has(t.type))return void h.w("mouseenter interaction required for mouseleave to work.");let d=Array.from(this.interactionsByType.get(t.type)).reverse(),m=!!o;o=o||this.queryTargets(t.point,d);let _=!1,y=new Set;for(let v of o){for(let[T,E]of d){if(!E.target)continue;let P=v.variants?v.variants[T]:null;if(P){for(let A of P){if(qh(A,v,y,T))continue;let D=new h.dl(v,A),z=lf(A,v,T);m&&D.id!==void 0&&(D.state=this.map.getFeatureState(D));let O=c?this.prevHoveredFeatures.get(z):null,k=new qs(t,T,E,D),N=O?O.stop:E.handler(k);if(c&&this.hoveredFeatures.set(z,{feature:v,stop:N}),N!==!1){_=!0;break}}if(_)break}}if(_)break}if(!_)for(let[v,T]of d){let{handler:E,target:P}=T;if(!P&&E(new qs(t,v,T,null))!==!1)break}}}function gg(a,t){if(Array.isArray(a)&&Array.isArray(t)){let o=new Set(a
3281),c=new Set(t);return o.size===c.size&&a.every(d=>c.has(d))}return h.b9(a,t)}let Sm=/matrix.*\((.+)\)/,yg={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,fontstackCompositing:"client",transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},xg={showCompass:!0,showZoom:!0,visualizePitch:!1};class ls{constructor(t,o,c=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new jr({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,c&&(this.mousePitch=new Gr({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),h.b0(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),o.addEventListener("mousedown",this.mousedown),o.addEventListener("touchstart",this.touchstart,{passive:!1}),o.addEventListener("touchmove",this.touchmove),o.addEventListener("touchend",this.touchend),o.addEventListener("touchcancel",this.reset)}down(t,o){this.mouseRotate.mousedown(t,o),this.mousePitch&&this.mousePitch.mousedown(t,o),Go()}move(t,o){let c=this.map,d=this.mouseRotate.mousemoveWindow(t,o),m=d&&d.bearingDelta;if(m&&c.setBearing(c.getBearing()+m),this.mousePitch){let _=this.mousePitch.mousemoveWindow(t,o),y=_&&_.pitchDelta;y&&c.setPitch(c.getPitch()+y)}}off(){let t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){Ho(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(Object.assign({},t,{button:t.button,type:t.type,ctrlKey:!0,preventDefault:()=>t.preventDefault()}),$o(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,$o(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){t.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=ta(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){t.targetTouches.length!==1?this.reset():(this._lastPos=ta(this.element,t.targetTouches)[0],this.move({buttons:1,preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){t.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function Em(a,t,o){if(a=new h.aX(a.lng,a.lat),t){let c=new h.aX(a.lng-360,a.lat),d=new h.aX(a.lng+360,a.lat),m=360*Math.ceil(Math.abs(a.lng-o.center.lng)/360),_=o.locationPoint3D(a).distSqr(t),y=t.x<0||t.y<0||t.x>o.width||t.y>o.height;o.locationPoint3D(c).distSqr(t)<_&&(y||Math.abs(c.lng-o.center.lng)<m)?a=c:o.locationPoint3D(d).distSqr(t)<_&&(y||Math.abs(d.lng-o.center.lng)<m)&&(a=d)}for(;Math.abs(a.lng-o.center.lng)>180;){let c=o.locationPoint3D(a);if(c.x>=0&&c.y>=0&&c.x<=o.width&&c.y<=o.height)break;a.lng>o.center.lng?a.lng-=360:a.lng+=360}return a}let Yc={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%)"},cp=/\s+/,ao={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class ph extends h.E{constructor(t,o){super(),(t instanceof HTMLElement||o)&&(t=Object.assign({element:t},o)),h.b0(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);let{anchor:c="center",color:d="#3FB1CE",scale:m=1,draggable:_=!1,clickTolerance:y=0,rotation:v=ao.rotation,rotationAlignment:T=ao.rotationAlignment,pitchAlignment:E=ao.pitchAlignment,occludedOpacity:P=ao.occludedOpacity,altitude:A=ao.altitude}=t||{};this._anchor=c,this._color=d,this._scale=m,this._draggable=_,this._clickTolerance=y,this._rotation=v,this._rotationAlignment=T,this._pitchAlignment=E,this._occludedOpacity=P,this._altitude=A,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=h.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=h.P.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",O=>{O.preventDefault()}),this._element.addEventListener("mousedown",O=>{O.preventDefault()});let D=this._element.classList;for(let O in Yc)D.remove(`mapboxgl-marker-anchor-${O}`);D.add(`mapboxgl-marker-anchor-${this._anchor}`);let z=t&&t.className?t.className.trim().split(cp):[];D.add(...z),this._popup=null}_createDefaultMarker(){let t=Mt("div"),o=Bn("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},t);if(this._altitude===0){let c=Bn("radialGradient",{id:"shadowGradient"},Bn("defs",{},o));
3281Bn("stop",{offset:"10%","stop-opacity":.4},c),Bn("stop",{offset:"100%","stop-opacity":.05},c),Bn("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},o)}return Bn("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},o),Bn("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},o),Bn("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},o),t}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){let t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=h.aX.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(t){return t===this._altitude||(this._defaultMarker&&(this._altitude===0&&t!==0||this._altitude!==0&&t===0)&&(this._element=this._createDefaultMarker()),this._altitude=t||ao.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){let d=Math.sqrt(Math.pow(13.5,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[d,-1*(38.1-13.5+d)],"bottom-right":[-d,-1*(38.1-13.5+d)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,t._marker=this,t._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(t){let o=t.code,c=t.charCode||t.keyCode;o!=="Space"&&o!=="Enter"&&c!==32&&c!==13||this.togglePopup()}_onMapClick(t){let o=t.originalEvent.target,c=this._element;this._popup&&(o===c||c.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){let t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){let t=this._map,o=this._pos;if(!t||!o)return!1;let c=t.unproject(o,this._altitude),d=t.getFreeCameraOptions();if(!d.position)return!1;let m=d.position.toLngLat();return m.distanceTo(c)<.9*m.distanceTo(this._lngLat)}_evaluateOpacity(){let t=this._map;if(!t)return;let o=this._pos;if(!o||o.x<0||o.x>t.transform.width||o.y<0||o.y>t.transform.height)return void this._clearFadeTimer();let c=t.unproject(o,this._altitude),d;t._showingGlobe()&&h.f2(t.transform,this._lngLat)?d=0:(d=1-t._queryFogOpacity(c),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(d*=this._occludedOpacity)),this._element.style.opacity=`${d}`,this._element.style.pointerEvents=d>0?"auto":"none",this._popup&&this._popup._setOpacity(d),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){let t=this._pos;if(!t||!this._map)return;let o=this._offset.mult(this._scale);this._element.style.transform=`
3282            translate(${t.x}px,${t.y}px)
3283            ${Yc[this._anchor]}
3284            ${this._calculateXYTransform()} ${this._calculateZTransform()}
3285            translate(${o.x}px,${o.y}px)
3286        `}_calculateXYTransform(){let t=this._pos,o=this._map,c=this.getPitchAlignment();if(!o||!t||c!=="map")return"";if(!o._showingGlobe()){let v=o.getPitch();return v?`rotateX(${v}deg)`:""}let d=h.cL(h.f3(o.transform,this._lngLat)),m=t.sub(h.f4(o.transform)),_=Math.abs(m.x)+Math.abs(m.y);if(_===0)return"";let y=d/_;return`rotateX(${-m.y*y}deg) rotateY(${m.x*y}deg)`}_calculateZTransform(){let t=this._pos,o=this._map;if(!o||!t)return"";let c=0,d=this.getRotationAlignment();if(d==="map")if(o._showingGlobe()){let m=o.project(new h.aX(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),_=o.project(new h.aX(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(m);c=h.cL(Math.atan2(_.y,_.x))-90}else c=-o.getBearing();else if(d==="horizon"){let m=h.ag(4,6,o.getZoom()),_=h.f4(o.transform);_.y+=m*o.transform.height;let y=t.sub(_),v=h.cL(Math.atan2(y.y,y.x));c=(v>90?v-270:v+90)*(1-m)}return c+=this._rotation,c?`rotateZ(${c}deg)`:""}_update(t){cancelAnimationFrame(this._updateFrameId);let o=this._map;
3286o&&(o.transform.renderWorldCopies&&(this._lngLat=Em(this._lngLat,this._pos,o.transform)),this._pos=o.project(this._lngLat,this._altitude),t===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),o._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(o._showingGlobe()||o.getTerrain()||o.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=h.P.convert(t),this._update(),this}addClassName(t){return this._element.classList.add(t),this}removeClassName(t){return this._element.classList.remove(t),this}toggleClassName(t){return this._element.classList.toggle(t)}_onMove(t){let o=this._map;if(!o)return;let c=this._pointerdownPos,d=this._positionDelta;if(c&&d){if(!this._isDragging){let m=this._clickTolerance||o._clickTolerance;if(t.point.dist(c)<m)return;this._isDragging=!0}this._pos=t.point.sub(d),this._lngLat=o.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new h.z("dragstart"))),this.fire(new h.z("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;let t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new h.z("dragend")),this._state="inactive"}_addDragHandler(t){let o=this._map,c=this._pos;o&&c&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(c),this._pointerdownPos=t.point,this._state="pending",o.on("mousemove",this._onMove),o.on("touchmove",this._onMove),o.once("mouseup",this._onUp),o.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;let o=this._map;return o&&(t?(o.on("mousedown",this._addDragHandler),o.on("touchstart",this._addDragHandler)):(o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||ao.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||ao.rotationAlignment,this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t||ao.pitchAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(t){return this._occludedOpacity=t||ao.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}let Im={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},Am={maxWidth:100,unit:"metric"},Mm={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},up=/\s+/,Ei={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},Cm=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function fh(a=new h.P(0,0),t="bottom"){if(typeof a=="number"){let o=Math.round(Math.sqrt(.5*Math.pow(a,2)));switch(t){case"top":return new h.P(0,a);case"top-left":return new h.P(o,o);case"top-right":return new h.P(-o,o);case"bottom":return new h.P(0,-a);case"bottom-left":return new h.P(o,-o);case"bottom-right":return new h.P(-o,-o);case"left":return new h.P(a,0);case"right":return new h.P(-a,0)}return new h.P(0,0)}return a instanceof h.P||Array.isArray(a)?h.P.convert(a):h.P.convert(a[t]||[0,0])}return{version:U,supported:Xn.supported,setRTLTextPlugin:h.f7,getRTLTextPluginStatus:h.f6,addTileProvider:h.f5,Map:class extends $s{constructor(a){wi.mark(Pn.create);let t=a;if((a=Object.assign({},yg,a)).minZoom!=null&&a.maxZoom!=null&&a.minZoom>a.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(a.minPitch!=null&&a.maxPitch!=null&&a.minPitch>a.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(a.minPitch!=null&&a.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(a.maxPitch!=null&&a.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");a.antialias&&h.f0(window)&&(a.antialias=!1,h.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Cs(a.minZ
3286oom,a.maxZoom,a.minPitch,a.maxPitch,a.renderWorldCopies,null,null),a),this._repaint=!!a.repaint,this._interactive=a.interactive,this._minTileCacheSize=a.minTileCacheSize,this._maxTileCacheSize=a.maxTileCacheSize,this._failIfMajorPerformanceCaveat=a.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=a.preserveDrawingBuffer,this._antialias=a.antialias,this._trackResize=a.trackResize,this._bearingSnap=a.bearingSnap,this._refreshExpiredTiles=a.refreshExpiredTiles,this._fadeDuration=a.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=a.crossSourceCollisions,this._collectResourceTiming=a.collectResourceTiming,this._language=this._parseLanguage(a.language),this._worldview=a.worldview,this._renderTaskQueue=new wm,this._domRenderTaskQueue=new wm,this._controls=[],this._markers=[],this._popups=[],this._mapId=h.an(),this._locale=Object.assign({},_g,a.locale),this._clickTolerance=a.clickTolerance,this._cooperativeGestures=a.cooperativeGestures,this._performanceMetricsCollection=a.performanceMetricsCollection,this._tessellationStep=a.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=a.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new lp(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=a.scaleFactor,this._requestManager=new mo(a.transformRequest,a.accessToken,a.testMode);let o=zr(a.accessToken||h.g.ACCESS_TOKEN);if(o&&"atlas"in o&&typeof o.atlas=="number"&&(this._tokenExpiration=o.atlas),this._silenceAuthErrors=!!a.testMode,this._contextCreateOptions=a.contextCreateOptions?Object.assign({},a.contextCreateOptions):{},typeof a.container=="string"){let c=document.getElementById(a.container);if(!c)throw new Error(`Container '${a.container.toString()}' not found.`);this._container=c}else{if(!(a.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=a.container}if(this._container.childNodes.length>0&&h.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),a.maxBounds&&this.setMaxBounds(a.maxBounds),this._spriteFormat="auto",h.b0(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new $r(this,a),this._localFontFamily=a.localFontFamily,this._localIdeographFontFamily=a.localIdeographFontFamily,this._fontstackCompositing=a.fontstackCompositing,(a.style||!a.testMode)&&this.setStyle(a.style||h.g.DEFAULT_STYLE,{config:a.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,fontstackCompositing:this._fontstackCompositing}),a.projection&&this.setProjection(a.projection),a.hash&&(this._hash=new lh(typeof a.hash=="string"&&a.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){t.center==null&&t.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch});let c=a.bounds;c&&(this.resize(),this.fitBounds(c,Object.assign({},a.fitBoundsOptions,{duration:0})))}this.resize(),a.attributionControl&&this.addControl(new vm({customAttribution:a.customAttribution}
vendor: 4,791 bytes, line 3286
3286)),this._logoControl=new bm,this.addControl(this._logoControl,a.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",c=>{this._update(c.dataType==="style"),this.fire(new h.z(`${c.dataType}data`,c))}),this.on("dataloading",c=>{this.fire(new h.z(`${c.dataType}dataloading`,c))}),this._interactions=new Tm(this)}_getMapId(){return this._mapId}addControl(a,t){if(t===void 0&&(t=a.getDefaultPosition?a.getDefaultPosition():"top-right"),!a||!a.onAdd)return this.fire(new h.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let o=a.onAdd(this);this._controls.push(a);let c=this._controlPositions[t];return t.includes("bottom")?c.insertBefore(o,c.firstChild):c.appendChild(o),this}removeControl(a){if(!a||!a.onRemove)return this.fire(new h.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(a);return t>-1&&this._controls.splice(t,1),a.onRemove(this),this}hasControl(a){return this._controls.includes(a)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(a){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));let t=!this._moving;return t&&this.fire(new h.z("movestart",a)).fire(new h.z("move",a)),this.fire(new h.z("resize",a)),t&&this.fire(new h.z("moveend",a)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(a){return this.transform.setMaxBounds(h.aI.convert(a)),this._update()}setMinZoom(a){if((a=a??-2)>=-2&&a<=this.transform.maxZoom)return this.transform.minZoom=a,this._update(),this.getZoom()<a?this.setZoom(a):this.fire(new h.z("zoomstart")).fire(new h.z("zoom")).fire(new h.z("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(a){if((a=a??22)>=this.transform.minZoom)return this.transform.maxZoom=a,this._update(),this.getZoom()>a?this.setZoom(a):this.fire(new h.z("zoomstart")).fire(new h.z("zoom")).fire(new h.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(a){if((a=a??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(a>=0&&a<=this.transform.maxPitch)return this.transform.minPitch=a,this._update(),this.getPitch()<a?this.setPitch(a):this.fire(new h.z("pitchstart")).fire(new h.z("pitch")).fire(new h.z("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(a){if((a=a??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(a>=this.transform.minPitch)return this.transform.maxPitch=a,this._update(),this.getPitch()>a?this.setPitch(a):this.fire(new h.z("pitchstart")).fire(new h.z("pitch")).fire(new h.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(a){return this._scaleFactor=a,this.painter.scaleFactor=a,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(t=>t.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(a){return this.transform.renderWorldCopies=a,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(a){return a==="auto"?navigator.language:Array.isArray(a)?a.length===0?void 0:a.map(t=>t==="auto"?navigator.language:t):a}setLanguage(a){let t=this._parseLanguage(a);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(let o of this._controls)o._setLanguage&&o._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(a){return this.style&&a!==this._worldview?(this._worldview=a,this._styleDirty=!0,this.style.setWorldview(a),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(a){return this._lazyInitEmptyStyle(),a?typeof a=="str
3286ing"&&(a={name:a}):a=null,this._useExplicitProjection=!!a,this._prioritizeAndUpdateProjection(a,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;let a=this.transform,t=a.projection.name,o;t==="globe"&&a.zoom>=h.cx?(a.setMercatorFromTransition(),o=!0):t==="mercator"&&a.zoom<h.cx&&(a.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0))}_prioritizeAndUpdateProjection(a,t){return this._updateProjection(a||t||{name:"mercator"})}_updateProjection(a){let t,o=this.transform.mercatorFromTransition;t=a.name==="globe"&&this.transform.zoom>=h.cx?this.transform.setMercatorFromTransition():this.transform.setProjection(a),this.style.applyProjectionUpdate();let c=this.transform.getProjection().name==="mercator"&&o!==this.transform.mercatorFromTransition;return(t||c)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(a,t){return this.transform.locationPoint3D(h.aX.convert(a),t)}unproject(a,t){return this.transform.pointLocation3D(h.P.convert(a),t)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(a,t,o){let c=d=>{let m=[];if(Array.isArray(t)){let _=t.filter(y=>this.getLayer(y));m=_.length?this.queryRenderedFeatures(d,{layers:_}):[]}else m=this.queryRenderedFeatures(d,{target:t});return m};if(a==="mouseenter"||a==="mouseover"){let d=!1;return{listener:o,targets:t,delegates:{mousemove:_=>{let y=c(_.point);y.length?d||(d=!0,o.call(this,new ar(a,this,_.originalEvent,{features:y}))):d=!1},mouseout:()=>{d=!1}}}}if(a==="mouseleave"||a==="mouseout"){let d=!1;return{listener:o,targets:t,delegates:{mousemove:y=>{c(y.point).length?d=!0:d&&(d=!1,o.call(this,new ar(a,this,y.originalEvent)))},mouseout:y=>{d&&(d=!1,o.call(this,new ar(a,this,y.originalEvent)))}}}}{let d=m=>{let _=c(m.point);_.length&&(m.features=_,o.call(this,m),delete m.features)};return{listener:o,targets:t,delegates:{[a]:d}}}}on(a,t,o){if(typeof t=="function"||o===void 0)return super.on(a,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;let c=this._createDelegatedListener(a,t,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[a]=this._delegatedListeners[a]||[],this._delegatedListeners[a].push(c);for(let d in c.delegates)this.on(d,c.delegates[d]);return this}once(a,t,o){if(typeof t=="function"||o===void 0)return super.once(a,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;let c=this._createDelegatedListener(a,t,o);for(let d in c.delegates)this.once(d,c.delegates[d]);return this}off(a,t,o){if(typeof t=="function"||o===void 0)return super.off(a,t);if(typeof t=="string"&&(t=[t]),!this._areTargetsValid(t))return this;let c=this._delegatedListeners?this._delegatedListeners[a]:void 0;return c&&(d=>{for(let m=0;m<d.length;m++){let _=d[m];if(_.listener===o&&gg(_.targets,t)){for(let y in _.delegates)this.off(y,_.delegates[y]);return d.splice(m,1),this}}})(c),this}queryRenderedFeatures(a,t){if(!this.style)return[];if(a===void 0||a instanceof h.P||Array.isArray(a)||t!==void 0||(t=a,a=void 0),a=a||[[0,0],[this.transform.width,this.transform.height]],!t){let m=this.style.queryRenderedFeatures(a,void 0,this.transform),_=this.style.queryRenderedFeatureset(a,void 0,this.transform);return m.concat(_)}let o=!0;if(t.target&&(o=this._isTargetValid(t.target),o&&!t.layers))return this.style.queryRenderedFeatureset(a,t,this.transform);let c=!0;if(t.layers&&Array.isArray(t.layers)){for(let m of t.layers)if(!this._isValidId(m)){c=!1;break}if(c&&!t.target)return this.style.queryRenderedFeatures(a,t,this.transform)}let d=[];return c&&(d=d.concat(this.style.queryRenderedFeatures(a,t,this.transform))),o&&(d=d.concat(this.style.queryRenderedFeatureset(a,t,this.transform))),d}
3286querySourceFeatures(a,t){return!a||typeof a=="string"&&!this._isValidId(a)?[]:this.style.querySourceFeatures(a,t)}queryRasterValue(a,t,o){return this._isValidId(a)?this.style.queryRasterValue(a,t,o):Promise.resolve(null)}isPointOnSurface(a){let{name:t}=this.transform.projection;return t!=="globe"&&t!=="mercator"&&h.w(`${t} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(h.P.convert(a))}addInteraction(a,t){return this._interactions.add(a,t),this}removeInteraction(a){return this._interactions.remove(a),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(a){return this._cooperativeGestures=a,this}setStyle(a,t){return t=Object.assign({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,fontstackCompositing:this._fontstackCompositing},t),this.style&&a&&t.diff!==!1&&t.localFontFamily===this._localFontFamily&&t.localIdeographFontFamily===this._localIdeographFontFamily&&t.fontstackCompositing===this._fontstackCompositing&&!t.config?(this.style._diffStyle(a,(o,c)=>{if(o){let d=typeof o=="string"?o:o instanceof Error?o.message:o.error;h.w(`Unable to perform style diff: ${d}. Rebuilding the style from scratch.`),this._updateStyle(a,t)}else c&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._fontstackCompositing=t.fontstackCompositing,this._updateStyle(a,t))}_getUIString(a){let t=this._locale[a];if(t==null)throw new Error(`Missing UI string '${a}'`);return t}_updateStyle(a,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),a){let o=Object.assign({},t);t&&t.config&&(o.initialConfig=t.config,delete o.config),this.style=new Nr(this,o).load(a),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Nr(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(h.w("There is no style added to the map."),!1)}_isValidId(a){return a==null?(this.fire(new h.y(new Error("IDs can't be empty."))),!1):!h.de(a)||(this.fire(new h.y(new Error(`IDs can't contain special symbols: "${a}".`))),!1)}_isTargetValid(a){return"featuresetId"in a?this._isValidId("importId"in a?a.importId:a.featuresetId):"layerId"in a&&this._isValidId(a.layerId)}_areTargetsValid(a){if(Array.isArray(a)){for(let t of a)if(!this._isValidId(t))return!1;return!0}return this._isTargetValid(a)}addSource(a,t){return this._isValidId(a)?(this._lazyInitEmptyStyle(),this.style.addSource(a,t),this._update(!0)):this}isSourceLoaded(a){return!!this._isValidId(a)&&!!this.style&&this.style._isSourceCacheLoaded(a)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(a,t,o){this._lazyInitEmptyStyle(),this.style.addSourceType(a,t,o)}removeSource(a){return this._isValidId(a)?(this.style.removeSource(a),this._updateTerrain(),this._update(!0)):this}getSource(a){return this._isValidId(a)?this.style.getOwnSource(a):null}addImage(a,t,{pixelRatio:o=1,sdf:c=!1,stretchX:d,stretchY:m,content:_}={}){this._lazyInitEmptyStyle();let y=h.I.from(a);if(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap){let{width:v,height:T,data:E}=h.o.getImageData(t);this.style.addImage(y,{data:new h.q({width:v,height:T},E),pixelRatio:o,stretchX:d,stretchY:m,content:_,sdf:c,version:0,usvg:!1})}else if(t.width===void 0||t.height===void 0)this.fire(new h.y(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`")));else{let{width:v,height:T}=t,E=t;this.style.addImage(y,{data:new h.q({width:v,height:T},new Uint8Array(E.data)),pixelRatio:o,stretchX:d,stretchY:m,content:_,sdf:c,usvg:!1,version:0,userImage:E}),E.onAdd&&E.onAdd(this,a)}}updateImage(a,t){this._lazyInitEmptyStyle();let o=h.I.from(a),c=this.style.getImage(o);if(!c)return void this.fire(new h.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let d=t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap?h.o.getImageData(t):t,{width:m,height:_,data:y}=d;if(m===void 0||_===void 0)return void this.fire(new h.y(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(m!==(c.usvg?c.icon.usvg_tree.width:c.data.width)||_!==(c.usvg?c.icon.usvg_tree.height:c.data.height))return void this.fire(new h.y(new Error(`The width and height of the updated image (${m}, ${_})
3287                must be that same as the previous version of the image
3288                (${c.data.width}, ${c.data.height})`)));let v=!(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap),T=!1;c.usvg?(c.data=new h.q({width:m,height:_},new Uint8Array(y)),c.usvg=!1,c.icon=void 0,T=!0):c.data.replace(y,v),this.style.updateImage(o,c,T)}hasImage(a){return a?!!this.style&&!!this.style.getImage(h.I.from(a)):(this.fire(new h.y(new Error("Missing required image id"))),!1)}removeImage(a){this.style.removeImage(h.I.from(a))}loadImage(a,t){h.n(this._requestManager.transformRequest(a,h.R.Image),(o,c)=>{t(o,c)})}listImages(){return this.style.listImages().map(a=>a.name)}addModel(a,t){this._lazyInitEmptyStyle(),this.style.addModel(a,t)}hasModel(a){return a?this.style.hasModel(a):(this.fire(new h.y(new Error("Missing required model id"))),!1)}removeModel(a){this.style.removeModel(a)}listModels(){return this.style.listModels()}addLayer(a,t){return this._isValidId(a.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(a,t),this._update(!0)):this}getSlot(a){let t=this.getLayer(a);return t&&t.slot||null}setSlot(a,t){return this.style.setSlot(a,t),this.style.mergeLayers(),this._update(!0)}
3288addImport(a,t){return this.style.addImport(a,t).catch(o=>this.fire(new h.y(new Error("Failed to add import",o)))),this}updateImport(a,t){return typeof t!="string"&&t.id!==a?(this.removeImport(a),this.addImport(t)):(this.style.updateImport(a,t),this._update(!0))}removeImport(a){return this.style.removeImport(a),this}moveImport(a,t){return this.style.moveImport(a,t),this._update(!0)}moveLayer(a,t){return this._isValidId(a)?(this.style.moveLayer(a,t),this._update(!0)):this}removeLayer(a){return this._isValidId(a)?(this.style.removeLayer(a),this._update(!0)):this}getLayer(a){if(!this._isValidId(a))return null;let t=this.style.getOwnLayer(a);return t?t.type==="custom"?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(a,t,o){return this._isValidId(a)?(this.style.setLayerZoomRange(a,t,o),this._update(!0)):this}setFilter(a,t,o={}){return this._isValidId(a)?(this.style.setFilter(a,t,o),this._update(!0)):this}getFilter(a){return this._isValidId(a)?this.style.getFilter(a):null}setPaintProperty(a,t,o,c={}){return this._isValidId(a)?(this.style.setPaintProperty(a,t,o,c),this._update(!0)):this}getPaintProperty(a,t){return this._isValidId(a)?this.style.getPaintProperty(a,t):null}setLayoutProperty(a,t,o,c={}){return this._isValidId(a)?(this.style.setLayoutProperty(a,t,o,c),this._update(!0)):this}getLayoutProperty(a,t){return this._isValidId(a)?this.style.getLayoutProperty(a,t):null}setLayerProperty(a,t,o,c={}){return this._isValidId(a)?(t==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(a,t,o,c),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(a){return this.style.setGlyphsUrl(a),this._update(!0)}getSchema(a){return this.style.getSchema(a)}setSchema(a,t){return this.style.setSchema(a,t),this._update(!0)}getConfig(a){return this.style.getConfig(a)}setConfig(a,t){return this.style.setConfig(a,t),this._update(!0)}getConfigProperty(a,t){return this.style.getConfigProperty(a,t)}setConfigProperty(a,t,o){return this.style.setConfigProperty(a,t,o),this._update(!0)}getFeaturesetDescriptors(a){return this.style.getFeaturesetDescriptors(a)}setLights(a){if(this._lazyInitEmptyStyle(),a&&a.length===1&&a[0].type==="flat"){let t=a[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(a),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){let a=this.style.getLights()||[];return a.length===0&&a.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),a}setLight(a,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:a}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(a){return this._lazyInitEmptyStyle(),!a&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(a),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(a){return this._lazyInitEmptyStyle(),this.style.setFog(a),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(a){return this._lazyInitEmptyStyle(),this.style.setSnow(a),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(a){return this._lazyInitEmptyStyle(),this.style.setRain(a),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(a){return this._lazyInitEmptyStyle(),this.style.setColorTheme(a),this._update(!0)}setImportColorTheme(a,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(a,t),this._update(!0)}setCamera(a){return this.style.setCamera(a),this._triggerCameraUpdate(a)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(a){let t=this.transform.nearClipOffset!==a;return this.transform.nearClipOffset=a,this._update(t)}_triggerCameraUpdate(a){return this._update(this.transform.setOrthogra
3288phicProjectionAtLowPitch(a["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(a){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(h.aX.convert(a),this.transform):0}setFeatureState(a,t){return a.source&&!this._isValidId(a.source)?this:(this.style.setFeatureState(a,t),this._update())}removeFeatureState(a,t){return a.source&&!this._isValidId(a.source)?this:(this.style.removeFeatureState(a,t),this._update())}getFeatureState(a){return a.source&&!this._isValidId(a.source)?null:this.style.getFeatureState(a)}_selectIndoorFloor(a){this.style.indoorManager.selectFloor(a)}_setIndoorActiveFloorsVisibility(a){this.style.indoorManager.setActiveFloorsVisibility(a)}getIndoorTileOptions(a,t){return this.style&&this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(a,t):null}_updateContainerDimensions(){if(!this._container)return;let a=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300,o,c,d,m=this._container;for(;m&&(!c||!d);){let _=window.getComputedStyle(m).transform;_&&_!=="none"&&(o=_.match(Sm)[1].split(", "),o[0]&&o[0]!=="0"&&o[0]!=="1"&&(c=o[0]),o[3]&&o[3]!=="0"&&o[3]!=="1"&&(d=o[3])),m=m.parentElement}this._containerWidth=c?Math.abs(a/c):a,this._containerHeight=d?Math.abs(t/d):t}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&h.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){let a=this._container;a.classList.add("mapboxgl-map"),(this._missingCSSCanary=Mt("div","mapboxgl-canary",a)).style.visibility="hidden",this._detectMissingCSS();let t=this._canvasContainer=Mt("div","mapboxgl-canvas-container",a);this._canvas=Mt("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);let o=this._controlContainer=Mt("div","mapboxgl-control-container",a),c=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(d=>{c[d]=Mt("div",`mapboxgl-ctrl-${d}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(a,t){let o=h.o.devicePixelRatio||1;this._canvas.width=o*Math.ceil(a),this._canvas.height=o*Math.ceil(t),this._canvas.style.width=`${a}px`,this._canvas.style.height=`${t}px`}_addMarker(a){this._markers.push(a)}_removeMarker(a){let t=this._markers.indexOf(a);t!==-1&&this._markers.splice(t,1)}_addPopup(a){this._popups.push(a)}_removePopup(a){let t=this._popups.indexOf(a);t!==-1&&this._popups.splice(t,1)}_setupPainter(){let a=Object.assign({},Xn.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl2",a);t?(Zo(t,!0),this.painter=new ep(t,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",o=>{if(o.dataType==="source"){let c=this.transform.elevation?this.transform.elevation._source():null;c&&o.sourceCacheId===c.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0)}}),h.k.testSupport(t)):this.fire(new h.y(new Error("Failed to initialize WebGL")))}_contextLost(a){a.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.style&&this.style.handleContextLost(),this.fire(new h.z("webglcontextlost",{originalEvent:a}))}_contextRestored(a){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new h.z("webglcontextrestored",{originalEvent:a}))}_onMapScroll(a){if(a.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(a){return this.style?(this._styleDirty=this._styleDirty||a,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(a){return this._update(),this._renderTaskQueue.add(a)}_cancelRenderFrame(a){this._renderTaskQueue.remove(a)}_requestDomTask(a){!this.loaded()||this.loaded()&&!this.isMoving()?a():this._domRenderTaskQueue.add(a)}_render(a){let t;this.fire(new h.z("renderstart")),++this._frameId;let o=this.painter.context.extTimerQuery,c=h.o.now(),d=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(t=d.createQuery(),d.beginQuery(o.TIME_ELAPSED_EXT,t)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&
3288(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(a),this._domRenderTaskQueue.run(a),this._removed)return;this._updateProjectionTransition();let m=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;let v=this.transform.zoom,T=this.transform.pitch,E=h.o.now(),P=new h.ab(v,{now:E,fadeDuration:m,pitch:T,transition:this.style.transition,worldview:this._worldview});this.style.update(P)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let _=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),_=this._updateAverageElevation(c),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):_=this._updateAverageElevation(c),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,m,this._crossSourceCollisions,this.painter.replacementSource)),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:m,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new h.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,wi.mark(Pn.load),this.fire(new h.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),t){let v=h.o.now()-c;d.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{let T=d.getQueryParameter(t,d.QUERY_RESULT)/1e6;d.deleteQuery(t),this.fire(new h.z("gpu-timing-frame",{cpuTime:v,gpuTime:T}))},50)}if(this.listens("gpu-timing-layer")){let v=this.painter.collectGpuTimers();setTimeout(()=>{let T=this.painter.queryGpuTimers(v);this.fire(new h.z("gpu-timing-layer",{layerTimes:T}))},50)}if(this.listens("gpu-timing-deferred-render")){let v=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{let T=this.painter.queryGpuTimeDeferredRender(v);this.fire(new h.z("gpu-timing-deferred-render",{gpuTime:T}))},50)}let y=this._sourcesDirty||this._styleDirty||this._placementDirty||_;if(y||this._repaint)this.triggerRepaint();else{let v=this.idle();if(v&&(_=this._updateAverageElevation(c,!0)),_)this.triggerRepaint();else{if(this._triggerFrame(!1),v&&(this.fire(new h.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){let T=this._calculateSpeedIndex();this.fire(new h.z("speedindexcompleted",{speedIndex:T})),this.speedIndexTiming=!1}v&&this.style&&this.style.handleIdle()}}!this._loaded||this._fullyLoaded||y||(this._fullyLoaded=!0,wi.mark(Pn.fullLoad),this._performanceMetricsCollection&&Xa(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(a){for(let t of this._markers)a&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(let t of this._popups)!a||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(a,t=!1){let o=d=>(this.transform.averageElevation=d,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&o(0);let c=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(c||(t||a-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(a)){let d=this.transform.averageElevation,m=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(m)?m=0:this._averageElevationLastSampledAt=a;let _=Math.abs(d-m);if(_>1){if(this._isInitialLoad||c)return this._averageElevation.jumpTo(m),o(m);this._averageElevation.easeTo(m,a,300)}else if(_>1e-4)return this._averageElevation.jumpTo(m),o(m)}return!!this._averageElevation.isEasing(a)&&o(this._averageElevation.getValue(a))}_isTokenExpired(){return this._tokenExpiration!=null&&Date.now()>this._tokenExpiration}_revokeAuth(){let a=this.painter.context.gl;Zo(a,!1),this._logoControl instanceof bm&&this._logoControl._updateLogo(),a&&a.clear(a.DEPTH_BUFFER_BIT|a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new h.y(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}_authenticate(){Ya(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,a=>{a&&(a.message!==nn&&a.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),Jn(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Bi(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Za(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){Po(this._requestManager._customAccessToken)}_updateTerrain(){let a=this._isDragging();this.painter.updateTerrain(this.style,a)}_calculateSpeedIndex(){let a=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());let o=this.painter.context.gl,c=o.createFramebuffer();function d(m){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,m,0);let _=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,_),_}return o.bindFramebuffer(o.FRAMEBUFFER,c),this._canvasPixelComparison(d(a),t.canvasCopies.map(d),t.timeStamps)}_canvasPixelComparison(a,t,o){let c=o[1]-o[0],d=a.length/4;for(let m=0;m<t.length;m++){let _=t[m],y=0;for(let v=0;v<_.length;v+=4)_[v]===a[v]&&_[v+1]===a[v+1]&&_[v+2]===a[v+2]&&_[v+3]===a[v+3]&&(y+=1);c+=(o[m+2]-o[m+1])*(1-y/d)}return c}remove(){if(this._removed)return;this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);let a=this.painter.context.gl.getExtension("WEBGL_lose_context");a&&a.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),oa.delete(this.painter.context.gl),ra.remove(),en.remove(),this._removed=!0,this.fire(new h.z("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(a){this._renderNextFrame=this._renderNextFrame||a,this.style&&!this._frame&&(this._frame=h.o.frame(t=>{let o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(t)}))}_preloadTiles(a){let t=this.style?this.style.getSourceCaches():[];return h.ao(t,(o,c)=>o._preloadTiles(a,c),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(a){this._trackResize&&this.resize({originalEvent:a})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(a){this._showTileBoundaries!==a&&(this._showTileBoundaries=a,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(a){this._showParseStatus!==a&&(this._showParseStatus=a,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(a){this._showTerrainWireframe!==a&&(this._showTerrainWireframe=a,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(a){this._showLayers2DWireframe!==a&&(this._showLayers2DWireframe=a,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(a){this._showLayers3DWireframe!==a&&(this._showLayers3DWireframe=a,this._update())}get showElevationIdDebug(){return!!this.painter&&this.painter._debugParams.showElevationIdDebug}set showElevationIdDebug(a){this.painter&&this.painter._debugParams.showElevationIdDebug!==a&&(this.painter._debugParams.showElevationIdDebug=a,this.style&&a?this.style._reloadSources():this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(a){this._speedIndexTiming!==a&&(this._speedIndexTiming=a,this._update())}get showPadding(){return!!this._showPadding}set showPadding(a){this._showPadding!==a&&(this._showPadding=a,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(a){this._showCollisionBoxes!==a&&(this._showCollisionBoxes=a,this.style&&a?this.style._reloadSources():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(a){this._showOverdrawInspector!==a&&(this._showOverdrawInspector=a,this._update())}get repaint(){return!!this._repaint}set repaint(a){this._repaint!==a&&(this._repaint=a,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(a){this._vertices=a,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(a){this._showTileAABBs!==a&&(this._showTileAABBs=a,a&&this._update())}_setCacheLimits(a,t){h.f1(a,t)}get version(){return U}},NavigationControl:class{constructor(a={}){this.options=Object.assign({},xg,a),this._container=Mt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(h.b0(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",t=>{this._map&&this._map.zoomIn({},{originalEvent:t})}),Mt("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",t=>{this._map&&this._map.zoomOut({},{originalEvent:t})}),Mt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(h.b0(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",t=>{let o=this._map;o&&(this.options.visualizePitch?o.resetNorthPitch({},{originalEvent:t}):o.resetNorth({},{originalEvent:t}))}),this._compassIcon=Mt("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){let a=this._map;if(!a)return;let t=a.getZoom(),o=t===a.getMaxZoom(),c=t===a.getMinZoom();this._zoomInButton.disabled=o,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",o.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.toString())}_rotateCompassArrow(){let a=this._map;if(!a)return;let t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(a.transform.pitch*(Math.PI/180)
3288),.5)}) rotateX(${a.transform.pitch}deg) rotateZ(${a.transform.angle*(180/Math.PI)}deg)`:`rotate(${a.transform.angle*(180/Math.PI)}deg)`;a._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(a){return this._map=a,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),a.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&a.on("pitch",this._rotateCompassArrow),a.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ls(a,this._compass,this.options.visualizePitch)),this._container}onRemove(){let a=this._map;a&&(this._container.remove(),this.options.showZoom&&a.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&a.off("pitch",this._rotateCompassArrow),a.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(a,t){let o=Mt("button",a,this._container);return o.type="button",o.addEventListener("click",t),o}_setButtonTitle(a,t){if(!this._map)return;let o=this._map._getUIString(`NavigationControl.${t}`);a.setAttribute("aria-label",o),a.firstElementChild&&a.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends h.E{constructor(a={}){super();let t=navigator.geolocation;this.options=Object.assign({geolocation:t},Im,a),h.b0(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=qc(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(a){return this._map=a,this._container=Mt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(a){let t=(o=!!this.options.geolocation)=>{this._supportsGeolocation=o,a(o)};this._supportsGeolocation!==void 0?a(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(o=>t(o.state!=="denied")).catch(()=>t()):t()}_isOutOfMapMaxBounds(a){let t=this._map.getMaxBounds(),o=a.coords;return!!t&&(o.longitude<t.getWest()||o.longitude>t.getEast()||o.latitude<t.getSouth()||o.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(a){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(a))return this._setErrorState(),this.fire(new h.z("outofmaxbounds",a)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=a,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(a),this.options.followUserLocation&&(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(a),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new h.z("geolocate",Object.assign({coords:a.coords,timestamp:a.timestamp},a.toJSON?{toJSON:a.toJSON.bind(a)}:{}))),this._finish()}}_updateCamera(a){let t=new h.aX(a.coords.longitude,a.coords.latitude),o=a.coords.accuracy,c=this._map.getBearing(),d=Object.assign({bearing:c},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(o),d,{geolocateSource:!0})}_updateMarker(a){if(a){let t=new h.aX(a.coords.longitude,a.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=a.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){let a=this._map.transform,t=h.bY(1,a._center.lat)*a.worldSize,o=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(a){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(
3288a.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(a.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new h.z("error",{code:a.code,message:a.message,PERMISSION_DENIED:a.PERMISSION_DENIED,POSITION_UNAVAILABLE:a.POSITION_UNAVAILABLE,TIMEOUT:a.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();let a=this.options.positionOptions.timeout;a&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},a))}_clearRequestTimeout(){this._requestTimeoutId!==void 0&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(a){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=Mt("button","mapboxgl-ctrl-geolocate",this._container),Mt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",a===!1){h.w("Geolocation support is not available so the GeolocateControl will be disabled.");let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{let t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Mt("div","mapboxgl-user-location"),this._dotElement.appendChild(Mt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(Mt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new ph({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Mt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new ph({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||this._watchState!=="ACTIVE_LOCK"||t.originalEvent&&t.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new h.z("trackuserlocationend")))})}}_onDeviceOrientation(a){this._userLocationDotMarker&&(a.webkitCompassHeading?this._heading=a.webkitCompassHeading:a.absolute===!0&&(this._heading=-1*a.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return h.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 h.z("trackuserlocationstart"));break;
3288case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new h.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new h.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let a;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(a={maximumAge:6e5,timeout:0},this._noTimeout=!0):(a=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,a),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}setFollowUserLocation(a){return this.options.followUserLocation=a??Im.followUserLocation,this.options.trackUserLocation&&this._watchState!=="OFF"&&(this.options.followUserLocation?this._watchState!=="BACKGROUND"&&this._watchState!=="BACKGROUND_ERROR"||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new h.z("trackuserlocationstart"))):this._watchState!=="ACTIVE_LOCK"&&this._watchState!=="ACTIVE_ERROR"||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new h.z("trackuserlocationend")))),this}_addDeviceOrientationListener(){let a=()=>{let t="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(t,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(t=>{t==="granted"&&a()}).catch(console.error):a()}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","fal
3288se"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:vm,ScaleControl:class{constructor(a={}){this.options=Object.assign({},Am,a),h.b0(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){let a=this.options.maxWidth||100,t=this._map,o=t._containerHeight/2,c=t._containerWidth/2-a/2,d=t.unproject([c,o]),m=t.unproject([c+a,o]),_=d.distanceTo(m);if(this.options.unit==="imperial"){let y=3.2808*_;y>5280?this._setScale(a,y/5280,"mile"):this._setScale(a,y,"foot")}else this.options.unit==="nautical"?this._setScale(a,_/1852,"nautical-mile"):_>=1e3?this._setScale(a,_/1e3,"kilometer"):this._setScale(a,_,"meter")}_setScale(a,t,o){this._map._requestDomTask(()=>{let c=function(m){let _=Math.pow(10,`${Math.floor(m)}`.length-1),y=m/_;return y=y>=10?10:y>=5?5:y>=3?3:y>=2?2:y>=1?1:function(v){let T=Math.pow(10,Math.ceil(-Math.log(v)/Math.LN10));return Math.round(v*T)/T}(y),_*y}(t),d=c/t;this._container.innerHTML=o!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:o}).format(c):`${c}&nbsp;${Mm[o]}`,this._container.style.width=a*d+"px"})}onAdd(a){return this._map=a,this._language=a.getLanguage(),this._container=Mt("div","mapboxgl-ctrl mapboxgl-ctrl-scale",a.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(a){this._language=a,this._update()}setUnit(a){this.options.unit=a,this._update()}},FullscreenControl:class{constructor(a={}){this._fullscreen=!1,a&&a.container&&(a.container instanceof HTMLElement?this._container=a.container:h.w("Full screen control 'container' must be a DOM element.")),h.b0(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(a){return this._map=a,this._container||(this._container=this._map.getContainer()),this._controlContainer=Mt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",h.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){let a=this._fullscreenButton=Mt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Mt("span","mapboxgl-ctrl-icon",a).setAttribute("aria-hidden","true"),a.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){let a=this._getTitle();this._fullscreenButton.setAttribute("aria-label",a),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",a)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:class{constructor(){h.b0(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(a){return this._map=a,this._container=Mt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){let a=this._map.style.indoorManager;a.off("selector-update",this._onIndoorUpdate),a.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(a.getControlState())}}_createButton(a,t){let o=Mt("button",a,this._container);return o.type="button",o.addEventListener("click",t),o}_setButtonTitle(a,t){a.setAttribute("aria-label",t),a.textContent=t}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"top-right"}_onIndoorUpdate(a){if(!a||!a.floors||a.floors.length===0)return this._model=a,void(this._container.style.display="none");let t=this._model;this._model=a,this._container.style.display="inline-block";let o=!t||t.floors.length!==a.floors.length||t.floors.some((c,d)=>c.id!==a.floors[d].id);if(o&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),a.selectedFloorId){if(a.selectedFloorId!==this._lastSelectedFloorId||o){let c=a.floors.findIndex(d=>d.id===a.selectedFloorId);if(c!==-1){let d=a.floors.length,m,_;d<=5?(m=0,_=d-1):this._visibleFloorStart===0?(m=0,_=3):this._visibleFloorStart>=d-3?(m=d-3-1,_=d-1):(m=this._visibleFloorStart,_=this._visibleFloorStart+3-1),c<m?this._visibleFloorStart=c:c>_&&(this._visibleFloorStart=c-2)}}this._lastSelectedFloorId=a.selectedFloorId}this._render()}
3288_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";let a=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);Mt("span","mapboxgl-ctrl-icon",a).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||a.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(a);let t=this._model.floors,o=t.length;if(o<=5)return void t.forEach(_=>this._createFloorButton(_));let c=this._visibleFloorStart===0,d=this._visibleFloorStart>=o-3;if(c)this._createFloorButton(t[0]);else{let _=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);Mt("span","mapboxgl-ctrl-icon",_).setAttribute("aria-hidden","true"),this._container.appendChild(_)}let m=[];if(m=c?t.slice(1,4):d?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),m.forEach(_=>this._createFloorButton(_)),d)this._createFloorButton(t[o-1]);else{let _=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);Mt("span","mapboxgl-ctrl-icon",_).setAttribute("aria-hidden","true"),this._container.appendChild(_)}}_createFloorButton(a){let t=this._createButton("mapboxgl-ctrl-level-button",()=>{let m=a.id;this._model&&this._model.selectedFloorId===m&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(m))}),o=(a.name||"").trim(),c=a.zIndex.toString(),d=o?Array.from(o).slice(0,3).join(""):c;this._setButtonTitle(t,d),this._model&&this._model.activeFloorsVisible&&a.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t)}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1)}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,this._visibleFloorStart===1&&(this._visibleFloorStart=0);let a=this._model&&this._model.floors||[];if(a.length>3){let t=a.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){let a=this._model.floors.length-3;this._visibleFloorStart<a&&(this._visibleFloorStart++,this._visibleFloorStart===1&&(this._visibleFloorStart=2),this._visibleFloorStart===a-1&&(this._visibleFloorStart=a),this._visibleFloorStart>a&&(this._visibleFloorStart=a),this._render())}}},Popup:class extends h.E{constructor(a){super(),this.options=Object.assign(Object.create(Ei),a),this._altitude=this.options.altitude,h.b0(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(a&&a.className?a.className.trim().split(up):[])}addTo(a){return this._map&&this.remove(),this._map=a,this.options.closeOnClick&&a.on("preclick",this._onClose),this.options.closeOnMove&&a.on("move",this._onClose),a.on("remove",this.remove),this._update(),a._addPopup(this),this._focusFirstElement(),this._trackPointer?(a.on("mousemove",this._onMouseEvent),a.on("mouseup",this._onMouseEvent),a._canvasContainer.classList.add("mapboxgl-track-pointer")):a.on("move",this._update),this.fire(new h.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);let a=this._map;return a&&(a.off("move",this._update),a.off("move",this._onClose),a.off("preclick",this._onClose),a.off("click",this._onClose),a.off("remove",this.remove),a.off("mousemove",this._onMouseEvent),a.off("mouseup",this._onMouseEvent),a.off("drag",this._onMouseEvent),a._canvasContainer&&a._canvasContainer.classList.remove("mapboxgl-track-pointer"),a._removePopup(this),this._map=void 0),this.fire(new h.z("close")),this}getLngLat(){return this._lngLat}setLngLat(a){this._lngLat=h.aX.convert(a),this._pos=null,this._trackPointer=!1,this._update();let t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(a){return this._altitude=a,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();let a=this._map;return a&&(a.off("move",this._update),a.on("mousemove",this._onMouseEvent),a.on("drag",this._onMouseEvent),a._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(a){return this.setDOMContent(document.createTextNode(a))}setHTML(a){let t=document.createDocumentFragment(),o=document.createElement("body"),c;for(o.innerHTML=a;c=o.firstChild,c;
3288)t.appendChild(c);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(a){return this.options.maxWidth=a,this._update(),this}setDOMContent(a){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=Mt("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(a),this.options.closeButton){let o=this._closeButton=Mt("button","mapboxgl-popup-close-button",t);o.type="button",o.setAttribute("aria-label","Close popup"),o.innerHTML='<span aria-hidden="true">&#215;</span>',o.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(a){return this._classList.add(a),this._updateClassList(),this}removeClassName(a){return this._classList.delete(a),this._updateClassList(),this}setOffset(a){return this.options.offset=a,this._update(),this}toggleClassName(a){let t;return this._classList.delete(a)?t=!1:(this._classList.add(a),t=!0),this._updateClassList(),t}_onMouseEvent(a){this._update(a.point)}_getAnchor(a){if(this.options.anchor)return this.options.anchor;let t=this._map,o=this._container,c=this._pos;if(!t||!o||!c)return"bottom";let d=o.offsetWidth,m=o.offsetHeight,_=c.x<d/2,y=c.x>t.transform.width-d/2;if(c.y+a<m)return _?"top-left":y?"top-right":"top";if(c.y>t.transform.height-m){if(_)return"bottom-left";if(y)return"bottom-right"}return _?"left":y?"right":"bottom"}_updateClassList(){let a=this._container;if(!a)return;let t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),a.className=t.join(" ")}_update(a){let t=this._map,o=this._content;if(!t||!this._lngLat&&!this._trackPointer||!o)return;let c=this._container;if(c||(c=this._container=Mt("div","mapboxgl-popup",t.getContainer()),this._tip=Mt("div","mapboxgl-popup-tip",c),c.appendChild(o)),this.options.maxWidth&&c.style.maxWidth!==this.options.maxWidth&&(c.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Em(this._lngLat,this._pos,t.transform)),!this._trackPointer||a){let d=this._pos=this._trackPointer&&a instanceof h.P?a:t.project(this._lngLat,this._altitude),m=fh(this.options.offset),_=this._anchor=this._getAnchor(m.y),y=fh(this.options.offset,_),v=d.add(y).round();t._requestDomTask(()=>{this._container&&_&&(this._container.style.transform=`${Yc[_]} translate(${v.x}px,${v.y}px)`)})}if(!this._marker&&t._showingGlobe()){let d=h.f2(t.transform,this._lngLat)?0:1;this._setOpacity(d)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let a=this._container.querySelector(Cm);a&&a.focus()}_onClose(){this.remove()}_setOpacity(a){this._container&&(this._container.style.opacity=`${a}`),this._content&&(this._content.style.pointerEvents=a?"auto":"none")}},Marker:ph,Style:Nr,LngLat:h.aX,LngLatBounds:h.aI,Point:h.P,MercatorCoordinate:h.ad,FreeCameraOptions:wc,Evented:h.E,config:h.g,prewarm:function(){sl().acquire(mu)},clearPrewarmedResources:function(){let a=Ko;a&&(a.isPreloaded()&&a.numActive()===1?(a.release(mu),Ko=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()"))},get accessToken(){return h.g.ACCESS_TOKEN},set accessToken(a){h.g.ACCESS_TOKEN=a},get baseApiUrl(){return h.g.API_URL},set baseApiUrl(a){h.g.API_URL=a},get workerCount(){return Ss.workerCount},set workerCount(a){Ss.workerCount=a},get maxParallelImageRequests(){return h.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(a){h.g.MAX_PARALLEL_IMAGE_REQUESTS=a},clearStorage(a){h.fb(a)},get workerUrl(){return to.workerUrl},set workerUrl(a){to.workerUrl=a},get workerClass(){return to.workerClass},set workerClass(a){to.workerClass=a},get workerParams(){return to.workerParams},set workerParams(a){to.workerParams=a},get dracoUrl(){return h.fa()},set dracoUrl(a){h.g.DRACO_URL=h.o.resolveURL(a)},get meshoptUrl(){return h.f9()},set meshoptUrl(a){let t=h.o.resolveURL(a);h.g.MESHOPT_URL=t,h.g.MESHOPT_SIMD_URL=t},get buildingGenUrl(){return h.f8()},set buildingGenUrl(a){h.g.BUILDING_GEN_URL=h.o.resolveURL(a)},setNow:h.o.setNow,restoreNow:h.o.restoreNow}});var mi=jt;return mi})});var l2=a2(M1());var C1=()=>new Promise((ot,bt)=>{if(navigator.geolocation)navigator.geolocation.getCurrentPosition(jt=>ot({latitude:jt.coords.latitude,longitude:jt.coords.longitude}),jt=>{jt.PERMISSION_DENIED?console.warn("Access to user location has been denied"):jt.TIMEOUT?console.error("Timeout when fetching user location"):jt.POSITION_UNAVAILABLE?console.error("User location is unavailable"):console.error(`Unhandled exception when fetching user location: ${jt.code}
3288`,jt.message),bt(`[Error code ${jt.code}] ${jt.message}`)});else{let jt="Geolocation not supported";console.error(jt),bt(jt)}});var c2=ot=>{let bt=window.getComputedStyle(ot);return bt.display!=="none"&&bt.visibility!=="hidden"},R1=ot=>{if(c2(ot)){let bt;if(ot.tabIndex<0)bt=!1;else if(ot.inert)bt=!1;else if(ot.disabled)bt=!1;else if(ot.tabIndex>=0)bt=!0;else switch(ot.nodeName){case"A":let jt=ot;bt=!!jt.href&&jt.rel!=="ignore";case"INPUT":bt=ot.type!=="hidden";case"BUTTON":case"SELECT":case"TEXTAREA":bt=!0;break;default:bt=!1}return{focusable:bt,visible:!0}}else return{focusable:!1,visible:!1}},L1=ot=>{for(let bt=0;bt<ot.children.length;++bt){let jt=ot.children[bt],Ai=R1(jt);if(Ai.visible){if(Ai.focusable)return jt;{let mi=L1(jt);if(mi)return mi}}}},z1=ot=>{for(let bt=ot.children.length-1;bt>=0;--bt){let jt=ot.children[bt],Ai=R1(jt);if(Ai.visible){let mi=z1(jt);if(mi)return mi;if(Ai.focusable)return jt}}},$y=ot=>{let bt=L1(ot);if(bt)return bt.focus(),!0},O1=ot=>{let bt=z1(ot);if(bt)return bt.focus(),!0};var P1=ot=>{let jt=window.getComputedStyle(ot).overflowY;return ot.scrollHeight>ot.clientHeight&&(jt==="scroll"||jt==="auto")},D1=(ot,bt)=>{let jt=ot.scrollTop===0,Ai=ot.scrollTop>=ot.scrollHeight-ot.clientHeight-1;return bt&&!Ai||!bt&&!jt},F1=(ot,bt)=>{let jt=0,Ai;ot.addEventListener("touchstart",mi=>{bt?.()&&(jt=mi.touches[0].clientY,Ai=void 0)}),ot.addEventListener("wheel",mi=>{if(bt?.()&&mi.target){let h=mi.target,U=mi.deltaY>0;for(;h!==null&&h!==ot;){if(P1(h)&&D1(h,U))return;h=h.parentElement}mi.preventDefault()}},{passive:!1}),ot.addEventListener("touchmove",mi=>{if(bt?.()&&mi.target){let h=mi.target;for(Ai===void 0&&(Ai=mi.touches[0].clientY<jt);h!==null&&h!==ot;){if(P1(h)&&D1(h,Ai))return;h=h.parentElement}mi.preventDefault()}},{passive:!1})};window.ani_modals||(window.ani_modals=new Map);var Xp=window.ani_modals,u2=()=>{document.addEventListener("keydown",ot=>{ot.key==="Escape"&&Xp.forEach(bt=>{bt.element.dataset.closeable==="true"&&bt.close(ot)})}),document.addEventListener("focus",ot=>{let bt=ot.relatedTarget,jt=ot.target;if(jt){for(let{element:Ai,isOpen:mi}of Xp.values())if(mi()){Ai.contains(jt)===!1&&(bt?!!(bt.compareDocumentPosition(jt)&Node.DOCUMENT_POSITION_FOLLOWING)?$y(Ai):O1(Ai):$y(Ai));break}}},!0)},qy=ot=>{window.ani_modalsInitialized||(window.ani_modalsInitialized=!0,u2());let bt=ot.querySelector("[data-dialog]"),jt=ot.querySelector("[data-dialog-content]"),Ai=ot.querySelectorAll("[data-close-button]");
3288if(!bt)throw`Modal with id "${ot.id}" dialog missing`;if(!jt)throw`Modal with id "${ot.id}" dialog content missing`;let mi=()=>document.querySelectorAll(`[aria-controls="${bt.id}"]`),h=()=>ot.inert===!1,U=Fn=>{if(h()){mi().forEach(Qr=>Qr.setAttribute("aria-expanded","false")),ot.inert=!0,mi()[0]?.focus();let yr=new CustomEvent("modal:close",{detail:{originalEvent:Fn}});ot.dispatchEvent(yr)}},Pn=()=>{h()||(mi().forEach(Fn=>Fn.setAttribute("aria-expanded","true")),ot.inert=!1,window.requestAnimationFrame(()=>jt.focus({preventScroll:!0})),ot.dispatchEvent(new Event("modal:open")))};mi().forEach(Fn=>Fn.addEventListener("click",yr=>{h()||Pn()})),F1(ot,h),ot.dataset.closeable==="true"&&(ot.addEventListener("click",Fn=>{bt.contains(Fn.target)===!1&&U(Fn)}),Ai.forEach(Fn=>{Fn.addEventListener("click",yr=>{U(yr)})}));let wi={close:U,element:ot,isOpen:h,open:Pn};return Xp.set(ot.id,wi),document.body.appendChild(ot),wi};var h2=ot=>{let bt=Xp.get(ot.id);bt&&(Xp.delete(ot.id),bt.isOpen()?(bt.close(),delete ot.dataset.modal,ot.id="",setTimeout(()=>{ot.remove()},500)):ot.remove())};document.addEventListener("htmx:beforeSwap",ot=>{let bt=ot;new DOMParser().parseFromString(bt.detail.serverResponse,"text/html").querySelectorAll("[data-modal]").forEach(mi=>{let h=document.getElementById(mi.id);h&&h2(h)})});document.querySelectorAll("[data-modal]").forEach(ot=>{ot.dataset.autoInit!=="false"&&qy(ot)});var B1=new Map,d2=ot=>{let jt=ot.getAttribute("id")?.substring("clinic-finder-".length)??"",Ai=ot.querySelector("[data-search-input-button]"),mi=ot.querySelector("[data-search-results-container]"),h=ot.querySelectorAll('[type="submit"]'),U=ot.querySelector("[data-position-button]"),Pn=ot.querySelector("[data-geolocation-failed-modal]");if(!Ai)throw new Error(`Clinic finder with id ${ot.id} searchInputButton missing`);if(!mi)throw new Error(`Clinic finder with id ${ot.id} searchResultsContainer missing`);let wi,Fn=()=>Ai.getAttribute("aria-expanded")==="true",yr=()=>{Fn()&&(Ai.setAttribute("aria-expanded","false"),mi.setAttribute("inert","true"))},Qr=()=>{Fn()||(Ai.setAttribute("aria-expanded","true"),mi.removeAttribute("inert"))};if(document.addEventListener("click",Xn=>{let eo=mi.contains(Xn.target)===!1,Rr=!0;h.forEach(Mt=>{Mt.contains(Xn.target)===!0&&(Rr=!1)}),eo&&Rr&&yr()}),document.addEventListener("keydown",Xn=>{Xn.key==="Escape"&&yr()}),B1.set(jt,{close:yr,isOpen:Fn,open:Qr}),U){let Xn,eo;htmx.on(U,"htmx:confirm",Rr=>{if(Xn===void 0||eo===void 0){let Mt=Rr;Rr.preventDefault(),C1().then(Bn=>{Xn=Bn.latitude,eo=Bn.longitude,Mt.detail.issueRequest()}).catch(Bn=>{console.warn(Bn),wi&&wi.open()})}}),htmx.on(U,"htmx:configRequest",Rr=>{let Mt=Rr;Mt.detail.parameters.latitude=Xn,Mt.detail.parameters.longitude=eo})}Pn&&(wi=qy(Pn))};htmx.onLoad(ot=>{let bt=ot.id,jt="search-results-";if(bt.startsWith(jt)){let Ai=bt.substring(jt.length);B1.get(Ai)?.open()}});document.querySelectorAll("[data-clinic-finder]").forEach(ot=>d2(ot));})();
3289//# sourceMappingURL=clinic-finder.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.