PageSourceSearch

https://partner.zing.coach/assets/mapbox-gl-DiYTSXjO.js

js zing.coach collected 2026-10-02 05:22:04 UTC 1,869,745 bytes, 3,422 lines download raw bytes

vendor: 89,354 bytes, line 1
1import{bB as NS,bZ as VS}from"./entry-Do74TiKF.js";var Mb={exports:{}};(function(Pb,GS){(function(Wh,Xh){Pb.exports=Xh()})(VS,function(){let Wh,Xh,u_;typeof self<"u"&&(self.__mapboxImport=d=>import(d));function h_(d,L){if(!Wh)Wh=L;else if(!Xh)Xh=L;else{const Eo={};Wh(void 0,Eo),u_=L(Eo);const Xn="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 = {}; self.__mapboxImport = (u) => import(u); ("+Wh+")(undefined, sharedChunk); ("+Xh+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(u_.workerUrl=window.URL.createObjectURL(new Blob([Xn],{type:"text/javascript"})))}}h_(["require","exports"],function(d,L){var Eo="3.29.0",Xn=1e-6,Lr=typeof Float32Array<"u"?Float32Array:Array;function Ac(i,e){var t=e[0],n=e[1],s=e[2],l=e[3],c=t*l-s*n;return c?(i[0]=l*(c=1/c),i[1]=-n*c,i[2]=-s*c,i[3]=t*c,i):null}function Bl(){var i=new Lr(9);return Lr!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[5]=0,i[6]=0,i[7]=0),i[0]=1,i[4]=1,i[8]=1,i}function ai(i,e,t){var n=e[0],s=e[1],l=e[2],c=e[3],h=e[4],p=e[5],_=e[6],y=e[7],v=e[8],b=t[0],T=t[1],S=t[2],A=t[3],C=t[4],D=t[5],z=t[6],O=t[7],F=t[8];return i[0]=b*n+T*c+S*_,i[1]=b*s+T*h+S*y,i[2]=b*l+T*p+S*v,i[3]=A*n+C*c+D*_,i[4]=A*s+C*h+D*y,i[5]=A*l+C*p+D*v,i[6]=z*n+O*c+F*_,i[7]=z*s+O*h+F*y,i[8]=z*l+O*p+F*v,i}function So(i,e){var t=Math.sin(e),n=Math.cos(e);return i[0]=n,i[1]=t,i[2]=0,i[3]=-t,i[4]=n,i[5]=0,i[6]=0,i[7]=0,i[8]=1,i}function Yn(){var i=new Lr(16);return Lr!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i}function Fs(i){var e=new Lr(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e}function Cc(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i}function rr(i){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function kl(i,e){if(i===e){var t=e[1],n=e[2],s=e[3],l=e[6],c=e[7],h=e[11];i[1]=e[4],i[2]=e[8],i[3]=e[12],i[4]=t,i[6]=e[9],i[7]=e[13],i[8]=n,i[9]=l,i[11]=e[14],i[12]=s,i[13]=c,i[14]=h}else i[0]=e[0],i[1]=e[4],i[2]=e[8],i[3]=e[12],i[4]=e[1],i[5]=e[5],i[6]=e[9],i[7]=e[13],i[8]=e[2],i[9]=e[6],i[10]=e[10],i[11]=e[14],i[12]=e[3],i[13]=e[7],i[14]=e[11],i[15]=e[15];return i}function yn(i,e){var t=e[0],n=e[1],s=e[2],l=e[3],c=e[4],h=e[5],p=e[6],_=e[7],y=e[8],v=e[9],b=e[10],T=e[11],S=e[12],A=e[13],C=e[14],D=e[15],z=t*h-n*c,O=t*p-s*c,F=t*_-l*c,N=n*p-s*h,j=n*_-l*h,te=s*_-l*p,H=y*A-v*S,W=y*C-b*S,K=y*D-T*S,ee=v*C-b*A,ae=v*D-T*A,he=b*D-T*C,be=z*he-O*ae+F*ee+N*K-j*W+te*H;return be?(i[0]=(h*he-p*ae+_*ee)*(be=1/be),i[1]=(s*ae-n*he-l*ee)*be,i[2]=(A*te-C*j+D*N)*be,i[3]=(b*j-v*te-T*N)*be,i[4]=(p*K-c*he-_*W)*be,i[5]=(t*he-s*K+l*W)*be,i[6]=(C*F-S*te-D*O)*be,i[7]=(y*te-b*F+T*O)*be,i[8]=(c*ae-h*K+_*H)*be,i[9]=(n*K-t*ae-l*H)*be,i[10]=(S*j-A*F+D*z)*be,i[11]=(v*F-y*j-T*z)*be,i[12]=(h*W-c*ee-p*H)*be,i[13]=(t*ee-n*W+s*H)*be,i[14]=(A*O-S*N-C*z)*be,i[15]=(y*N-v*O+b*z)*be,i):null}function Dt(i,e,t){var n=e[0],s=e[1],l=e[2],c=e[3],h=e[4],p=e[5],_=e[6],y=e[7],v=e[8],b=e[9],T=e[10],S=e[11],A=e[12],C=e[13],D=e[14],z=e[15],O=t[0],F=t[1],N=t[2],j=t[3];return i[0]=O*n+F*h+N*v+j*A,i[1]=O*s+F*p+N*b+j*C,i[2]=O*l+F*_+N*T+j*D,i[3]=O*c+F*y+N*S+j*z,i[4]=(O=t[4])*n+(F=t[5])*h+(N=t[6])*v+(j=t[7])*A,i[5]=O*s+F*p+N*b+j*C,i[6]=O*l+F*_+N*T+j*D,i[7]=O*c+F*y+N*S+j*z,i[8]=(O=t[8])*n+(F=t[9])*h+(N=t[10])*v+(j=t[11])*A,i[9]=O*s+F*p+N*b+j*C,i[10]=O*l+F*_+N*T+j*D,i[11]=O*c+F*y+N*S+j*z,i[12]=(O=t[12])*n+(F=t[13])*h+(N=t[14])*v+(j=t[15])*A,i[13]=O*s+F*p+N*b+j*C,i[14]=O*l+F*_+N*T+j*D,i[15]=O*c+F*y+N*S+j*z,i}function Yi(i,e,t){var n,s,l,c,h,p,_,y,v,b,T,S,A=t[0],C=t[1],D=t[2];return e===i?(i[12]=e[0]*A+e[4]*C+e[8]*D+e[12],i[13]=e[1]*A+e[5]*C+e[9]*D+e[13],i[14]=e[2]*A+e[6]*C+e[10]*D+e[14],i[15]=e[3]*A+e[7]*C+e[11]*D+e[15]):(s=e[1],l=e[2],c=e[3],h=e[4],p=e[5],_=e[6],y=e[7],v=e[8],b=e[9],T=e[10],S=e[11],i[0]=n=e[0],i[1]=s,i[2]=l,i[3]=c,i[4]=h,i[5]=p,i[6]=_,i[7]=y,i[8]=v,i[9]=b,i[10]=T,i[11]=S,i[12]=n*A+h*C+v*D+e[12],i[13]=s*A+p*C+b*D+e[13],i[14]=l*A+_*C+T*D+e[14],i[15]=c*A+y*C+S*D+e[15]),i}function hr(i,e,t){var n=t[0],s=t[1],l=t[2];return i[0]=e[0]*n,i[1]=e[1]*n,i[2]=e[2]*n,i[3]=e[3]*n,i[4]=e[4]*s,i[5]=e[5]*s,i[6]=e[6]*s,i[7]=e[7]*s,i[8]=e[8]*l,i[9]=e[9]*l,i[10]=e[10]*l,i[11]=e[11]*l,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i}function Es(i,e,t){var n=Math.sin(t),s=Math.cos(t),l=e[4],c=e[5],h=e[6],p=e[7],_=e[8],y=e[9],v=e[10],b=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=l*s+_*n,i[5]=c*s+y*n,i[6]=h*s+v*n,i[7]=p*s+b*n,i[8]=_*s-l*n,i[9]=y*s-c*n,i[10]=v*s-h*n,i[11]=b*s-p*n,i}function Io(i,e,t){var n=Math.sin(t),s=Math.cos(t),l=e[0],c=e[1],h=e[2],p=e[3],_=e[8],y=e[9],v=e[10],b=e[11];return e!==i&&(i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=l*s-_*n,i[1]=c*s-y*n,i[2]=h*s-v*n,i[3]=p*s-b*n,i[8]=l*n+_*s,i[9]=c*n+y*s,i[10]=h*n+v*s,i[11]=p*n+b*s,i}function Os(i,e,t){var n=Math.sin(t),s=Math.cos(t),l=e[0],c=e[1],h=e[2],p=e[3],_=e[4],y=e[5],v=e[6],b=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=l*s+_*n,i[1]=c*s+y*n,i[2]=h*s+v*n,i[3]=p*s+b*n,i[4]=_*s-l*n,i[5]=y*s-c*n,i[6]=v*s-h*n,i[7]=b*s-p*n,i}function Bs(i,e){return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=e[0],i[13]=e[1],i[14]=e[2],i[15]=1,i}function Ho(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}function Kn(i,e,t){var n,s,l,c=t[0],h=t[1],p=t[2],_=Math.sqrt(c*c+h*h+p*p);return _<Xn?null:(c*=_=1/_,h*=_,p*=_,n=Math.sin(e),s=Math.cos(e),i[0]=c*c*(l=1-s)+s,i[1]=h*c*l+p*n,i[2]=p*c*l-h*n,i[3]=0,i[4]=c*h*l-p*n,i[5]=h*h*l+s,i[6]=p*h*l+c*n,i[7]=0,i[8]=c*p*l+h*n,i[9]=h*p*l-c*n,i[10]=p*p*l+s,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i)}function Nl(i,e){var t=e[0],n=e[1],s=e[2],l=e[4],c=e[5],h=e[6],p=e[8],_=e[9],y=e[10];return i[0]=Math.sqrt(t*t+n*n+s*s),i[1]=Math.sqrt(l*l+c*c+h*h),i[2]=Math.sqrt(p*p+_*_+y*y),i}function zu(i,e){var t=new Lr(3);Nl(t,e);var n=1/t[0],s=1/t[1],l=1/t[2],c=e[0]*n,h=e[1]*s,p=e[2]*l,_=e[4]*n,y=e[5]*s,v=e[6]*l,b=e[8]*n,T=e[9]*s,S=e[10]*l,A=c+y+S,C=0;return A>0?(C=2*Math.sqrt(A+1),i[3]=.25*C,i[0]=(v-T)/C,i[1]=(b-p)/C,i[2]=(h-_)/C):c>y&&c>S?(C=2*Math.sqrt(1+c-y-S),i[3]=(v-T)/C,i[0]=.25*C,i[1]=(h+_)/C,i[2]=(b+p)/C):y>S?(C=2*Math.sqrt(1+y-c-S),i[3]=(b-p)/C,i[0]=(h+_)/C,i[1]=.25*C,i[2]=(v+T)/C):(C=2*Math.sqrt(1+S-c-y),i[3]=(h-_)/C,i[0]=(b+p)/C,i[1]=(v+T)/C,i[2]=.25*C),i}function Ga(i,e){var t=e[0],n=e[1],s=e[2],l=e[3],c=t+t,h=n+n,p=s+s,_=t*c,y=n*c,v=n*h,b=s*c,T=s*h,S=s*p,A=l*c,C=l*h,D=l*p;return i[0]=1-v-S,i[1]=y+D,i[2]=b-C,i[3]=0,i[4]=y-D,i[5]=1-_-S,i[6]=T+A,i[7]=0,i[8]=b+C,i[9]=T-A,i[10]=1-_-v,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i}var Vl=function(i,e,t,n,s){var l=1/Math.tan(e/2);if(i[0]=l/t,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=l,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,s!=null&&s!==1/0){var c=1/(n-s);i[10]=(s+n)*c,i[14]=2*s*n*c}else i[10]=-1,i[14]=-2*n;return i},Fu=function(i,e,t,n,s,l,c){var h=1/(e-t),p=1/(n-s),_=1/(l-c);return i[0]=-2*h,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=-2*p,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=2*_,i[11]=0,i[12]=(e+t)*h,i[13]=(s+n)*p,i[14]=(c+l)*_,i[15]=1,i},Ha=Dt;function Jt(){var i=new Lr(3);return Lr!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function ks(i){var e=new Lr(3);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e}function Ki(i){var e=i[0],t=i[1],n=i[2];return Math.sqrt(e*e+t*t+n*n)}function br(i,e,t){var n=new Lr(3);return n[0]=i,n[1]=e,n[2]=t,n}function Ui(i,e,t,n){return i[0]=e,i[1]=t,i[2]=n,i}function Ji(i,e,t){return i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i}function Jn(i,e,t){return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i[2]=e[2]-t[2],i}function Mc(i,e,t){return i[0]=e[0]*t[0],i[1]=e[1]*t[1],i[2]=e[2]*t[2],i}function Ns(i,e,t){return i[0]=Math.min(e[0],t[0]),i[1]=Math.min(e[1],t[1]),i[2]=Math.min(e[2],t[2]),i}function Vs(i,e,t){return i[0]=Math.max(e[0],t[0]),i[1]=Math.max(e[1],t[1]),i[2]=Math.max(e[2],t[2]),i}function si(i,e,t){return i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i}function cn(i,e,t,n){return i[0]=e[0]+t[0]*n,i[1]=e[1]+t[1]*n,i[2]=e[2]+t[2]*n,i}function Za(i,e){var t=e[0]-i[0],n=e[1]-i[1],s=e[2]-i[2];return Math.sqrt(t*t+n*n+s*s)}function Us(i,e){var t=e[0]-i[0],n=e[1]-i[1],s=e[2]-i[2];return t*t+n*n+s*s}function rs(i){var e=i[0],t=i[1],n=i[2];return e*e+t*t+n*n}function ns(i,e){return i[0]=-e[0],i[1]=-e[1],i[2]=-e[2],i}function ei(i,e){var t=e[0],n=e[1],s=e[2],l=t*t+n*n+s*s;return l>0&&(l=1/Math.sqrt(l)),i[0]=e[0]*l,i[1]=e[1]*l,i[2]=e[2]*l,i}function Ri(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]}function gr(i,e,t){var n=e[0],s=e[1],l=e[2],c=t[0],h=t[1],p=t[2];return i[0]=s*p-l*h,i[1]=l*c-n*p,i[2]=n*h-s*c,i}function js(i,e,t,n){var s=e[0],l=e[1],c=e[2];return i[0]=s+n*(t[0]-s),i[1]=l+n*(t[1]-l),i[2]=c+n*(t[2]-c),i}function hi(i,e,t){var n=e[0],s=e[1],l=e[2],c=t[3]*n+t[7]*s+t[11]*l+t[15];return i[0]=(t[0]*n+t[4]*s+t[8]*l+t[12])/(c=c||1),i[1]=(t[1]*n+t[5]*s+t[9]*l+t[13])/c,i[2]=(t[2]*n+t[6]*s+t[10]*l+t[14])/c,i}function Ao(i,e,t){var n=e[0],s=e[1],l=e[2];return i[0]=n*t[0]+s*t[3]+l*t[6],i[1]=n*t[1]+s*t[4]+l*t[7],i[2]=n*t[2]+s*t[5]+l*t[8],i}function oa(i,e,t){var n=t[0],s=t[1],l=t[2],c=t[3],h=e[0],p=e[1],_=e[2],y=s*_-l*p,v=l*h-n*_,b=n*p-s*h;return i[0]=h+c*(y+=y)+s*(b+=b)-l*(v+=v),i[1]=p+c*v+l*y-n*b,i[2]=_+c*b+n*v-s*y,i}function Rc(i){return i[0]=0,i[1]=0,i[2]=0,i}function os(i,e){return i[0]===e[0]&&i[1]===e[1]&&i[2]===e[2]}var Pi=Jn,Ou=Mc,Ss=Ki;function Qn(){var i=new Lr(4);return Lr!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0,i[3]=0),i}function Pc(i,e,t,n){var s=new Lr(4);return s[0]=i,s[1]=e,s[2]=t,s[3]=n,s}function Zo(i,e,t){return i[0]=e[0]*t,i[1]=e[1]*t,i[2]=e[2]*t,i[3]=e[3]*t,i}function Ul(i,e){var t=e[0],n=e[1],s=e[2],l=e[3],c=t*t+n*n+s*s+l*l;return c>0&&(c=1/Math.sqrt(c)),i[0]=t*c,i[1]=n*c,i[2]=s*c,i[3]=l*c,i}function lr(i,e,t){var n=e[0],s=e[1],l=e[2],c=e[3];return i[0]=t[0]*n+t[4]*s+t[8]*l+t[12]*c,i[1]=t[1]*n+t[5]*s+t[9]*l+t[13]*c,i[2]=t[2]*n+t[6]*s+t[10]*l+t[14]*c,i[3]=t[3]*n+t[7]*s+t[11]*l+t[15]*c,i}function it(){var i=new Lr(4);return Lr!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i[3]=1,i}function Mn(i){return i[0]=0,i[1]=0,i[2]=0,i[3]=1,i}function jl(i,e){var t=2*Math.acos(e[3]),n=Math.sin(t/2);return n>Xn?(i[0]=e[0]/n,i[1]=e[1]/n,i[2]=e[2]/n):(i[0]=1,i[1]=0,i[2]=0),t}function Gs(i,e,t){t*=.5;var n=e[0],s=e[1],l=e[2],c=e[3],h=Math.sin(t),p=Math.cos(t);return i[0]=n*p+c*h,i[1]=s*p+l*h,i[2]=l*p-s*h,i[3]=c*p-n*h,i}function sa(i,e,t){t*=.5;var n=e[0],s=e[1],l=e[2],c=e[3],h=Math.sin(t),p=Math.cos(t);return i[0]=n*p-l*h,i[1]=s*p+c*h,i[2]=l*p+n*h,i[3]=c*p-s*h,i}function Co(i,e,t){t*=.5;var n=e[0],s=e[1],l=e[2],c=e[3],h=Math.sin(t),p=Math.cos(t);return i[0]=n*p+s*h,i[1]=s*p-n*h,i[2]=l*p+c*h,i[3]=c*p-l*h,i}Jt(),Qn();var eo,Dc,aa,$a=Ul,Hs=(eo=Jt(),Dc=br(1,0,0),aa=br(0,1,0),function(i,e,t){var n=Ri(e,t);return n<-.999999?(gr(eo,Dc,e),Ss(eo)<1e-6&&gr(eo,aa,e),ei(eo,eo),function(s,l,c){c*=.5;var h=Math.sin(c);s[0]=h*l[0],s[1]=h*l[1],s[2]=h*l[2],s[3]=Math.cos(c)}(i,eo,Math.PI),i):n>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(gr(eo,e,t),i[0]=eo[0],i[1]=eo[1],i[2]=eo[2],i[3]=1+n,$a(i,i))});function Xr(){var i=new Lr(2);return Lr!=Float32Array&&(i[0]=0,i[1]=0),i}function Zs(i,e){var t=new Lr(2);return t[0]=i,t[1]=e,t}function Gl(i,e,t){return i[0]=e,i[1]=t,i}function ss(i,e,t){return i[0]=e[0]+t[0],i[1]=e[1]+t[1],i}function $s(i,e,t){return i[0]=e[0]-t[0],i[1]=e[1]-t[1],i}function qa(i,e,t){return i[0]=e[0]*t,i[1]=e[1]*t,i}function Hl(i){var e=i[0],t=i[1];return Math.sqrt(e*e+t*t)}function la(i,e){var t=e[0],n=e[1],s=t*t+n*n;return s>0&&(s=1/Math.sqrt(s)),i[0]=e[0]*s,i[1]=e[1]*s,i}function Wa(i,e){return i[0]*e[0]+i[1]*e[1]}it(),it(),Bl();var as=$s;function Lc(i,e,t,n){const s=3*i,l=3*(t-i)-s,c=1-s-l,h=3*e,p=3*(n-e)-h,_=1-h-p;return function(y,v=1e-6){if(y<=0)return 0;if(y>=1)return 1;let b=y;for(let A=0;A<8;A++){const C=((c*b+l)*b+s)*b-y;if(Math.abs(C)<v)return((_*b+p)*b+h)*b;const D=(3*c*b+2*l)*b+s;if(Math.abs(D)<1e-6)break;b-=C/D}let T=0,S=1;b=y;for(let A=0;A<20;A++){const C=((c*b+l)*b+s)*b;if(Math.abs(C-y)<v)break;y>C?T=b:S=b,b=.5*(T+S)}return((_*b+p)*b+h)*b}}function De(i,e){this.x=i,this.y=e}function ls(i,e){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!ls(i[t],e[t]))return!1;return!0}if(typeof i=="object"&&i!==null&&e!==null){if(typeof e!="object")return!1;const t=i,n=e;if(Object.keys(t).length!==Object.keys(n).length)return!1;for(const s in t)if(!ls(t[s],n[s]))return!1;return!0}return i===e}function Xa(i,e,t=0,n=i.length-1,s=Zl){for(;n>t;){if(n-t>600){const p=n-t+1,_=e-t+1,y=Math.log(p),v=.5*Math.exp(2*y/3),b=.5*Math.sqrt(y*v*(p-v)/p)*(_-p/2<0?-1:1);Xa(i,e,Math.max(t,Math.floor(e-_*v/p+b)),Math.min(n,Math.floor(e+(p-_)*v/p+b)),s)}const l=i[e];let c=t,h=n;for(qs(i,t,e),s(i[n],l)>0&&qs(i,t,n);c<h;){for(qs(i,c,h),c++,h--;s(i[c],l)<0;)c++;for(;s(i[h],l)>0;)h--}s(i[t],l)===0?qs(i,t,h):(h++,qs(i,h,n)),h<=e&&(t=h+1),e<=h&&(n=h-1)}}function qs(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function Zl(i,e){return i<e?-1:i>e?1:0}function Bu(i){let e=0;for(let t,n,s=0,l=i.length,c=l-1;s<l;c=s++)t=i[s],n=i[c],e+=(n.x-t.x)*(t.y+n.y);return e}function ku(i,e){return e.area-i.area}function Ei(i,e){const t=i.length;if(t<=1)return[i];const n=[];let s,l;for(let c=0;c<t;c++){const h=Bu(i[c]);h!==0&&(i[c].area=Math.abs(h),l===void 0&&(l=h<0),l===h<0?(s&&n.push(s),s=[i[c]]):s.push(i[c]))}if(s&&n.push(s),e>1)for(let c=0;c<n.length;c++){const h=n[c];h.length<=e||(Xa(h,e,1,h.length-1,ku),n[c]=h.slice(0,e))}return n}function zr(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function Ya(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function Nu(i,e,t){const n=i[0]-e[0],s=i[1]-e[1],l=i[0]-t[0],c=i[1]-t[1];return n*c-l*s===0&&n*l<=0&&s*c<=0}function un(i,e,t){return e[1]>i[1]!=t[1]>i[1]&&i[0]<(t[0]-e[0])*(i[1]-e[1])/(t[1]-e[1])+e[0]}function Un(i,e,t=!1){let n=!1;for(let s=0,l=e.length;s<l;s++){const c=e[s];for(let h=0,p=c.length,_=p-1;h<p;_=h++){const y=c[_],v=c[h];if(Nu(i,y,v))return t;un(i,y,v)&&(n=!n)}}return n}function zc(i,e,t,n){const s=n[0]-t[0],l=n[1]-t[1],c=(i[0]-t[0])*l-s*(i[1]-t[1]),h=(e[0]-t[0])*l-s*(e[1]-t[1]);return c>0&&h<0||c<0&&h>0}function Ws(i,e,t,n){return(s=[n[0]-t[0],n[1]-t[1]])[0]*(l=[e[0]-i[0],e[1]-i[1]])[1]-s[1]*l[0]!==0&&!(!zc(i,e,t,n)||!zc(t,n,i,e));var s,l}function Ka(i){const e=new De(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),t=new De(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of i[0])e.x>n.x&&(e.x=n.x),e.y>n.y&&(e.y=n.y),t.x<n.x&&(t.x=n.x),t.y<n.y&&(t.y=n.y);return{min:e,max:t}}Xr(),De.prototype={clone(){return new De(this.x,this.y)},add(i){return this.clone()._add(i)},sub(i){return this.clone()._sub(i)},multByPoint(i){return this.clone()._multByPoint(i)},divByPoint(i){return this.clone()._divByPoint(i)},mult(i){return this.clone()._mult(i)},div(i){return this.clone()._div(i)},rotate(i){return this.clone()._rotate(i)},rotateAround(i,e){return this.clone()._rotateAround(i,e)},matMult(i){return this.clone()._matMult(i)},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(i){return this.x===i.x&&this.y===i.y},dist(i){return Math.sqrt(this.distSqr(i))},distSqr(i){const e=i.x-this.x,t=i.y-this.y;return e*e+t*t},angle(){return Math.atan2(this.y,this.x)},angleTo(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith(i){return this.angleWithSep(i.x,i.y)},angleWithSep(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult(i){const e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add(i){return this.x+=i.x,this.y+=i.y,this},_sub(i){return this.x-=i.x,this.y-=i.y,this},_mult(i){return this.x*=i,this.y*=i,this},_div(i){return this.x/=i,this.y/=i,this},_multByPoint(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint(i){return this.x/=i.x,this.y/=i.y,this},_unit(){return this._div(this.mag()),this},_perp(){const i=this.y;return this.y=this.x,this.x=-i,this},_rotate(i){const e=Math.cos(i),t=Math.sin(i),n=t*this.x+e*this.y;return this.x=e*this.x-t*this.y,this.y=n,this},_rotateAround(i,e){const t=Math.cos(i),n=Math.sin(i),s=e.y+n*(this.x-e.x)+t*(this.y-e.y);return this.x=e.x+t*(this.x-e.x)-n*(this.y-e.y),this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:De},De.convert=function(i){if(i instanceof De)return i;if(Array.isArray(i))return new De(+i[0],+i[1]);if(i.x!==void 0&&i.y!==void 0)return new De(+i.x,+i.y);throw new Error("Expected [x, y] or {x, y} point format")};const Fc=Math.PI/180,ca=180/Math.PI,Vu=/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Ot(i){return i*Fc}function Gr(i){return i*ca}const Ja=[[0,0],[1,0],[1,1],[0,1]];function ua(i){if(i<=0)return 0;if(i>=1)return 1;const e=i*i,t=e*i;return 4*(i<.5?t:3*(i-e)+t-.75)}const Yh=Lc(.25,.1,.25,1);function vt(i,e,t){return Math.min(t,Math.max(e,i))}function cs(i,e,t){return(t=vt((t-i)/(e-i),0,1))*t*(3-2*t)}function xn(i,e,t){const n=t-e,s=((i-e)%n+n)%n+e;return s===e?t:s}function Is(i,e,t){if(!i.length)return t(null,[]);let n=i.length;const s=new Array(i.length);let l=null;i.forEach((c,h)=>{e(c,(p,_)=>{p&&(l=p),s[h]=_,--n===0&&t(l,s)})})}function Qa(i,e){const t={};for(let n=0;n<e.length;n++){const s=e[n];s in i&&(t[s]=i[s])}return t}let Uu=1;function $l(){return function i(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,i)}()}function ql(i){return i<=1?1:Math.pow(2,Math.ceil(Math.log2(i)))}function Wl(i){return!!i&&Vu.test(i)}function us(i,e){i.forEach(t=>{e[t]&&(e[t]=e[t].bind(e))})}function to(i,e,t){const n={};for(const s in i)n[s]=e.call(this,i[s],s,i);return n}function Oc(i,e,t){const n={};for(const s in i)e.call(this,i[s],s,i)&&(n[s]=i[s]);return n}function jn(i){return Array.isArray(i)?i.map(jn):typeof i=="object"&&i?to(i,jn):i}function Bc(i,e){for(let t=0;t<i.length;t++)if(e.includes(i[t]))return!0;return!1}const Xl={};function _i(i){Xl[i]||(typeof console<"u"&&console.warn(i),Xl[i]=!0)}function $o(i,e,t){return(t.y-i.y)*(e.x-i.x)>(e.y-i.y)*(t.x-i.x)}function kc([i,e,t]){const n=Ot(e+90),s=Ot(t);return{x:i*Math.cos(n)*Math.sin(s),y:i*Math.sin(n)*Math.sin(s),z:i*Math.cos(s),azimuthal:e,polar:t}}function el(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n>0?Math.acos(t/n)*ca:0;let l=i!==0||e!==0?Math.atan2(-e,-i)*ca+90:0;return l<0&&(l+=360),[n,l,s]}function hs(i){return(typeof self<"u"||i!==void 0)&&typeof WorkerGlobalScope<"u"&&(i!==void 0?i:self)instanceof WorkerGlobalScope}function Gn(i){const e={};if(i.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(t,n,s,l)=>{const c=s||l;return e[n]=!c||c.toLowerCase(),""}),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}function qo(i){return i?{cacheControl:i.get("cache-control"),expires:i.get("expires")}:{cacheControl:void 0,expires:void 0}}function ha(i){try{const e=self[i];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}function Fr(i,e){return[i[4*e],i[4*e+1],i[4*e+2],i[4*e+3]]}function io(i,e,t){i[4*e+0]=t[0],i[4*e+1]=t[1],i[4*e+2]=t[2],i[4*e+3]=t[3]}function ju(i){return[Math.pow(i[0],1/2.2),Math.pow(i[1],1/2.2),Math.pow(i[2],1/2.2)]}function Gu(i){return i>0?1/(1.001-i):1+i}function Yl(i){return i>0?1-1/(1.001-i):-i}function Hu(i,e,t){return(i-e.min)*(t.max-t.min)/(e.max-e.min)+t.min}function Nc(i){return i*i*i*i*i}function Kl(i){return i>>>=0,i=Math.imul(2747636419^i,2654435769)>>>0,i=Math.imul(i^i>>>16,2654435769)>>>0,(i=Math.imul(i^i>>>16,2654435769)>>>0)/4294967296}let Vc,tl,Z,M,k,q;function J(){return Vc??(Vc=self.OffscreenCanvas&&!!new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Vc}const X={requestIdleCallback:i=>{if(typeof requestIdleCallback<"u")return requestIdleCallback(i);setTimeout(()=>i({didTimeout:!1,timeRemaining:()=>50}),0)},now:()=>M!==void 0?M:performance.now(),setNow(i){M=i},restoreNow(){M=void 0},frame(i){const e=requestAnimationFrame(i);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(i,e=0){const{width:t,height:n}=i;k||(k=document.createElement("canvas"));const s=k.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("failed to create canvas 2d context");return(t>k.width||n>k.height)&&(k.width=t,k.height=n),s.clearRect(-e,-e,t+2*e,n+2*e),s.drawImage(i,0,0,t,n),s.getImageData(-e,-e,t+2*e,n+2*e)},resolveURL:i=>(tl||(tl=document.createElement("a")),tl.href=i,tl.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Z??(Z=window.matchMedia("(prefers-reduced-motion: reduce)")),Z.matches)},hasCanvasFingerprintNoise(){if(q!==void 0)return q;if(!J())return q=!1,!1;const i=new OffscreenCanvas(85,1),e=i.getContext("2d",{willReadFrequently:!0});let t=0;for(let s=0;s<i.width;++s)e.fillStyle=`rgba(${t++},${t++},${t++}, 255)`,e.fillRect(s,0,1,1);const n=e.getImageData(0,0,i.width,i.height);t=0;for(let s=0;s<n.data.length;++s)if(s%4!=3&&t++!==n.data[s])return q=!0,!0;return q=!1,!1}};let Q;const ie={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(!ie.API_URL)return null;try{const i=new URL(ie.API_URL);return i.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":i.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_v1.2.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v1.2.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 ne(){return new URL(ie.DRACO_URL,ie.API_URL).href}function le(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(Q===void 0){if(typeof WebAssembly!="object")return!1;const i=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]);Q=WebAssembly.validate(i)}return Q}()?ie.MESHOPT_SIMD_URL:ie.MESHOPT_URL,ie.API_URL).href}function ye(){return new URL(ie.BUILDING_GEN_URL,ie.API_URL).href}function Ee(i,e){const t=i.indexOf("?"),n=t<0?i:i.slice(0,t),s=new URLSearchParams(t<0?"":i.slice(t));for(const[l,c]of Object.entries(e))s.set(l,c);return`${n}?${s}`}function Le(i,e={persistentParams:[]}){const t=i.indexOf("?");if(t<0)return i;const n=new URLSearchParams,s=new URLSearchParams(i.slice(t));for(const c of e.persistentParams){const h=s.get(c);h&&n.set(c,h)}const l=n.toString();return`${i.slice(0,t)}${l.length>0?`?${l}`:""}`}const Ne="mapbox-tiles";let Ge=500,ut=50;const nt=["language","worldview","jobid"];let Qe;function gt(){try{return caches}catch{}}function at(){const i=gt();i&&Qe==null&&(Qe=i.open(Ne))}let It=1/0;function Nt(i){return ie.API_URL_REGEX.test(i)}function Ut(i){return i.indexOf("mapbox:")===0}function Gt(i){return ie.API_CDN_URL_REGEX.test(i)}function At(i){return ie.API_SPRITE_REGEX.test(i)}function xi(i){return ie.API_STYLE_REGEX.test(i)&&!At(i)}const fi={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(fi);class Bt extends Error{constructor(e,t,n){super(),this.url=n,this.statusText=e,this.status=t}get message(){return this.status===401&&Nt(this.url)?`${this.statusText}: you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/guides/#access-tokens-and-token-scopes`:this.statusText}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function Ht(i){return typeof i=="object"&&i!==null&&"status"in i&&i.status===404}const Ct=hs()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Zt=/^\w+:/,pi=/[\r\n]+/;async function zt(i,e){let t;return t=i.type==="arrayBuffer"?await e.arrayBuffer():i.type==="json"?await e.json():await e.text(),{data:t,headers:e.headers}}async function di(i,e){return e&&e.throwIfAborted(),(t=i.url).startsWith("file:")||Ct().startsWith("file:")&&!Zt.test(t)?async function(n,s){return new Promise((l,c)=>{const h=new XMLHttpRequest,p=()=>{s.removeEventListener("abort",p),h.abort(),c(s.reason)};s&&s.addEventListener("abort",p),h.open(n.method||"GET",n.url,!0),n.type==="arrayBuffer"&&(h.responseType="arraybuffer");for(const _ in n.headers)h.setRequestHeader(_,n.headers[_]);n.type==="json"&&(h.responseType="text",h.setRequestHeader("Accept","application/json")),h.withCredentials=n.credentials==="include",h.onerror=()=>{s&&s.removeEventListener("abort",p),c(new Error(h.statusText))},h.onload=()=>{if(s&&s.removeEventListener("abort",p),(h.status>=200&&h.status<300||h.status===0)&&h.response!==null){let _=h.response;if(n.type==="json")try{_=JSON.parse(h.response)}catch(v){return void c(v)}const y=new Headers;h.getAllResponseHeaders().trim().split(pi).forEach(v=>{const b=v.split(": "),T=b.shift(),S=b.join(": ");T&&y.set(T,S)}),l({data:_,headers:y})}else c(new Bt(h.statusText,h.status,n.url))},h.send(n.body)})}(i,e):async function(n,s){const l=new Request(n.url,{method:n.method||"GET",body:n.body,credentials:n.credentials,headers:n.headers,referrer:Ct(),referrerPolicy:n.referrerPolicy,signal:s}),c=(h=l.url).indexOf("sku=")>0&&Nt(h);var h;if(n.type==="json"&&l.headers.set("Accept","application/json"),c){let b=null;try{b=await async function(T){if(at(),Qe==null)return null;const S=await Qe;let A=Le(T.url,{persistentParams:nt});const C=T.headers.get("Range");C&&(A=Ee(A,{range:C}));const D=await S.match(A);if(!D)return null;const z=function(O){if(!O)return!1;const F=new Date(O.headers.get("expires")||0),N=Gn(O.headers.get("cache-control")||"");return Number(F)>Date.now()&&!N["no-cache"]}(D);return S.delete(A).catch(O=>_i(O.message)),z&&S.put(A,D.clone()).catch(O=>_i(O.message)),{response:D,fresh:z}}(l)}catch(T){T.message!=="SecurityError"&&_i(T.toString())}if(b&&b.fresh)return s&&s.throwIfAborted(),zt(n,b.response)}const p=Date.now();let _;try{_=await fetch(l)}catch(b){throw b.name==="AbortError"?b:new Error(`${b.message} ${n.url}`,{cause:b})}if(s&&s.throwIfAborted(),!_.ok)throw new Bt(_.statusText,_.status,n.url);const y=c?_.clone():null,v=await zt(n,_);return y&&async function(b,T,S){if(at(),Qe==null)return;const A=Gn(T.headers.get("cache-control")||"");if(A["no-store"])return;const C={status:T.status,statusText:T.statusText,headers:new Headers(T.headers)};A["max-age"]&&C.headers.set("Expires",new Date(S+1e3*A["max-age"]).toUTCString());const D=C.headers.get("expires");if(!D||new Date(D).getTime()-S<42e4)return;let z=Le(b.url,{persistentParams:nt});if(T.status===206){const N=b.headers.get("Range");if(!N)return;C.status=200,z=Ee(z,{range:N})}const O=new Response((F=T.status)!==200&&F!==404&&[101,103,204,205,304].includes(F)?null:T.body,C);var F;if(at(),Qe!=null)try{await(await Qe).put(z,O)}catch(N){_i(N.message)}}(l,y,p),v}(i,e);var t}async function yr(i,e){return di(Object.assign(i,{type:"json"}),e)}async function vi(i,e){return di(Object.assign(i,{type:"arrayBuffer"}),e)}function dr(i){const e=document.createElement("a");return e.href=i,e.protocol===location.protocol&&e.host===location.host}let Qi,Si;Qi=[],Si=0;const Li="01",Ii={create:"create",load:"load",fullLoad:"fullLoad"},nr={mark(i){performance.mark(i)},measure(i,e,t){performance.measure(i,e,t)}};function Hr(i){const e=i.name.split("?")[0];return Gt(e)&&e.includes("mapbox-gl.js")?"javascript":Gt(e)&&e.includes("mapbox-gl.css")?"css":function(t){return ie.API_FONTS_REGEX.test(t)}(e)?"fontRange":At(e)?"sprite":xi(e)?"style":function(t){return ie.API_TILEJSON_REGEX.test(t)}(e)?"tilejson":"other"}const Zr=/(\.(png|jpg)\d*)(?=$)/,fr=/^.+\/v4\//,ro=/\.[\w]+$/,Ai=/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/,gi=/^access_token=(.*)$/,Yr="NO_ACCESS_TOKEN",wr=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Vt(i){const e=i.match(wr);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function $i(i){const e=i.params.length?`?${i.params.join("&")}`:"";return`${i.protocol}://${i.authority}${i.path}${e}`}const Or="mapbox.eventData";function Rn(i){if(!i)return null;const e=i.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent(atob(e[1]).split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}function tn(i){return!(!ie.EVENTS_URL||!i&&!ie.ACCESS_TOKEN)}let Br;const no=/^[\w.+-]+(\/[\w.+-]+)?$/;let oo="other";class Ci{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=!1}getStorageKey(e){const t=Rn(ie.ACCESS_TOKEN);let n="";return n=t&&t.u?btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,(s,l)=>String.fromCharCode(+("0x"+l)))):ie.ACCESS_TOKEN||"",e?`${Or}.${e}:${n}`:`${Or}:${n}`}fetchEventData(){const e=ha("localStorage"),t=this.getStorageKey(),n=this.getStorageKey("uuid"),s=this.getStorageKey("uuidTimestamp");if(e)try{const l=localStorage.getItem(t);l&&(this.eventData=JSON.parse(l));const c=localStorage.getItem(n);c&&(this.anonId=c);const h=localStorage.getItem(s);h&&(this.anonIdTimestamp=Number(h));const p=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<p)&&this.refreshUUID()}catch{_i("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=$l(),this.anonIdTimestamp=Date.now()}saveEventData(){const e=ha("localStorage"),t=this.getStorageKey(),n=this.getStorageKey("uuid"),s=this.getStorageKey("uuidTimestamp"),l=this.anonId,c=this.anonIdTimestamp;if(e&&l)try{localStorage.setItem(n,l),Object.keys(this.eventData).length>=1&&localStorage.setItem(t,JSON.stringify(this.eventData)),c&&localStorage.setItem(s,c.toString())}catch{_i("Unable to write to LocalStorage")}}processRequests(){}postEvent(e,t,n,s){if(!ie.EVENTS_URL)return;const l=Vt(ie.EVENTS_URL);l.params.push(`access_token=${s||ie.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(e).toISOString()},h=t?Object.assign(c,t):c,p={url:$i(l),headers:{"Content-Type":"text/plain"},body:JSON.stringify([h])};this.pendingRequest=!0,async function(_){return di(Object.assign(_,{method:"POST"}),void 0)}(p).then(()=>{this.pendingRequest=!1,n(null),this.saveEventData(),this.processRequests()}).catch(_=>{this.pendingRequest=!1,n(_),this.saveEventData(),this.processRequests()})}queueRequest(e,t){this.queue.push({...e,customAccessToken:t}),this.processRequests()}}class ar extends Ci{constructor(e){super("metrics"),e&&(this.data=e)}postMetricsEvent(e){if(!tn(e))return;this.anonId||this.fetchEventData(),Wl(this.anonId)||this.refreshUUID();const t={...this.data,sessionId:this.anonId};this.queueRequest({timestamp:Date.now(),payload:t},e)}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:e,payload:t,customAccessToken:n}=this.queue.shift();this.postEvent(e,t,()=>{},n)}}const kr=new class extends Ci{constructor(i){super("appUserTurnstile"),this._customAccessToken=i}postTurnstileEvent(i,e){tn(e)&&Array.isArray(i)&&i.some(t=>Ut(t)||Nt(t))&&this.queueRequest({timestamp:Date.now()},e)}processRequests(){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const i=Rn(ie.ACCESS_TOKEN),e=i?i.u:ie.ACCESS_TOKEN;let t=e!==this.eventData.tokenU;Wl(this.anonId)||(this.refreshUUID(),t=!0);const{timestamp:n,customAccessToken:s}=this.queue.shift();if(this.eventData.lastSuccess){const c=new Date(this.eventData.lastSuccess),h=new Date(n),p=(n-this.eventData.lastSuccess)/864e5;t=t||p>=1||p<-1||c.getDate()!==h.getDate()}else t=!0;if(!t)return void this.processRequests();const l={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:Eo,skuId:Li,"enabled.telemetry":!1,userId:this.anonId,bundleFormat:"umd",bundleDistribution:oo};Br&&(l.sdkInfo=Br),this.postEvent(n,l,c=>{c||(this.eventData.lastSuccess=n,this.eventData.tokenU=e)},s)}},Pn=kr.postTurnstileEvent.bind(kr),vn=new class extends Ci{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(i,e,t,n){this.skuToken=e,this.errorCb=n,ie.EVENTS_URL&&(t||ie.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},t):this.errorCb(new Error(Yr)))}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{id:i,timestamp:e,customAccessToken:t}=this.queue.shift();if(i&&this.success[i])return;this.anonId&&this.anonIdTimestamp||this.fetchEventData(),Wl(this.anonId)||this.refreshUUID();const n={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:Eo,skuId:Li,skuToken:this.skuToken,userId:this.anonId,bundleFormat:"umd",bundleDistribution:oo};Br&&(n.sdkInfo=Br),this.postEvent(e,n,s=>{s?this.errorCb(s):i&&(this.success[i]=!0)},t)}remove(){this.errorCb=null}},rn=vn.postMapLoadEvent.bind(vn),$r=new class extends Ci{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(i){let e=this.mapInstanceIdMap.get(i);return e||(e=$l(),this.mapInstanceIdMap.set(i,e)),e}getEventId(i){const e=this.eventIdPerMapInstanceMap.get(i)||0;return this.eventIdPerMapInstanceMap.set(i,e+1),e}postStyleLoadEvent(i,e){const{map:t,style:n,importedStyles:s}=e;if(!tn(i))return;const l=this.getMapInstanceId(t),c={mapInstanceId:l,eventId:this.getEventId(l),style:n};s.length&&(c.importedStyles=s),this.queueRequest({timestamp:Date.now(),payload:c},i)}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:i,payload:e,customAccessToken:t}=this.queue.shift();this.postEvent(i,e,()=>{},t)}},so=$r.postStyleLoadEvent.bind($r),Wo=new ar({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Hn=Wo.postMetricsEvent.bind(Wo),or=new ar({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),bn=or.postMetricsEvent.bind(or),Oi=new class extends Ci{constructor(){super("gljs.performance")}postPerformanceEvent(i,e){tn(i)&&this.queueRequest({timestamp:Date.now(),performanceData:e},i)}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:i,performanceData:e,customAccessToken:t}=this.queue.shift(),n=function(s){const l=performance.getEntriesByType("resource"),c=performance.getEntriesByType("mark"),h=function(T){const S={};if(T){for(const A in T)if(A!=="other")for(const C of T[A]){const D=`${A}ResolveRangeMin`,z=`${A}ResolveRangeMax`,O=`${A}RequestCount`,F=`${A}RequestCachedCount`;S[D]=Math.min(S[D]||1/0,C.startTime),S[z]=Math.max(S[z]||-1/0,C.responseEnd);const N=j=>{S[j]===void 0&&(S[j]=0),++S[j]};C.transferSize!==void 0&&C.transferSize===0&&N(F),N(O)}}return S}(function(T,S){const A={};if(T)for(const C of T){const D=S(C);A[D]===void 0&&(A[D]=[]),A[D].push(C)}return A}(l,Hr)),p=window.devicePixelRatio,_=navigator.connection||navigator.mozConnection||navigator.webkitConnection,y=_?_.effectiveType:void 0,v={counters:[],metadata:[],attributes:[]},b=(T,S,A)=>{A!=null&&T.push({name:S,value:A.toString()})};for(const T in h)b(v.counters,T,h[T]);if(s.interactionRange[0]!==1/0&&s.interactionRange[1]!==-1/0&&(b(v.counters,"interactionRangeMin",s.interactionRange[0]),b(v.counters,"interactionRangeMax",s.interactionRange[1])),c)for(const T of Object.values(Ii)){const S=c.find(A=>A.name===T);S&&b(v.counters,T,S.startTime)}return b(v.counters,"visibilityHidden",s.visibilityHidden),b(v.attributes,"style",function(T){if(T)for(const S of T){const A=S.name.split("?")[0];if(xi(A)){const C=A.split("/").slice(-2);if(C.length===2)return`mapbox://styles/${C[0]}/${C[1]}`}}}(l)),b(v.attributes,"terrainEnabled",s.terrainEnabled?"true":"false"),b(v.attributes,"fogEnabled",s.fogEnabled?"true":"false"),b(v.attributes,"projection",s.projection),b(v.attributes,"zoom",s.zoom),b(v.metadata,"devicePixelRatio",p),b(v.metadata,"connectionEffectiveType",y),b(v.metadata,"navigatorUserAgent",navigator.userAgent),b(v.metadata,"screenWidth",window.screen.width),b(v.metadata,"screenHeight",window.screen.height),b(v.metadata,"windowWidth",window.innerWidth),b(v.metadata,"windowHeight",window.innerHeight),b(v.metadata,"mapWidth",s.width/p),b(v.metadata,"mapHeight",s.height/p),b(v.metadata,"webglRenderer",s.renderer),b(v.metadata,"webglVendor",s.vendor),b(v.metadata,"sdkVersion",Eo),b(v.metadata,"sdkIdentifier","mapbox-gl-js"),v}(e);for(const s of n.metadata);for(const s of n.counters);for(const s of n.attributes);this.postEvent(i,n,()=>{},t)}},Tr=Oi.postPerformanceEvent.bind(Oi),ao=new class extends Ci{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(i,e,t,n){if(!ie.API_URL||!ie.SESSION_PATH)return;const s=Vt(ie.API_URL+ie.SESSION_PATH);s.params.push(`sku=${e||""}`),s.params.push(`access_token=${n||ie.ACCESS_TOKEN||""}`);const l={url:$i(s),headers:{"Content-Type":"text/plain"}};this.pendingRequest=!0,async function(c){return di(Object.assign(c,{method:"GET"}),void 0)}(l).then(()=>{this.pendingRequest=!1,t(null),this.saveEventData(),this.processRequests()}).catch(c=>{this.pendingRequest=!1,t(c),this.saveEventData(),this.processRequests()})}getSessionAPI(i,e,t,n){this.skuToken=e,this.errorCb=n,ie.EVENTS_URL&&ie.SESSION_PATH&&ie.API_URL&&(t||ie.ACCESS_TOKEN?this.queueRequest({id:i,timestamp:Date.now()},t):this.errorCb(new Error(Yr)))}processRequests(){if(this.pendingRequest||this.queue.length===0)return;const{id:i,timestamp:e,customAccessToken:t}=this.queue.shift();i&&this.success[i]||this.getSession(e,this.skuToken,n=>{n?this.errorCb(n):i&&(this.success[i]=!0)},t)}remove(){this.errorCb=null}},As=ao.getSessionAPI.bind(ao),hn=new Set;function il(i,e=0){const s=i.length,l=s-(3&s);let c,h=0|e,p=0;for(;p<l;)c=255&i.charCodeAt(p)|(255&i.charCodeAt(p+1))<<8|(255&i.charCodeAt(p+2))<<16|(255&i.charCodeAt(p+3))<<24,p+=4,c=Math.imul(c,3432918353),c=c<<15|c>>>17,c=Math.imul(c,461845907),h^=c,h=h<<13|h>>>19,h=Math.imul(h,5)+3864292196|0;c=0;const _=3&s;return _>0&&(_>=3&&(c^=(255&i.charCodeAt(p+2))<<16),_>=2&&(c^=(255&i.charCodeAt(p+1))<<8),c^=255&i.charCodeAt(p),c=Math.imul(c,3432918353),c=c<<15|c>>>17,c=Math.imul(c,461845907),h^=c),h^=s,h^=h>>>16,h=Math.imul(h,2246822507),h^=h>>>13,h=Math.imul(h,3266489909),h^=h>>>16,h>>>0}class Mo{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e}}class wn extends Mo{constructor(e,t={}){super("error",{error:e,...t}),this.error=e}}function Ro(i,e,t){t[i]&&t[i].includes(e)||(t[i]=t[i]||[],t[i].push(e))}function Xo(i,e,t){if(t[i]){const n=t[i].indexOf(e);n!==-1&&t[i].splice(n,1)}}class Dn{constructor(){this._listeners={},this._oneTimeListeners={}}on(e,t){return Ro(e,t,this._listeners),this}off(e,t){return Xo(e,t,this._listeners),Xo(e,t,this._oneTimeListeners),this}once(e,t){return t?(Ro(e,t,this._oneTimeListeners),this):new Promise(n=>{this.once(e,n)})}fire(e,t){const n=typeof e=="string"?new Mo(e,t):e,s=n.type;if(this.listens(s)){n.target=this;const l=this._listeners[s]?this._listeners[s].slice():[];for(const p of l)p.call(this,n);const c=this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const p of c)Xo(s,p,this._oneTimeListeners),p.call(this,n);const h=this._eventedParent;if(h){const p=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(n,p),h.fire(n)}}else n instanceof wn&&console.error(n.error);return this}listens(e){return!!(this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}class Er{constructor(e){typeof e=="string"?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new Er(e)}static toString(e){return e.iconsetId?`${e.name}�${e.iconsetId}`:e.name}static parse(e){const[t,n]=e.split("�");return new Er({name:t,iconsetId:n})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return Er.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var Yo,ds={},Cs=function(){if(Yo)return ds;Yo=1;var i={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 t(l){return e(l[l.length-1]==="%"?parseFloat(l)/100*255:parseInt(l))}function n(l){return(c=l[l.length-1]==="%"?parseFloat(l)/100:parseFloat(l))<0?0:c>1?1:c;var c}function s(l,c,h){return h<0?h+=1:h>1&&(h-=1),6*h<1?l+(c-l)*h*6:2*h<1?c:3*h<2?l+(c-l)*(2/3-h)*6:l}try{ds.parseCSSColor=function(l){var c,h=l.replace(/ /g,"").toLowerCase();if(h in i)return i[h].slice();if(h[0]==="#")return h.length===4?(c=parseInt(h.substr(1),16))>=0&&c<=4095?[(3840&c)>>4|(3840&c)>>8,240&c|(240&c)>>4,15&c|(15&c)<<4,1]:null:h.length===7&&(c=parseInt(h.substr(1),16))>=0&&c<=16777215?[(16711680&c)>>16,(65280&c)>>8,255&c,1]:null;var p=h.indexOf("("),_=h.indexOf(")");if(p!==-1&&_+1===h.length){var y=h.substr(0,p),v=h.substr(p+1,_-(p+1)).split(","),b=1;switch(y){case"rgba":if(v.length!==4)return null;b=n(v.pop());case"rgb":return v.length!==3?null:[t(v[0]),t(v[1]),t(v[2]),b];case"hsla":if(v.length!==4)return null;b=n(v.pop());case"hsl":if(v.length!==3)return null;var T=(parseFloat(v[0])%360+360)%360/360,S=n(v[1]),A=n(v[2]),C=A<=.5?A*(S+1):A+S-A*S,D=2*A-C;return[e(255*s(D,C,T+1/3)),e(255*s(D,C,T)),e(255*s(D,C,T-1/3)),b];default:return null}}return null}}catch{}return ds}();function lt(i,e,t){return i*(1-t)+e*t}const Xs=new Map;class Pt{constructor(e,t,n,s=1){this.r=e,this.g=t,this.b=n,this.a=s}static parse(e){if(!e)return;if(e instanceof Pt)return e;if(typeof e!="string")return;const t=Xs.get(e);if(t)return t;const n=Cs.parseCSSColor(e);if(!n)return;const s=new Pt(n[0]/255,n[1]/255,n[2]/255,n[3]);return Xs.set(e,s),s}toString(){const{r:e,g:t,b:n,a:s}=this;return`rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*n)},${s})`}toNonPremultipliedRenderColor(e){const{r:t,g:n,b:s,a:l}=this;return new Zu(e,t,n,s,l)}toPremultipliedRenderColor(e){const{r:t,g:n,b:s,a:l}=this;return new $u(e,t*l,n*l,s*l,l)}clone(){return new Pt(this.r,this.g,this.b,this.a)}}class Ms{constructor(e,t,n,s,l,c=!1){if(this.premultiplied=!1,this.premultiplied=c,e){const h=e.image.height,p=h*h;this.premultiplied?(t=l===0?0:t/l*(h-1),n=l===0?0:n/l*(h-1),s=l===0?0:s/l*(h-1)):(t*=h-1,n*=h-1,s*=h-1),t=Math.max(0,Math.min(h-1,t)),n=Math.max(0,Math.min(h-1,n)),s=Math.max(0,Math.min(h-1,s));const _=Math.floor(t),y=Math.floor(n),v=Math.floor(s),b=Math.ceil(t),T=Math.ceil(n),S=Math.ceil(s),A=t-_,C=n-y,D=s-v,z=e.image.data,O=4*(_+y*p+v*h),F=4*(_+y*p+S*h),N=4*(_+T*p+v*h),j=4*(_+T*p+S*h),te=4*(b+y*p+v*h),H=4*(b+y*p+S*h),W=4*(b+T*p+v*h),K=4*(b+T*p+S*h);this.r=lt(lt(lt(z[O],z[F],D),lt(z[N],z[j],D),C),lt(lt(z[te],z[H],D),lt(z[W],z[K],D),C),A)/255*(this.premultiplied?l:1),this.g=lt(lt(lt(z[O+1],z[F+1],D),lt(z[N+1],z[j+1],D),C),lt(lt(z[te+1],z[H+1],D),lt(z[W+1],z[K+1],D),C),A)/255*(this.premultiplied?l:1),this.b=lt(lt(lt(z[O+2],z[F+2],D),lt(z[N+2],z[j+2],D),C),lt(lt(z[te+2],z[H+2],D),lt(z[W+2],z[K+2],D),C),A)/255*(this.premultiplied?l:1),this.a=l}else this.r=t,this.g=n,this.b=s,this.a=l}toArray(){const{r:e,g:t,b:n,a:s}=this;return[255*e,255*t,255*n,s]}toHslaArray(){let{r:e,g:t,b:n,a:s}=this;if(this.premultiplied){if(s===0)return[0,0,0,0];const S=1/s;e*=S,t*=S,n*=S}const l=Math.min(Math.max(e,0),1),c=Math.min(Math.max(t,0),1),h=Math.min(Math.max(n,0),1),p=Math.min(l,c,h),_=Math.max(l,c,h),y=_-p,v=.5*(p+_);if(y===0)return[0,0,100*v,s];const b=v>.5?y/(2-_-p):y/(_+p);let T;switch(_){case l:T=60*((c-h)/y+(c<h?6:0));break;case c:T=60*((h-l)/y+2);break;default:T=60*((l-c)/y+4)}return[T,100*b,100*v,s]}toArray01(){const{r:e,g:t,b:n,a:s}=this;return[e,t,n,s]}toArray01Scaled(e){const{r:t,g:n,b:s}=this;return[t*e,n*e,s*e]}toArray01Linear(){const{r:e,g:t,b:n,a:s}=this;return[Math.pow(e,2.2),Math.pow(t,2.2),Math.pow(n,2.2),s]}}class Zu extends Ms{constructor(e,t,n,s,l){super(e,t,n,s,l,!1)}}class $u extends Ms{constructor(e,t,n,s,l){super(e,t,n,s,l,!0)}}function Tn(i,e,t){return i.map((n,s)=>lt(n,e[s],t))}Pt.black=new Pt(0,0,0,1),Pt.white=new Pt(1,1,1,1),Pt.transparent=new Pt(0,0,0,0),Pt.red=new Pt(1,0,0,1),Pt.blue=new Pt(0,0,1,1);var da=Object.freeze({__proto__:null,array:Tn,color:function(i,e,t){return new Pt(lt(i.r,e.r,t),lt(i.g,e.g,t),lt(i.b,e.b,t),lt(i.a,e.a,t))},number:lt});class dn extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class rl{constructor(e,t=[]){this.parent=e,this.bindings=Object.create(null);for(const[n,s]of t)this.bindings[n]=s}concat(e){return new rl(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)}}const fa={kind:"null"},st={kind:"number"},ti={kind:"string"},$t={kind:"boolean"},nn={kind:"color"},lo={kind:"object"},qt={kind:"value"},co={kind:"collator"},fs={kind:"formatted"},pa={kind:"resolvedImage"};function ji(i,e){return{kind:"array",itemType:i,N:e}}function Bi(i){if(i.kind==="array"){const e=Bi(i.itemType);return typeof i.N=="number"?`array<${e}, ${i.N}>`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const Po=[fa,st,ti,$t,nn,fs,lo,ji(qt),pa];function Ln(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!Ln(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const t of Po)if(!Ln(t,e))return null}}return`Expected ${Bi(i)} but found ${Bi(e)} instead.`}function Jl(i,e){return e.some(t=>t==="null"?i===null:t==="array"?Array.isArray(i):t==="object"?i&&!Array.isArray(i)&&typeof i=="object":t===typeof i)}function nl(i,e){return i.kind==="array"&&e.kind==="array"?i.N===e.N&&nl(i.itemType,e.itemType):i.kind===e.kind}class Ql{constructor(e,t,n){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ma{constructor(e,t,n,s,l){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=n,this.fontStack=s,this.textColor=l}}class Sr{constructor(e){this.sections=e}static fromString(e){return new Sr([new ma(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 Sr?e:Sr.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const s=t.image.getPrimary().id.toString();e.push(["image",s]);continue}e.push(t.text);const n={};t.fontStack&&(n["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(n["font-scale"]=t.scale),t.textColor&&(n["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(n)}return e}}class uo{constructor(e,t={}){this.id=Er.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1}toString(){return JSON.stringify(this)}static parse(e){let t,n,s,l;try{({id:t,params:n,sx:s,sy:l}=JSON.parse(e)||{})}catch{return null}return t?new uo(t,{params:n,sx:s,sy:l}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class fn{constructor(e,t,n,s,l=!1){this.primaryId=Er.from(e),this.primaryOptions=t,n&&(this.secondaryId=Er.from(n)),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 uo(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new uo(this.secondaryId,this.secondaryOptions):null}static from(e){return typeof e!="string"?e:fn.build({name:e})}static build(e,t,n,s){return!e||typeof e=="object"&&!("name"in e)?null:new fn(e,n,t,s)}}function Uc(i,e,t,n){return typeof i=="number"&&i>=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof t=="number"&&t>=0&&t<=255?n===void 0||typeof n=="number"&&n>=0&&n<=1?null:`Invalid rgba value [${[i,e,t,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof n=="number"?[i,e,t,n]:[i,e,t]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ys(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof Pt||i instanceof Ql||i instanceof Sr||i instanceof fn)return!0;if(Array.isArray(i)){for(const e of i)if(!Ys(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!Ys(i[e]))return!1;return!0}return!1}function Nr(i){if(i===null)return fa;if(typeof i=="string")return ti;if(typeof i=="boolean")return $t;if(typeof i=="number")return st;if(i instanceof Pt)return nn;if(i instanceof Ql)return co;if(i instanceof Sr)return fs;if(i instanceof fn)return pa;if(Array.isArray(i)){const e=i.length;let t;for(const n of i){const s=Nr(n);if(t){if(t===s)continue;t=qt;break}t=s}return ji(t||qt,e)}return lo}function Do(i){return i===null?"":typeof i=="string"||typeof i=="number"||typeof i=="boolean"?String(i):i instanceof Sr||i instanceof fn||i instanceof Pt?i.toString():JSON.stringify(i)}class Ko{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(e.length!==2)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ys(e[1]))return t.error("invalid value");const n=e[1];let s=Nr(n);const l=t.expectedType;return s.kind!=="array"||s.N!==0||!l||l.kind!=="array"||typeof l.N=="number"&&l.N!==0||(s=l),new Ko(s,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Pt?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Sr?this.value.serialize():this.value}}class xr{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const ec={string:ti,number:st,boolean:$t,object:lo};class Tt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let n,s=1;const l=e[0];if(l==="array"){let h,p;if(e.length>2){const _=e[1];if(typeof _!="string"||!(_ in ec)||_==="object")return t.error('The item type argument of "array" must be one of string, number, boolean',1);h=ec[_],s++}else h=qt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);p=e[2],s++}n=ji(h,p)}else n=ec[l];const c=[];for(;s<e.length;s++){const h=t.parse(e[s],s,qt);if(!h)return null;c.push(h)}return new Tt(n,c)}evaluate(e){for(let t=0;t<this.args.length;t++){const n=this.args[t].evaluate(e);if(!Ln(this.type,Nr(n)))return n;if(t===this.args.length-1)throw new xr(`The expression ${JSON.stringify(this.args[t].serialize())} evaluated to ${Bi(Nr(n))} but was expected to be of type ${Bi(this.type)}.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,t=[e.kind];if(e.kind==="array"){const n=e.itemType;if(n.kind==="string"||n.kind==="number"||n.kind==="boolean"){t.push(n.kind);const s=e.N;(typeof s=="number"||this.args.length>1)&&t.push(s)}}return t.concat(this.args.map(n=>n.serialize()))}}class Zn{constructor(e){this.type=fs,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&typeof n=="object")return t.error("First argument must be an image or text section.");const s=[];let l=!1;for(let c=1;c<=e.length-1;++c){const h=e[c];if(l&&typeof h=="object"&&!Array.isArray(h)){l=!1;let p=null;if(h["font-scale"]&&(p=t.parseObjectValue(h["font-scale"],c,"font-scale",st),!p))return null;let _=null;if(h["text-font"]&&(_=t.parseObjectValue(h["text-font"],c,"text-font",ji(ti)),!_))return null;let y=null;if(h["text-color"]&&(y=t.parseObjectValue(h["text-color"],c,"text-color",nn),!y))return null;const v=s.at(-1);v.scale=p,v.font=_,v.textColor=y}else{const p=t.parse(e[c],c,qt);if(!p)return null;const _=p.type.kind;if(_!=="string"&&_!=="value"&&_!=="null"&&_!=="resolvedImage")return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");l=!0,s.push({content:p,scale:null,font:null,textColor:null})}}return new Zn(s)}evaluate(e){return new Sr(this.sections.map(t=>{const n=t.content.evaluate(e);return nl(Nr(n),pa)?new ma("",n,null,null,null):new ma(Do(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const n={};t.scale&&(n["font-scale"]=t.scale.serialize()),t.font&&(n["text-font"]=t.font.serialize()),t.textColor&&(n["text-color"]=t.textColor.serialize()),e.push(n)}return e}}class _a{constructor(e,t,n,s){this._imageWarnHistory={},this.type=pa,this.namePrimary=e,this.nameSecondary=t,n&&(this.paramsPrimary=n.params,this.iconsetIdPrimary=n.iconset?n.iconset.id:void 0),s&&(this.paramsSecondary=s.params,this.iconsetIdSecondary=s.iconset?s.iconset.id:void 0)}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let n=1;const s=[];function l(){if(n<e.length){const h=t.parse(e[n],n++,ti);return h?(s.push({image:h,options:{}}),!0):(t.error(s.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function c(){if(n<e.length){const p=e[n];if((h=p)===null||typeof h!="object"||Array.isArray(h))return!0;const _=p.params,y=p.iconset,v=t.concat(n);if(!_&&!y)return n++,!0;if(_){if(typeof _!="object"||_.constructor!==Object)return v.error('Image options "params" should be an object'),!1;const b={},T=v.concat(void 0,"params");for(const S in _){if(!S)return T.error("Image parameter name should be non-empty"),!1;const A=T.concat(void 0,S).parse(_[S],void 0,nn,void 0,{typeAnnotation:"coerce"});if(!A)return!1;b[S]=A}s.at(-1).options.params=b}if(y){if(typeof y!="object"||y.constructor!==Object)return v.error('Image options "iconset" should be an object'),!1;if(!y.id)return v.error('Image options "iconset" should have an "id" property'),!1;s.at(-1).options.iconset=y}return n++,!0}var h;return!0}for(let h=0;h<2;h++)if(!l()||!c())return;return new _a(s[0].image,s[1]?s[1].image:void 0,s[0].options,s[1]?s[1].options:void 0)}evaluateParams(e,t){const n={};if(t){for(const s in t)if(t[s])try{n[s]=t[s].evaluate(e)}catch{continue}if(Object.keys(n).length!==0)return{params:n}}}evaluate(e){const t={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},n=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,s=fn.build(t,n,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(s&&e.availableImages){const l=s.getPrimary().id;if(s.available=e.availableImages.some(c=>Er.isEqual(c,l)),s.available){const c=s.getSecondary()?s.getSecondary().id:null;c&&(s.available=e.availableImages.some(h=>Er.isEqual(h,c)))}}return s}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t])}outputDefined(){return!1}serializeOptions(e,t){const n={};if(t&&(n.iconset={id:t}),e){n.params={};for(const s in e)e[s]&&(n.params[s]=e[s].serialize())}return Object.keys(n).length>0?n:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t)}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t)}return e}}function ol(i){return tc(i)?"string":ya(i)?"number":jc(i)?"boolean":Array.isArray(i)?"array":i===null?"null":ga(i)?"object":typeof i}function ga(i){return i!=null&&!Array.isArray(i)&&typeof i!="function"&&!(i instanceof String||i instanceof Number||i instanceof Boolean)&&typeof i=="object"}function tc(i){return typeof i=="string"||i instanceof String}function ya(i){return typeof i=="number"||i instanceof Number}function jc(i){return typeof i=="boolean"||i instanceof Boolean}const qu={"to-boolean":$t,"to-color":nn,"to-number":st,"to-string":ti};class Rs{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[0],s=[];let l=fa;if(n==="to-array"){if(!Array.isArray(e[1]))return null;const c=e[1].length;if(t.expectedType){if(t.expectedType.kind!=="array")return t.error(`Expected ${t.expectedType.kind} but found array.`);l=ji(t.expectedType.itemType,c)}else{if(!(c>0&&Ys(e[1][0])))return null;l=ji(Nr(e[1][0]),c)}for(let h=0;h<c;h++){const p=e[1][h];let _;if(Array.isArray(p))_=t.parse(p,void 0,l.itemType);else{const y=ol(p);if(y!==l.itemType.kind)return t.error(`Expected ${l.itemType.kind} but found ${y}.`);_=t.registry.literal.parse(["literal",p===void 0?null:p],t)}if(!_)return null;s.push(_)}}else{if((n==="to-boolean"||n==="to-string")&&e.length!==2)return t.error("Expected one argument.");l=qu[n];for(let c=1;c<e.length;c++){const h=t.parse(e[c],c,qt);if(!h)return null;s.push(h)}}return new Rs(l,s)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let t,n;for(const s of this.args){if(t=s.evaluate(e),n=null,t instanceof Pt)return t;if(typeof t=="string"){const l=e.parseColor(t);if(l)return l}else if(Array.isArray(t)&&(n=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Uc(t[0],t[1],t[2],t[3]),!n))return new Pt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new xr(n||`Could not parse color from value '${typeof t=="string"?t:String(JSON.stringify(t))}'`)}if(this.type.kind==="number"){let t=null;for(const n of this.args){if(t=n.evaluate(e),t===null)return 0;const s=Number(t);if(!isNaN(s))return s}throw new xr(`Could not convert ${JSON.stringify(t)} to number.`)}return this.type.kind==="formatted"?Sr.fromString(Do(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?fn.build(Do(this.args[0].evaluate(e))):this.type.kind==="array"?this.args.map(t=>t.evaluate(e)):Do(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 Zn([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new _a(this.args[0]).serialize();const e=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize())}),e}}const Wu=["Unknown","Point","LineString","Polygon"];class ho{constructor(e,t,n){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t,this.iconImageUseTheme=n}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Wu[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){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:n,y:s}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*t-e[0])+this.featureDistanceData.bearing[1]*(s*t-e[1])}return 0}parseColor(e){return Pt.parse(e)}getConfig(e){return this.options?this.options.get(e):null}}class En{constructor(e,t,n,s,l){this.name=e,this.type=t,this._evaluate=n,this.args=s,this._overloadIndex=l}evaluate(e){if(!this._evaluate){const t=En.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.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,t){const n=e[0],s=En.definitions[n];if(!s)return t.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const l=Array.isArray(s)?s[0]:s.type,c=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,h=[];let p=null,_=-1;for(const[y,v]of c){if(Array.isArray(y)&&y.length!==e.length-1)continue;h.push(y),_++,p===null?p=t._forkForSignature():p.errors.length=0;const b=[];let T=!1;for(let S=1;S<e.length;S++){const A=e[S],C=Array.isArray(y)?y[S-1]:y.type,D=p.parse(A,1+b.length,C);if(!D){T=!0;break}b.push(D)}if(!T)if(Array.isArray(y)&&y.length!==b.length)p.error(`Expected ${y.length} arguments, but found ${b.length} instead.`);else{for(let S=0;S<b.length;S++){const A=Array.isArray(y)?y[S]:y.type;p.checkSubtype(A,b[S].type,S+1)}if(p.errors.length===0)return new En(n,l,v,b,_)}}if(h.length===1)t.errors.push(...p.errors);else{const y=(h.length?h:c.map(([b])=>b)).map(Xu).join(" | "),v=[];for(let b=1;b<e.length;b++){const T=t.parse(e[b],1+v.length);if(!T)return null;v.push(Bi(T.type))}t.error(`Expected arguments of type ${y}, but found (${v.join(", ")}) instead.`)}return null}static register(e,t){En.definitions=t;for(const n in t)e[n]=En}}function Xu(i){return Array.isArray(i)?`(${i.map(Bi).join(", ")})`:`(${Bi(i.type)}...)`}class xa{constructor(e,t,n){this.type=co,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(e.length!==2)return t.error("Expected one argument."),null;const n=e[1];if(typeof n!="object"||Array.isArray(n))return t.error("Collator options argument must be an object."),null;const s=n["case-sensitive"]===void 0?t.parse(!1,1,$t):t.parseObjectValue(n["case-sensitive"],1,"case-sensitive",$t);if(!s)return null;const l=n["diacritic-sensitive"]===void 0?t.parse(!1,1,$t):t.parseObjectValue(n["diacritic-sensitive"],1,"diacritic-sensitive",$t);if(!l)return null;let c=null;return n.locale&&(c=t.parseObjectValue(n.locale,1,"locale",ti),!c)?null:new xa(s,l,c)}evaluate(e){return new Ql(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(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function fo(i){return(180+i)/360}function $n(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function qn(i){return 360*i-180}function vr(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}const Ks=8192;function d_(i,e){const t=fo(i[0]),n=$n(i[1]),s=Math.pow(2,e.z);return[Math.round(t*s*Ks),Math.round(n*s*Ks)]}function Df(i,e){for(let t=0;t<e.length;t++)if(Un(i,e[t]))return!0;return!1}function Lf(i,e,t){for(const n of t)for(let s=0,l=n.length,c=l-1;s<l;c=s++)if(Ws(i,e,n[c],n[s]))return!0;return!1}function zf(i,e){for(let t=0;t<i.length;++t)if(!Un(i[t],e))return!1;for(let t=0;t<i.length-1;++t)if(Lf(i[t],i[t+1],e))return!1;return!0}function f_(i,e){for(let t=0;t<e.length;t++)if(zf(i,e[t]))return!0;return!1}function Kh(i,e,t){const n=[];for(let s=0;s<i.length;s++){const l=[];for(let c=0;c<i[s].length;c++){const h=d_(i[s][c],t);zr(e,h),l.push(h)}n.push(l)}return n}function Jh(i,e,t){const n=[];for(let s=0;s<i.length;s++){const l=Kh(i[s],e,t);n.push(l)}return n}function Ff(i,e,t,n){if(i[0]<t[0]||i[0]>t[2]){const s=.5*n;let l=i[0]-t[0]>s?-n:t[0]-i[0]>s?n:0;l===0&&(l=i[0]-t[2]>s?-n:t[2]-i[0]>s?n:0),i[0]+=l}zr(e,i)}function ic(i,e,t,n){const s=Math.pow(2,n.z)*Ks,l=[n.x*Ks,n.y*Ks],c=[];if(!i)return c;for(const h of i)for(const p of h){const _=[p.x+l[0],p.y+l[1]];Ff(_,e,t,s),c.push(_)}return c}function Qh(i,e,t,n){const s=Math.pow(2,n.z)*Ks,l=[n.x*Ks,n.y*Ks],c=[];if(!i)return c;for(const p of i){const _=[];for(const y of p){const v=[y.x+l[0],y.y+l[1]];zr(e,v),_.push(v)}c.push(_)}if(e[2]-e[0]<=s/2){(h=e)[0]=h[1]=1/0,h[2]=h[3]=-1/0;for(const p of c)for(const _ of p)Ff(_,e,t,s)}var h;return c}class sl{constructor(e,t){this.type=$t,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ys(e[1])){const n=e[1];if(n.type==="FeatureCollection")for(let s=0;s<n.features.length;++s){const l=n.features[s].geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new sl(n,n.features[s].geometry)}else if(n.type==="Feature"){const s=n.geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new sl(n,n.geometry)}else if(n.type==="Polygon"||n.type==="MultiPolygon")return new sl(n,n)}return t.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(t,n){const s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],c=t.canonicalID();if(!c)return!1;if(n.type==="Polygon"){const h=Kh(n.coordinates,l,c),p=ic(t.geometry(),s,l,c);if(!Ya(s,l))return!1;for(const _ of p)if(!Un(_,h))return!1}if(n.type==="MultiPolygon"){const h=Jh(n.coordinates,l,c),p=ic(t.geometry(),s,l,c);if(!Ya(s,l))return!1;for(const _ of p)if(!Df(_,h))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(t,n){const s=[1/0,1/0,-1/0,-1/0],l=[1/0,1/0,-1/0,-1/0],c=t.canonicalID();if(!c)return!1;if(n.type==="Polygon"){const h=Kh(n.coordinates,l,c),p=Qh(t.geometry(),s,l,c);if(!Ya(s,l))return!1;for(const _ of p)if(!zf(_,h))return!1}if(n.type==="MultiPolygon"){const h=Jh(n.coordinates,l,c),p=Qh(t.geometry(),s,l,c);if(!Ya(s,l))return!1;for(const _ of p)if(!f_(_,h))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}class Gc{constructor(e=[],t=(n,s)=>n<s?-1:n>s?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,s=t[e];for(;e>0;){const l=e-1>>1,c=t[l];if(n(s,c)>=0)break;t[e]=c,e=l}t[e]=s}_down(e){const{data:t,compare:n}=this,s=this.length>>1,l=t[e];for(;e<s;){let c=1+(e<<1);const h=c+1;if(h<this.length&&n(t[h],t[c])<0&&(c=h),n(t[c],l)>=0)break;t[e]=t[c],e=c}t[e]=l}}var qe=8192;function rc(i,e,t){return[i,e,t].filter(Boolean).join("�")}function nc(i,e){switch(i){case"string":return Do(e);case"number":return+e;case"boolean":return!!e;case"color":return Pt.parse(e);case"formatted":return Sr.fromString(Do(e));case"resolvedImage":return fn.build(Do(e))}return e}function Of(i,e,t,n){return n!==void 0&&(i=n*Math.round(i/n)),e!==void 0&&i<e&&(i=e),t!==void 0&&i>t&&(i=t),i}class oc{constructor(e,t,n,s=!1){this.type=e,this.key=t,this.scope=n,this.featureConstant=s}static parse(e,t){let n=t.expectedType;if(n??(n=qt),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const s=t.parse(e[1],1);if(!(s instanceof Ko))return t.error("Key name of 'config' expression must be a string literal.");let l,c=!0;const h=Do(s.value);if(e.length>=3){const p=t.parse(e[2],2);if(!(p instanceof Ko))return t.error("Scope of 'config' expression must be a string literal.");l=Do(p.value)}if(t.options){const p=rc(h,l,t._scope),_=t.options.get(p);_&&(c=al(_.value||_.default))}return new oc(n,h,l,c)}evaluate(e){const t=rc(this.key,this.scope,e.scope),n=e.getConfig(t);if(!n)return null;const{type:s,value:l,values:c,minValue:h,maxValue:p,stepValue:_}=n,y=n.default.evaluate(e);let v=y;if(l){const b=e.scope;e.scope=(b||"").split("�").slice(1).join("�"),v=l.evaluate(e),e.scope=b}return s&&(v=nc(s,v)),v===void 0||h===void 0&&p===void 0&&_===void 0||(typeof v=="number"?v=Of(v,h,p,_):Array.isArray(v)&&(v=v.map(b=>typeof b=="number"?Of(b,h,p,_):b))),l!==void 0&&v!==void 0&&c&&!c.includes(v)&&(v=y,s&&(v=nc(s,v))),(s&&s!==this.type||v!==void 0&&!nl(Nr(v),this.type))&&(v=nc(this.type.kind,v)),v}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}function al(i){if(i instanceof En&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||i.name.startsWith("filter-"))||i instanceof sl||i instanceof dl)return!1;if(i instanceof oc)return i.featureConstant;let e=!0;return i.eachChild(t=>{e&&!al(t)&&(e=!1)}),e}function va(i){if(i instanceof En&&i.name==="feature-state")return!1;let e=!0;return i.eachChild(t=>{e&&!va(t)&&(e=!1)}),e}function Hc(i,e){if(i instanceof En&&e.has(i.name))return!1;let t=!0;return i.eachChild(n=>{t&&!Hc(n,e)&&(t=!1)}),t}function Jo(i,e){return Hc(i,new Set(e))}const Zc=1/298.257223563,Bf=Zc*(2-Zc),$c=Math.PI/180;function ed(i){const e=6378.137*$c*1e3,t=Math.cos(i*$c),n=1/(1-Bf*(1-t*t)),s=Math.sqrt(n);return[e*s*t,e*s*n*(1-Bf)]}function ll(i){for(;i<-180;)i+=360;for(;i>180;)i-=360;return i}function qc(i,e,t,n){const s=ll(i[0]-e[0])*t,l=(i[1]-e[1])*n;return Math.sqrt(s*s+l*l)}function Wc(i,e,t,n,s){let l=e[0],c=e[1],h=ll(t[0]-l)*n,p=(t[1]-c)*s;if(h!==0||p!==0){const _=(ll(i[0]-l)*n*h+(i[1]-c)*s*p)/(h*h+p*p);_>1?(l=t[0],c=t[1]):_>0&&(l+=h/n*_,c+=p/s*_)}return h=ll(i[0]-l)*n,p=(i[1]-c)*s,Math.sqrt(h*h+p*p)}function kf(i,e){return e.dist-i.dist}function Nf(i){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==i.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==i[t])return!1;return!0}function Yu(i){return i[1]-i[0]+1}function Ps(i,e){const t=i[1]>=i[0]&&i[1]<e;return t||console.warn("Distance Expression: Index is out of range"),t}function ba(i,e){if(i[0]>i[1])return[null,null];const t=Yu(i);if(e){if(t===2)return[i,null];const n=Math.floor(t/2);return[[i[0],i[0]+n],[i[0]+n,i[1]]]}{if(t===1)return[i,null];const n=Math.floor(t/2)-1;return[[i[0],i[0]+n],[i[0]+n+1,i[1]]]}}function cl(i,e){const t=[1/0,1/0,-1/0,-1/0];if(!Ps(e,i.length))return t;for(let n=e[0];n<=e[1];++n)zr(t,i[n]);return t}function Lo(i){const e=[1/0,1/0,-1/0,-1/0];for(let t=0;t<i.length;++t)for(let n=0;n<i[t].length;++n)zr(e,i[t][n]);return e}function ul(i,e,t,n){if(Nf(i)||Nf(e))return NaN;let s=0,l=0;return i[2]<e[0]&&(s=e[0]-i[2]),i[0]>e[2]&&(s=i[0]-e[2]),i[1]>e[3]&&(l=i[1]-e[3]),i[3]<e[1]&&(l=e[1]-i[3]),qc([0,0],[s,l],t,n)}function Ku(i,e,t=8192){const n=Math.pow(2,e.z),s=(i.y/t+e.y)/n;return[qn((i.x/t+e.x)/n),vr(s)]}function p_(i,e){const t=[];for(let n=0;n<i.length;++n)t.push(Ku(i[n],e));return t}function td(i,e,t,n){const s=function(l,c,h,p){let _=1/0,y=l[0][0],v=l[0][1];for(let b=0;b<l.length-1;b++){let T=l[b][0],S=l[b][1],A=ll(l[b+1][0]-T)*h,C=(l[b+1][1]-S)*p,D=0;A===0&&C===0||(D=(ll(c[0]-T)*h*A+(c[1]-S)*p*C)/(A*A+C*C),D>1?(T=l[b+1][0],S=l[b+1][1]):D>0&&(T+=A/h*D,S+=C/p*D)),A=ll(c[0]-T)*h,C=(c[1]-S)*p;const z=A*A+C*C;z<_&&(_=z,y=T,v=S)}return[y,v]}(e,i,t,n);return qc(i,s,t,n)}function Ju(i,e,t,n,s,l){const c=t.slice(n[0],n[1]+1);let h=1/0;for(let p=e[0];p<=e[1];++p)if((h=Math.min(h,td(i[p],c,s,l)))===0)return 0;return h}function id(i,e,t,n,s,l){const c=Math.min(Wc(i,t,n,s,l),Wc(e,t,n,s,l)),h=Math.min(Wc(t,i,e,s,l),Wc(n,i,e,s,l));return Math.min(c,h)}function m_(i,e,t,n,s,l){if(!Ps(e,i.length)||!Ps(n,t.length))return NaN;let c=1/0;for(let h=e[0];h<e[1];++h)for(let p=n[0];p<n[1];++p){if(Ws(i[h],i[h+1],t[p],t[p+1]))return 0;c=Math.min(c,id(i[h],i[h+1],t[p],t[p+1],s,l))}return c}function __(i,e,t,n,s,l){if(!Ps(e,i.length)||!Ps(n,t.length))return NaN;let c=1/0;for(let h=e[0];h<=e[1];++h)for(let p=n[0];p<=n[1];++p)if((c=Math.min(c,qc(i[h],t[p],s,l)))===0)return c;return c}function g_(i,e,t,n){if(Un(i,e,!0))return 0;let s=1/0;for(const l of e){const c=l.length;if(c<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(l[0]!==l[c-1]&&(s=Math.min(s,Wc(i,l[c-1],l[0],t,n)))===0||(s=Math.min(s,td(i,l,t,n)))===0)return s}return s}function y_(i,e,t,n,s){if(!Ps(e,i.length))return NaN;for(let c=e[0];c<=e[1];++c)if(Un(i[c],t,!0))return 0;let l=1/0;for(let c=e[0];c<e[1];++c)for(const h of t)for(let p=0,_=h.length,y=_-1;p<_;y=p++){if(Ws(i[c],i[c+1],h[y],h[p]))return 0;l=Math.min(l,id(i[c],i[c+1],h[y],h[p],n,s))}return l}function Vf(i,e){for(const t of i)for(let n=0;n<=t.length-1;++n)if(Un(t[n],e,!0))return!0;return!1}function x_(i,e,t,n,s=1/0){const l=Lo(i),c=Lo(e);if(s!==1/0&&ul(l,c,t,n)>=s)return s;if(Ya(l,c)){if(Vf(i,e))return 0}else if(Vf(e,i))return 0;let h=s;for(const p of i)for(let _=0,y=p.length,v=y-1;_<y;v=_++)for(const b of e)for(let T=0,S=b.length,A=S-1;T<S;A=T++){if(Ws(p[v],p[_],b[A],b[T]))return 0;h=Math.min(h,id(p[v],p[_],b[A],b[T],t,n))}return h}function sc(i,e,t,n,s,l,c,h){if(c===null||h===null)return;const p=ul(cl(s,c),cl(l,h),t,n);p<e&&i.push({dist:p,range1:c,range2:h})}function v_(i,e,t,n,s,l=1/0){let c=Math.min(qc(i[0],t[0][0],n,s),l);if(c===0)return c;const h=new Gc([{dist:0,range1:[0,i.length-1],range2:[0,0]}],kf),p=e?50:100,_=Lo(t);for(;h.length;){const y=h.pop();if(y.dist>=c)continue;const v=y.range1;if(Yu(v)<=p){if(!Ps(v,i.length))return NaN;if(e){const b=y_(i,v,t,n,s);if((c=Math.min(c,b))===0)return c}else for(let b=v[0];b<=v[1];++b){const T=g_(i[b],t,n,s);if((c=Math.min(c,T))===0)return c}}else{const b=ba(v,e);if(b[0]!==null){const T=ul(cl(i,b[0]),_,n,s);T<c&&h.push({dist:T,range1:b[0],range2:[0,0]})}if(b[1]!==null){const T=ul(cl(i,b[1]),_,n,s);T<c&&h.push({dist:T,range1:b[1],range2:[0,0]})}}}return c}function Qu(i,e,t,n,s,l,c=1/0){let h=Math.min(c,qc(i[0],t[0],s,l));if(h===0)return h;const p=new Gc([{dist:0,range1:[0,i.length-1],range2:[0,t.length-1]}],kf),_=e?50:100,y=n?50:100;for(;p.length;){const v=p.pop();if(v.dist>=h)continue;const b=v.range1,T=v.range2;if(Yu(b)<=_&&Yu(T)<=y){if(!Ps(b,i.length)||!Ps(T,t.length))return NaN;if(e&&n?h=Math.min(h,m_(i,b,t,T,s,l)):e||n?e&&!n?h=Math.min(h,Ju(t,T,i,b,s,l)):!e&&n&&(h=Math.min(h,Ju(i,b,t,T,s,l))):h=Math.min(h,__(i,b,t,T,s,l)),h===0)return h}else{const S=ba(b,e),A=ba(T,n);sc(p,h,s,l,i,t,S[0],A[0]),sc(p,h,s,l,i,t,S[0],A[1]),sc(p,h,s,l,i,t,S[1],A[0]),sc(p,h,s,l,i,t,S[1],A[1])}}return h}function rd(i,e,t,n,s,l=1/0){let c=l;const h=cl(i,[0,i.length-1]);for(const p of t)if(!(c!==1/0&&ul(h,cl(p,[0,p.length-1]),n,s)>=c)&&(c=Math.min(c,Qu(i,e,p,!0,n,s,c)),c===0))return c;return c}function eh(i,e,t,n,s,l=1/0){let c=l;const h=cl(i,[0,i.length-1]);for(const p of t){if(c!==1/0&&ul(h,Lo(p),n,s)>=c)continue;const _=v_(i,e,p,n,s,c);if(isNaN(_))return _;if((c=Math.min(c,_))===0)return c}return c}function Uf(i,e,t){const n=[];for(const c of i)for(const h of c)n.push(Ku(h,e));const[s,l]=ed(n[0][1]);return t.type==="Point"||t.type==="MultiPoint"||t.type==="LineString"?Qu(n,!1,t.type==="Point"?[t.coordinates]:t.coordinates,t.type==="LineString",s,l):t.type==="MultiLineString"?rd(n,!1,t.coordinates,s,l):t.type==="Polygon"||t.type==="MultiPolygon"?eh(n,!1,t.type==="Polygon"?[t.coordinates]:t.coordinates,s,l):null}function b_(i,e,t){const n=[];for(const c of i){const h=[];for(const p of c)h.push(Ku(p,e));n.push(h)}const[s,l]=ed(n[0][0][1]);if(t.type==="Point"||t.type==="MultiPoint"||t.type==="LineString")return rd(t.type==="Point"?[t.coordinates]:t.coordinates,t.type==="LineString",n,s,l);if(t.type==="MultiLineString"){let c=1/0;for(let h=0;h<t.coordinates.length;h++){const p=rd(t.coordinates[h],!0,n,s,l,c);if(isNaN(p))return p;if((c=Math.min(c,p))===0)return c}return c}if(t.type==="Polygon"||t.type==="MultiPolygon"){let c=1/0;for(let h=0;h<n.length;h++){const p=eh(n[h],!0,t.type==="Polygon"?[t.coordinates]:t.coordinates,s,l,c);if(isNaN(p))return p;if((c=Math.min(c,p))===0)return c}return c}return null}function hl(i,e,t){const n=[];for(const c of Ei(i,0)){const h=[];for(let p=0;p<c.length;++p)h.push(p_(c[p],e));n.push(h)}const[s,l]=ed(n[0][0][0][1]);if(t.type==="Point"||t.type==="MultiPoint"||t.type==="LineString")return eh(t.type==="Point"?[t.coordinates]:t.coordinates,t.type==="LineString",n,s,l);if(t.type==="MultiLineString"){let c=1/0;for(let h=0;h<t.coordinates.length;h++){const p=eh(t.coordinates[h],!0,n,s,l,c);if(isNaN(p))return p;if((c=Math.min(c,p))===0)return c}return c}return t.type==="Polygon"||t.type==="MultiPolygon"?function(c,h,p,_){let y=1/0;for(const v of c)for(const b of h){const T=x_(v,b,p,_,y);if(isNaN(T))return T;if((y=Math.min(y,T))===0)return y}return y}(t.type==="Polygon"?[t.coordinates]:t.coordinates,n,s,l):null}function nd(i){return i==="Point"||i==="MultiPoint"||i==="LineString"||i==="MultiLineString"||i==="Polygon"||i==="MultiPolygon"}function jf(i){if(!Ys(i)||typeof i!="object"||i===null||Array.isArray(i))return null;const e=i;if(e.type==="FeatureCollection"){if(e.features.length===0)return null;const t=[];for(const n of e.features){if(!nd(n.geometry.type))return null;t.push(n.geometry)}return t}return e.type==="Feature"?nd(e.geometry.type)?[e.geometry]:null:nd(e.type)?[e]:null}class dl{constructor(e){this.type=st,this.geojson=e}static parse(e,t){if(e.length!==2)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);const n=e[1],s=Ys(n)&&!Array.isArray(n),l=t.parse(s?["literal",n]:n,1,qt);if(!l)return null;for(const[c,h]of[[["measure-light"],"brightness"],[["pitch"],"pitch"],[["distance-from-center"],"distance-from-center"]])if(!Jo(l,c))return t.error(`'distance' expression may not depend on ${h}.`);return va(l)?l instanceof Ko&&!jf(l.value)?t.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj]."):new dl(l):t.error("'distance' expression may not depend on feature-state.")}evaluate(e){const t=jf(this.geojson.evaluate(e));if(!t)return console.warn("Distance Expression: could not resolve a valid Point/LineString/Polygon GeoJSON geometry."),null;const n=e.geometry(),s=e.canonicalID();if(n==null||s==null)return console.warn("Distance Expression: requires valid feature and canonical information."),null;const l=e.geometryType(),c=l==="Point"?Uf:l==="LineString"?b_:l==="Polygon"?hl:null;if(!c)return console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries."),null;let h=1/0;for(const p of t){const _=c(n,s,p);if(_==null||isNaN(_))return _;if((h=Math.min(h,_))===0)break}return h}eachChild(e){e(this.geojson)}outputDefined(){return!0}serialize(){return["distance",this.geojson.serialize()]}}class Xc{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(e.length!==2||typeof e[1]!="string")return t.error("'var' expression requires exactly one string literal argument.");const n=e[1];return t.scope.has(n)?new Xc(n,t.scope.get(n)):t.error(`Unknown variable "${n}". Make sure "${n}" 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 Yc{constructor(e,t=[],n,s=new rl,l=[],c,h,p){this.registry=e,this.path=t,this.scope=s,this.errors=l,this.expectedType=n,this._scope=c,this.options=h,this.iconImageUseTheme=p}get key(){let e="";for(let t=0;t<this.path.length;t++){const n=this.path[t];e+=typeof n=="string"?`['${n}']`:`[${n}]`}return e}parse(e,t,n,s,l={}){if(t||n){const c=this.expectedType,h=this.scope;s&&(this.scope=this.scope.concat(s)),this.expectedType=n||null;const p=typeof t=="number";p&&this.path.push(t);const _=this._parse(e,l);return p&&this.path.pop(),this.expectedType=c,this.scope=h,_}return this._parse(e,l)}parseObjectValue(e,t,n,s,l,c={}){const h=this.expectedType,p=this.scope;l&&(this.scope=this.scope.concat(l)),this.expectedType=s||null,this.path.push(t),this.path.push(n);const _=this._parse(e,c);return this.path.pop(),this.path.pop(),this.expectedType=h,this.scope=p,_}_parse(e,t){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", []].');const n=typeof e[0]=="string"&&Object.hasOwn(this.registry,e[0])?this.registry[e[0]]:void 0;if(n){let s=n.parse(e,this);if(!s)return null;if(this.expectedType){const l=this.expectedType,c=s.type;if(l.kind!=="string"&&l.kind!=="number"&&l.kind!=="boolean"&&l.kind!=="object"&&l.kind!=="array"||c.kind!=="value")if(l.kind!=="color"&&l.kind!=="formatted"&&l.kind!=="resolvedImage"||c.kind!=="value"&&c.kind!=="string"){if(this.checkSubtype(l,c))return null}else s=Gf(s,l,t.typeAnnotation||"coerce");else s=Gf(s,l,t.typeAnnotation||"assert")}if(!(s instanceof Ko)&&s.type.kind!=="resolvedImage"&&od(s)){const l=new ho(this._scope,this.options,this.iconImageUseTheme);try{s=new Ko(s.type,s.evaluate(l))}catch(c){return this.error(c.message),null}}return s}return Rs.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.`)}concat(e,t,n,s){const l=s?this.scope.concat(s):this.scope,c=this.path.slice();return typeof e=="number"&&c.push(e),typeof t=="string"&&c.push(t),new Yc(this.registry,c,n||null,l,this.errors,this._scope,this.options,this.iconImageUseTheme)}_forkForSignature(){return new Yc(this.registry,this.path.slice(),null,this.scope,[],this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const n=`${this.key}${t.map(s=>`[${s}]`).join("")}`;this.errors.push(new dn(n,e))}checkSubtype(e,t,n){const s=Ln(e,t);return s&&this.error(s,...typeof n=="number"?[n]:[]),s}}const fl=new Set(["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 Gf(i,e,t){return t==="assert"?new Tt(e,[i]):t==="coerce"?new Rs(e,[i]):i}function od(i){if(i instanceof Xc)return od(i.boundExpression);if(i instanceof En&&i.name==="error"||i instanceof xa||i instanceof sl||i instanceof dl||i instanceof oc)return!1;const e=i instanceof Rs||i instanceof Tt;let t=!0;return i.eachChild(n=>{t=e?t&&od(n):t&&n instanceof Ko}),!!t&&al(i)&&Hc(i,fl)}function th(i,e){const t=i.length-1;let n,s,l=0,c=t,h=0;for(;l<=c;)if(h=Math.floor((l+c)/2),n=i[h],s=i[h+1],n<=e){if(h===t||e<s)return h;l=h+1}else{if(!(n>e))throw new xr("Input is not a number.");c=h-1}return 0}class pl{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[s,l]of n)this.labels.push(s),this.outputs.push(l)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const n=t.parse(e[1],1,st);if(!n)return null;const s=[];let l=null;t.expectedType&&t.expectedType.kind!=="value"&&(l=t.expectedType);for(let c=1;c<e.length;c+=2){const h=c===1?-1/0:e[c],p=e[c+1],_=c,y=c+1;if(typeof h!="number")return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not c
1omputed expressions) for the input values.',_);if(s.length&&s.at(-1)[0]>=h)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',_);const v=t.parse(p,y,l);if(!v)return null;l=l||v.type,s.push([h,v])}return new pl(l,n,s)}evaluate(e){const t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);const s=this.input.evaluate(e);if(s<=t[0])return n[0].evaluate(e);const l=t.length;return s>=t[l-1]?n[l-1].evaluate(e):n[th(t,s)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const Hf=.95047,Gi=1.08883,Zf=4/29,ac=6/29,$f=3*ac*ac,w_=ac*ac*ac,T_=Math.PI/180,E_=180/Math.PI;function sd(i){return i>w_?Math.pow(i,1/3):i/$f+Zf}function ad(i){return i>ac?i*i*i:$f*(i-Zf)}function ld(i){return 255*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055)}function cd(i){return(i/=255)<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function qf(i){const e=cd(i.r),t=cd(i.g),n=cd(i.b),s=sd((.4124564*e+.3575761*t+.1804375*n)/Hf),l=sd((.2126729*e+.7151522*t+.072175*n)/1);return{l:116*l-16,a:500*(s-l),b:200*(l-sd((.0193339*e+.119192*t+.9503041*n)/Gi)),alpha:i.a}}function Wf(i){let e=(i.l+16)/116,t=isNaN(i.a)?e:e+i.a/500,n=isNaN(i.b)?e:e-i.b/200;return e=1*ad(e),t=Hf*ad(t),n=Gi*ad(n),new Pt(ld(3.2404542*t-1.5371385*e-.4985314*n),ld(-.969266*t+1.8760108*e+.041556*n),ld(.0556434*t-.2040259*e+1.0572252*n),i.alpha)}function S_(i,e,t){const n=e-i;return i+t*(n>180||n<-180?n-360*Math.round(n/360):n)}const Kc={forward:qf,reverse:Wf,interpolate:function(i,e,t){return{l:lt(i.l,e.l,t),a:lt(i.a,e.a,t),b:lt(i.b,e.b,t),alpha:lt(i.alpha,e.alpha,t)}}},Jc={forward:function(i){const{l:e,a:t,b:n}=qf(i),s=Math.atan2(n,t)*E_;return{h:s<0?s+360:s,c:Math.sqrt(t*t+n*n),l:e,alpha:i.a}},reverse:function(i){const e=i.h*T_,t=i.c;return Wf({l:i.l,a:Math.cos(e)*t,b:Math.sin(e)*t,alpha:i.alpha})},interpolate:function(i,e,t){return{h:S_(i.h,e.h,t),c:lt(i.c,e.c,t),l:lt(i.l,e.l,t),alpha:lt(i.alpha,e.alpha,t)}}};var Xf=Object.freeze({__proto__:null,hcl:Jc,lab:Kc});class zo{constructor(e,t,n,s,l){this.type=e,this.operator=t,this.interpolation=n,this.input=s,this.labels=[],this.outputs=[];for(const[c,h]of l)this.labels.push(c),this.outputs.push(h)}static interpolationFactor(e,t,n,s){let l=0;if(e.name==="exponential")l=ud(t,e.base,n,s);else if(e.name==="linear")l=ud(t,1,n,s);else if(e.name==="cubic-bezier"){const c=e.controlPoints;l=Lc(c[0],c[1],c[2],c[3])(ud(t,1,n,s))}return l}static parse(e,t){let[n,s,l,...c]=e;if(!Array.isArray(s)||s.length===0)return t.error("Expected an interpolation type expression.",1);if(s[0]==="linear")s={name:"linear"};else if(s[0]==="exponential"){const _=s[1];if(typeof _!="number")return t.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:_}}else{if(s[0]!=="cubic-bezier")return t.error(`Unknown interpolation type ${String(s[0])}`,1,0);{const _=s.slice(1);if(_.length!==4||_.some(y=>typeof y!="number"||y<0||y>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:_}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(l=t.parse(l,2,st),!l)return null;const h=[];let p=null;n==="interpolate-hcl"||n==="interpolate-lab"?p=nn:t.expectedType&&t.expectedType.kind!=="value"&&(p=t.expectedType);for(let _=0;_<c.length;_+=2){const y=c[_],v=c[_+1],b=_+3,T=_+4;if(typeof y!="number")return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',b);if(h.length&&h.at(-1)[0]>=y)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',b);const S=t.parse(v,T,p);if(!S)return null;p=p||S.type,h.push([y,S])}return p.kind==="number"||p.kind==="color"||p.kind==="array"&&p.itemType.kind==="number"&&typeof p.N=="number"?new zo(p,n,s,l,h):t.error(`Type ${Bi(p)} is not interpolatable.`)}evaluate(e){const t=this.labels,n=this.outputs;if(t.length===1)return n[0].evaluate(e);const s=this.input.evaluate(e);if(s<=t[0])return n[0].evaluate(e);const l=t.length;if(s>=t[l-1])return n[l-1].evaluate(e);const c=th(t,s),h=zo.interpolationFactor(this.interpolation,s,t[c],t[c+1]),p=n[c].evaluate(e),_=n[c+1].evaluate(e);return this.operator==="interpolate"?da[this.type.kind.toLowerCase()](p,_,h):this.operator==="interpolate-hcl"?Jc.reverse(Jc.interpolate(Jc.forward(p),Jc.forward(_),h)):Kc.reverse(Kc.interpolate(Kc.forward(p),Kc.forward(_),h))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}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];const t=[this.operator,e,this.input.serialize()];for(let n=0;n<this.labels.length;n++)t.push(this.labels[n],this.outputs[n].serialize());return t}}function ud(i,e,t,n){const s=n-t,l=i-t;return s===0?0:e===1?l/s:(Math.pow(e,l)-1)/(Math.pow(e,s)-1)}class ih{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument."),null;let n=null;const s=t.expectedType;s&&s.kind!=="value"&&(n=s);const l=[];for(const h of e.slice(1)){const p=t.parse(h,1+l.length,n,void 0,{typeAnnotation:"omit"});if(!p)return null;n=n||p.type,l.push(p)}const c=s&&l.some(h=>Ln(s,h.type));return new ih(c?qt:n,l)}
vendor: 30,620 bytes, line 1
1evaluate(e){let t,n=null,s=0;for(const l of this.args){if(s++,n=l.evaluate(e),n&&n instanceof fn&&!n.available&&(t||(t=n),n=null,s===this.args.length))return t;if(n!==null)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize())}),e}}const I_=/[^a-zA-Z0-9_]/;class rh{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const n=[];for(let l=1;l<e.length-1;l+=2){const c=e[l];if(typeof c!="string")return t.error(`Expected string, but found ${typeof c} instead.`,l);if(I_.test(c))return t.error("Variable names must contain only alphanumeric characters or '_'.",l);const h=t.parse(e[l+1],l+1);if(!h)return null;n.push([c,h])}const s=t.parse(e.at(-1),e.length-1,t.expectedType,n);return s?new rh(n,s):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,n]of this.bindings)e.push(t,n.serialize());return e.push(this.result.serialize()),e}}class hd{constructor(e,t,n){this.type=e,this.index=t,this.input=n}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,st),s=t.parse(e[2],2,ji(t.expectedType||qt));return n&&s?new hd(s.type.itemType,n,s):null}evaluate(e){const t=this.index.evaluate(e),n=this.input.evaluate(e);if(t<0)throw new xr("Array index out of bounds: negative index");if(t>=n.length)throw new xr("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new xr("Array index must be an integer. Use at-interpolated for fractional indices");return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class dd{constructor(e,t,n){this.type=e,this.index=t,this.input=n}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,st),s=t.parse(e[2],2,ji(t.expectedType||qt));return n&&s?new dd(s.type.itemType,n,s):null}evaluate(e){const t=this.index.evaluate(e),n=this.input.evaluate(e);if(t<0)throw new xr(`Array index out of bounds: ${t} < 0.`);if(t>n.length-1)throw new xr(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t===Math.floor(t))return n[t];const s=Math.floor(t),l=Math.ceil(t),c=n[s],h=n[l];if(typeof c!="number"||typeof h!="number")throw new xr(`Cannot interpolate between non-number values at index ${t}.`);return lt(c,h,t-s)}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class fd{constructor(e,t,n,s,l,c){this.inputType=e,this.type=t,this.input=n,this.cases=s,this.outputs=l,this.otherwise=c}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let n,s;t.expectedType&&t.expectedType.kind!=="value"&&(s=t.expectedType);const l={},c=[];for(let _=2;_<e.length-1;_+=2){let y=e[_];const v=e[_+1];if(Array.isArray(y)||(y=[y]),y.length===0)return t.error("Expected at least one branch label.",_);for(const T of y){if(typeof T!="number"&&typeof T!="string")return t.error("Branch labels must be numbers or strings.",_);if(typeof T=="number"&&Math.abs(T)>Number.MAX_SAFE_INTEGER)return t.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`,_);if(typeof T=="number"&&Math.floor(T)!==T)return t.error("Numeric branch labels must be integer values.",_);if(n){if(t.checkSubtype(n,Nr(T),_))return null}else n=Nr(T);if(l[String(T)]!==void 0)return t.error("Branch labels must be unique.",_);l[String(T)]=c.length}const b=t.parse(v,_,s);if(!b)return null;s=s||b.type,c.push(b)}const h=t.parse(e[1],1,qt);if(!h)return null;const p=t.parse(e.at(-1),e.length-1,s);return p?h.type.kind!=="value"&&t.checkSubtype(n,h.type,1)?null:new fd(n,s,h,l,c,p):null}evaluate(e){const t=this.input.evaluate(e);return(nl(Nr(t),this.inputType)&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),n=[],s={};for(const c of t){const h=s[this.cases[c]];h===void 0?(s[this.cases[c]]=n.length,n.push([this.cases[c],[c]])):n[h][1].push(c)}const l=c=>this.inputType.kind==="number"?Number(c):c;for(const[c,h]of n)e.push(h.length===1?l(h[0]):h.map(l)),e.push(this.outputs[c].serialize());return e.push(this.otherwise.serialize()),e}}class pd{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return t.error("Expected an odd number of arguments."),null;let n;t.expectedType&&t.expectedType.kind!=="value"&&(n=t.expectedType);const s=[];for(let c=1;c<e.length-1;c+=2){const h=t.parse(e[c],c,$t);if(!h)return null;const p=t.parse(e[c+1],c+1,n);if(!p)return null;s.push([h,p]),n=n||p.type}const l=t.parse(e.at(-1),e.length-1,n);return l?new pd(n,s,l):null}evaluate(e){for(const[t,n]of this.branches)if(t.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,n]of this.branches)e(t),e(n);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}class nh{constructor(e,t,n,s){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=s}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const n=t.parse(e[1],1,qt),s=t.parse(e[2],2,st);if(!n||!s)return null;if(l=n.type,![ji(qt),ti,qt].some(c=>c.kind===l.kind))return t.error(`Expected first argument to be of type array or string, but found ${Bi(n.type)} instead`),null;var l;if(e.length===4){const c=t.parse(e[3],3,st);return c?new nh(n.type,n,s,c):null}return new nh(n.type,n,s)}evaluate(e){const t=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!Jl(t,["string","array"]))throw new xr(`Expected first argument to be of type array or string, but found ${Bi(Nr(t))} instead.`);if(this.endIndex){const s=this.endIndex.evaluate(e);return t.slice(n,s)}return t.slice(n)}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){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Yf(i,e){return i==="=="||i==="!="?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 Kf(i,e,t,n){return n.compare(e,t)===0}function lc(i,e,t){const n=i!=="=="&&i!=="!=";return class Rb{constructor(l,c,h){this.type=$t,this.lhs=l,this.rhs=c,this.collator=h,this.hasUntypedArgument=l.type.kind==="value"||c.type.kind==="value"}static parse(l,c){if(l.length!==3&&l.length!==4)return c.error("Expected two or three arguments.");const h=l[0];let p=c.parse(l[1],1,qt);if(!p)return null;if(!Yf(h,p.type))return c.error(`"${h}" comparisons are not supported for type '${Bi(p.type)}'.`,1);let _=c.parse(l[2],2,qt);if(!_)return null;if(!Yf(h,_.type))return c.error(`"${h}" comparisons are not supported for type '${Bi(_.type)}'.`,2);if(p.type.kind!==_.type.kind&&p.type.kind!=="value"&&_.type.kind!=="value")return c.error(`Cannot compare types '${Bi(p.type)}' and '${Bi(_.type)}'.`);n&&(p.type.kind==="value"&&_.type.kind!=="value"?p=new Tt(_.type,[p]):p.type.kind!=="value"&&_.type.kind==="value"&&(_=new Tt(p.type,[_])));let y=null;if(l.length===4){if(p.type.kind!=="string"&&_.type.kind!=="string"&&p.type.kind!=="value"&&_.type.kind!=="value")return c.error("Cannot use collator to compare non-string types.");if(y=c.parse(l[3],3,co),!y)return null}return new Rb(p,_,y)}evaluate(l){const c=this.lhs.evaluate(l),h=this.rhs.evaluate(l);if(n&&this.hasUntypedArgument){const p=Nr(c),_=Nr(h);if(p.kind!==_.kind||p.kind!=="string"&&p.kind!=="number")throw new xr(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${p.kind}, ${_.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const p=Nr(c),_=Nr(h);if(p.kind!=="string"||_.kind!=="string")return e(l,c,h)}return this.collator?t(l,c,h,this.collator.evaluate(l)):e(l,c,h)}eachChild(l){l(this.lhs),l(this.rhs),this.collator&&l(this.collator)}outputDefined(){return!0}serialize(){const l=[i];return this.eachChild(c=>{l.push(c.serialize())}),l}}}const A_=lc("==",function(i,e,t){return e===t},Kf),C_=lc("!=",function(i,e,t){return e!==t},function(i,e,t,n){return!Kf(0,e,t,n)}),md=lc("<",function(i,e,t){return e<t},function(i,e,t,n){return n.compare(e,t)<0}),oh=lc(">",function(i,e,t){return e>t},function(i,e,t,n){return n.compare(e,t)>0}),Jf=lc("<=",function(i,e,t){return e<=t},function(i,e,t,n){return n.compare(e,t)<=0}),M_=lc(">=",function(i,e,t){return e>=t},function(i,e,t,n){return n.compare(e,t)>=0});class _d{constructor(e,t,n,s,l,c){this.type=ti,this.number=e,this.locale=t,this.currency=n,this.unit=s,this.minFractionDigits=l,this.maxFractionDigits=c}static parse(e,t){if(e.length!==3)return t.error("Expected two arguments.");const n=t.parse(e[1],1,st);if(!n)return null;const s=e[2];if(typeof s!="object"||Array.isArray(s))return t.error("NumberFormat options argument must be an object.");let l=null;if(s.locale&&(l=t.parseObjectValue(s.locale,2,"locale",ti),!l))return null;let c=null;if(s.currency&&(c=t.parseObjectValue(s.currency,2,"currency",ti),!c))return null;let h=null;if(s.unit&&(h=t.parseObjectValue(s.unit,2,"unit",ti),!h))return null;let p=null;if(s["min-fraction-digits"]!==void 0&&(p=t.parseObjectValue(s["min-fraction-digits"],2,"min-fraction-digits",st),!p))return null;let _=null;return s["max-fraction-digits"]===void 0||(_=t.parseObjectValue(s["max-fraction-digits"],2,"max-fraction-digits",st),_)?new _d(n,l,c,h,p,_):null}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(){const 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 gd{constructor(e){this.type=st,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;const n=t.parse(e[1],1);return n?n.type.kind!=="array"&&n.type.kind!=="string"&&n.type.kind!=="value"?(t.error(`Expected argument of type string or array, but found ${Bi(n.type)} instead.`),null):new gd(n):null}evaluate(e){const t=this.input.evaluate(e);if(typeof t=="string"||Array.isArray(t))return t.length;throw new xr(`Expected value to be of type string or array, but found ${Bi(Nr(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}function sh(i){return function(){i=1831565813+(i|=0)|0;let e=Math.imul(i^i>>>15,1|i);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const ml={"==":A_,"!=":C_,">":oh,"<":md,">=":M_,"<=":Jf,array:Tt,at:hd,"at-interpolated":dd,boolean:Tt,case:pd,coalesce:ih,collator:xa,format:Zn,image:_a,interpolate:zo,"interpolate-hcl":zo,"interpolate-lab":zo,length:gd,let:rh,literal:Ko,match:fd,number:Tt,"number-format":_d,object:Tt,slice:nh,step:pl,string:Tt,"to-boolean":Rs,"to-color":Rs,"to-number":Rs,"to-string":Rs,var:Xc,within:sl,distance:dl,config:oc};function _l(i,[e,t,n,s]){e=e.evaluate(i),t=t.evaluate(i),n=n.evaluate(i);const l=s?s.evaluate(i):1,c=Uc(e,t,n,l);if(c)throw new xr(c);return new Pt(e/255,t/255,n/255,l)}function yd(i,[e,t,n,s]){e=e.evaluate(i),t=t.evaluate(i),n=n.evaluate(i);const l=s?s.evaluate(i):1,c=function(_,y,v,b){return typeof _=="number"&&_>=0&&_<=360?typeof y=="number"&&y>=0&&y<=100&&typeof v=="number"&&v>=0&&v<=100?b===void 0||typeof b=="number"&&b>=0&&b<=1?null:`Invalid hsla value [${[_,y,v,b].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof b=="number"?[_,y,v,b]:[_,y,v]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof b=="number"?[_,y,v,b]:[_,y,v]).join(", ")}]: 'h' must be between 0 and 360.`}(e,t,n,l);if(c)throw new xr(c);const h=`hsla(${e}, ${t}%, ${n}%, ${l})`,p=Pt.parse(h);if(!p)throw new xr(`Failed to parse HSLA color: ${h}`);return p}function Qf(i,e){return i in e}function Qc(i,e){const t=e[i];return t===void 0?null:t}function wa(i){return{type:i}}function xd(i,e){if(!Jl(i,["boolean","string","number","null"]))throw new xr(`Expected first argument to be of type boolean, string, number or null, but found ${Bi(Nr(i))} instead.`);if(!Jl(e,["string","array"]))throw new xr(`Expected second argument to be of type array or string, but found ${Bi(Nr(e))} instead.`)}function eu(i){if(i instanceof oc)return new Set([i.key]);let e=new Set;return i.eachChild(t=>{e=new Set([...e,...eu(t)])}),e}function tu(i){if(i instanceof En&&i.name==="is-active-floor")return!0;let e=!1;return i.eachChild(t=>{!e&&tu(t)&&(e=!0)}),e}function ep(i){return{result:"success",value:i}}function Ta(i){return{result:"error",value:i}}function vd(i,e){return!!i&&!!i.parameters&&i.parameters.includes(e)}function iu(i){return i["property-type"]==="data-driven"}function bd(i){return vd(i.expression,"measure-light")}function wd(i){return vd(i.expression,"zoom")}function Td(i){return!!i.expression&&i.expression.interpolated}function Ed(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function R_(i){return i}function tp(i,e){const t=e.type==="color",n=i.stops&&typeof i.stops[0][0]=="object",s=n||!(n||i.property!==void 0),l=i.type||(Td(e)?"exponential":"interval");if(t&&((i={...i}).stops&&(i.stops=i.stops.map(_=>[_[0],Pt.parse(_[1])])),i.default=Pt.parse(i.default?i.default:e.default)),i.colorSpace&&i.colorSpace!=="rgb"&&!Xf[i.colorSpace])throw new Error(`Unknown color space: ${i.colorSpace}`);let c,h,p;if(l==="exponential")c=rp;else if(l==="interval")c=ip;else if(l==="categorical"){c=P_,h=Object.create(null);for(const _ of i.stops)h[_[0]]=_[1];p=typeof i.stops[0][0]}else{if(l!=="identity")throw new Error(`Unknown function type "${l}"`);c=np}if(n){const _={},y=[];for(let T=0;T<i.stops.length;T++){const S=i.stops[T],A=S[0].zoom;_[A]===void 0&&(_[A]={zoom:A,type:i.type,property:i.property,default:i.default,stops:[]},y.push(A)),_[A].stops.push([S[0].value,S[1]])}const v=[];for(const T of y)v.push([_[T].zoom,tp(_[T],e)]);const b={name:"linear"};return{kind:"composite",interpolationType:b,interpolationFactor:zo.interpolationFactor.bind(void 0,b),zoomStops:v.map(T=>T[0]),evaluate:({zoom:T},S)=>rp({stops:v,base:i.base},e,T).evaluate(T,S)}}if(s){const _=l==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:_,interpolationFactor:zo.interpolationFactor.bind(void 0,_),zoomStops:i.stops.map(y=>y[0]),evaluate:({zoom:y})=>c(i,e,y,h,p)}}return{kind:"source",evaluate(_,y){const v=y&&y.properties?y.properties[i.property]:void 0;return v===void 0?ru(i.default,e.default):c(i,e,v,h,p)}}}function ru(i,e,t){return i!==void 0?i:e!==void 0?e:t!==void 0?t:void 0}function P_(i,e,t,n,s){return ru(typeof t===s?n[t]:void 0,i.default,e.default)}function ip(i,e,t){if(!ya(t))return ru(i.default,e.default);const n=i.stops.length;if(n===1||t<=i.stops[0][0])return i.stops[0][1];if(t>=i.stops[n-1][0])return i.stops[n-1][1];const s=th(i.stops.map(l=>l[0]),t);return i.stops[s][1]}function rp(i,e,t){const n=i.base!==void 0?i.base:1;if(!ya(t))return ru(i.default,e.default);const s=i.stops.length;if(s===1||t<=i.stops[0][0])return i.stops[0][1];if(t>=i.stops[s-1][0])return i.stops[s-1][1];const l=th(i.stops.map(y=>y[0]),t),c=function(y,v,b,T){const S=T-b,A=y-b;return S===0?0:v===1?A/S:(Math.pow(v,A)-1)/(Math.pow(v,S)-1)}(t,n,i.stops[l][0],i.stops[l+1][0]),h=i.stops[l][1],p=i.stops[l+1][1];let _=da[e.type]||R_;if(i.colorSpace&&i.colorSpace!=="rgb"){const y=Xf[i.colorSpace];_=(v,b)=>y.reverse(y.interpolate(y.forward(v),y.forward(b),c))}return typeof h.evaluate=="function"?{evaluate(...y){const v=h.evaluate.apply(void 0,y),b=p.evaluate.apply(void 0,y);if(v!==void 0&&b!==void 0)return _(v,b,c)}}:_(h,p,c)}function np(i,e,t){return e.type==="color"?t=Pt.parse(t):e.type==="formatted"?t=Sr.fromString(t.toString()):e.type==="resolvedImage"?t=fn.build(t.toString()):ol(t)===e.type||e.type==="enum"&&e.values[t]||(t=void 0),ru(t,i.default,e.default)}En.register(ml,{error:[{kind:"error"},[ti],(i,[e])=>{throw new xr(e.evaluate(i))}],typeof:[ti,[qt],(i,[e])=>Bi(Nr(e.evaluate(i)))],"to-rgba":[ji(st,4),[nn],(i,[e])=>e.evaluate(i).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[ji(st,4),[nn],(i,[e])=>e.evaluate(i).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[nn,[st,st,st],_l],rgba:[nn,[st,st,st,st],_l],hsl:[nn,[st,st,st],yd],hsla:[nn,[st,st,st,st],yd],has:{type:$t,overloads:[[[ti],(i,[e])=>Qf(e.evaluate(i),i.properties())],[[ti,lo],(i,[e,t])=>Qf(e.evaluate(i),t.evaluate(i))]]},get:{type:qt,overloads:[[[ti],(i,[e])=>Qc(e.evaluate(i),i.properties())],[[ti,lo],(i,[e,t])=>Qc(e.evaluate(i),t.evaluate(i))]]},"feature-state":[qt,[ti],(i,[e])=>Qc(e.evaluate(i),i.featureState||{})],properties:[lo,[],i=>i.properties()],"geometry-type":[ti,[],i=>i.geometryType()],worldview:[ti,[],i=>i.globals.worldview||""],"is-active-floor":[$t,wa(ti),(i,e)=>{if(!(i.globals&&i.globals.activeFloors&&i.globals.activeFloors.size>0))return!1;if(e.length===0)return!0;const t=i.globals.activeFloors;return e.some(n=>{const s=n.evaluate(i);return t.has(s)})}],id:[qt,[],i=>i.id()],zoom:[st,[],i=>i.globals.zoom],pitch:[st,[],i=>i.globals.pitch||0],"distance-from-center":[st,[],i=>i.distanceFromCenter()],"measure-light":[st,[ti],(i,[e])=>i.measureLight(e.evaluate(i))],"heatmap-density":[st,[],i=>i.globals.heatmapDensity||0],"line-progress":[st,[],i=>i.globals.lineProgress||0],"raster-value":[st,[],i=>i.globals.rasterValue||0],"raster-particle-speed":[st,[],i=>i.globals.rasterParticleSpeed||0],"sky-radial-progress":[st,[],i=>i.globals.skyRadialProgress||0],accumulated:[qt,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[st,wa(st),(i,e)=>{let t=0;for(const n of e)t+=n.evaluate(i);return t}],"*":[st,wa(st),(i,e)=>{let t=1;for(const n of e)t*=n.evaluate(i);return t}],"-":{type:st,overloads:[[[st,st],(i,[e,t])=>e.evaluate(i)-t.evaluate(i)],[[st],(i,[e])=>-e.evaluate(i)]]},"/":[st,[st,st],(i,[e,t])=>e.evaluate(i)/t.evaluate(i)],"%":[st,[st,st],(i,[e,t])=>e.evaluate(i)%t.evaluate(i)],ln2:[st,[],()=>Math.LN2],pi:[st,[],()=>Math.PI],e:[st,[],()=>Math.E],"^":[st,[st,st],(i,[e,t])=>Math.pow(e.evaluate(i),t.evaluate(i))],sqrt:[st,[st],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[st,[st],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[st,[st],(i,[e])=>Math.log(e.evaluate(i))],log2:[st,[st],(i,[e])=>Math.log2(e.evaluate(i))],sin:[st,[st],(i,[e])=>Math.sin(e.evaluate(i))],cos:[st,[st],(i,[e])=>Math.cos(e.evaluate(i))],tan:[st,[st],(i,[e])=>Math.tan(e.evaluate(i))],asin:[st,[st],(i,[e])=>Math.asin(e.evaluate(i))],acos:[st,[st],(i,[e])=>Math.acos(e.evaluate(i))],atan:[st,[st],(i,[e])=>Math.atan(e.evaluate(i))],min:[st,wa(st),(i,e)=>Math.min(...e.map(t=>t.evaluate(i)))],max:[st,wa(st),(i,e)=>Math.max(...e.map(t=>t.evaluate(i)))],abs:[st,[st],(i,[e])=>Math.abs(e.evaluate(i))],round:[st,[st],(i,[e])=>{const t=e.evaluate(i);return t<0?-Math.round(-t):Math.round(t)}],floor:[st,[st],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[st,[st],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[$t,[ti,qt],(i,[e,t])=>i.properties()[e.value]===t.value],"filter-id-==":[$t,[qt],(i,[e])=>i.id()===e.value],"filter-type-==":[$t,[ti],(i,[e])=>i.geometryType()===e.value],"filter-<":[$t,[ti,qt],(i,[e,t])=>{const n=i.properties()[e.value],s=t.value;return typeof n==typeof s&&n<s}],"filter-id-<":[$t,[qt],(i,[e])=>{const t=i.id(),n=e.value;return typeof t==typeof n&&t<n}],"filter->":[$t,[ti,qt],(i,[e,t])=>{const n=i.properties()[e.value],s=t.value;return typeof n==typeof s&&n>s}],"filter-id->":[$t,[qt],(i,[e])=>{const t=i.id(),n=e.value;return typeof t==typeof n&&t>n}],"filter-<=":[$t,[ti,qt],(i,[e,t])=>{const n=i.properties()[e.value],s=t.value;return typeof n==typeof s&&n<=s}],"filter-id-<=":[$t,[qt],(i,[e])=>{const t=i.id(),n=e.value;return typeof t==typeof n&&t<=n}],"filter->=":[$t,[ti,qt],(i,[e,t])=>{const n=i.properties()[e.value],s=t.value;return typeof n==typeof s&&n>=s}],"filter-id->=":[$t,[qt],(i,[e])=>{const t=i.id(),n=e.value;return typeof t==typeof n&&t>=n}],"filter-has":[$t,[qt],(i,[e])=>e.value in i.properties()],"filter-has-id":[$t,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[$t,[ji(ti)],(i,[e])=>e.value.includes(i.geometryType())],"filter-id-in":[$t,[ji(qt)],(i,[e])=>e.value.includes(i.id())],"filter-in-small":[$t,[ti,ji(qt)],(i,[e,t])=>t.value.includes(i.properties()[e.value])],"filter-in-large":[$t,[ti,ji(qt)],(i,[e,t])=>function(n,s,l,c){for(;l<=c;){const h=l+c>>1;if(s[h]===n)return!0;s[h]>n?c=h-1:l=h+1}return!1}(i.properties()[e.value],t.value,0,t.value.length-1)],all:{type:$t,overloads:[[[$t,$t],(i,[e,t])=>e.evaluate(i)&&t.evaluate(i)],[wa($t),(i,e)=>{for(const t of e)if(!t.evaluate(i))return!1;return!0}]]},any:{type:$t,overloads:[[[$t,$t],(i,[e,t])=>e.evaluate(i)||t.evaluate(i)],[wa($t),(i,e)=>{for(const t of e)if(t.evaluate(i))return!0;return!1}]]},"!":[$t,[$t],(i,[e])=>!e.evaluate(i)],"is-supported-script":[$t,[ti],(i,[e])=>{const t=i.globals&&i.globals.isSupportedScript;return!t||t(e.evaluate(i))}],upcase:[ti,[ti],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[ti,[ti],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[ti,wa(qt),(i,e)=>e.map(t=>Do(t.evaluate(i))).join("")],split:[ji(ti),[ti,ti],(i,[e,t])=>e.evaluate(i).split(t.evaluate(i))],in:[$t,[qt,qt],(i,[e,t])=>{const n=e.evaluate(i),s=t.evaluate(i);return s!=null&&(xd(n,s),s.includes(n))}],"index-of":{type:st,overloads:[[[qt,qt],(i,[e,t])=>{const n=e.evaluate(i),s=t.evaluate(i);return xd(n,s),s.indexOf(n)}],[[qt,qt,st],(i,[e,t,n])=>{const s=e.evaluate(i),l=t.evaluate(i),c=n.evaluate(i);return xd(s,l),l.indexOf(s,c)}]]},"resolved-locale":[ti,[co],(i,[e])=>e.evaluate(i).resolvedLocale()],random:[st,[st,st,qt],(i,e)=>{const[t,n,s]=e.map(c=>c.evaluate(i));if(t>n||t===n)return t;let l;if(typeof s=="string")l=function(c){let h=0;if(c.length===0)return h;for(let p=0;p<c.length;p++)h=(h<<5)-h+c.charCodeAt(p),h&=h;return h}(s);else{if(typeof s!="number")throw new xr(`Invalid seed input: ${s}`);l=s}return t+sh(l)()*(n-t)}]});class ah{constructor(e,t,n,s,l){this.expression=e,this._warningHistory={},this._scope=n,this._options=s,this._iconImageUseTheme=l,this._evaluator=new ho(n,s,l),this._defaultValue=t?function(c){return c.type==="color"&&(Ed(c.default)||Array.isArray(c.default))?new Pt(0,0,0,0):c.type==="color"?Pt.parse(c.default)||null:c.default===void 0?null:c.default}(t):null,this._enumValues=t&&t.type==="enum"?t.values:null,this.configDependencies=eu(e),this.isIndoorDependent=tu(e)}evaluateWithoutErrorHandling(e,t,n,s,l,c,h,p){const _=this._evaluator;return _.globals=e,_.feature=t,_.featureState=n,_.canonical=s||null,_.availableImages=l||null,_.formattedSection=c,_.featureTileCoord=h||null,_.featureDistanceData=p||null,this.expression.evaluate(_)}evaluate(e,t,n,s,l,c,h,p,_){this._evaluator||(this._evaluator=new ho(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=s||null,this._evaluator.availableImages=l||null,this._evaluator.formattedSection=c||null,this._evaluator.featureTileCoord=h||null,this._evaluator.featureDistanceData=p||null,this._evaluator.iconImageUseTheme=_||null;try{const y=this.expression.evaluate(this._evaluator);if(y==null||typeof y=="number"&&y!=y)return this._defaultValue;if(this._enumValues&&!(y in this._enumValues))throw new xr(`Expected value to be one of ${Object.keys(this._enumValues).map(v=>JSON.stringify(v)).join(", ")}, but found ${JSON.stringify(y)} instead.`);return y}catch(y){const v=y;return this._warningHistory[v.message]||(this._warningHistory[v.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${v.message}`)),this._defaultValue}}}function nu(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&Object.hasOwn(ml,i[0])}function Ea(i,e,t,n,s){const l=new Yc(ml,[],e?function(h){const p={color:nn,string:ti,number:st,enum:ti,boolean:$t,formatted:fs,resolvedImage:pa,object:lo};return h.type==="array"?ji(p[h.value]||qt,h.length):p[h.type]}(e):void 0,void 0,void 0,t,n,s),c=l.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return c?ep(new ah(c,e,t,n,s)):Ta(l.errors)}class lh{constructor(e,t,n,s){this.kind=e,this._styleExpression=t,this.isLightConstant=n,this.isLineProgressConstant=s,this.isStateDependent=e!=="constant"&&!va(t.expression),this.configDependencies=eu(t.expression),this.isIndoorDependent=tu(t.expression)}evaluateWithoutErrorHandling(e,t,n,s,l,c){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,s,l,c)}evaluate(e,t,n,s,l,c,h){return this._styleExpression.evaluate(e,t,n,s,l,c,void 0,void 0,h)}}class Fo{constructor(e,t,n,s,l,c){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent=e!=="camera"&&!va(t.expression),this.isIndoorDependent=tu(t.expression),this.isLightConstant=l,this.isLineProgressConstant=c,this.configDependencies=eu(t.expression),this.interpolationType=s}evaluateWithoutErrorHandling(e,t,n,s,l,c){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,s,l,c)}evaluate(e,t,n,s,l,c){return this._styleExpression.evaluate(e,t,n,s,l,c)}interpolationFactor(e,t,n){return this.interpolationType?zo.interpolationFactor(this.interpolationType,e,t,n):0}}function op(i,e,t,n,s){if((i=Ea(i,e,t,n,s)).result==="error")return i;const l=i.value.expression,c=al(l);if(!c&&!iu(e))return Ta([new dn("","data expressions not supported")]);const h=Jo(l,["zoom","pitch","distance-from-center"]);if(!h&&!wd(e))return Ta([new dn("","zoom expressions not supported")]);const p=Jo(l,["measure-light"]);if(!p&&!bd(e))return Ta([new dn("","measure-light expression not supported")]);const _=Jo(l,["line-progress"]);if(!_&&!function(b){return vd(b.expression,"line-progress")}(e))return Ta([new dn("","line-progress expression not supported")]);const y=e.expression&&e.expression.relaxZoomRestriction,v=Js(l);return v||h||y?v instanceof dn?Ta([v]):v instanceof zo&&!Td(e)?Ta([new dn("",'"interpolate" expressions cannot be used with this property')]):ep(v?new Fo(c&&_?"camera":"composite",i.value,v.labels,v instanceof zo?v.interpolation:void 0,p,_):new lh(c&&_?"constant":"source",i.value,p,_)):Ta([new dn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class ch{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,tp(this._parameters,this._specification))}static deserialize(e){return new ch(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Js(i){let e=null;if(i instanceof rh)e=Js(i.result);else if(i instanceof ih){for(const t of i.args)if(e=Js(t),e)break}else(i instanceof pl||i instanceof zo)&&i.input instanceof En&&i.input.name==="zoom"&&(e=i);return e instanceof dn||i.eachChild(t=>{const n=Js(t);n instanceof dn?e=n:e&&n&&e!==n&&(e=new dn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class ou{constructor(e,t,n){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,e instanceof ArrayBuffer){const 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];const l=this.xCellCount*this.yCellCount,c=[];for(let y=0;y<l;y++){const v=s[6+y],b=s[6+y+1];c.push(v===b?null:s.subarray(v,b))}const h=s[6+l],p=[];for(let y=0;y<l;y++){const v=s[h+y],b=s[h+y+1];p.push(v===b?null:s.subarray(v,b))}let _=s[h+l];this.boxCells=c,this.circleCells=p,this.boxKeys=s.subarray(_,_+this.boxUid),_+=this.boxUid,this.circleKeys=s.subarray(_,_+this.circleUid),_+=this.circleUid,this.bboxes=s.subarray(_,_+4*this.boxUid),_+=4*this.boxUid,this.circles=s.subarray(_,_+3*this.circleUid)}else{this.width=e,this.height=t,this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);const s=this.xCellCount*this.yCellCount,l=[],c=[];for(let h=0;h<s;h++)l.push([]),c.push([]);this.boxCells=l,this.circleCells=c,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}clear(){for(const e of this.boxCells)e&&(e.length=0);for(const e of this.circleCells)e&&(e.length=0);this.circleKeys.length=0,this.boxKeys.length=0,this.bboxes.length=0,this.circles.length=0,this.boxUid=0,this.circleUid=0}insert(e,t,n,s,l){const c=this.boxUid++,h=this._xCell(t),p=this._yCell(n),_=this._xCell(s),y=this._yCell(l);for(let v=h;v<=_;v++)for(let b=p;b<=y;b++)this.boxCells[this.xCellCount*b+v].push(c);this.boxKeys.push(e),this.bboxes.push(t,n,s,l)}
vendor: 2,103 bytes, line 1
1insertCircle(e,t,n,s){const l=this.circleUid++,c=this._xCell(t-s),h=this._yCell(n-s),p=this._xCell(t+s),_=this._yCell(n+s);for(let y=c;y<=p;y++)for(let v=h;v<=_;v++)this.circleCells[this.xCellCount*v+y].push(l);this.circleKeys.push(e),this.circles.push(t,n,s)}query(e,t,n,s,l){const c=[];if(n<0||e>this.width||s<0||t>this.height)return c;const h=this._nextGen(),{boxCells:p,circleCells:_,boxKeys:y,circleKeys:v,bboxes:b,circles:T,boxSeen:S,circleSeen:A,xCellCount:C}=this,D=this._xCell(e),z=this._yCell(t),O=this._xCell(n),F=this._yCell(s);for(let N=D;N<=O;N++)for(let j=z;j<=F;j++){const te=C*j+N,H=p[te];if(H)for(let K=0;K<H.length;K++){const ee=H[K];if(S[ee]===h)continue;S[ee]=h;const ae=4*ee,he=b[ae],be=b[ae+1],xe=b[ae+2],Te=b[ae+3];e<=xe&&t<=Te&&n>=he&&s>=be&&(!l||l(y[ee]))&&c.push({key:y[ee],x1:he,y1:be,x2:xe,y2:Te})}const W=_[te];if(W)for(let K=0;K<W.length;K++){const ee=W[K];if(A[ee]===h)continue;A[ee]=h;const ae=3*ee,he=T[ae],be=T[ae+1],xe=T[ae+2];!this._circleAndRectCollide(he,be,xe,e,t,n,s)||l&&!l(v[ee])||c.push({key:v[ee],x1:he-xe,y1:be-xe,x2:he+xe,y2:be+xe})}}return c}queryKeys(e,t,n,s,l){const c=[];if(n<0||e>this.width||s<0||t>this.height)return c;const h=this._nextGen(),{boxCells:p,boxKeys:_,bboxes:y,boxSeen:v,xCellCount:b,xScale:T,yScale:S}=this,A=this._xCell(e),C=this._yCell(t),D=this._xCell(n),z=this._yCell(s);for(let O=A;O<=D;O++)for(let F=C;F<=z;F++){if(l&&!l(O/T,F/S,(O+1)/T,(F+1)/S))continue;const N=p[b*F+O];if(N)for(let j=0;j<N.length;j++){const te=N[j];if(v[te]===h)continue;v[te]=h;const H=4*te,W=y[H],K=y[H+1],ee=y[H+2],ae=y[H+3];(l?l(W,K,ee,ae):e<=ee&&t<=ae&&n>=W&&s>=K)&&c.push(_[te])}}return c}hitTest(e,t,n,s,l){if(n<0||e>this.width||s<0||t>this.height)return!1;const c=this._nextGen(),{boxCells:h,circleCells:p,boxKeys:_,circleKeys:y,bboxes:v,circles:b,boxSeen:T,circleSeen:S,xCellCount:A}=this,C=this._xCell(e),D=this._yCell(t),z=this._xCell(n),O=this._yCell(s);for(let F=C;F<=z;F++)for(let N=D;N<=O;N++){const j=A*N+F,te=h[j];if(te)for(let W=0;W<te.length;W++){const K=te[W];if(T[K]===c)continue;T[K]=c;const ee=4*K;if(e<=v[ee+2]&&t<=v[ee+3]&&n>=v[ee]&&s>
vendor: 17,288 bytes, line 1
1=v[ee+1]&&(!l||l(_[K])))return!0}const H=p[j];if(H)for(let W=0;W<H.length;W++){const K=H[W];if(S[K]===c)continue;S[K]=c;const ee=3*K;if(this._circleAndRectCollide(b[ee],b[ee+1],b[ee+2],e,t,n,s)&&(!l||l(y[K])))return!0}}return!1}hitTestCircle(e,t,n,s){const l=e-n,c=t-n,h=e+n,p=t+n;if(h<0||l>this.width||p<0||c>this.height)return!1;const _=this._nextGen(),{boxCells:y,circleCells:v,boxKeys:b,circleKeys:T,bboxes:S,circles:A,boxSeen:C,circleSeen:D,xCellCount:z}=this,O=this._xCell(l),F=this._yCell(c),N=this._xCell(h),j=this._yCell(p);for(let te=O;te<=N;te++)for(let H=F;H<=j;H++){const W=z*H+te,K=y[W];if(K)for(let ae=0;ae<K.length;ae++){const he=K[ae];if(C[he]===_)continue;C[he]=_;const be=4*he;if(this._circleAndRectCollide(e,t,n,S[be],S[be+1],S[be+2],S[be+3])&&(!s||s(b[he])))return!0}const ee=v[W];if(ee)for(let ae=0;ae<ee.length;ae++){const he=ee[ae];if(D[he]===_)continue;D[he]=_;const be=3*he;if(this._circlesCollide(A[be],A[be+1],A[be+2],e,t,n)&&(!s||s(T[he])))return!0}}return!1}static serialize(e,t){const n=e.toArrayBuffer();return t&&t.add(n),{buffer:n}}static deserialize(e){return new ou(e.buffer)}toArrayBuffer(){const e=this.xCellCount*this.yCellCount;let t=0,n=0;for(let h=0;h<e;h++)t+=this.boxCells[h].length,n+=this.circleCells[h].length;const s=new Int32Array(6+(e+1)+t+(e+1)+n+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 h=0;h<e;h++){s[6+h]=l;const p=this.boxCells[h];s.set(p,l),l+=p.length}s[6+e]=l;const c=l;l+=e+1;for(let h=0;h<e;h++){s[c+h]=l;const p=this.circleCells[h];s.set(p,l),l+=p.length}return s[c+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}_circlesCollide(e,t,n,s,l,c){const h=s-e,p=l-t,_=n+c;return _*_>h*h+p*p}_circleAndRectCollide(e,t,n,s,l,c,h){const p=(c-s)/2,_=Math.abs(e-(s+p));if(_>p+n)return!1;const y=(h-l)/2,v=Math.abs(t-(l+y));if(v>y+n)return!1;if(_<=p||v<=y)return!0;const b=_-p,T=v-y;return b*b+T*T<=n*n}}const gl={};function et(i,e,t={}){Object.defineProperty(i,"_classRegistryKey",{value:e,writable:!1}),gl[e]={klass:i,omit:t.omit||[]}}et(Object,"Object"),et(ou,"Grid"),delete De.prototype.constructor,et(Pt,"Color"),et(Sr,"Formatted"),et(ma,"FormattedSection"),et(fn,"ResolvedImage"),et(ch,"StylePropertyFunction"),et(ah,"StyleExpression",{omit:["_evaluator"]}),et(Er,"ImageId"),et(uo,"ImageVariant"),et(Fo,"ZoomDependentExpression"),et(lh,"ZoomConstantExpression"),et(En,"CompoundExpression",{omit:["_evaluate"]});for(const i in ml)gl[ml[i]._classRegistryKey]||et(ml[i],`Expression${i}`);function sp(i){return i&&(i instanceof ArrayBuffer||i.constructor&&i.constructor.name==="ArrayBuffer")}const ap={Error,TypeError,RangeError,SyntaxError,ReferenceError,URIError,EvalError},uh=new Set(["message","stack","cause","errors","name","class"]);function po(i,e){if(i===null)return null;const t=typeof i;if(t!=="object")return t==="bigint"?{$name:"BigInt",value:i.toString()}:i;if(Array.isArray(i)){const c=i.length,h=[];h.length=c;for(let p=0;p<c;p++)h[p]=po(i[p],e);return h}if(ArrayBuffer.isView(i))return e&&e.add(i.buffer),i;if(sp(i)||i instanceof ImageBitmap)return e&&e.add(i),i;if(i instanceof ImageData)return e&&e.add(i.data.buffer),i;if(i instanceof Map){const c={$name:"Map",entries:[]};for(const[h,p]of i.entries())c.entries.push(po(h),po(p,e));return c}if(i instanceof Headers)return{$name:"Headers",entries:[...i]};if(i instanceof Set){const c={$name:"Set"};let h=0;for(const p of i.values())c[++h]=po(p);return c}if(i instanceof Date||i instanceof RegExp||i instanceof Boolean||i instanceof Number||i instanceof String)return i;if(i instanceof Error){const c=i,h=c.constructor&&c.constructor.name||"Error",p={$name:"$Error",class:c instanceof Bt?"AJAXError":c instanceof DOMException?"DOMException":c instanceof AggregateError?"AggregateError":ap[h]?h:"Error",name:c.name,message:c.message};c.stack&&(p.stack=c.stack),"cause"in c&&c.cause!==c&&(p.cause=po(c.cause,e)),c instanceof AggregateError&&(p.errors=c.errors.filter(y=>y!==c).map(y=>po(y,e)));const _=c;for(const y in _)Object.hasOwn(_,y)&&(uh.has(y)||(p[y]=po(_[y],e)));return p}const n=i.constructor||Object,s=n._classRegistryKey;if(!s)throw new Error(`Can't serialize object of unregistered class "${n.name}".`);const l=n.serialize?n.serialize(i,e):{};if(!n.serialize){const c=gl[s].omit,h=i;for(const p in h)Object.hasOwn(h,p)&&(c.includes(p)||(l[p]=po(h[p],e)))}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return s!=="Object"&&(l.$name=s),l}function Oo(i){if(i===null||typeof i!="object")return i;if(Array.isArray(i)){for(let s=0;s<i.length;s++)i[s]=Oo(i[s]);return i}if(ArrayBuffer.isView(i)||sp(i)||i instanceof ImageBitmap||i instanceof ImageData||i instanceof Date||i instanceof RegExp||i instanceof Boolean||i instanceof Number||i instanceof String)return i;const e=i.$name||"Object";if(e==="Map"){const s=i.entries||[],l=new Map;for(let c=0;c<s.length;c+=2)l.set(Oo(s[c]),Oo(s[c+1]));return l}if(e==="Headers")return new Headers(i.entries);if(e==="Set"){const s=new Set;for(const l in i)l!=="$name"&&s.add(Oo(i[l]));return s}if(e==="BigInt")return BigInt(i.value);if(e==="$Error"){const s=i.class||"Error",l=i.name||s,c=i.message||"";let h;h=s==="DOMException"?new DOMException(c,l):s==="AggregateError"?new AggregateError((i.errors||[]).map(Oo),c):s==="AJAXError"?new Bt(i.statusText,i.status,i.url):new(ap[s]||Error)(c),s!=="DOMException"&&(h.name=l),i.stack&&(h.stack=i.stack),"cause"in i&&(h.cause=Oo(i.cause));const p=h;for(const _ in i)Object.hasOwn(i,_)&&(_==="$name"||uh.has(_)||(p[_]=Oo(i[_])));return h}const{klass:t}=gl[e];if(!t)throw new Error(`Can't deserialize unregistered class "${e}".`);if(t.deserialize)return t.deserialize(i);const n=Object.create(t.prototype);for(const s in i)s!=="$name"&&(n[s]=Oo(i[s]));return n}const Sd=i=>i>=1536&&i<=1791,lp=i=>i>=1872&&i<=1919,su=i=>i>=2208&&i<=2303,au=i=>i>=11904&&i<=12031,hh=i=>i>=12032&&i<=12255,Id=i=>i>=12272&&i<=12287,lu=i=>i>=12288&&i<=12351,dh=i=>i>=12352&&i<=12447,cc=i=>i>=12448&&i<=12543,Ad=i=>i>=12544&&i<=12591,fh=i=>i>=12704&&i<=12735,cp=i=>i>=12736&&i<=12783,up=i=>i>=12784&&i<=12799,hp=i=>i>=12800&&i<=13055,dp=i=>i>=13056&&i<=13311,Cd=i=>i>=13312&&i<=19903,Ds=i=>i>=19968&&i<=40959,Md=i=>i>=40960&&i<=42127,yl=i=>i>=42128&&i<=42191,fp=i=>i>=44032&&i<=55215,pp=i=>i>=63744&&i<=64255,Rd=i=>i>=64336&&i<=65023,mp=i=>i>=65040&&i<=65055,Pd=i=>i>=65072&&i<=65103,_p=i=>i>=65104&&i<=65135,Dd=i=>i>=65136&&i<=65279,xl=i=>i>=65280&&i<=65519;function cu(i){for(const e of i)if(Ld(e.charCodeAt(0)))return!0;return!1}function gp(i){return!(Sd(i)||lp(i)||su(i)||Rd(i)||Dd(i))}function Ld(i){return!(i!==746&&i!==747&&(i<4352||!(fh(i)||Ad(i)||Pd(i)&&!(i>=65097&&i<=65103)||pp(i)||dp(i)||au(i)||cp(i)||!(!lu(i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||Cd(i)||Ds(i)||hp(i)||(e=>e>=12592&&e<=12687)(i)||(e=>e>=43360&&e<=43391)(i)||(e=>e>=55216&&e<=55295)(i)||(e=>e>=4352&&e<=4607)(i)||fp(i)||dh(i)||Id(i)||(e=>e>=12688&&e<=12703)(i)||hh(i)||up(i)||cc(i)&&i!==12540||!(!xl(i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!_p(i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||(e=>e>=5120&&e<=5759)(i)||(e=>e>=6320&&e<=6399)(i)||mp(i)||(e=>e>=19904&&e<=19967)(i)||Md(i)||yl(i))))}function zd(i){return!(Ld(i)||function(e){return!!((t=>t>=128&&t<=255)(e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||(t=>t>=8192&&t<=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)||(t=>t>=8448&&t<=8527)(e)||(t=>t>=8528&&t<=8591)(e)||(t=>t>=8960&&t<=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)||(t=>t>=9216&&t<=9279)(e)&&e!==9251||(t=>t>=9280&&t<=9311)(e)||(t=>t>=9312&&t<=9471)(e)||(t=>t>=9632&&t<=9727)(e)||(t=>t>=9728&&t<=9983)(e)&&!(e>=9754&&e<=9759)||(t=>t>=11008&&t<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||lu(e)||cc(e)||(t=>t>=57344&&t<=63743)(e)||Pd(e)||_p(e)||xl(e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(i))}function yp(i){return i>=1424&&i<=2303||Rd(i)||Dd(i)}function D_(i,e){return!(!e&&yp(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||(t=>t>=6016&&t<=6143)(i))}function xp(i){for(const e of i)if(yp(e.charCodeAt(0)))return!0;return!1}const Sn={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let Fd=null,zn=Sn.unavailable,Sa=null;const vp=function(i){i&&(zn=Sn.error),Fd&&Fd(i)};function Od(){uc.fire(new Mo("pluginStateChange",{pluginStatus:zn,pluginURL:Sa}))}const uc=new Dn,hc=function(){return zn},mo=function(){if(zn!==Sn.deferred||!Sa)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");zn=Sn.loading,Od(),Sa&&vi({url:Sa}).then(()=>{zn=Sn.loaded,Od()}).catch(i=>{vp(i)})},ps={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>zn===Sn.loaded||ps.applyArabicShaping!=null,isLoading:()=>zn===Sn.loading,setState(i){zn=i.pluginStatus,Sa=i.pluginURL},isParsing:()=>zn===Sn.parsing,isParsed:()=>zn===Sn.parsed,getPluginURL:()=>Sa};class zi{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness,this.worldview=t.worldview,this.activeFloors=t.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(t,n){for(const s of t)if(!D_(s.charCodeAt(0),n))return!1;return!0}(e,ps.isLoaded())}}class ph{constructor(e,t,n,s,l){this.property=e,this.value=t,this.expression=function(c,h,p,_,y){if(Ed(c))return new ch(c,h);if(nu(c)||Array.isArray(c)&&c.length>0){const v=op(c,h,p,_,y);if(v.result==="error")throw new Error(v.value.map(b=>`${b.key}: ${b.message}`).join(", "));return v.value}{let v=c;return typeof c=="string"&&h.type==="color"&&(v=Pt.parse(c)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>v}}}(t===void 0?e.specification.default:t,e.specification,n,s,l)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,t,n,s){return this.property.possiblyEvaluate(this,e,t,n,s)}}class Bd{constructor(e,t,n,s){this.property=e,this.value=new ph(e,void 0,t,n,s)}transitioned(e,t){return new mh(this.property,this.value,t,{...e.transition,...this.transition},e.now)}untransitioned(){return new mh(this.property,this.value,null,{},0)}}class bp{constructor(e,t,n,s){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=n,this._iconImageUseTheme=s,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return jn(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Bd(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new ph(this._values[e].property,t===null?void 0:jn(t),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,t){t&&(this._options=t);const n=this._properties.properties;if(e)for(const s in e){const l=e[s];if(s.endsWith("-transition")){const c=s.slice(0,-11);n[c]&&this.setTransition(c,l)}else Object.hasOwn(n,s)&&this.setValue(s,l)}}getTransition(e){return jn(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Bd(this._values[e].property)),this._values[e].transition=jn(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const n=this.getValue(t);n!==void 0&&(e[t]=n);const s=this.getTransition(t);s!==void 0&&(e[`${t}-transition`]=s)}return e}transitioned(e,t){const n=new wp(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].transitioned(e,t._values[s]);return n}untransitioned(){const e=new wp(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class mh{constructor(e,t,n,s,l){const c=s.delay||0,h=s.duration||0;l=l||0,this.property=e,this.value=t,this.begin=l+c,this.end=this.begin+h,e.specification.transition&&(s.delay||s.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){const s=e.now||0,l=this.value.possiblyEvaluate(e,t,n),c=this.prior;if(c){if(s>this.end)return this.prior=null,l;if(this.value.isDataDriven())return this.prior=null,l;if(s<this.begin)return c.possiblyEvaluate(e,t,n);{const h=(s-this.begin)/(this.end-this.begin);return this.property.interpolate(c.possiblyEvaluate(e,t,n),l,ua(h))}}return l}}class wp{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,n){const s=new Ia(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].possiblyEvaluate(e,t,n);return s}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class uu{constructor(e,t,n,s){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=t,this._options=n,this._iconImageUseTheme=s,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return jn(this._values[e].value)}setValue(e,t){this._values[e]=new ph(this._values[e].property,t===null?void 0:jn(t),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(){const e={};for(const t of Object.keys(this._values)){const n=this.getValue(t);n!==void 0&&(e[t]=n)}return e}possiblyEvaluate(e,t,n,s){const l=new Ia(this._properties);for(const c of Object.keys(this._values))l._values[c]=this._values[c].possiblyEvaluate(e,t,n,s);return l}isIndoorDependent(){return this._isIndoorDependent}}class Qs{constructor(e,t,n,s){this.property=e,this.value=t,this.parameters=n,this.iconImageUseTheme=s}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,t,n,s,l){return this.property.evaluate(this.value,this.parameters,e,t,n,s,this.iconImageUseTheme,l)}}class Ia{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class He{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,n){const s=da[this.specification.type];return s?s(e,t,n):e}}class Ze{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,n,s,l){return e.expression.kind==="constant"||e.expression.kind==="camera"?new Qs(this,{kind:"constant",value:e.expression.evaluate(t,null,{},n,s,void 0,l)},t):new Qs(this,e.expression,t,l)}interpolate(e,t,n){if(e.value.kind!=="constant"||t.value.kind!=="constant")return e;if(e.value.value===void 0||t.value.value===void 0)return new Qs(this,{kind:"constant",value:void 0},e.parameters);const s=da[this.specification.type];return s?new Qs(this,{kind:"constant",value:s(e.value.value,t.value.value,n)},e.parameters):e}evaluate(e,t,n,s,l,c,h,p){return e.kind==="constant"?e.value:e.evaluate(t,n,s,l,c,p,h)}}class Aa{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,s){return!!e.expression.evaluate(t,null,{},n,s)}interpolate(){return!1}}class ki{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new zi(0,{});for(const n in e){const s=e[n],l=s.specification;l&&l.overridable&&this.overridableProperties.push(n);const c=this.defaultPropertyValues[n]=new ph(s,void 0),h=this.defaultTransitionablePropertyValues[n]=new Bd(s);this.defaultTransitioningPropertyValues[n]=h.untransitioned(),this.defaultPossiblyEvaluatedValues[n]=c.possiblyEvaluate(t)}}}et(Ze,"DataDrivenProperty"),et(He,"DataConstantProperty"),et(Aa,"ColorRampProperty");var de=
vendor: 7,853 bytes, line 1
1JSON.parse('{"expression":1,"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":1,"parameters":["distance-from-center","feature","feature-state","measure-light","pitch","zoom"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"function":{"type":{"type":"enum","default":"exponential","values":{"identity":1,"exponential":1,"interval":1,"categorical":1}},"default":{"type":"*"},"expression":1,"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"colorSpace":{"type":"enum","default":"rgb","values":{"rgb":1,"lab":1,"hcl":1}}},"$version":8,"$root":{"transition":{"type":"transition"},"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},"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"},"projection":{"type":"projection"},"layers":{"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"type":"featuresets"}},"featuresets":{"*":{"type":"featureset"}},"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":{"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1,"object":{}}},"default":{"type":"*","expression":1},"values":{"type":"array","value":"*"},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}},"id":{"type":"string"},"properties":{"type":"properties"}},"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","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"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":1,"parameters":["zoom"]},"transition":1},"shadow-draw-before-layer":{"type":"string"}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"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","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"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","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"scheme":{"type":"enum","default":"xyz","values":{"xyz":1,"tms":1}},"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","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","default":"xyz","values":{"xyz":1,"tms":1}},"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","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","default":"mapbox","values":{"terrarium":1,"mapbox":1}},"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","default":[-180,-85.051129,180,85.051129],"length":4,"value":"number"},"extra_bounds":{"type":"array","value":{"type":"array","length":4,"value":"number"}},"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,"minimum":0,"maximum":512},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0}
vendor: 52,630 bytes, line 1
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","default":[0,0,0],"length":3,"value":"number"}},"modelLightOverrides":{"light-ambient-color":{"type":"color"},"light-ambient-intensity":{"type":"number"},"light-directional-color":{"type":"color"},"light-directional-intensity":{"type":"number"}},"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","default":[0,0],"minimum":[-180,-90],"maximum":[180,90],"length":2,"value":"number"},"orientation":{"type":"array","default":[0,0,0],"length":3,"value":"number"},"lightOverrides":{"type":"modelLightOverrides"},"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":{"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"id":{"type":"string"},"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"}},"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","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_sky":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_model":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"model-id":{"type":"string","default":"","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"model-allow-density-reduction":{"type":"boolean","default":true}},"layout_clip":{"clip-layer-types":{"type":"array","default":[],"value":"enum","values":{"model":1,"symbol":1},"expression":1},"clip-layer-scope":{"type":"array","default":[],"value":"string","expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"fill-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"expression":1},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"hd-road-markup":1},"expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_heatmap":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_fill-extrusion":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"source-max-zoom":{"type":"number","minimum":0,"maximum":24}},"layout_building":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","default":3,"minimum":1,"maximum":200,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-unit-width":{"type":"number","default":3.1,"minimum":1,"maximum":20,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-window":{"type":"array","default":[0.9,0.9],"minimum":0.1,"maximum":1,"length":2,"value":"number","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-roof-shape":{"type":"enum","default":"flat","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"expression":1,"transition":1,"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"expression":1,"transition":1,"property-type":"data-driven"},"building-flood-light-wall-radius":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"building-flood-light-ground-radius":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"building-flip-roof-orientation":{"type":"boolean","default":false,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"}},"layout_line":{"line-cap":{"type":"enum","default":"butt","values":{"butt":1,"round":1,"square":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-join":{"type":"enum","default":"miter","values":{"bevel":1,"round":1,"miter":1,"none":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":1,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":1,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["feature","line-progress","zoom"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","default":"none","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"expression":1},"line-cross-slope":{"type":"number","expression":1},"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1},"line-width-unit":{"type":"enum","default":"pixels","values":{"pixels":1,"meters":1},"expression":{"parameters":["zoom"]}},"line-elevation-ground-scale":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","line-progress","zoom"]},"transition":1,"property-type":"data-driven"}},"layout_symbol":{"symbol-placement":{"type":"enum","default":"point","values":{"point":1,"line":1,"line-center":1},"expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":1,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","default":"auto","values":{"auto":1,"viewport-y":1,"source":1},"expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","default":"ground","values":{"sea":1,"ground":1,"hd-road-markup":1},"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","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-size-scale-range":{"type":"array","default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"length":2,"value":"number","expression":1},"icon-text-fit":{"type":"enum","default":"none","values":{"none":1,"width":1,"height":1,"both":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","default":[0,0,0,0],"length":4,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"use-theme":1,"property-type":"data-driven","appearance":1,"tokens":1},"icon-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"icon-anchor":{"type":"enum","default":"center","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":["feature","zoom"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-pitch-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-rotation-alignment":{"type":"enum","default":"auto","values":{"map":1,"viewport":1,"auto":1},"expression":{"parameters":["zoom"]}},"text-field":{"type":"formatted","default":"","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven","tokens":1},"text-font":{"type":"array","default":["Open Sans Regular","Arial Unicode MS Regular"],"value":"string","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"text-size-scale-range":{"type":"array","default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"length":2,"value":"number","expression":1},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-justify":{"type":"enum","default":"center","values":{"auto":1,"left":1,"center":1,"right":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven"},"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","default":"center","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":["feature","zoom"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":1,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","default":"none","values":{"none":1,"uppercase":1,"lowercase":1},"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"text-offset":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["feature","zoom"]},"property-type":"data-driven","appearance":1},"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","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_raster":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_raster-particle":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"layout_hillshade":{"visibility":{"type":"enum","default":"visible","values":{"visible":1,"none":1},"expression":1}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"expression":{"parameters":["distance-from-center","feature","pitch","zoom"]},"property-type":"data-driven"},"filter_fill":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_hillshade":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_raster":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_raster-particle":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_clip":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_model":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_line":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_circle":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_fill-extrusion":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_building":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"filter_heatmap":{"type":"boolean","default":false,"expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"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_stop":{"type":"array","minimum":0,"maximum":24,"length":2,"value":["number","color"]},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1,"use-theme":1},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"],"relaxZoomRestriction":1},"transition":1}},"camera":{"camera-projection":{"type":"enum","default":"perspective","values":{"perspective":1,"orthographic":1}}},"colorTheme":{"data":{"type":"string","expression":1}},"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","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"use-theme":1},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"projection":{"name":{"type":"enum","default":"mercator","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1}},"center":{"type":"array","minimum":[-180,-90],"maximum":[180,90],"length":2,"value":"number"},"parallels":{"type":"array","minimum":[-90,-90],"maximum":[90,90],"length":2,"value":"number"}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"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,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-outline-color":{"type":"color","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","expression":{"interpolated":1,"parameters":["feature","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","default":"flat","values":{"terrain":1,"flat":1}},"fill-extrusion-base-alignment":{"type":"enum","default":"terrain","values":{"terrain":1,"flat":1}},"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":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"fill-extrusion-flood-light-wall-radius":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-radius":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"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":1},"fill-extrusion-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":1},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"use-theme":1,"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"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":1,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"building-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"building-flood-light-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-dasharray":{"type":"array","minimum":0,"value":"number","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["feature","zoom"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-gradient":{"type":"color","expression":{"interpolated":1,"parameters":["line-progress"]},"use-theme":1},"line-trim-offset":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number"},"line-trim-fade-range":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[1,1],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"line-trim-color":{"type":"color","default":"transparent","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["line-progress","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"line-border-gradient":{"type":"color","expression":{"interpolated":1,"parameters":["line-progress"]},"use-theme":1},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"line-blend-mode":{"type":"enum","default":"default","values":{"default":1,"multiply":1,"additive":1},"expression":{"parameters":["zoom"]}},"line-blend-additive-clamp":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"line-cutout-depth":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"circle-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"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"],"expression":{"interpolated":1,"parameters":["heatmap-density"]},"use-theme":1},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":1,"parameters":["feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"icon-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"icon-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"icon-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1,"overridable":1},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven","appearance":1},"text-halo-width":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-halo-blur":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"property-type":"data-driven","appearance":1},"text-translate":{"type":"array","default":[0,0],"length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1,"appearance":1},"text-translate-anchor":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":1},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":1},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["feature","zoom"]},"transition":1,"property-type":"data-driven","appearance":1}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-value"]},"use-theme":1},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color-range":{"type":"array","length":2,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-color-scale":{"type":"enum","default":"linear","values":{"linear":1,"log":1},"expression":{"parameters":[]}},"raster-hue-rotate":{"type":"number","default":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-resampling":{"type":"enum","default":"linear","values":{"linear":1,"nearest":1},"expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-elevation-reference":{"type":"enum","default":"sea","values":{"sea":1,"ground":1},"expression":1},"raster-allow-draping":{"type":"boolean","default":true}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","expression":{"interpolated":1,"parameters":["raster-particle-speed"]},"use-theme":1},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":1,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"hillshade-shadow-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-accent-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_background":{"background-pitch-alignment":{"type":"enum","default":"map","values":{"map":1,"viewport":1},"expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1,"use-theme":1},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"expression":{"interpolated":1,"parameters":["measure-light","zoom"]},"transition":1}},"paint_sky":{"sky-type":{"type":"enum","default":"atmosphere","values":{"gradient":1,"atmosphere":1},"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","default":[0,0],"minimum":[0,0],"maximum":[360,180],"length":2,"value":"number","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"],"expression":{"interpolated":1,"parameters":["sky-radial-progress"]},"use-theme":1},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":1},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":1},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["zoom"]},"transition":1}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-rotation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-scale":{"type":"array","default":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-translation":{"type":"array","default":[0,0,0],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","zoom"]},"transition":1,"property-type":"data-driven"},"model-color":{"type":"color","default":"#ffffff","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":1,"use-theme":1,"property-type":"data-driven"},"model-color-mix-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-type":{"type":"enum","default":"common-3d","values":{"common-3d":1,"location-indicator":1}},"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":1,"parameters":["zoom"]},"transition":1},"model-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":1,"parameters":["feature","feature-state"]},"transition":1,"property-type":"data-driven"},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","expression":{"interpolated":1,"parameters":["feature","feature-state","measure-light"]},"transition":1,"property-type":"data-driven"},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":1},"model-front-cutoff":{"type":"array","default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1],"length":3,"value":"number","expression":{"interpolated":1,"parameters":["zoom"]}},"model-elevation-reference":{"type":"enum","default":"ground","values":{"sea":1,"ground":1,"hd-road-markup":1},"expression":1},"model-line-cutout-mode":{"type":"enum","default":"enabled","values":{"enabled":1,"disabled":1,"enabled-above-cutout":1},"expression":1}},"promoteId":{"*":{"type":"*"}}}');function 
vendor: 37,496 bytes, lines 1-7
1kd(i){return i instanceof Number||i instanceof String||i instanceof Boolean?i.valueOf():i}function hu(i){if(Array.isArray(i))return i.map(hu);if(i instanceof Object&&!(i instanceof Number||i instanceof String||i instanceof Boolean)){const e={},t=i;for(const n in t)e[n]=hu(t[n]);return e}return kd(i)}function Nd(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const e of i.slice(1))if(!Nd(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function du(i,e="",t=null,n="fill"){if(i==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Nd(i)||(i=gh(i));const s=i;let l=!0;try{l=function(y){if(!dc(y))return y;let v=hu(y);return Vd(v),v=fu(v),v}(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 c=null,h=null;if(n!=="background"&&n!=="sky"&&n!=="slot"){h=de[`filter_${n}`];const y=Ea(l,h,e,t);if(y.result==="error")throw new Error(y.value.map(v=>`${v.key}: ${v.message}`).join(", "));c=(v,b,T)=>y.value.evaluate(v,b,{},T)}let p=null,_=null;if(l!==s){const y=Ea(s,h,e,t);if(y.result==="error")throw new Error(y.value.map(v=>`${v.key}: ${v.message}`).join(", "));p=(v,b,T,S,A)=>y.value.evaluate(v,b,{},T,void 0,void 0,S,A),_=!al(y.value.expression)}return{filter:c,dynamicFilter:p||void 0,needGeometry:_h(l),needFeature:!!_}}function fu(i){if(!Array.isArray(i))return i;const e=function(t){if(Tp.has(t[0])){for(let n=1;n<t.length;n++)if(dc(t[n]))return!0}return t}(i);return e===!0?e:e.map(t=>fu(t))}function Vd(i){let e=!1;const t=[];if(i[0]==="case"){for(let n=1;n<i.length-1;n+=2)e=e||dc(i[n]),t.push(i[n+1]);t.push(i.at(-1))}else if(i[0]==="match"){e=e||dc(i[1]);for(let n=2;n<i.length-1;n+=2)t.push(i[n+1]);t.push(i.at(-1))}else if(i[0]==="step"){e=e||dc(i[1]);for(let n=1;n<i.length-1;n+=2)t.push(i[n+1])}e&&(i.length=0,i.push("any",...t));for(let n=1;n<i.length;n++)Vd(i[n])}function dc(i){if(!Array.isArray(i))return!1;if((e=i[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let t=1;t<i.length;t++)if(dc(i[t]))return!0;return!1}const Tp=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function L_(i,e){return i<e?-1:i>e?1:0}function _h(i){if(!Array.isArray(i))return!1;if(i[0]==="within"||i[0]==="distance")return!0;for(let e=1;e<i.length;e++)if(_h(i[e]))return!0;return!1}function gh(i){if(!i)return!0;const e=i[0];return i.length<=1?e!=="any":e==="=="?Ud(i[1],i[2],"=="):e==="!="?pu(Ud(i[1],i[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Ud(i[1],i[2],e):e==="any"?(t=i.slice(1),["any"].concat(t.map(gh))):e==="all"?["all"].concat(i.slice(1).map(gh)):e==="none"?["all"].concat(i.slice(1).map(gh).map(pu)):e==="in"?Ep(i[1],i.slice(2)):e==="!in"?pu(Ep(i[1],i.slice(2))):e==="has"?Sp(i[1]):e!=="!has"||pu(Sp(i[1]));var t}function Ud(i,e,t){switch(i){case"$type":return[`filter-type-${t}`,e];case"$id":return[`filter-id-${t}`,e];default:return[`filter-${t}`,i,e]}}function Ep(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(t=>typeof t!=typeof e[0])?["filter-in-large",i,["literal",e.sort(L_)]]:["filter-in-small",i,["literal",e]]}}function Sp(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function pu(i){return["!",i]}const mu="�";function yh(i,e){return e?`${i}${mu}${e}`:i}function Ip(i){const e=i.indexOf(mu);return e>=0?i.slice(e+1):""}let Ap;const Cp=()=>Ap||(Ap=new ki({"icon-size":new Ze(de.layout_symbol["icon-size"]),"icon-image":new Ze(de.layout_symbol["icon-image"]),"icon-rotate":new Ze(de.layout_symbol["icon-rotate"]),"icon-offset":new Ze(de.layout_symbol["icon-offset"]),"text-size":new Ze(de.layout_symbol["text-size"]),"text-rotate":new Ze(de.layout_symbol["text-rotate"]),"text-offset":new Ze(de.layout_symbol["text-offset"])}));let Mp;const Rp=()=>Mp||(Mp=new ki({"icon-opacity":new Ze(de.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Ze(de.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Ze(de.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ze(de.paint_symbol["text-emissive-strength"]),"icon-color":new Ze(de.paint_symbol["icon-color"]),"icon-halo-color":new Ze(de.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ze(de.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ze(de.paint_symbol["icon-halo-blur"]),"icon-translate":new Ze(de.paint_symbol["icon-translate"]),"text-opacity":new Ze(de.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Ze(de.paint_symbol["text-occlusion-opacity"]),"text-color":new Ze(de.paint_symbol["text-color"],{runtimeType:nn,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Ze(de.paint_symbol["text-halo-color"]),"text-halo-width":new Ze(de.paint_symbol["text-halo-width"]),"text-halo-blur":new Ze(de.paint_symbol["text-halo-blur"]),"text-translate":new Ze(de.paint_symbol["text-translate"]),"symbol-z-offset":new Ze(de.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 z_{constructor(e,t,n,s,l,c){this._conditionSpec=e,this._propertiesSpec=n;const h=Ea(e,de.appearance.condition);if(h.result==="success"&&(this.condition=h.value),this.name=t,n){this.layoutProperties=new Ia(Cp()),this.unevaluatedLayout=new uu(Cp(),s,l,c),this.paintProperties=new Ia(Rp()),this.unevaluatedPaint=new uu(Rp(),s,l,"");for(const p in n)p in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(p,n[p]):p in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(p,n[p])}}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,t,n){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,n)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,t,""))}serialize(){const e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);const t={...this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},...this.unevaluatedPaint?this.unevaluatedPaint.serialize():{}};return Object.keys(t).length>0&&(e.properties=t),e}hasIconLayoutProperties(){const e=this.hasLayoutProperty("icon-image"),t=this.hasLayoutProperty("icon-size"),n=this.hasLayoutProperty("icon-offset"),s=this.hasLayoutProperty("icon-rotate");return e||t||n||s}hasTextLayoutProperties(){const e=this.hasLayoutProperty("text-size"),t=this.hasLayoutProperty("text-offset"),n=this.hasLayoutProperty("text-rotate");return e||t||n}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}}const Pp="-transition",xh=new Set(["fill","line","background","hillshade","raster"]);class Fn extends Dn{constructor(e,t,n,s,l,c){if(super(),this.id=e.id,this.fqid=yh(this.id,n),this.type=e.type,this.scope=n,this.lut=s,this.options=l,this.iconImageUseTheme=c,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,e.type!=="custom"&&(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),e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new uu(t.layout,this.scope,l,this.iconImageUseTheme)),t.paint)){this._transitionablePaint=new bp(t.paint,this.scope,l);for(const h in e.paint)this.setPaintProperty(h,e.paint[h]);for(const h in e.layout)this.setLayoutProperty(h,e.layout[h]);this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ia(t.paint)}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&xh.has(this.type)}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if(this.type==="custom"&&e==="visibility")return void(this.visibility=t);const n=this._unevaluatedLayout;n._properties.properties[e]&&(n.setValue(e,t),e==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach(t=>{this.appearances.push(new z_(t.condition,t.name,t.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(Pp)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return!!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const n=this._transitionablePaint,s=n._properties.properties;if(e.endsWith(Pp)){const v=e.slice(0,-11);return s[v]&&n.setTransition(v,t||void 0),!1}if(!s[e])return!1;const l=n._values[e],c=l.value.isDataDriven(),h=l.value;n.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const p=n._values[e].value,_=p.isDataDriven(),y=e.endsWith("pattern")||e==="line-dasharray";return _||c||y||this._handleOverridablePaintPropertyUpdate(e,h,p)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,n){return null}_handleOverridablePaintPropertyUpdate(e,t,n){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,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const 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(t=>t.serialize())),Oc(e,(t,n)=>!(t===void 0||n==="layout"&&!Object.keys(t).length||n==="paint"&&!Object.keys(t).length))}is3D(e){return!1}hasElevation(){return!1}mayUse(e){return!1}prepare(){return Promise.resolve()}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(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Qs&&iu(t.property.specification)&&(t.value.kind==="source"||t.value.kind==="composite")&&t.value.isStateDependent)return!0}for(const e of this.appearances)if(!va(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=du(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,t,n){return{}}queryRadius(e){}queryIntersectsFeature(e,t,n,s,l,c,h,p,_,y){}}function vh(i,e,t){if(!i._unevaluatedLayout)return!1;const n=i._unevaluatedLayout.getValue(e);return n!==void 0&&(typeof n!="string"||t(n))}function ea(i,e,t=2){const n=e&&e.length,s=n?e[0]*t:i.length;let l=Dp(i,0,s,t,!0);const c=[];if(!l||l.next===l.prev)return c;let h,p,_;if(n&&(l=function(y,v,b,T){const S=[];for(let A=0,C=v.length;A<C;A++){const D=Dp(y,v[A]*T,A<C-1?v[A+1]*T:y.length,T,!1);D===D.next&&(D.steiner=!0),S.push(k_(D))}S.sort(O_);for(let A=0;A<S.length;A++)b=B_(S[A],b);return b}(i,e,l,t)),i.length>80*t){h=i[0],p=i[1];let y=h,v=p;for(let b=t;b<s;b+=t){const T=i[b],S=i[b+1];T<h&&(h=T),S<p&&(p=S),T>y&&(y=T),S>v&&(v=S)}_=Math.max(y-h,v-p),_=_!==0?32767/_:0}return _u(l,c,t,h,p,_,0),c}function Dp(i,e,t,n,s){let l;if(s===function(c,h,p,_){let y=0;for(let v=h,b=p-_;v<p;v+=_)y+=(c[b]-c[v])*(c[v+1]+c[b+1]),b=v;return y}(i,e,t,n)>0)for(let c=e;c<t;c+=n)l=yu(c/n|0,i[c],i[c+1],l);else for(let c=t-n;c>=e;c-=n)l=yu(c/n|0,i[c],i[c+1],l);return l&&vl(l,l.next)&&(xu(l),l=l.next),l}function Ca(i,e){if(!i)return i;e||(e=i);let t,n=i;do if(t=!1,n.steiner||!vl(n,n.next)&&Ir(n.prev,n,n.next)!==0)n=n.next;else{if(xu(n),n=e=n.prev,n===n.next)break;t=!0}while(t||n!==e);return e}function _u(i,e,t,n,s,l,c){if(!i)return;!c&&l&&function(p,_,y,v){let b=p;do b.z===0&&(b.z=jd(b.x,b.y,_,y,v)),b.prevZ=b.prev,b.nextZ=b.next,b=b.next;while(b!==p);b.prevZ.nextZ=null,b.prevZ=null,function(T){let S,A=1;do{let C,D=T;T=null;let z=null;for(S=0;D;){S++;let O=D,F=0;for(let j=0;j<A&&(F++,O=O.nextZ,O);j++);let N=A;for(;F>0||N>0&&O;)F!==0&&(N===0||!O||D.z<=O.z)?(C=D,D=D.nextZ,F--):(C=O,O=O.nextZ,N--),z?z.nextZ=C:T=C,C.prevZ=z,z=C;D=O}z.nextZ=null,A*=2}while(S>1)}(b)}(i,n,s,l);let h=i;for(;i.prev!==i.next;){const p=i.prev,_=i.next;if(l?Lp(i,n,s,l):F_(i))e.push(p.i,i.i,_.i),xu(i),i=_.next,h=_.next;else if((i=_)===h){c?c===1?_u(i=zp(Ca(i),e),e,t,n,s,l,2):c===2&&Fp(i,e,t,n,s,l):_u(Ca(i),e,t,n,s,l,1);break}}}function F_(i){const e=i.prev,t=i,n=i.next;if(Ir(e,t,n)>=0)return!1;const s=e.x,l=t.x,c=n.x,h=e.y,p=t.y,_=n.y,y=Math.min(s,l,c),v=Math.min(h,p,_),b=Math.max(s,l,c),T=Math.max(h,p,_);let S=n.next;for(;S!==e;){if(S.x>=y&&S.x<=b&&S.y>=v&&S.y<=T&&gu(s,h,l,p,c,_,S.x,S.y)&&Ir(S.prev,S,S.next)>=0)return!1;S=S.next}return!0}function Lp(i,e,t,n){const s=i.prev,l=i,c=i.next;if(Ir(s,l,c)>=0)return!1;const h=s.x,p=l.x,_=c.x,y=s.y,v=l.y,b=c.y,T=Math.min(h,p,_),S=Math.min(y,v,b),A=Math.max(h,p,_),C=Math.max(y,v,b),D=jd(T,S,e,t,n),z=jd(A,C,e,t,n);let O=i.prevZ,F=i.nextZ;for(;O&&O.z>=D&&F&&F.z<=z;){if(O.x>=T&&O.x<=A&&O.y>=S&&O.y<=C&&O!==s&&O!==c&&gu(h,y,p,v,_,b,O.x,O.y)&&Ir(O.prev,O,O.next)>=0||(O=O.prevZ,F.x>=T&&F.x<=A&&F.y>=S&&F.y<=C&&F!==s&&F!==c&&gu(h,y,p,v,_,b,F.x,F.y)&&Ir(F.prev,F,F.next)>=0))return!1;F=F.nextZ}for(;O&&O.z>=D;){if(O.x>=T&&O.x<=A&&O.y>=S&&O.y<=C&&O!==s&&O!==c&&gu(h,y,p,v,_,b,O.x,O.y)&&Ir(O.prev,O,O.next)>=0)return!1;O=O.prevZ}for(;F&&F.z<=z;){if(F.x>=T&&F.x<=A&&F.y>=S&&F.y<=C&&F!==s&&F!==c&&gu(h,y,p,v,_,b,F.x,F.y)&&Ir(F.prev,F,F.next)>=0)return!1;F=F.nextZ}return!0}function zp(i,e){let t=i;do{const n=t.prev,s=t.next.next;!vl(n,s)&&bh(n,t,t.next,s)&&bl(n,s)&&bl(s,n)&&(e.push(n.i,t.i,s.i),xu(t),xu(t.next),t=i=s),t=t.next}while(t!==i);return Ca(t)}function Fp(i,e,t,n,s,l){let c=i;do{let h=c.next.next;for(;h!==c.prev;){if(c.i!==h.i&&N_(c,h)){let p=kp(c,h);return c=Ca(c,c.next),p=Ca(p,p.next),_u(c,e,t,n,s,l,0),void _u(p,e,t,n,s,l,0)}h=h.next}c=c.next}while(c!==i)}function O_(i,e){let t=i.x-e.x;return t===0&&(t=i.y-e.y,t===0)&&(t=(i.next.y-i.y)/(i.next.x-i.x)-(e.next.y-e.y)/(e.next.x-e.x)),t}function B_(i,e){const t=function(s,l){let c=l;const h=s.x,p=s.y;let _,y=-1/0;if(vl(s,c))return c;do{if(vl(s,c.next))return c.next;if(p<=c.y&&p>=c.next.y&&c.next.y!==c.y){const A=c.x+(p-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(A<=h&&A>y&&(y=A,_=c.x<c.next.x?c:c.next,A===h))return _}c=c.next}while(c!==l);if(!_)return null;const v=_,b=_.x,T=_.y;let S=1/0;c=_;do{if(h>=c.x&&c.x>=b&&h!==c.x&&Bp(p<T?h:y,p,b,T,p<T?y:h,p,c.x,c.y)){const A=Math.abs(p-c.y)/(h-c.x);bl(c,s)&&(A<S||A===S&&(c.x>_.x||c.x===_.x&&Op(_,c)))&&(_=c,S=A)}c=c.next}while(c!==v);return _}(i,e);if(!t)return e;const n=kp(t,i);return Ca(n,n.next),Ca(t,t.next)}function Op(i,e){return Ir(i.prev,i,e.prev)<0&&Ir(e.next,i,i.next)<0}function jd(i,e,t,n,s){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-t)*s|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function k_(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Bp(i,e,t,n,s,l,c,h){return(s-c)*(e-h)>=(i-c)*(l-h)&&(i-c)*(n-h)>=(t-c)*(e-h)&&(t-c)*(l-h)>=(s-c)*(n-h)}function gu(i,e,t,n,s,l,c,h){return!(i===c&&e===h)&&Bp(i,e,t,n,s,l,c,h)}function N_(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!function(t,n){let s=t;do{if(s.i!==t.i&&s.next.i!==t.i&&s.i!==n.i&&s.next.i!==n.i&&bh(s,s.next,t,n))return!0;s=s.next}while(s!==t);return!1}(i,e)&&(bl(i,e)&&bl(e,i)&&function(t,n){let s=t,l=!1;const c=(t.x+n.x)/2,h=(t.y+n.y)/2;do s.y>h!=s.next.y>h&&s.next.y!==s.y&&c<(s.next.x-s.x)*(h-s.y)/(s.next.y-s.y)+s.x&&(l=!l),s=s.next;while(s!==t);return l}(i,e)&&(Ir(i.prev,i,e.prev)||Ir(i,e.prev,e))||vl(i,e)&&Ir(i.prev,i,i.next)>0&&Ir(e.prev,e,e.next)>0)}function Ir(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function vl(i,e){return i.x===e.x&&i.y===e.y}function bh(i,e,t,n){const s=Bo(Ir(i,e,t)),l=Bo(Ir(i,e,n)),c=Bo(Ir(t,n,i)),h=Bo(Ir(t,n,e));return s!==l&&c!==h||!(s!==0||!wh(i,t,e))||!(l!==0||!wh(i,n,e))||!(c!==0||!wh(t,i,n))||!(h!==0||!wh(t,e,n))}function wh(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Bo(i){return i>0?1:i<0?-1:0}function bl(i,e){return Ir(i.prev,i,i.next)<0?Ir(i,e,i.next)>=0&&Ir(i,i.prev,e)>=0:Ir(i,e,i.prev)<0||Ir(i,i.next,e)<0}function kp(i,e){const t=Ma(i.i,i.x,i.y),n=Ma(e.i,e.x,e.y),s=i.next,l=e.prev;return i.next=e,e.prev=i,t.next=s,s.prev=t,n.next=t,t.prev=n,l.next=n,n.prev=l,n}function yu(i,e,t,n){const s=Ma(i,e,t);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function xu(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Ma(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Np(i,e,t=1){if(!i)return null;const n=typeof i=="string"?fn.from(i).getPrimary():i.getPrimary(),s=typeof i=="string"?null:i.getSecondary();for(const l of[n,s]){if(!l)continue;const c=l.id.toString();e.has(c)||e.set(c,[]),l.scaleSelf(t),e.get(c).push(l)}return{primary:n.toString(),secondary:s?s.toString():null}}function Gd(i,e,t,n){const s=n.patternDependencies;let l=!1;for(const c of e){const h=c.paint.get(`${i}-pattern`);h.isConstant()||(l=!0),Np(h.constantOr(null),s,t)&&(l=!0)}return l}function Hd(i,e,t,n,s,l){const c=l.patternDependencies;for(const h of e){const p=h.paint.get(`${i}-pattern`).value;if(p.kind!=="constant"){const _=Np(p.evaluate({zoom:n},t,{},void 0,l.availableImages),c,s);if(!_)continue;const{primary:y,secondary:v}=_;y&&(t.patterns[h.id]=[y,v].filter(Boolean))}}return t}const On=qe/Math.PI/2,wl=64,Th=[wl,32,16],_o=-On,ms=On;function a(i,e,t,n=On){return t=Ot(t),[i*Math.sin(t)*n,-e*n,i*Math.cos(t)*n]}function r(i,e,t){return a(Math.cos(Ot(i)),Math.sin(Ot(i)),e,t)}const o=63710088e-1,u=2*Math.PI*o;class f{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new f(xn(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,n=this.lat*t,s=e.lat*t,l=Math.sin(n)*Math.sin(s)+Math.cos(n)*Math.cos(s)*Math.cos((e.lng-this.lng)*t);return o*Math.acos(Math.min(l,1))}toBounds(e=0){const t=360*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return new m({lng:this.lng-n,lat:this.lat-t},{lng:this.lng+n,lat:this.lat+t})}toEcef(e){return r(this.lat,this.lng,On+e*On/o)}static convert(e){if(e instanceof f)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new f(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new f(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 m{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):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 f?new f(e.lng,e.lat):f.convert(e),this}setSouthWest(e){return this._sw=e instanceof f?new f(e.lng,e.lat):f.convert(e),this}extend(e){const t=this._sw,n=this._ne;let s,l;if(e instanceof f)s=e,l=e;else{if(!(e instanceof m))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(m.convert(e)):this.extend(f.convert(e)):typeof e=="object"&&e!==null&&Object.hasOwn(e,"lat")&&(Object.hasOwn(e,"lon")||Object.hasOwn(e,"lng"))?this.extend(f.convert(e)):this;if(s=e._sw,l=e._ne,!s||!l)return this}return t||n?(t.lng=Math.min(s.lng,t.lng),t.lat=Math.min(s.lat,t.lat),n.lng=Math.max(l.lng,n.lng),n.lat=Math.max(l.lat,n.lat)):(this._sw=new f(s.lng,s.lat),this._ne=new f(l.lng,l.lat)),this}getCenter(){return new f((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 f(this.getWest(),this.getNorth())}getSouthEast(){return new f(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:n}=f.convert(e);let s=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&s}static convert(e){if(e)return e instanceof m?e:new m(e)}}function g(i){return u*Math.cos(i*Math.PI/180)}function x(i,e){return i/g(e)}function w(i,e){return i*g(vr(e))}const E=85.051129;function I(i){return Math.cos(Ot(vt(i,-85.051129,E)))}function R(i,e){const t=vt(e,0,25.5),n=Math.pow(2,t);return I(i)*u/(512*n)}function P(i){return 1/Math.cos(i*Math.PI/180)}function B(i,e=0){const t=Math.exp(Math.PI*(1-(i.y+e/qe)/(1<<i.z)*2));return 80150034*t/(t*t+1)/qe/(1<<i.z)}class V{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e,t=0){const n=f.convert(e);return new V(fo(n.lng),$n(n.lat),x(t,n.lat))}toLngLat(){return new f(qn(this.x),vr(this.y))}toAltitude(){return w(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/u*P(vr(this.y))}}function U(i,e,t,n,s,l,c,h,p){const _=(e+n)/2,y=(t+s)/2,v=new De(_,y);h(v),function(b,T,S,A,C,D){const z=S-C,O=A-D;return Math.abs((A-T)*z-(S-b)*O)/Math.hypot(z,O)}(v.x,v.y,l.x,l.y,c.x,c.y)>=p?(U(i,e,t,_,y,l,v,h,p),U(i,_,y,n,s,v,c,h,p)):i.push(c)}function G(i,e,t){let n=i[0],s=n.x,l=n.y;e(n);const c=[n];for(let h=1;h<i.length;h++){const p=i[h],{x:_,y}=p;e(p),U(c,s,l,_,y,n,p,e,t),s=_,l=y,n=p}return c}function $(i,e,t,n){if(n(e,t)){const s=e.add(t)._mult(.5);$(i,e,s,n),$(i,s,t,n)}else i.push(t)}function Y(i,e){let t=i[0];const n=[t];for(let s=1;s<i.length;s++){const l=i[s];$(n,t,l,e),t=l}return n}const re=Math.pow(2,14)-1,oe=-re-1;function pe(i,e){const t=Math.round(i.x*e),n=Math.round(i.y*e);return i.x=vt(t,oe,re),i.y=vt(n,oe,re),(t<i.x||t>i.x+1||n<i.y||n>i.y+1)&&_i("Geometry exceeds allowed extent, reduce your vector tile buffer size"),i}function ce(i,e,t){const n=i.loadGeometry(),s=i.extent,l=qe/s;if(e&&t&&t.projection.isReprojectedInTileSpace){const c=1<<e.z,{scale:h,x:p,y:_,projection:y}=t,v=b=>{const T=qn((e.x+b.x/s)/c),S=vr((e.y+b.y/s)/c),A=y.project(T,S);b.x=(A.x*h-p)*s,b.y=(A.y*h-_)*s};for(let b=0;b<n.length;b++)if(i.type!==1)n[b]=G(n[b],v,1);else{const T=[];for(const S of n[b])S.x<0||S.x>=s||S.y<0||S.y>=s||(v(S),T.push(S));n[b]=T}}for(const c of n)for(const h of c)pe(h,l);return n}function _e(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?ce(i):[]}}const ue={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class me{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Ie=new ArrayBuffer(0);class we{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(e,t){return e._trim(),t&&e.arrayBuffer&&t.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,e.arrayBuffer?t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement:(t.capacity=0,t.arrayBuffer=Ie),t._refreshViews(),t}_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}resizeExact(e){this.reserveExact(e),this.length=e}reserve(e){e>this.capacity&&this._allocate(Math.max(e,Math.floor(5*this.capacity),128))}reserveExact(e){(e>this.capacity||!this.arrayBuffer)&&this._allocate(e)}_allocate(e){this._reallocCount++,this.capacity=e,this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}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 ve(i,e=1){let t=0,n=0;return{members:i.map(s=>{const l=ue[s.type].BYTES_PER_ELEMENT,c=t=Se(t,Math.max(e,l)),h=s.components||1;return n=Math.max(n,l),t+=l*h,{name:s.name,type:s.type,components:h,offset:c}}),size:Se(t,Math.max(n,e)),alignment:e}}function Se(i,e){return Math.ceil(i/e)*e}class Re extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const s=2*e;return this.int16[s+0]=t,this.int16[s+1]=n,e}}Re.prototype.bytesPerElement=4,et(Re,"StructArrayLayout2i4");class Ue extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n)}emplace(e,t,n,s){const l=3*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.int16[l+2]=s,e}}Ue.prototype.bytesPerElement=6,et(Ue,"StructArrayLayout3i6");class Pe extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,s)}emplace(e,t,n,s,l){const c=4*e;return this.int16[c+0]=t,this.int16[c+1]=n,this.uint16[c+2]=s,this.uint16[c+3]=l,e}}Pe.prototype.bytesPerElement=8,et(Pe,"StructArrayLayout2i2ui8");class Oe extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Oe.prototype.bytesPerElement=4,et(Oe,"StructArrayLayout1f4");class Xe extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n)}emplace(e,t,n,s){const l=4*e,c=2*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.float32[c+1]=s,e}}Xe.prototype.bytesPerElement=8,et(Xe,"StructArrayLayout2i1f8");class ot extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n)}emplace(e,t,n,s){const l=4*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.int16[l+2]=s,e}}ot.prototype.bytesPerElement=8,et(ot,"StructArrayLayout3i8");class tt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,s)}emplace(e,t,n,s,l){const c=4*e;return this.int16[c+0]=t,this.int16[c+1]=n,this.int16[c+2]=s,this.int16[c+3]=l,e}}tt.prototype.bytesPerElement=8,et(tt,"StructArrayLayout4i8");class Ye extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,s,l)}emplace(e,t,n,s,l,c){const h=5*e;return this.int16[h+0]=t,this.int16[h+1]=n,this.int16[h+2]=s,this.int16[h+3]=l,this.int16[h+4]=c,e}}Ye.prototype.bytesPerElement=10,et(Ye,"StructArrayLayout5i10");class mt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,n,s,l,c,h)}emplace(e,t,n,s,l,c,h,p){const _=6*e,y=12*e,v=3*e;return this.int16[_+0]=t,this.int16[_+1]=n,this.uint8[y+4]=s,this.uint8[y+5]=l,this.uint8[y+6]=c,this.uint8[y+7]=h,this.float32[v+2]=p,e}}mt.prototype.bytesPerElement=12,et(mt,"StructArrayLayout2i4ub1f12");class We extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n)}emplace(e,t,n,s){const l=3*e;return this.float32[l+0]=t,this.float32[l+1]=n,this.float32[l+2]=s,e}}We.prototype.bytesPerElement=12,et(We,"StructArrayLayout3f12");class je extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,s,l)}emplace(e,t,n,s,l,c){const h=6*e,p=3*e;return this.uint16[h+0]=t,this.uint16[h+1]=n,this.uint16[h+2]=s,this.uint16[h+3]=l,this.float32[p+2]=c,e}}je.prototype.bytesPerElement=12,et(je,"StructArrayLayout4ui1f12");class Je extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,s)}emplace(e,t,n,s,l){const c=4*e;return this.uint16[c+0]=t,this.uint16[c+1]=n,this.uint16[c+2]=s,this.uint16[c+3]=l,e}}Je.prototype.bytesPerElement=8,et(Je,"StructArrayLayout4ui8");class ft extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,n,s,l,c)}emplace(e,t,n,s,l,c,h){const p=6*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=s,this.int16[p+3]=l,this.int16[p+4]=c,this.int16[p+5]=h,e}}ft.prototype.bytesPerElement=12,et(ft,"StructArrayLayout6i12");class rt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c,h,p,_,y,v,b){const T=this.length;return this.resize(T+1),this.emplace(T,e,t,n,s,l,c,h,p,_,y,v,b)}emplace(e,t,n,s,l,c,h,p,_,y,v,b,T){const S=12*e;return this.int16[S+0]=t,this.int16[S+1]=n,this.int16[S+2]=s,this.int16[S+3]=l,this.uint16[S+4]=c,this.uint16[S+5]=h,this.uint16[S+6]=p,this.uint16[S+7]=_,this.int16[S+8]=y,this.int16[S+9]=v,this.int16[S+10]=b,this.int16[S+11]=T,e}}rt.prototype.bytesPerElement=24,et(rt,"StructArrayLayout4i4ui4i24");class ct extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,n,s,l,c)}emplace(e,t,n,s,l,c,h){const p=10*e,_=5*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=s,this.float32[_+2]=l,this.float32[_+3]=c,this.float32[_+4]=h,e}}ct.prototype.bytesPerElement=20,et(ct,"StructArrayLayout3i3f20");class xt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,s)}emplace(e,t,n,s,l){const c=4*e;return this.float32[c+0]=t,this.float32[c+1]=n,this.float32[c+2]=s,this.float32[c+3]=l,e}}xt.prototype.bytesPerElement=16,et(xt,"StructArrayLayout4f16");class Rt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}Rt.prototype.bytesPerElement=4,et(Rt,"StructArrayLayout1ul4");class Mt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const s=2*e;return this.uint16[s+0]=t,this.uint16[s+1]=n,e}}Mt.prototype.bytesPerElement=4,et(Mt,"StructArrayLayout2ui4");class Ft extends we{_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,t,n,s,l,c,h,p,_,y,v,b,T){const S=this.length;return this.resize(S+1),this.emplace(S,e,t,n,s,l,c,h,p,_,y,v,b,T)}emplace(e,t,n,s,l,c,h,p,_,y,v,b,T,S){const A=20*e,C=10*e;return this.int16[A+0]=t,this.int16[A+1]=n,this.int16[A+2]=s,this.int16[A+3]=l,this.int16[A+4]=c,this.float32[C+3]=h,this.float32[C+4]=p,this.float32[C+5]=_,this.float32[C+6]=y,this.int16[A+14]=v,this.uint32[C+8]=b,this.uint16[A+18]=T,this.uint16[A+19]=S,e}}Ft.prototype.bytesPerElement=40,et(Ft,"StructArrayLayout5i4f1i1ul2ui40");class bi extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,n,s,l,c,h)}emplace(e,t,n,s,l,c,h,p){const _=8*e;return this.int16[_+0]=t,this.int16[_+1]=n,this.int16[_+2]=s,this.int16[_+4]=l,this.int16[_+5]=c,this.int16[_+6]=h,this.int16[_+7]=p,e}}bi.prototype.bytesPerElement=16,et(bi,"StructArrayLayout3i2i2i16");class yi extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,s,l)}emplace(e,t,n,s,l,c){const h=4*e,p=8*e;return this.float32[h+0]=t,this.float32[h+1]=n,this.float32[h+2]=s,this.int16[p+6]=l,this.int16[p+7]=c,e}}yi.prototype.bytesPerElement=16,et(yi,"StructArrayLayout2f1f2i16");class kt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,n,s,l,c)}
vendor: 11,662 bytes, line 7
7emplace(e,t,n,s,l,c,h){const p=20*e,_=5*e;return this.uint8[p+0]=t,this.uint8[p+1]=n,this.float32[_+1]=s,this.float32[_+2]=l,this.float32[_+3]=c,this.float32[_+4]=h,e}}kt.prototype.bytesPerElement=20,et(kt,"StructArrayLayout2ub4f20");class _t extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n)}emplace(e,t,n,s){const l=3*e;return this.uint16[l+0]=t,this.uint16[l+1]=n,this.uint16[l+2]=s,e}}_t.prototype.bytesPerElement=6,et(_t,"StructArrayLayout3ui6");class wi extends we{_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,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O,F,N){const j=this.length;return this.resize(j+1),this.emplace(j,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O,F,N)}emplace(e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O,F,N,j){const te=30*e,H=15*e,W=60*e;return this.int16[te+0]=t,this.int16[te+1]=n,this.int16[te+2]=s,this.float32[H+2]=l,this.float32[H+3]=c,this.uint16[te+8]=h,this.uint16[te+9]=p,this.uint32[H+5]=_,this.uint32[H+6]=y,this.uint32[H+7]=v,this.uint16[te+16]=b,this.uint16[te+17]=T,this.uint16[te+18]=S,this.float32[H+10]=A,this.float32[H+11]=C,this.uint8[W+48]=D,this.uint8[W+49]=z,this.uint8[W+50]=O,this.uint32[H+13]=F,this.int16[te+28]=N,this.uint8[W+58]=j,e}}wi.prototype.bytesPerElement=60,et(wi,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class sr extends we{_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,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O,F,N,j,te,H,W,K,ee,ae,he,be,xe,Te,Fe){const se=this.length;return this.resize(se+1),this.emplace(se,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O,F,N,j,te,H,W,K,ee,ae,he,be,xe,Te,Fe)}emplace(e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O,F,N,j,te,H,W,K,ee,ae,he,be,xe,Te,Fe,se){const fe=20*e,ge=40*e,Ae=80*e;return this.float32[fe+0]=t,this.float32[fe+1]=n,this.int16[ge+4]=s,this.int16[ge+5]=l,this.int16[ge+6]=c,this.int16[ge+7]=h,this.int16[ge+8]=p,this.int16[ge+9]=_,this.int16[ge+10]=y,this.int16[ge+11]=v,this.int16[ge+12]=b,this.uint16[ge+13]=T,this.uint16[ge+14]=S,this.uint16[ge+15]=A,this.uint16[ge+16]=C,this.uint16[ge+17]=D,this.uint16[ge+18]=z,this.uint16[ge+19]=O,this.uint16[ge+20]=F,this.uint16[ge+21]=N,this.uint16[ge+22]=j,this.uint16[ge+23]=te,this.uint16[ge+24]=H,this.uint16[ge+25]=W,this.uint16[ge+26]=K,this.uint16[ge+27]=ee,this.uint32[fe+14]=ae,this.float32[fe+15]=he,this.float32[fe+16]=be,this.float32[fe+17]=xe,this.float32[fe+18]=Te,this.uint8[Ae+76]=Fe,this.uint16[ge+39]=se,e}}sr.prototype.bytesPerElement=80,et(sr,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class qi extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,n,s,l,c)}emplace(e,t,n,s,l,c,h){const p=6*e;return this.float32[p+0]=t,this.float32[p+1]=n,this.float32[p+2]=s,this.float32[p+3]=l,this.float32[p+4]=c,this.float32[p+5]=h,e}}qi.prototype.bytesPerElement=24,et(qi,"StructArrayLayout6f24");class Yt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,s,l)}emplace(e,t,n,s,l,c){const h=5*e;return this.float32[h+0]=t,this.float32[h+1]=n,this.float32[h+2]=s,this.float32[h+3]=l,this.float32[h+4]=c,e}}Yt.prototype.bytesPerElement=20,et(Yt,"StructArrayLayout5f20");class Wi extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,n,s,l,c,h)}emplace(e,t,n,s,l,c,h,p){const _=7*e;return this.float32[_+0]=t,this.float32[_+1]=n,this.float32[_+2]=s,this.float32[_+3]=l,this.float32[_+4]=c,this.float32[_+5]=h,this.float32[_+6]=p,e}}Wi.prototype.bytesPerElement=28,et(Wi,"StructArrayLayout7f28");class Mi extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c,h,p,_,y,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,n,s,l,c,h,p,_,y,v)}emplace(e,t,n,s,l,c,h,p,_,y,v,b){const T=11*e;return this.float32[T+0]=t,this.float32[T+1]=n,this.float32[T+2]=s,this.float32[T+3]=l,this.float32[T+4]=c,this.float32[T+5]=h,this.float32[T+6]=p,this.float32[T+7]=_,this.float32[T+8]=y,this.float32[T+9]=v,this.float32[T+10]=b,e}}Mi.prototype.bytesPerElement=44,et(Mi,"StructArrayLayout11f44");class Wt extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c,h,p,_){const y=this.length;return this.resize(y+1),this.emplace(y,e,t,n,s,l,c,h,p,_)}emplace(e,t,n,s,l,c,h,p,_,y){const v=9*e;return this.float32[v+0]=t,this.float32[v+1]=n,this.float32[v+2]=s,this.float32[v+3]=l,this.float32[v+4]=c,this.float32[v+5]=h,this.float32[v+6]=p,this.float32[v+7]=_,this.float32[v+8]=y,e}}Wt.prototype.bytesPerElement=36,et(Wt,"StructArrayLayout9f36");class Ti extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const s=2*e;return this.float32[s+0]=t,this.float32[s+1]=n,e}}Ti.prototype.bytesPerElement=8,et(Ti,"StructArrayLayout2f8");class tr extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,s)}emplace(e,t,n,s,l){const c=6*e;return this.uint32[3*e+0]=t,this.uint16[c+2]=n,this.uint16[c+3]=s,this.uint16[c+4]=l,e}}tr.prototype.bytesPerElement=12,et(tr,"StructArrayLayout1ul3ui12");class ni extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}ni.prototype.bytesPerElement=2,et(ni,"StructArrayLayout1ui2");class ii extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C){const D=this.length;return this.resize(D+1),this.emplace(D,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C)}emplace(e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D){const z=16*e;return this.float32[z+0]=t,this.float32[z+1]=n,this.float32[z+2]=s,this.float32[z+3]=l,this.float32[z+4]=c,this.float32[z+5]=h,this.float32[z+6]=p,this.float32[z+7]=_,this.float32[z+8]=y,this.float32[z+9]=v,this.float32[z+10]=b,this.float32[z+11]=T,this.float32[z+12]=S,this.float32[z+13]=A,this.float32[z+14]=C,this.float32[z+15]=D,e}}ii.prototype.bytesPerElement=64,et(ii,"StructArrayLayout16f64");class Ni extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,s,l,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,n,s,l,c,h)}emplace(e,t,n,s,l,c,h,p){const _=10*e,y=5*e;return this.uint16[_+0]=t,this.uint16[_+1]=n,this.uint16[_+2]=s,this.uint16[_+3]=l,this.float32[y+2]=c,this.float32[y+3]=h,this.float32[y+4]=p,e}}Ni.prototype.bytesPerElement=20,et(Ni,"StructArrayLayout4ui3f20");class Ar extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}Ar.prototype.bytesPerElement=2,et(Ar,"StructArrayLayout1i2");class go extends we{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}go.prototype.bytesPerElement=1,et(go,"StructArrayLayout1ub1");class In extends me{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]}}In.prototype.size=40;class _s extends Ft{get(e){return new In(this,e)}}et(_s,"CollisionBoxArray");class Fi extends me{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]}get 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}}Fi.prototype.size=60;class mi extends wi{get(e){return new Fi(this,e)}}et(mi,"PlacedSymbolArray");class oi extends me{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]}
vendor: 19,950 bytes, line 7
7get 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]}}oi.prototype.size=80;class ir extends sr{get(e){return new oi(this,e)}}et(ir,"SymbolInstanceArray");class qr extends Oe{getoffsetX(e){return this.float32[1*e+0]}}et(qr,"GlyphOffsetArray");class Vi extends Re{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}et(Vi,"SymbolLineVertexArray");class Kt extends me{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]}}Kt.prototype.size=12;class Cr extends tr{get(e){return new Kt(this,e)}}et(Cr,"FeatureIndexArray");class Vr extends Mt{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}et(Vr,"FillExtrusionCentroidArray");class Qo extends me{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]}}Qo.prototype.size=6;class es extends Ue{get(e){return new Qo(this,e)}}et(es,"FillExtrusionWallArray");const Ls=ve([{name:"a_pos",components:2,type:"Int16"}],4),ko=ve([{name:"a_road_z_offset",components:1,type:"Float32"}],4),Ra=ve([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),gs=ve([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);class li{constructor(e=[]){this.segments=e}_prepareSegment(e,t,n,s,l){let c=this.segments.at(-1);return e>li.MAX_VERTEX_ARRAY_LENGTH&&_i(`Max vertices per segment is ${li.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!c||c.vertexLength+e>li.MAX_VERTEX_ARRAY_LENGTH||c.sortKey!==s||l!==void 0&&c&&c.batchIndex!==void 0&&c.batchIndex!==l)&&(c={vertexOffset:t,primitiveOffset:n,vertexLength:0,primitiveLength:0},s!==void 0&&(c.sortKey=s),l!==void 0&&(c.batchIndex=l),this.segments.push(c)),c}prepareSegment(e,t,n,s,l){return this._prepareSegment(e,t.length,n.length,s,l)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,s){return new li([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:s,vaos:{},sortKey:0}])}}function Pa(i,e){return 256*(i=vt(Math.floor(i),0,255))+vt(Math.floor(e),0,255)}li.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,et(li,"SegmentVector");const Eh=ve([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Zd=ve([{name:"a_pattern_b",components:4,type:"Uint16"}]),$d=ve([{name:"a_dash",components:4,type:"Uint16"}]);class Tl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,n,s){this.ids.push(Sh(e)),this.positions.push(t,n,s)}eachPosition(e,t){const n=Sh(e);let s=0,l=this.ids.length-1;for(;s<l;){const c=s+l>>1;this.ids[c]>=n?l=c:s=c+1}for(;this.ids[s]===n;)t(this.positions[3*s],this.positions[3*s+1],this.positions[3*s+2]),s++}static serialize(e,t){const n=new Float64Array(e.ids),s=new Uint32Array(e.positions);return vu(n,s,0,n.length-1),t&&(t.add(n.buffer),t.add(s.buffer)),{ids:n,positions:s}}static deserialize(e){const t=new Tl;let n;t.ids=e.ids,t.positions=e.positions;for(const s of t.ids)s!==n&&t.uniqueIds.push(s),n=s;return t.indexed=!0,t}}function Sh(i){const e=+i;return Number.isSafeInteger(e)?e:il(String(i))}function vu(i,e,t,n){for(;t<n;){const s=i[t+n>>1];let l=t-1,c=n+1;for(;;){do l++;while(i[l]<s);do c--;while(i[c]>s);if(l>=c)break;fc(i,l,c),fc(e,3*l,3*c),fc(e,3*l+1,3*c+1),fc(e,3*l+2,3*c+2)}c-t<n-c?(vu(i,e,t,c),t=c+1):(vu(i,e,c+1,n),n=c)}}function fc(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}et(Tl,"FeaturePositionMap");class ts{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}set(e,t,n){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class pr extends ts{constructor(e){super(e),this.current=0}set(e,t,n){this.fetchUniformLocation(e,t)&&this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}}class Et extends ts{constructor(e){super(e),this.current=0}set(e,t,n){this.fetchUniformLocation(e,t)&&this.current!==n&&(this.current=n,this.gl.uniform1f(this.location,n))}}class on extends ts{constructor(e){super(e),this.current=[0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1])))}}class Ur extends ts{constructor(e){super(e),this.current=[0,0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2])))}}class Lb extends ts{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]&&n[3]===this.current[3]||(this.current=n,this.gl.uniform4ui(this.location,n[0],n[1],n[2],n[3])))}}class El extends ts{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]&&n[3]===this.current[3]||(this.current=n,this.gl.uniform4f(this.location,n[0],n[1],n[2],n[3])))}}class V_ extends ts{constructor(e){super(e),this.current=Pt.transparent.toPremultipliedRenderColor(null)}set(e,t,n){this.fetchUniformLocation(e,t)&&(n.r===this.current.r&&n.g===this.current.g&&n.b===this.current.b&&n.a===this.current.a||(this.current=n,this.gl.uniform4f(this.location,n.r,n.g,n.b,n.a)))}}class Kr extends ts{constructor(e){super(e),this.current=new Float32Array(16)}set(e,t,n){if(!this.fetchUniformLocation(e,t))return;const s=this.current;if(n[12]!==s[12]||n[0]!==s[0])return s.set(n),void this.gl.uniformMatrix4fv(this.location,!1,s);for(let l=1;l<16;l++)if(n[l]!==s[l]){s.set(n),this.gl.uniformMatrix4fv(this.location,!1,s);break}}}class U_ extends ts{constructor(e){super(e),this.current=new Float32Array(4)}set(e,t,n){if(!this.fetchUniformLocation(e,t))return;const s=this.current;for(let l=0;l<4;l++)if(n[l]!==s[l]){s.set(n),this.gl.uniformMatrix2fv(this.location,!1,s);break}}}function j_(i){return[Pa(255*i.r,255*i.g),Pa(255*i.b,255*i.a)]}function Vp(i,e,t,n,s,l,c,h){return!!i&&(i.kind==="composite"||i.kind==="source"?i.evaluate(new zi(0,{brightness:l,worldview:h}),e,t,s,n,c)==="none":i.value==="none")}class Up{constructor(e,t,n,s){this.value=e,this.uniformNames=t.map(l=>`u_${l}`),this.type=n,this.context=s}setUniform(e,t,n,s,l){const c=s.constantOr(this.value);t.set(e,l,c instanceof Pt?c.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):c)}getBinding(e,t){return this.type==="color"?new V_(e):new Et(e)}}class qd{constructor(e,t){this.uniformNames=t.map(n=>`u_${n}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(e,t){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=t?t.tl.concat(t.br):this.pattern}setUniform(e,t,n,s,l){let c=null;l!=="u_pattern"&&l!=="u_dash"||(c=this.pattern),l==="u_pattern_b"&&(c=this.patternTransition),l==="u_pixel_ratio"&&(c=this.pixelRatio),c&&t.set(e,l,c)}getBinding(e,t){return t==="u_pattern"||t==="u_pattern_b"||t==="u_dash"?new Lb(e):new Et(e)}}class Sl{constructor(e,t,n,s){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map(l=>({name:`a_${l}`,type:"Float32",components:n==="color"?2:1,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,t,n,s,l,c,h,p){const _=this.paintVertexArray.length,y=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new zi(0,{brightness:c,worldview:p}),t,{},l,s,h):this.expression.kind==="constant"&&this.expression.value,v=Vp(this.lutExpression,t,{},s,l,c,h,p);this.paintVertexArray.resize(e),this._setPaintValue(_,e,y,v?null:this.context.lut)}updatePaintArray(e,t,n,s,l,c,h,p){const _=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:h,worldview:p},n,s,void 0,l):this.expression.kind==="constant"&&this.expression.value,y=Vp(this.lutExpression,n,s,l,void 0,h,void 0,p);this._setPaintValue(e,t,_,y?null:this.context.lut)}_setPaintValue(e,t,n,s){if(this.type==="color"){const l=j_(n.toPremultipliedRenderColor(s));for(let c=e;c<t;c++)this.paintVertexArray.emplace(c,l[0],l[1])}else{for(let l=e;l<t;l++)this.paintVertexArray.emplace(l,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}}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 Da{constructor(e,t,n,s,l,c){this.expression=e,this.uniformNames=t.map(h=>`u_${h}_t`),this.type=n,this.useIntegerZoom=s,this.context=l,this.maxValue=0,this.paintVertexAttributes=t.map(h=>({name:`a_${h}`,type:"Float32",components:n==="color"?4:2,offset:0})),this.paintVertexArray=new c}populatePaintArray(e,t,n,s,l,c,h,p){const _=this.expression.evaluate(new zi(this.context.zoom,{brightness:c,worldview:p}),t,{},l,s,h),y=this.expression.evaluate(new zi(this.context.zoom+1,{brightness:c,worldview:p}),t,{},l,s,h),v=Vp(this.lutExpression,t,{},s,l,c,h,p),b=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(b,e,_,y,v?null:this.context.lut)}updatePaintArray(e,t,n,s,l,c,h,p){const _=this.expression.evaluate({zoom:this.context.zoom,brightness:h,worldview:p},n,s,void 0,l),y=this.expression.evaluate({zoom:this.context.zoom+1,brightness:h,worldview:p},n,s,void 0,l),v=Vp(this.lutExpression,n,s,l,void 0,h,void 0,p);this._setPaintValue(e,t,_,y,v?null:this.context.lut)}_setPaintValue(e,t,n,s,l){if(this.type==="color"){const c=j_(n.toPremultipliedRenderColor(l)),h=j_(s.toPremultipliedRenderColor(l));for(let p=e;p<t;p++)this.paintVertexArray.emplace(p,c[0],c[1],h[0],h[1])}else{for(let c=e;c<t;c++)this.paintVertexArray.emplace(c,n,s);this.maxValue=Math.max(this.maxValue,Math.abs(n),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,t,n,s,l){const c=this.useIntegerZoom?Math.floor(n.zoom):n.zoom,h=vt(this.expression.interpolationFactor(c,this.context.zoom,this.context.zoom+1),0,1);t.set(e,l,h)}getBinding(e,t){return new Et(e)}}class La{constructor(e,t,n,s,l){this.expression=e,this.layerId=l,this.paintVertexAttributes=(n==="array"?$d:Eh).members;for(let c=0;c<t.length;++c);this.paintVertexArray=new s,this.paintTransitionVertexArray=new Je}populatePaintArray(e,t,n,s){const l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(l,e,t.patterns&&t.patterns[this.layerId],n)}updatePaintArray(e,t,n,s,l,c,h){this._setPaintValues(e,t,n.patterns&&n.patterns[this.layerId],c)}_setPaintValues(e,t,n,s){if(!s||!n)return;const l=s[n[0]],c=s[n[1]];if(l){if(l){const{tl:h,br:p,pixelRatio:_}=l;for(let y=e;y<t;y++)this.paintVertexArray.emplace(y,h[0],h[1],p[0],p[1],_)}if(c){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);const{tl:h,br:p}=c;for(let _=e;_<t;_++)this.paintTransitionVertexArray.emplace(_,h[0],h[1],p[0],p[1])}}}upload(e){const t=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,t)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=e.createVertexBuffer(this.paintTransitionVertexArray,Zd.members,t))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class bu{constructor(e,t,n=()=>!0){this.binders={},this._buffers=[],this.context=t;const s=[],l=e;for(const c in e.paint._values){const h=l.paint.get(c);if(c.endsWith("-use-theme")||!n(c)||!(h instanceof Qs&&iu(h.property.specification)))continue;const p=Fb(c,e.type),_=h.value,y=h.property.specification.type,v=!!h.property.useIntegerZoom,b=c==="line-dasharray"||c.endsWith("pattern"),T=l.paint.get(`${c}-use-theme`),S=c==="line-dasharray"&&l.layout.get("line-cap").value.kind!=="constant"||T&&T.value.kind!=="constant";if(_.kind!=="constant"||S)if(_.kind==="source"||S||b){const A=Vy(c,y,"source");this.binders[c]=b?new La(_,p,y,A,e.id):new Sl(_,p,y,A),s.push(`/a_${c}`)}else{const A=Vy(c,y,"composite");this.binders[c]=new Da(_,p,y,v,t,A),s.push(`/z_${c}`)}else this.binders[c]=b?new qd(_.value,p):new Up(_.value,p,y,t),s.push(`/u_${c}`);T&&(this.binders[c].lutExpression=T.value)}this.cacheKey=s.sort().join("")}updateExpressions(e){const t=e;for(const n in this.binders){const s=this.binders[n];if(s instanceof Sl||s instanceof Da||s instanceof La){const l=t.paint.get(n);s.expression=l.value}}}getMaxValue(e){const t=this.binders[e];return t instanceof Sl||t instanceof Da?t.maxValue:0}populatePaintArrays(e,t,n,s,l,c,h,p){for(const _ in this.binders){const y=this.binders[_];y.context=this.context,(y instanceof Sl||y instanceof Da||y instanceof La)&&y.populatePaintArray(e,t,n,s,l,c,h,p)}}setConstantPatternPositions(e,t){for(const n in this.binders){const s=this.binders[n];s instanceof qd&&s.setConstantPatternPositions(e,t)}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof La?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,n,s,l,c,h,p,_,y){let v=!1;const b=Object.keys(e),T=b.length!==0&&!p,S=T?b:t.uniqueIds;this.context.lut=l.lut;for(const A in this.binders){const C=this.binders[A];if(C.context=this.context,(C instanceof Sl||C instanceof Da||C instanceof La)&&C.expression&&C.expression.kind&&C.expression.kind!=="constant"&&(C.expression.isStateDependent===!0||C.expression.isLightConstant===!1)){const D=l.paint.get(A);C.expression=D.value;for(const z of S){const O=e[z.toString()];t.eachPosition(z,(F,N,j)=>{const te=s.feature(F);C.updatePaintArray(N,j,te,O,c,h,_,y)})}if(!T)for(const z of n.uniqueIds){const O=e[z.toString()];n.eachPosition(z,(F,N,j)=>{const te=s.feature(F);C.updatePaintArray(N,j,te,O,c,h,_,y)})}v=!0}}return v}defines(){const e=[];for(const t in this.binders){const n=this.binders[t];(n instanceof Up||n instanceof qd)&&e.push(...n.uniformNames.map(s=>`#define HAS_UNIFORM_${s}`))}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const n in this.binders){const s=this.binders[n];if(s instanceof Up||s instanceof qd||s instanceof Da)for(const l of s.uniformNames)t.push({name:l,property:n,binding:s.getBinding(e,l)})}return t}setUniforms(e,t,n,s,l){for(const{name:c,property:h,binding:p}of n)this.binders[h].setUniform(e,p,l,s.get(h),c)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof Sl||t instanceof Da||t instanceof La)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof La&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer)}}upload(e){for(const t in this.binders){const n=this.binders[t];(n instanceof Sl||n instanceof Da||n instanceof La)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof Sl||t instanceof Da||t instanceof La)&&t.destroy()}}}class ta{constructor(e,t,n=()=>!0){this.programConfigurations={};for(const s of e)this.programConfigurations[s.id]=new bu(s,t,n);this.needsUpload=!1,this._featureMap=new Tl,this._featureMapWithoutIds=new Tl,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,n,s,l,c,h,p,_){for(const y in this.programConfigurations)this.programConfigurations[y].populatePaintArrays(e,t,s,l,c,h,p,_);t.id!==void 0?this._featureMap.add(t.id,n,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,n,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,s,l,c,h,p){for(const _ of n)this.needsUpload=this.programConfigurations[_.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,_,s,l,c,h||0,p)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}updateExpressions(e){const t=new Set;for(const n of e){const s=this.programConfigurations[n.id];s&&(s.updateExpressions(n),t.add(n.id))}for(const n in this.programConfigurations)t.has(n)||delete this.programConfigurations[n]}}const zb={"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":["ga
7pwidth"],"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 Fb(i,e){return zb[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}const Ob={"line-pattern":{source:je,composite:je},"fill-pattern":{source:je,composite:je},"fill-extrusion-pattern":{source:je,composite:je},"line-dasharray":{source:Je,composite:Je}},Bb={color:{source:Ti,composite:xt},number:{source:Oe,composite:Ti}};function Vy(i,e,t){const n=Ob[i];return n&&n[t]||Bb[e][t]}et(Up,"ConstantBinder"),et(qd,"PatternConstantBinder"),et(Sl,"SourceExpressionBinder",{omit:["expression"]}),et(La,"PatternCompositeBinder",{omit:["expression"]}),et(Da,"CompositeExpressionBinder",{omit:["expression"]}),et(bu,"ProgramConfiguration",{omit:["_buffers"]}),et(ta,"ProgramConfigurationSet");class G_{constructor(e,t,n){this.layoutVertexArray=new Re,this.indexArray=new _t,this.lineIndexArray=new Mt,this.triangleSegments=new li,this.lineSegments=new li,this.programConfigurations=new ta(e,{zoom:t,lut:n}),this.uploaded=!1}update(e,t,n,s,l,c,h,p){this.programConfigurations.updatePaintArrays(e,t,l,n,s,c,h,p)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ls.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(e,t,n,s,l,c,h){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,n,s,l,c,void 0,h)}}et(G_,"FillBufferData");class H_{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new G_(e.layers,e.zoom,e.lut),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.projection=e.projection,this.sourceLayerIndex=e.sourceLayerIndex,this.sourceLayerName=e.sourceLayerName||"",this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,n,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,n,s){this.hasPattern=Gd("fill",this.layers,this.pixelRatio,t);const l=this.layers[0].layout.get("fill-sort-key"),c=[];for(const{feature:h,id:p,index:_,sourceLayerIndex:y}of e){const v=this.layers[0]._featureFilter.needGeometry,b=_e(h,v);if(!this.layers[0]._featureFilter.filter(new zi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),b,n))continue;const T=l?l.evaluate(b,{},n,t.availableImages):void 0,S={id:p,properties:h.properties,type:h.type,sourceLayerIndex:y,index:_,geometry:v?b.geometry:ce(h,n,s),patterns:{},sortKey:T};c.push(S)}l&&c.sort((h,p)=>h.sortKey-p.sortKey);for(const h of c){const{geometry:p,index:_,sourceLayerIndex:y}=h;if(this.hasPattern){const v=Hd("fill",this.layers,h,this.zoom,this.pixelRatio,t);this.patternFeatures.push(v)}else this.addFeature(h,p,_,n,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[_].feature,p,_,y,this.index)}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this)}update(e,t,n,s,l,c,h){this.bufferData.update(e,t,n,s,l,c,h,this.worldview),this.hdExt&&this.hdExt.update(e,t,n,s,l,c,h,this.worldview)}updateExpressions(e){this.bufferData.programConfigurations.updateExpressions(e),this.hdExt&&this.hdExt.updateExpressions(e)}addFeatures(e,t,n,s,l,c){for(const h of this.patternFeatures)this.addFeature(h,h.geometry,h.index,t,n,s,c,e.elevationFeatures);this.hdExt&&this.hdExt.buildFrcSegments(this)}isEmpty(){return this.bufferData.isEmpty()&&(!this.hdExt||this.hdExt.isEmpty())}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.hdExt!=null&&this.hdExt.needsUpload()}upload(e){this.bufferData.upload(e),this.hdExt&&this.hdExt.upload(e)}destroy(){this.bufferData.destroy(),this.hdExt&&this.hdExt.destroy()}
vendor: 56,313 bytes, line 7
7addFeature(e,t,n,s,l,c=[],h,p){const _=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,y=this.bufferData.indexArray.length,v=Ei(t,500);this.hdExt!=null&&this.hdExt.handleFeature(e,v,n,s,p,this)||this.addGeometry(v,this.bufferData),this.bufferData.populatePaintArrays(e,n,l,c,s,h,this.worldview),this.hdExt&&this.hdExt.populatePaintArrays(e,n,l,c,s,h,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,y,this.bufferData.indexArray.length,_)}addGeometry(e,t,n,s){let l=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,h=null;n&&(h=n.elevationSampler.constantElevation(n.elevation,n.bias),h!=null&&(l=h,c=h));const p=n?t:null,_=(y,v,b)=>{if(n!=null)if(v.push(y),h!=null)p.elevatedLayoutVertexArray.emplaceBack(h),b.push(h);else{const T=n.elevationSampler.pointElevation(y,n.elevation,n.bias);p.elevatedLayoutVertexArray.emplaceBack(T),b.push(T),l=Math.min(l,T),c=Math.max(c,T)}};for(const y of e){let v=0;for(const N of y)v+=N.length;const b=t.triangleSegments.prepareSegment(v,t.layoutVertexArray,t.indexArray),T=b.vertexLength,S=[],A=[],C=[],D=[],z=[],O=t.layoutVertexArray.length;for(const N of y){if(N.length===0)continue;N!==y[0]&&A.push(S.length/2);const j=t.lineSegments.prepareSegment(N.length,t.layoutVertexArray,t.lineIndexArray),te=j.vertexLength;n&&z.push(t.layoutVertexArray.length-O),_(N[0],C,D),t.layoutVertexArray.emplaceBack(N[0].x,N[0].y),t.lineIndexArray.emplaceBack(te+N.length-1,te),S.push(N[0].x),S.push(N[0].y);for(let H=1;H<N.length;H++)_(N[H],C,D),t.layoutVertexArray.emplaceBack(N[H].x,N[H].y),t.lineIndexArray.emplaceBack(te+H-1,te+H),S.push(N[H].x),S.push(N[H].y);j.vertexLength+=N.length,j.primitiveLength+=N.length}const F=ea(S,A);for(let N=0;N<F.length;N+=3)t.indexArray.emplaceBack(T+F[N],T+F[N+1],T+F[N+2]);if(F.length>0&&n&&s){const N=n.elevation.isTunnel(),j=n.elevation.safeArea,te=s.addVertices(C,D);s.addTriangles(F,te,N);const H=z.length;if(H>0){for(let W=0;W<H-1;W++)s.addRenderableRing(n.index,z[W]+te,z[W+1]-z[W],N,j,n.featureInfo);s.addRenderableRing(n.index,z[H-1]+te,C.length-z[H-1],N,j,n.featureInfo)}}b.vertexLength+=v,b.primitiveLength+=F.length/3}return[l,c]}}et(H_,"FillBucket",{omit:["layers","patternFeatures"]});const kb=ve([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),Nb=ve([{name:"a_z_offset_width",components:4,type:"Float32"}],4),Vb=ve([{name:"a_elevation_id_col",components:3,type:"Float32"}],4),Ub=ve([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:jb}=kb,Gb=ve([{name:"a_packed",components:3,type:"Float32"}]),{members:Hb}=Gb,Zb=ve([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:$b}=Zb;class pc{constructor(e,t,n,s,l){for(this.properties=Object.create(null),this.extent=n,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=s,this._values=l;e.pos<t;){const c=e.readVarint();if(c===8)this.id=e.readVarint();else if(c===18){const h=e.readVarint()+e.pos;for(;e.pos<h;){const p=s[e.readVarint()],_=l[e.readVarint()];this.properties[p]=_}}else c===24?this.type=e.readVarint():(c===34&&(this._geometry=e.pos),e.skip(c))}}loadGeometry(){if(this._geometry<0)throw new Error("feature has no geometry");const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let s,l=1,c=0,h=0,p=0;for(;e.pos<t;){if(c<=0){const _=e.readVarint();if(l=7&_,c=_>>3,c===0)continue}if(c--,l===1)h+=e.readSVarint(),p+=e.readSVarint(),s&&n.push(s),s=[new De(h,p)];else if(l===2)h+=e.readSVarint(),p+=e.readSVarint(),s&&s.push(new De(h,p));else{if(l!==7)throw new Error(`unknown command ${l}`);s&&s.push(s[0].clone())}}return s&&n.push(s),n}bbox(){if(this._geometry<0)throw new Error("feature has no geometry");const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n=1,s=0,l=0,c=0,h=1/0,p=-1/0,_=1/0,y=-1/0;for(;e.pos<t;){if(s<=0){const v=e.readVarint();if(n=7&v,s=v>>3,s===0)continue}if(s--,n===1||n===2)l+=e.readSVarint(),c+=e.readSVarint(),l<h&&(h=l),l>p&&(p=l),c<_&&(_=c),c>y&&(y=c);else if(n!==7)throw new Error(`unknown command ${n}`)}return[h,_,p,y]}toGeoJSON(e,t,n){const s=this.extent*Math.pow(2,n),l=this.extent*e,c=this.extent*t,h=this.loadGeometry();function p(b){return[360*(b.x+l)/s-180,360/Math.PI*Math.atan(Math.exp((1-2*(b.y+c)/s)*Math.PI))-90]}function _(b){return b.map(p)}let y;if(this.type===1){const b=[];for(const S of h)b.push(S[0]);const T=_(b);y=b.length===1?{type:"Point",coordinates:T[0]}:{type:"MultiPoint",coordinates:T}}else if(this.type===2){const b=h.map(_);y=b.length===1?{type:"LineString",coordinates:b[0]}:{type:"MultiLineString",coordinates:b}}else{if(this.type!==3)throw new Error("unknown feature type");{const b=function(S){const A=S.length;if(A<=1)return[S];const C=[];let D,z;for(let O=0;O<A;O++){const F=qb(S[O]);F!==0&&(z===void 0&&(z=F<0),z===F<0?(D&&C.push(D),D=[S[O]]):D&&D.push(S[O]))}return D&&C.push(D),C}(h),T=[];for(const S of b)T.push(S.map(_));y=T.length===1?{type:"Polygon",coordinates:T[0]}:{type:"MultiPolygon",coordinates:T}}}const v={type:"Feature",geometry:y,properties:this.properties};return this.id!=null&&(v.id=this.id),v}}function qb(i){let e=0;for(let t,n,s=0,l=i.length,c=l-1;s<l;c=s++)t=i[s],n=i[c],e+=(n.x-t.x)*(t.y+n.y);return e}pc.types=["Unknown","Point","LineString","Polygon"];class Wb{constructor(e,t){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],t===void 0&&(t=e.length);e.pos<t;){const n=e.readVarint();n===10?this.name=e.readString():n===18?(this._features.push(e.pos),e.skip(n)):n===26?this._keys.push(e.readString()):n===34?this._values.push(Xb(e)):n===40?this.extent=e.readVarint():n===120?this.version=e.readVarint():e.skip(n)}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];const t=this._pbf.readVarint()+this._pbf.pos;return new pc(this._pbf,t,this.extent,this._keys,this._values)}}function Xb(i){let e=null;const t=i.readVarint()+i.pos;for(;i.pos<t;){const n=i.readVarint();e=n===10?i.readString():n===21?i.readFloat():n===25?i.readDouble():n===32?i.readVarint(!0):n===40?i.readVarint():n===48?i.readSVarint():n===56?i.readBoolean():(i.skip(n),null)}if(e==null)throw new Error("unknown feature value");return e}class Z_{constructor(e,t=e.length){const n=Object.create(null);for(;e.pos<t;){const s=e.readVarint();if(s===26){const l=new Wb(e,e.readVarint()+e.pos);l.length&&(n[l.name]=l)}else e.skip(s)}this.layers=n}}function $_(i,e){for(let t=0;t<i.length;t++)if(mc(e,i[t]))return!0;for(let t=0;t<e.length;t++)if(mc(i,e[t]))return!0;return!!W_(i,e)}function Yb(i,e,t){return!!mc(i,e)||!!Y_(e,i,t)}function q_(i,e){if(i.length===1)return jy(e,i[0]);for(let t=0;t<e.length;t++){const n=e[t];for(let s=0;s<n.length;s++)if(mc(i,n[s]))return!0}for(let t=0;t<i.length;t++)if(jy(e,i[t]))return!0;for(let t=0;t<e.length;t++)if(W_(i,e[t]))return!0;return!1}function Kb(i,e,t){if(i.length>1){if(W_(i,e))return!0;for(let n=0;n<e.length;n++)if(Y_(e[n],i,t))return!0}for(let n=0;n<i.length;n++)if(Y_(i[n],e,t))return!0;return!1}function W_(i,e){if(i.length===0||e.length===0)return!1;for(let t=0;t<i.length-1;t++){const n=i[t],s=i[t+1];for(let l=0;l<e.length-1;l++)if(Jb(n,s,e[l],e[l+1]))return!0}return!1}function Jb(i,e,t,n){return $o(i,t,n)!==$o(e,t,n)&&$o(i,e,t)!==$o(i,e,n)}function X_(i,e,t){return(i.x-t.x)*(e.y-t.y)-(i.y-t.y)*(e.x-t.x)}function Qb(i,e,t,n){const s=X_(i,e,n),l=X_(i,e,t);if(Math.sign(s)===Math.sign(l))return;const c=X_(t,n,i),h=c+l-s;return Math.sign(c)!==Math.sign(h)?[c/(c-h),l/(l-s)]:void 0}function Y_(i,e,t){const n=t*t;if(e.length===1)return i.distSqr(e[0])<n;for(let s=1;s<e.length;s++)if(Uy(i,e[s-1],e[s])<n)return!0;return!1}function Uy(i,e,t){const n=e.distSqr(t);if(n===0)return i.distSqr(e);const s=((i.x-e.x)*(t.x-e.x)+(i.y-e.y)*(t.y-e.y))/n;return i.distSqr(s<0?e:s>1?t:t.sub(e)._mult(s)._add(e))}function jy(i,e){let t,n,s,l=!1;for(let c=0;c<i.length;c++){t=i[c];for(let h=0,p=t.length-1;h<t.length;p=h++)n=t[h],s=t[p],n.y>e.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(l=!l)}return l}function mc(i,e){let t=!1;for(let n=0,s=i.length-1;n<i.length;s=n++){const l=i[n],c=i[s];l.y>e.y!=c.y>e.y&&e.x<(c.x-l.x)*(e.y-l.y)/(c.y-l.y)+l.x&&(t=!t)}return t}function K_(i,e,t,n,s){for(const c of i)if(e<=c.x&&t<=c.y&&n>=c.x&&s>=c.y)return!0;const l=[new De(e,t),new De(e,s),new De(n,s),new De(n,t)];if(i.length>2){for(const c of l)if(mc(i,c))return!0}for(let c=0;c<i.length-1;c++)if(Ih(i[c],i[c+1],l))return!0;return!1}function Ih(i,e,t){const n=t[0],s=t[2];if(i.x<n.x&&e.x<n.x||i.x>s.x&&e.x>s.x||i.y<n.y&&e.y<n.y||i.y>s.y&&e.y>s.y)return!1;const l=$o(i,e,t[0]);return l!==$o(i,e,t[1])||l!==$o(i,e,t[2])||l!==$o(i,e,t[3])}function Ah(i,e,t,n,s,l){let c=e.y-i.y,h=i.x-e.x;if(l=l||0){const p=c*c+h*h;if(p===0)return!0;const _=Math.sqrt(p);c/=_,h/=_}return!((t.x-i.x)*c+(t.y-i.y)*h-l<0||(n.x-i.x)*c+(n.y-i.y)*h-l<0||(s.x-i.x)*c+(s.y-i.y)*h-l<0)}function J_(i,e,t,n,s,l,c){return!(Ah(i,e,n,s,l,c)||Ah(e,t,n,s,l,c)||Ah(t,i,n,s,l,c)||Ah(n,s,i,e,t,c)||Ah(s,l,i,e,t,c)||Ah(l,n,i,e,t,c))}class wu extends De{constructor(e,t,n){super(e,t),this.z=n}}class Gy extends wu{constructor(e,t,n,s){super(e,t,n),this.w=s}}function Hy(i,e,t,n){const s=t==="x"?"y":"x",l=(n-i[t])/(e[t]-i[t]);i[s]=Math.round(i[s]+(e[s]-i[s])*l),i[t]=n,Object.hasOwn(i,"z")&&(i.z=lt(i.z,e.z,l)),Object.hasOwn(i,"w")&&(i.w=lt(i.w,e.w,l))}function Zy(i,e,t,n){const s=t,l=n;for(const c of["x","y"]){let h=i,p=e;h[c]>=p[c]&&(h=e,p=i),h[c]<s&&p[c]>s&&Hy(h,p,c,s),h[c]<l&&p[c]>l&&Hy(p,h,c,l)}}function Q_(i,e,t,n,s,l){const c=[];for(let h=0;h<i.length;h++){const p=i[h];let _;const y=c.length;let v=0;for(let b=0;b<p.length-1;b++){let T=p[b],S=p[b+1],A=0;const C=v;let D,z;l&&(A=Math.hypot(S.x-T.x,S.y-T.y),v+=A,D=T,z=S),T.x<e&&S.x<e||(T.x<e?T=new De(e,T.y+(e-T.x)/(S.x-T.x)*(S.y-T.y))._round():S.x<e&&(S=new De(e,T.y+(e-T.x)/(S.x-T.x)*(S.y-T.y))._round()),T.y<t&&S.y<t||(T.y<t?T=new De(T.x+(t-T.y)/(S.y-T.y)*(S.x-T.x),t)._round():S.y<t&&(S=new De(T.x+(t-T.y)/(S.y-T.y)*(S.x-T.x),t)._round()),T.x>=n&&S.x>=n||(T.x>=n?T=new De(n,T.y+(n-T.x)/(S.x-T.x)*(S.y-T.y))._round():S.x>=n&&(S=new De(n,T.y+(n-T.x)/(S.x-T.x)*(S.y-T.y))._round()),T.y>=s&&S.y>=s||(T.y>=s?T=new De(T.x+(s-T.y)/(S.y-T.y)*(S.x-T.x),s)._round():S.y>=s&&(S=new De(T.x+(s-T.y)/(S.y-T.y)*(S.x-T.x),s)._round()),_&&T.equals(_.at(-1))||(_=[T],c.push(_),l&&l.push({progress:{min:C+$y(D,z,T)*A,max:1},parentIndex:h,prevPoint:D,nextPoint:z})),_.push(S),l&&(l.at(-1).progress.max=C+$y(D,z,S)*A,l.at(-1).nextPoint=z)))))}if(l&&v>0)for(let b=y;b<c.length;b++)l[b].progress.min/=v,l[b].progress.max/=v}return c}function ew(i,e,t,n,s){if(i.length<2)return void n.push(i);const l=[];for(;e.valid();){const[_,y]=e.get();for(let v=0;v<i.length-1;v++){const b=i[v],T=i[v+1],S=Qb(b,T,_,y);if(S){const[A]=S,C=new De(lt(b.x,T.x,A),lt(b.y,T.y,A));l.push({t:v+A,distance:0,point:C})}}e.next()}if(l.length===0)return void n.push(i);l.sort((_,y)=>_.t-y.t);let c=0,h=0,p=[];for(n.push(p);c!==i.length;){if(h===l.length){for(;c!==i.length;)p.length!==0&&p.at(-1).equals(i[c])||p.push(i[c]),c++;break}l[h].t<=c?(p.length!==0&&p.at(-1).equals(l[h].point)||p.push(l[h].point),Math.trunc(l[h].t),h++):(p.length!==0&&p.at(-1).equals(i[c])||p.push(i[c]),c++)}}function $y(i,e,t){return i.x!==e.x?(t.x-i.x)/(e.x-i.x):i.y!==e.y?(t.y-i.y)/(e.y-i.y):0}function qy(i,{width:e,height:t},n,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*t*n)throw new RangeError("mismatched image size")}else s=new Uint8Array(e*t*n);return i.width=e,i.height=t,i.data=s,i}function Wy(i,e,t){const{width:n,height:s}=e;n===i.width&&s===i.height||(eg(i,e,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,n),height:Math.min(i.height,s)},t,null),i.width=n,i.height=s,i.data=e.data)}function eg(i,e,t,n,s,l,c,h){if(s.width===0||s.height===0)return e;if(s.width>i.width||s.height>i.height||t.x>i.width-s.width||t.y>i.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||n.x>e.width-s.width||n.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const p=i.data,_=e.data,y=l===4&&h;for(let v=0;v<s.height;v++){const b=((t.y+v)*i.width+t.x)*l,T=((n.y+v)*e.width+n.x)*l;if(y)for(let S=0;S<s.width;S++){const A=b+S*l+3,C=T+S*l;_[C+0]=255,_[C+1]=255,_[C+2]=255,_[C+3]=p[A]}else if(c)for(let S=0;S<s.width;S++){const A=b+S*l,C=T+S*l,D=new Pt(p[A+0]/255,p[A+1]/255,p[A+2]/255,p[A+3]).toNonPremultipliedRenderColor(c).toArray();_[C+0]=D[0],_[C+1]=D[1],_[C+2]=D[2],_[C+3]=D[3]}else for(let S=0;S<s.width*l;S++)_[T+S]=p[b+S]}return e}class _c{constructor(e,t){qy(this,e,1,t)}resize(e){Wy(this,new _c(e),1)}clone(){return new _c({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,n,s,l){eg(e,t,n,s,l,1,null)}}class An{constructor(e,t){qy(this,e,4,t)}resize(e){Wy(this,new An(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new An({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,n,s,l,c,h){eg(e,t,n,s,l,4,c,h)}}class Xy{constructor(e,t){this.width=e.width,this.height=e.height,this.data=t instanceof Uint8Array?new Float32Array(t.buffer):t}}et(_c,"AlphaImage"),et(An,"RGBAImage");class Yy{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new _c({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const n=this.getKey(e,t);return this.positions[n]}trim(){const e=this.width,t=this.height=ql(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,n){const s=[];let l=e.length%2==1?-e.at(-1)*n:0,c=e[0]*n,h=!0;s.push({left:l,right:c,isDash:h,zeroLength:e[0]===0});let p=e[0];for(let _=1;_<e.length;_++){h=!h;const y=e[_];l=p*n,p+=y,c=p*n,s.push({left:l,right:c,isDash:h,zeroLength:y===0})}return s}addRoundDash(e,t,n){const s=t/2;for(let l=-n;l<=n;l++){const c=this.width*(this.nextRow+n+l);let h=0,p=e[h];for(let _=0;_<this.width;_++){_/p.right>1&&(p=e[++h]);const y=Math.abs(_-p.left),v=Math.abs(_-p.right),b=Math.min(y,v);let T;const S=l/n*(s+1);if(p.isDash){const A=s-Math.abs(S);T=Math.sqrt(b*b+A*A)}else T=s-Math.sqrt(b*b+S*S);this.image.data[c+_]=Math.max(0,Math.min(255,T+128))}}}addRegularDash(e,t){for(let p=e.length-1;p>=0;--p){const _=e[p],y=e[p+1];_.zeroLength?e.splice(p,1):y&&y.isDash===_.isDash&&(y.left=_.left,e.splice(p,1))}const n=e[0],s=e.at(-1);n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);const l=this.width*this.nextRow;let c=0,h=e[c];for(let p=0;p<this.width;p++){p/h.right>1&&(h=e[++c]);const _=Math.abs(p-h.left),y=Math.abs(p-h.right),v=Math.min(_,y);this.image.data[l+p]=Math.max(0,Math.min(255,(h.isDash?v:-v)+t+128))}}addDash(e,t){const n=this.getKey(e,t);if(this.positions[n])return this.positions[n];const s=t==="round",l=s?7:0,c=2*l+1;if(this.nextRow+c>this.height)return _i("LineAtlas out of space"),null;e.length===0&&e.push(1);let h=0;for(let T=0;T<e.length;T++)e[T]<0&&(_i("Negative value is found in line dasharray, replacing values with 0"),e[T]=0),h+=e[T];if(h!==0){const T=this.width/h,S=this.getDashRanges(e,this.width,T);s?this.addRoundDash(S,T,l):this.addRegularDash(S,t==="square"?.5*T:0)}const p=this.nextRow+l;let _=0;if(h!==0){const T=this.width*p;for(let S=0;S<this.width;S++)this.image.data[T+S]>=128&&_++}const y=Math.round(_/this.width*4095);this.nextRow+=c;const v=Math.floor(h),b={tl:[p,l|y<<4],br:[v,Math.round(65535*(h-v))]};return this.positions[n]=b,b}}et(Yy,"LineAtlas");const Il="3d_elevation_id",Ky="level",tw=pc.types,iw=Math.cos(Math.PI/180*37.5),rw=Math.cos(Math.PI/180*5);class tg{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.showElevationIdDebug=!1,this.terrainEnabled=!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(t=>t.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.borderGradients={},this.layers.forEach(t=>{this.gradients[t.id]={},this.borderGradients[t.id]={}}),this.layoutVertexArray=new mt,this.layoutVertexArray2=new We,this.patternVertexArray=new We,this.indexArray=new _t,this.programConfigurations=new ta(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new li,this.sourceLayerName=e.sourceLayerName||"",this.maxLineLength=0,this.zOffsetVertexArray=new xt,this.elevationIdColVertexArray=new We,this.elevationGroundScaleVertexArray=new Oe,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,n,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,n,s){this.showElevationIdDebug=t.showElevationIdDebug,this.terrainEnabled=t.terrainEnabled,this.hasPattern=Gd("line",this.layers,this.pixelRatio,t);const l=this.layers[0].layout.get("line-sort-key");this.tileToMeter=B(n);const c=this.layers[0].layout.get("line-elevation-reference");if(c==="hd-road-markup")this.elevationType="road";else{const b=this.layers[0].layout.get("line-z-offset"),T=b.isConstant()&&!b.constantOr(0);this.elevationType=c!=="sea"&&c!=="ground"&&T?"none":"offset",this.elevationType==="offset"&&c==="none"&&_i(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference=c==="sea"}const h=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&h!==void 0;const p=[];for(const{feature:b,id:T,index:S,sourceLayerIndex:A}of e){const C=this.layers[0]._featureFilter.needGeometry,D=_e(b,C);if(!this.layers[0]._featureFilter.filter(new zi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),D,n))continue;const z=l?l.evaluate(D,{},n):void 0,O={id:T,properties:b.properties,type:b.type,sourceLayerIndex:A,index:S,geometry:C?D.geometry:ce(b,n,s),patterns:{},sortKey:z};p.push(O)}l&&p.sort((b,T)=>b.sortKey-T.sortKey);const{lineAtlas:_,featureIndex:y}=t,v=this.addConstantDashes(_);for(const b of p){const{geometry:T,index:S,sourceLayerIndex:A}=b;if(v&&this.addFeatureDashes(b,_),this.hasPattern){const C=Hd("line",this.layers,b,this.zoom,this.pixelRatio,t);this.patternFeatures.push(C)}else this.addFeature(b,T,S,n,_.positions,t.availableImages,t.brightness,t.elevationFeatures,t.elevationParams,t.crossSourceElevationEnabled);y.insert(e[S].feature,T,S,A,this.index)}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this),this.hdExt&&this.hdExt.endPopulate()}addConstantDashes(e){let t=!1;for(const n of this.layers){const s=n.paint.get("line-dasharray").value,l=n.layout.get("line-cap").value;if(s.kind!=="constant"||l.kind!=="constant")t=!0;else{const c=l.value,h=s.value;if(!h)continue;e.addDash(h,c)}}return t}addFeatureDashes(e,t){const n=this.zoom;for(const s of this.layers){const l=s.paint.get("line-dasharray").value,c=s.layout.get("line-cap").value;if(l.kind==="constant"&&c.kind==="constant")continue;let h,p;if(l.kind==="constant"){if(h=l.value,!h)continue}else h=l.evaluate({zoom:n},e);p=c.kind==="constant"?c.value:c.evaluate({zoom:n},e),t.addDash(h,p),e.patterns[s.id]=[t.getKey(h,p)]}}update(e,t,n,s,l,c,h,p,_){this.programConfigurations.updatePaintArrays(e,t,l,n,s,c,h,_)}updateExpressions(e){this.programConfigurations.updateExpressions(e)}addFeatures(e,t,n,s,l,c){for(const h of this.patternFeatures)this.addFeature(h,h.geometry,h.index,t,n,s,c,e.elevationFeatures,e.elevationParams,e.crossSourceElevationEnabled);this.hdExt&&(this.hdExt.buildFrcSegments(this),this.hdExt.endPopulate())}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,Hb)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,$b)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Nb.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=e.createVertexBuffer(this.elevationIdColVertexArray,Vb.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,Ub.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,jb),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,t){let n,s;if(t&&t>0?(n=`mapbox_clip_start_${t}`,s=`mapbox_clip_end_${t}`):(n="mapbox_clip_start",s="mapbox_clip_end"),e.properties&&Object.hasOwn(e.properties,n)&&Object.hasOwn(e.properties,s))return{start:+e.properties[n],end:+e.properties[s]}}addFeature(e,t,n,s,l,c,h,p,_,y){const v=this.layers[0].layout,b=this.hdExt?this.hdExt.trackFeatureFrc(e.properties):null,T=this.indexArray.length,S=v.get("line-join").evaluate(e,{}),A=v.get("line-cap").evaluate(e,{}),C=v.get("line-miter-limit"),D=v.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const z=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=v.get("line-z-offset").value;const O=this.layers[0].paint,F=O.get("line-width").value;F.kind!=="constant"&&F.isLineProgressConstant===!1&&(this.variableWidthValue=F);const N=O.get("line-emissive-strength").value;if(N.kind!=="constant"&&N.isLineProgressConstant===!1&&(this.variableEmissiveStrengthValue=N),this.isSeaLevelReference){const j=v.get("line-elevation-ground-scale").value;j.kind==="constant"&&j.value===0||(this.elevationGroundScaleValue=j)}if(this.hdExt==null||!this.hdExt.handleFeature(e,t,s,p,_,!!y,S,A,C,D,this))for(let j=0;j<t.length;j++)this.addLine(t[j],e,s,S,A,C,D,void 0,z&&j>0?j:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,l,c,s,h,void 0,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,T,this.indexArray.length,b)}fillNonElevatedRoadSegment(e){for(let t=Math.max(e,this.zOffsetVertexArray.length);t<this.layoutVertexArray.length;t++)this.zOffsetVertexArray.emplaceBack(0,0,0,0),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)}addLine(e,t,n,s,l,c,h,p,_){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0,this.lineClips=_?this.lineFeatureClips(t,_):this.lineClips;const y=s==="none";this.patternJoinNone=this.hasPattern&&y,this.currentLineJoinType=s,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];const v=p&&p.progress.min>0,b=p&&p.progress.max<1;if(this.lineClips){let W={min:this.lineClips.start,max:this.lineClips.end},K=1;if(p){const he=this.lineClips.end-this.lineClips.start;W=function(be,xe,Te){return{min:Hu(be.min,xe,Te),max:Hu(be.max,xe,Te)}}(p.progress,{min:0,max:1},W),he>0&&(K=(W.max-W.min)/he)}const ee=+t.properties.mapbox_clip_feature_len,ae=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(ee)||Number.isNaN(ae)){for(let be=0;be<e.length-1;be++)this.totalDistance+=e[be].dist(e[be+1]);const he=this.totalDistance/(W.max-W.min);this.totalFeatureLength=Number.isFinite(he)?he:0,this.lineClips.start=W.min,this.lineClips.end=W.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=ee,this.distance=ae*K,this.lineClips.start=W.min,this.lineClips.end=W.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}const T=tw[t.type]==="Polygon";let S=e.length;for(;S>=2&&e[S-1].equals(e[S-2]);)S--;let A=0;for(;A<S-1&&e[A].equals(e[A+1]);)A++;if(S<(T?3:2))return;s==="bevel"&&(c=1.05);const C=this.segments.prepareSegment(10*S,this.layoutVertexArray,this.indexArray);let D,z,O,F,N,j,te,H;p&&p.prevDir&&(j=p.prevDir.perp()),p&&p.nextDir&&(te=p.nextDir.perp()),this.e1=this.e2=-1,T&&(D=e[S-2],N=e[A].sub(D)._unit()._perp());for(let W=A;W<S;W++){if(O=W===S-1?T?e[A+1]:void 0:e[W+1],O&&e[W].equals(O))continue;N&&(F=N),D&&(z=D),D=e[W],H=this.evaluateLineProgressFeatures(z?z.dist(D):0),N=O?O.sub(D)._unit()._perp():F,F=F||N;const K=z&&O;let ee=K?s:T||y?"butt":l;const ae=F.x*N.x+F.y*N.y;if(y){const ge=function(Ae){if(Ae.patternJoinNone){const Me=Ae.segmentPoints.length/2,ze=Ae.lineSoFar-Ae.segmentStart;for(let Ce=0;Ce<Me;++Ce){const Be=Ae.segmentPoints[2*Ce+1],ke=Math.round(Ae.segmentPoints[2*Ce])+.5+.25*Be;Ae.patternVertexArray.emplaceBack(ke,ze,Ae.segmentStart),Ae.patternVertexArray.emplaceBack(ke,ze,Ae.segmentStart)}Ae.segmentPoints.length=0}Ae.e1=Ae.e2=-1};if(K&&ae<rw){this.updateDistance(z,D),this.addCurrentVertex(D,F,1,1,C,H),ge(this),this.addCurrentVertex(D,N,-1,-1,C,H);continue}if(z){if(!O){this.updateDistance(z,D),this.addCurrentVertex(D,F,1,1,C,H),ge(this);continue}ee="miter"}}let he=F.add(N);he.x===0&&he.y===0||he._unit();const be=he.x*N.x+he.y*N.y,xe=be!==0?1/be:1/0,Te=2*Math.sqrt(2-2*be),Fe=be<iw&&z&&O,se=F.x*N.y-F.y*N.x>0,fe=this.overscaling<=16?122880/(512*this.overscaling):0;if(K&&ee==="round"){if(xe<h)ee="miter";else if(xe<=2){const ge=ig(D,-10,8202);ee=this.elevationType==="offset"&&(ge||this.hasCrossSlope)?"miter":"fakeround"}}if(ee==="miter"&&xe>c&&(ee="bevel"),ee==="bevel"&&(xe>2&&(ee="flipbevel"),xe<c&&(ee="miter")),z&&!(ee==="miter"&&Fe)&&this.updateDistance(z,D),ee==="miter")if(Fe){const ge=D.dist(z);if(ge>2*fe){const Me=D.sub(D.sub(z)._mult(fe/ge)._round());this.updateDistance(z,Me),this.addCurrentVertex(Me,F,0,0,C,H),z=Me}this.updateDistance(z,D),he._mult(xe),this.addCurrentVertex(D,he,0,0,C,H);const Ae=D.dist(O);if(Ae>2*fe){const Me=D.add(O.sub(D)._mult(fe/Ae)._round());this.updateDistance(D,Me),this.addCurrentVertex(Me,N,0,0,C,H),D=Me}}else he._mult(xe),this.addCurrentVertex(D,he,0,0,C,H);else if(ee==="flipbevel"){if(xe>100)he=N.mult(-1);else{const ge=xe*F.add(N).mag()/F.sub(N).mag();he._perp()._mult(ge*(se?-1:1))}this.addCurrentVertex(D,he,0,0,C,H),this.addCurrentVertex(D,he.mult(-1),0,0,C,H)}else if(ee==="bevel"||ee==="fakeround"){const ge=D.dist(z);let Ae=1;if(this.elevationType==="offset"&&ee==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&H!=null&&z&&O){const Ve=4*fe;ge<Ve&&(Ae=Math.max(0,ge/Ve))}H!=null&&z&&this.addCurrentVertex(D,te||F,-Ae,-Ae,C,H);const Me=ge<=1*fe&&ee!=="bevel",ze=Me?1:xe,Ce=he.mult(se?1:-1);Ce._mult(ze);const Be=N.mult(se?-1:1),ke=F.mult(se?-1:1),Ke=this.evaluateLineProgressFeatures(this.distance);if(H==null&&(this.addHalfVertex(D,Ce.x,Ce.y,!1,!se,0,C,Ke),Me||this.addHalfVertex(D,Ce.x+2*ke.x,Ce.y+2*ke.y,!1,se,0,C,Ke)),ee==="fakeround"){const Ve=Math.round(180*Te/Math.PI/20);this.addHalfVertex(D,ke.x,ke.y,!1,se,0,C,Ke);for(let $e=0;$e<Ve;$e++){let dt=$e/Ve;if(dt!==.5){const yt=dt-.5;dt+=dt*yt*(dt-1)*((1.0904+ae*(ae*(3.55645-1.43519*ae)-3.2452))*yt*yt+(.848013+ae*(.215638*ae-1.06021)))}const pt=Be.sub(ke)._mult(dt)._add(ke)._unit();this.addHalfVertex(D,pt.x,pt.y,!1,se,0,C,Ke)}this.addHalfVertex(D,Be.x,Be.y,!1,se,0,C,Ke)}Me||H!=null||this.addHalfVertex(D,Ce.x+2*Be.x,Ce.y+2*Be.y,!1,se,0,C,Ke),H!=null&&O&&this.addCurrentVertex(D,j||N,Ae,Ae,C,H)}else if(ee==="butt")this.addCurrentVertex(D,he,0,0,C,H);else if(ee==="square"){if(!z){const ge=v?0:-1;this.addCurrentVertex(D,he,ge,ge,C,H)}if(this.addCurrentVertex(D,he,0,0,C,H),z){const ge=b?0:1;this.addCurrentVertex(D,he,ge,ge,C,H)}}else if(ee==="round"){if(z){const ge=!K&&te?te:F;this.addCurrentVertex(D,ge,0,0,C,H),!K&&b||this.addCurrentVertex(D,ge,1,1,C,H,!0)}if(O){const ge=!K&&j?j:N;!K&&v||this.addCurrentVertex(D,ge,-1,-1,C,H,!0),this.addCurrentVertex(D,ge,0,0,C,H)}}}}addVerticesTo(e,t,n,s,l,c,h,p,_,y){const v=(t.w-e.w)/this.tessellationStep|0;let b=0;const T=this.scaledDistance;if(v>1){this.lineSoFar=e.w;const A=(t.x-e.x)/v,C=(t.y-e.y)/v,D=(t.z-e.z)/v,z=(t.w-e.w)/v,O=t.x-e.x,F=t.y-e.y,N=Math.sqrt(O*O+F*F);if(N===0)return;const j=-F/N,te=O/N,H=j,W=te,K=-j,ee=-te;for(let ae=1;ae<v;++ae){e.x+=A,e.y+=C,e.z+=D,this.lineSoFar+=z,b+=z;const he=this.evaluateLineProgressFeatures(this.prevDistance+b);this.scaledDistance=(this.prevDistance+b)/this.totalDistance,this.addHalfVertex(e,H,W,y,!1,0,_,he),this.addHalfVertex(e,K,ee,y,!0,0,_,he)}}this.lineSoFar=t.w,this.scaledDistance=T;const S=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(t,n,s,y,!1,h,_,S),this.addHalfVertex(t,l,c,y,!0,-p,_,S)}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&!this.variableEmissiveStrengthValue&&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):_i(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let t=0;this.variableWidthValue&&this.variableWidthValue.kind!=="constant"&&(t=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,t*=.5);let n=0;this.variableEmissiveStrengthValue&&this.variableEmissiveStrengthValue.kind!=="constant"&&(n=this.variableEmissiveStrengthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);const s=this.evaluateElevationGroundScale();return this.elevationType!=="offset"?{zOffset:0,variableWidth:t,elevationGroundScale:s,variableEmissiveStrength:n}:this.zOffsetValue.kind==="constant"?{zOffset:this.zOffsetValue.value,variableWidth:t,elevationGroundScale:s,variableEmissiveStrength:n}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:t,elevationGroundScale:s,variableEmissiveStrength:n}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?this.elevationGroundScaleValue.kind==="constant"?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(e,t,n,s,l,c,h=!1){const p=t.x+t.y*n,_=t.y-t.x*n,y=t.y*s-t.x,v=-t.y-t.x*s;if(c!=null){const b=this.elevationType==="offset",T=this.elevationType==="offset"?2:10,S=-T,A=qe+T,C=c.zOffset,D=new Gy(e.x,e.y,C,this.lineSoFar),z=!!b&&ig(e,S,A),O=this.lineSoFar,F=this.distance;if(this.currentVertex)if(z){const N=this.currentVertexIsOutside,j=this.currentVertex,te=new Gy(e.x,e.y,C,this.lineSoFar);if(Zy(j,te,S,A),!ig(te,S,A)){if(N){this.e1=this.e2=-1,this.distance-=j.dist(D),this.lineSoFar=j.w;const H=this.evaluateLineProgressFeatures(j.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(j,p,_,h,!1,n,l,H),this.addHalfVertex(j,y,v,h,!0,-s,l,H),this.prevDistance=this.distance}this.distance=this.prevDistance+j.dist(te),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(j,te,p,_,y,v,n,s,l,h),this.distance=F,this.scaledDistance=this.distance/this.totalDistance}}else{const N=this.currentVertex;if(this.currentVertexIsOutside){Zy(N,D,S,A),this.e1=this.e2=-1,this.distance-=N.dist(D),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=N.w;const j=this.evaluateLineProgressFeatures(N.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(N,p,_,h,!1,n,l,j),this.addHalfVertex(N,y,v,h,!0,-s,l,j),this.prevDistance=this.distance,this.distance=F,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(N,D,p,_,y,v,n,s,l,h)}else z||(this.addHalfVertex(e,p,_,h,!1,n,l,c),this.addHalfVertex(e,y,v,h,!0,-s,l,c));this.currentVertex=D,this.currentVertexIsOutside=z,this.lineSoFar=O}else this.addHalfVertex(e,p,_,h,!1,n,l,c),this.addHalfVertex(e,y,v,h,!0,-s,l,c)}addHalfVertex({x:e,y:t},n,s,l,c,h,p,_){if(this.patternJoinNone&&(this.segmentPoints.length===0&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),c||this.segmentPoints.push(this.lineSoFar-this.segmentStart,h)),this.layoutVertexArray.emplaceBack((e<<1)+(l?1:0),(t<<1)+(c?1:0),Math.round(63*n)+128,Math.round(63*s)+128,1+(h===0?0:h<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){const v=lt(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,v)}const y=p.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,y),p.primitiveLength++),c?this.e2=y:this.e1=y,_!=null&&(this.zOffsetVertexArray.emplaceBack(_.zOffset,_.variableWidth,_.variableWidth,_.variableEmissiveStrength),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){const v=_?_.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(v)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance()}}function ig(i,e,t){return i.x<e||i.x>t||i.y<e||i.y>t}et(tg,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const nw=ve([{name:"a_pos",components:2,type:"Int16"}],4),ow=ve([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),sw=ve([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class jp{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Re,this.indexArray=new _t,this.segments=new li,this.programConfigurations=new ta(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,n,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,n,s){const l=this.layers[0],c=[];let h=null;l.type==="circle"&&(h=l.layout.get("circle-sort-key"));for(const{feature:_,id:y,index:v,sourceLayerIndex:b}of e){const T=this.layers[0]._featureFilter.needGeometry,S=_e(_,T);if(!this.layers[0]._featureFilter.filter(new zi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),S,n))continue;const A=h?h.evaluate(S,{},n):void 0,C={id:y,properties:_.properties,type:_.type,sourceLayerIndex:b,index:v,geometry:T?S.geometry:ce(_,n,s),patterns:{},sortKey:A};c.push(C)}h&&c.sort((_,y)=>_.sortKey-y.sortKey);let p=null;s.projection.name==="globe"&&(this.globeExtVertexArray=new ft,p=s.projection);for(const _ of c){const{geometry:y,index:v,sourceLayerIndex:b}=_,T=e[v].feature;this.addFeature(_,y,v,t.availableImages,n,p,t.brightness,t.elevationFeatures),t.featureIndex.insert(T,y,v,b,this.index)}this.hdExt&&this.hdExt.finalize()}update(e,t,n,s,l,c,h){this.programConfigurations.updatePaintArrays(e,t,l,n,s,c,h,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,nw.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,sw.members)),this.hdExt&&this.hdExt.upload(e)),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.hdExt&&this.hdExt.destroy())}addFeature(e,t,n,s,l,c,h,p){this.hdExt&&this.hdExt.beginFeature(e,p,l);for(const _ of t)for(const y of _){const v=y.x,b=y.y;if(v<0||v>=qe||b<0||b>=qe)continue;if(c){const A=c.projectTilePoint(v,b,l),C=c.upVector(l,v,b);this.addGlobeExtVertex(A,C),this.addGlobeExtVertex(A,C),this.addGlobeExtVertex(A,C),this.addGlobeExtVertex(A,C)}const T=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),S=T.vertexLength;this.addCircleVertex(v,b,-1,-1),this.addCircleVertex(v,b,1,-1),this.addCircleVertex(v,b,1,1),this.addCircleVertex(v,b,-1,1),this.hdExt&&this.hdExt.writeVertexQuad(v,b),this.indexArray.emplaceBack(S,S+1,S+2),this.indexArray.emplaceBack(S,S+2,S+3),T.vertexLength+=4,T.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},s,l,h,void 0,this.worldview)}addCircleVertex(e,t,n,s){this.layoutVertexArray.emplaceBack(2*e+(n+1)/2,2*t+(s+1)/2)}addGlobeExtVertex(e,t){this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*16384,t[1]*16384,t[2]*16384)}}et(jp,"CircleBucket",{omit:["layers"]});const aw=ve([{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=ve([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),cw=ve([{name:"a_projected_pos",components:4,type:"Float32"}],4);ve([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const uw=ve([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),hw=ve([{name:"a_feature_index",components:1,type:"Float32"}],4),dw=ve([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),fw=ve([{name:"a_texb",components:2,type:"Uint16"}]),pw=ve([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),mw=ve([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ve([{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"}]);const Jy=ve([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),_w=ve([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ve([{name:"triangle",components:3,type:"Uint16"}]),ve([{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"}]),ve([{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"}]),ve([{type:"Float32",name:"offsetX"}]),ve([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const Qy=new Float32Array(1),gw=new Uint32Array(Qy.buffer);function Gp(i){return Qy[0]=i,gw[0]}const Ch=class qh{static getBlockIndices(e){let t=qh._blockIndicesTemplate;if(!t){t=qh._blockIndicesTemplate=new Uint32Array(e);for(let n=0;n<e;n++)t[n]=n}return t}constructor(e,t,n,s){this.batchIndex=t,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=e||null,this.propsDwords=n,this.totalBytes=4*this.propsDwords,this.headerData=s,this.propertiesData=new Float32Array(this.propsDwords),this._headerDirty=!0,this._propsDirtyMin=-1,this._propsDirtyMax=-1,this._blockIndicesDirty=!0,e&&this._initBuffers(e)}_initBuffers(e){const t=e.gl;if(this.totalBytes>e.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${e.maxUniformBlockSize}`);if(this.headerBuffer=t.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(t.bindBuffer(t.UNIFORM_BUFFER,this.headerBuffer),t.bufferData(t.UNIFORM_BUFFER,qh.HEADER_BYTES,t.DYNAMIC_DRAW),this.propertiesBuffer=t.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(t.bindBuffer(t.UNIFORM_BUFFER,this.propertiesBuffer),t.bufferData(t.UNIFORM_BUFFER,this.totalBytes,t.DYNAMIC_DRAW),this.blockIndicesBuffer=t.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");t.bindBuffer(t.UNIFORM_BUFFER,this.blockIndicesBuffer),t.bufferData(t.UNIFORM_BUFFER,this.totalBytes,t.DYNAMIC_DRAW),t.bindBuffer(t.UNIFORM_BUFFER,null)}markHeaderDirty(){this._headerDirty=!0}writeDataDrivenBlock(e,t){const n=this.headerData,s=4*n[2];if(s===0)return;const l=t*s;if(l+s>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${t} exceeds propertiesData capacity`);const c=n[0];for(let p=0;p<9;p++)c&1<<p&&this._copyFromFlat(l+4*n[3+p],p,e);(this._propsDirtyMin===-1||l<this._propsDirtyMin)&&(this._propsDirtyMin=l);const h=l+s;h>this._propsDirtyMax&&(this._propsDirtyMax=h)}rightSizeForTransfer(){const e=this._propsDirtyMax===-1?0:this._propsDirtyMax;e<this.propertiesData.length&&(this.propertiesData=this.propertiesData.slice(0,e))}_copyFromFlat(e,t,n){let s=4;(t<2||t===8)&&(s=this.headerData[1]>>>t&1?8:4);const l=qh.EVAL_FLAT_OFFSETS[t];this.propertiesData.set(n.subarray(l,l+s),e)}upload(e){this.context||(this.context=e);const t=e.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(e);let n=!1;if(this._headerDirty&&(t.bindBuffer(t.UNIFORM_BUFFER,this.headerBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.headerData),this._headerDirty=!1,n=!0),this._propsDirtyMin!==-1){const s=this._propsDirtyMin,l=this._propsDirtyMax;t.bindBuffer(t.UNIFORM_BUFFER,this.propertiesBuffer),t.bufferSubData(t.UNIFORM_BUFFER,4*s,this.propertiesData,s,l-s),this._propsDirtyMin=-1,this._propsDirtyMax=-1,n=!0}this._blockIndicesDirty&&(t.bindBuffer(t.UNIFORM_BUFFER,this.blockIndicesBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,qh.getBlockIndices(this.propsDwords)),this._blockIndicesDirty=!1,n=!0),n&&t.bindBuffer(t.UNIFORM_BUFFER,null)}bind(e,t){const n=e.gl,s=(c,h,p)=>{if(!h)return;const _=n.getUniformBlockIndex(t,c);_!==n.INVALID_INDEX&&(n.uniformBlockBinding(t,_,p),n.bindBufferBase(n.UNIFORM_BUFFER,p,h))},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){const 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)}}};Ch.HEADER_DWORDS=16,Ch.HEADER_BYTES=64,Ch.EVAL_FLAT_OFFSETS=[0,8,16,20,24,28,32,36,40],Ch.EVAL_FLAT_TOTAL=48,Ch._blockIndicesTemplate=null;let Wd=Ch;function ex(i,e,t,n,s,l,c,h){return!!i&&(i.kind==="constant"?i.value==="none":i.evaluate({zoom:0,brightness:l,worldview:h},e,t,s,n,c)==="none")}function tx(i){if(!(i instanceof Qs))return!1;const e=i.value;return(e.kind==="source"||e.kind==="composite")&&e.isStateDependent}et(Wd,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});const Xd=["icon","text"].map(i=>[`${i}-color`,`${i}-halo-color`,`${i}-opacity`,`${i}-halo-width`,`${i}-halo-blur`,`${i}-emissive-strength`,`${i}-occlusion-opacity`,"symbol-z-offset",`${i}-translate`]),cr=new Float32Array(Wd.EVAL_FLAT_TOTAL),yw=[0,0],ix=new WeakMap;class rg{constructor(e,t,n,s,l="",c,h){this.layer=e,this.zoom=t,this.lut=n,this.isText=s,this.worldview=l,this.maxUniformBufferBindings=c||24,this.uboSizeDwords=h||4096,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.allFormattedSections=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.ubos=[],this.featureCount=0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.cachedConstantPaint=null,this.activeAppearanceByVtIndex=null,this.zoomDependency=new Uint8Array(9),this.sharedZoomRanges=new Float32Array(18),this._zoomRangeScratch=new Float32Array(2),this._floorZoom=Math.floor(this.zoom),this.header=new Uint32Array(Wd.HEADER_DWORDS),this.updateHeader(),this.isAllConstant=this.header[0]===0;const p=4*this.header[2];this.maxFeaturesPerBatch=p===0?Number.MAX_SAFE_INTEGER:Math.floor(this.uboSizeDwords/p)}updateHeader(){const e=this.layer.paint;let t=0,n=0,s=0,l=0,c=!0;const h=this._floorZoom,p=Xd[+this.isText];for(let _=0;_<9;_++){const y=p[_],v=_<2,b=e.get(y),T=!(!b||typeof b.isConstant!="function"||b.isConstant()),S=this._appearancesHavePaintProperties(y);if(!T&&!S){const N=this._layerUnevaluated(y);N&&N.expression&&N.expression.kind==="camera"&&(s|=1<<_);continue}t|=1<<_;const A=this._collectZoomSignatures(y,h),C=A.hasZoom,D=A.differs,z=_===8;this.zoomDependency[_]=D?2:C?1:0;const O=D||z&&C;O&&(n|=1<<_);const F=b&&b.value;F&&F.isLightConstant===!1&&(c=!1),this.header[3+_]=l,l+=O?2:1,C&&!D&&A.representative&&(this._computeZoomRange(A.representative,h,this.sharedZoomRanges,2*_),v&&(this.header[12+2*_]=Gp(this.sharedZoomRanges[2*_]),this.header[12+2*_+1]=Gp(this.sharedZoomRanges[2*_+1])))}this.header[0]=t,this.header[1]=n,this.header[2]=l,this.isLightConstant=c,this.cameraMask=s}_recomputeSharedRanges(){const e=this._floorZoom,t=Xd[+this.isText];let n=0,s=!1;for(let l=0;l<9;l++){const c=t[l],h=this.zoomDependency[l];if(this.header[0]&1<<l){if(h!==0&&h!==2){const p=this._collectZoomSignatures(c,e);p.representative&&(this._computeZoomRange(p.representative,e,this.sharedZoomRanges,2*l),l<2&&(this.header[12+2*l]=Gp(this.sharedZoomRanges[2*l]),this.header[12+2*l+1]=Gp(this.sharedZoomRanges[2*l+1]),s=!0))}}else{const p=this._layerUnevaluated(c);p&&p.expression&&p.expression.kind==="camera"&&(n|=1<<l)}}if(this.cameraMask=n,s)for(const l of this.ubos)l.markHeaderDirty()}_collectZoomSignatures(e,t){let n=!1,s=!1,l=null,c=0,h=0;const p=_=>{if(!_)return;this._computeZoomRange(_,t,this._zoomRangeScratch,0);const y=this._zoomRangeScratch[0],v=this._zoomRangeScratch[1];n?y===c&&v===h||(s=!0):(n=!0,c=y,h=v,l=_)};p(this._zoomExprOf(this._layerUnevaluated(e)));for(const _ of this.layer.getAppearances()||[])_.hasPaintProperty(e)&&p(this._zoomExprOf(_.getUnevaluatedPaintProperty(e)));return{hasZoom:n,differs:s,representative:l}}evaluateAllProperties(e,t,n,s,l,c,h){const p={brightness:l,worldview:this.worldview},_={feature:e,featureState:t,canonical:n,availableImages:s,params:new zi(this.zoom,p),paramsNext:new zi(this.zoom+1,p),formattedSection:c,activeAppearance:h},y=Xd[+this.isText];for(let v=0;v<9;v++){const b=y[v],T=v<2,S=v===8,A=this.zoomDependency[v],C=A!==0,D=A===2,z=Wd.EVAL_FLAT_OFFSETS[v],O=z+(T||S?4:2);T?this._evaluateColorValue(b,v,C,D,O,_,z):S?this._evaluateTranslateValue(b,v,C,D,O,_,z):this._evaluateFloatValue(b,v,C,D,O,_,z)}return cr}_resolveProp(e,t,n=!1,s){const l=this.layer.paint,c=l.get(e),h=e,p=!(!t||!t.hasPaintProperty(h)),_=p?s&&c&&c.property.overrides&&c.property.overrides.hasOverride(s)?c:t.paintProperties.get(h):l.get(e);if(n||!_||typeof _.isConstant!="function"||!_.isConstant())return _;const y=p?t.getUnevaluatedPaintProperty(h):this._layerUnevaluated(e);return this._unbakeCamera(_,y)}_unbakeCamera(e,t){const n=t&&t.expression;if(!n||n.kind!=="camera")return e;let s=ix.get(t);return s||(s=new Qs(e.property,n,e.parameters,e.iconImageUseTheme),ix.set(t,s)),s}_layerUnevaluated(e){const t=this.layer._transitionablePaint._values[e];return t&&t.value}_zoomExprOf(e){const t=e&&e.expression;return!t||t.kind!=="composite"&&t.kind!=="camera"?null:t}_evalAt(e,t,n){return e.property.evaluate(e.value,t,n.feature,n.featureState,n.canonical,n.availableImages,e.iconImageUseTheme,n.formattedSection)}_evaluateColorValue(e,t,n,s,l,c,h){const p=this._resolveProp(e,c.activeAppearance,!1,c.formattedSection);if(this._writePropertyZoomRange(t,n,s,p,l),!p)return cr[h]=0,cr[h+1]=0,cr[h+2]=0,void(cr[h+3]=1);const _=this._resolveProp(`${e}-use-theme`,c.activeAppearance,!0),y=ex(_&&typeof _!="string"?_.value:void 0,c.feature,c.featureState,c.availableImages,c.canonical,c.params.brightness,c.formattedSection,this.worldview)?null:this.lut,v=(p.isConstant()?p.constantOr(Pt.transparent):this._evalAt(p,c.params,c)||Pt.transparent).toNonPremultipliedRenderColor(y);if(cr[h]=Pa(255*v.r,255*v.g),cr[h+1]=Pa(255*v.b,255*v.a),n){const b=(this._evalAt(p,c.paramsNext,c)||Pt.transparent).toNonPremultipliedRenderColor(y);cr[h+2]=Pa(255*b.r,255*b.g),cr[h+3]=Pa(255*b.b,255*b.a)}else cr[h+2]=cr[h],cr[h+3]=cr[h+1]}_computeZoomRange(e,t,n,s){let l=0,c=1;const h=!e||e.kind!=="composite"&&e.kind!=="camera"?null:e.zoomStops;if(h&&h.length>0)if(e.interpolationType==null){l=c=1;for(const p of h)if(p>t&&p<t+1){l=c=p-t;break}}else h[0]>t&&h[0]<t+1&&(l=h[0]-t);n[s]=l,n[s+1]=c}_writeZoomRange(e,t){this._computeZoomRange(e&&e.value,this._floorZoom,cr,t)}_writePropertyZoomRange(e,t,n,s,l){n?this._writeZoomRange(s,l):t?(cr[l]=this.sharedZoomRanges[2*e],cr[l+1]=this.sharedZoomRanges[2*e+1]):(cr[l]=0,cr[l+1]=0)}_evaluateFloatValue(e,t,n,s,l,c,h){const p=e.endsWith("opacity")?1:0,_=this._resolveProp(e,c.activeAppearance);this._writePropertyZoomRange(t,n,s,_,l);const y=(_?_.isConstant()?_.constantOr(p):this._evalAt(_,c.params,c):p)??p;if(cr[h]=y,n){const v=this._evalAt(_,c.paramsNext,c);cr[h+1]=v??p}else cr[h+1]=y}_evaluateTranslateValue(e,t,n,s,l,c,h){const p=this._resolveProp(e,c.activeAppearance);this._writePropertyZoomRange(t,n,s,p,l);const _=!!p&&typeof p.isConstant=="function"&&!p.isConstant(),y=p?typeof p.isConstant!="function"?p:_?this._evalAt(p,c.params,c):p.constantOr(yw):void 0;if(cr[h]=y?y[0]:0,cr[h+1]=y?y[1]:0,n){const v=_?this._evalAt(p,c.paramsNext,c):y;cr[h+2]=v?v[0]:0,cr[h+3]=v?v[1]:0}else cr[h+2]=cr[h],cr[h+3]=cr[h+1]}_appearancesHavePaintProperties(e){return this.layer.getAppearances().some(t=>t.hasPaintProperty(e))}hasStateDependentPaint(e){const t=e.paint,n=Xd[+this.isText];for(const s of n)if(tx(t.get(s)))return!0;for(const s of e.getAppearances()||[])for(const l of n){const c=l;if(s.hasPaintProperty(c)&&tx(s.paintProperties.get(c)))return!0}return!1}hasPerFeatureTranslate(){return!!(256&this.header[0])}getCurrentBatchIndex(){return this.maxFeaturesPerBatch===0?0:Math.floor(this.featureCount/this.maxFeaturesPerBatch)}_writeFeatureBlock(e,t){const n=this.isAllConstant?0:e;let s=Math.floor(n/this.maxFeaturesPerBatch),l=n%this.maxFeaturesPerBatch;this._batchExceedsDeviceLimit(s)&&(s=0,l=0);const c=this.ubos[s];return!!c&&(c.writeDataDrivenBlock(t,l),!0)}_batchExceedsDeviceLimit(e){return 3*e+2>=this.maxUniformBufferBindings}_reevaluateAt(e,t,n,s,l,c){if(!t)return;const h=this.allFeatureVtIndices[e],p=t.feature(h);if(!p)return;const _=this.allFeatureIds[e],y=_!=null&&l[_]||{},v={type:p.type,id:_,properties:p.properties||{},geometry:[]},b=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(h):void 0,T=this.evaluateAllProperties(v,y,n,s,c,(this.allFormattedSections?this.allFormattedSections[e]:void 0)||void 0,b);this._writeFeatureBlock(e,T)}_ensureRangeMaps(){if(!this.featureVertexRangesFromId){this.featureVertexRangesFromId=new Map,this.featureVertexRangesFromVtIndex=new Map;for(let e=0;e<this.allFeatureVtIndices.length;e++){const t=this.allFeatureIds[e];if(t!=null){let l=this.featureVertexRangesFromId.get(t);l||this.featureVertexRangesFromId.set(t,l=[]),l.push(e)}const n=this.allFeatureVtIndices[e];let s=this.featureVertexRangesFromVtIndex.get(n);s||this.featureVertexRangesFromVtIndex.set(n,s=[]),s.push(e)}}}populateUBO(e,t,n,s,l,c){const h=e.id,p=this.header,_=this.evaluateAllProperties(e,{},n,s,l,c);let y,v;this.isAllConstant?(y=0,v=this.featureCount===0,v&&(this.featureCount=1)):(y=this.featureCount++,v=!0);let b=Math.floor(y/this.maxFeaturesPerBatch),T=y%this.maxFeaturesPerBatch;return v&&(this._batchExceedsDeviceLimit(b)?(_i(`Too many symbol features: batch ${b} requires binding points up to ${3*b+2}, device limit ${this.maxUniformBufferBindings}. Some features will render incorrectly.`),b=0,T=0):(this.ubos[b]||(this.ubos[b]=new Wd(null,b,this.uboSizeDwords,p)),this.ubos[b].writeDataDrivenBlock(_,T))),this.allFeatureVtIndices.push(t),this.allFeatureIds.push(h),this.allFormattedSections.push(c||null),T}updateFeatures(e,t,n,s,l,c,h){this.layer=t,this.cachedConstantUniforms=null,this._ensureRangeMaps();for(const p of e){const _=this.featureVertexRangesFromId.get(p);if(_)for(const y of _)this._reevaluateAt(y,n,s,l,c,h)}}updateDynamicExpressions(e,t,n,s,l,c){if(this.layer=e,this.cachedConstantUniforms=null,this._recomputeSharedRanges(),this.header[0]!==0)for(let h=0;h<this.allFeatureVtIndices.length;h++)this._reevaluateAt(h,t,n,s,l,c)}updateFeaturePaintForAppearance(e,t,n,s,l,c,h){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(e,h||null),this.header[0]===0))return!1;this._ensureRangeMaps();const p=this.featureVertexRangesFromVtIndex.get(e);if(!p)return!1;let _=!1;for(const y of p){const v=this.evaluateAllProperties(t,n,s,l,c,(this.allFormattedSections?this.allFormattedSections[y]:void 0)||void 0,h);_=this._writeFeatureBlock(y,v)||_}return _}getConstantUniformValues(e,t){const n=!!this.cameraMask;if(this.cachedConstantUniforms&&this.cachedConstantPaint===this.layer.paint&&this.cachedConstantBrightness===t&&(!n||this.cachedConstantRenderZoom===e))return this.cachedConstantUniforms;const s=this.layer.paint,l=n?new zi(e,{brightness:t,worldview:this.worldview}):null,c={type:1,id:void 0,properties:{},geometry:[]},h=Xd[+this.isText],p=v=>{const b=h[v],T=s.get(b);if(!T)return[0,0,0,1];const S=s.get(`${b}
7-use-theme`),A=ex(S&&typeof S!="string"?S.value:void 0,c,{},[],void 0,t,void 0,this.worldview)?null:this.lut;return(this.cameraMask&1<<v&&l?T.property.evaluate(T.value,l,c,{},void 0,[])||Pt.transparent:T.constantOr(Pt.transparent)).toNonPremultipliedRenderColor(A).toArray01()},_=(v,b)=>{const T=s.get(h[v]);return T?this.cameraMask&1<<v&&l?T.property.evaluate(T.value,l,c,{},void 0,[])??b:T.constantOr(b):b},y={fill_np_color:p(0),halo_np_color:p(1),opacity:_(2,1),halo_width:_(3,0),halo_blur:_(4,0),emissive_strength:_(5,0),occlusion_opacity:_(6,1),z_offset:_(7,0)};return this.cachedConstantUniforms=y,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=t,this.cachedConstantPaint=this.layer.paint,y}finalize(){for(const e of this.ubos)e.rightSizeForTransfer()}upload(e){for(const t of this.ubos)t.upload(e)}bind(e,t,n=0){this.ubos[n]&&this.ubos[n].bind(e,t)}destroy(){for(const e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.featureCount=0,this.maxFeaturesPerBatch=0}}et(rg,"SymbolPropertyBinderUBO",{omit:["layer","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","cachedConstantPaint","activeAppearanceByVtIndex","featureVertexRangesFromId","featureVertexRangesFromVtIndex"]});const Mh=24;function xw(i,e,t){return i.sections.forEach(n=>{n.text=function(s,l,c){const h=l.layout.get("text-transform").evaluate(c,{});return h==="uppercase"?s=s.toLocaleUpperCase():h==="lowercase"&&(s=s.toLocaleLowerCase()),ps.applyArabicShaping&&(s=ps.applyArabicShaping(s)),s}(n.text,e,t)}),i}const Al={horizontal:1,vertical:2,horizontalOnly:3};function rx(i){let e=.5,t=.5;switch(i){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(i){case"bottom":case"bottom-right":case"bottom-left":t=1;break;case"top":case"top-right":case"top-left":t=0}return{horizontalAlign:e,verticalAlign:t}}function nx(i,e,t,n){const{horizontalAlign:s,verticalAlign:l}=rx(n),c=t[0]-i.displaySize[0]*s,h=t[1]-i.displaySize[1]*l;return{imagePrimary:i,imageSecondary:e,top:h,bottom:h+i.displaySize[1],left:c,right:c+i.displaySize[0]}}function ox(i,e,t,n,s,l){const c=i.imagePrimary;let h;if(c.content){const C=c.content,D=c.pixelRatio||1;h=[C[0]/D,C[1]/D,c.displaySize[0]-C[2]/D,c.displaySize[1]-C[3]/D]}const p=e.left*l,_=e.right*l;let y,v,b,T;t==="width"||t==="both"?(T=s[0]+p-n[3],v=s[0]+_+n[1]):(T=s[0]+(p+_-c.displaySize[0])/2,v=T+c.displaySize[0]);const S=e.top*l,A=e.bottom*l;return t==="height"||t==="both"?(y=s[1]+S-n[0],b=s[1]+A+n[2]):(y=s[1]+(S+A-c.displaySize[1])/2,b=y+c.displaySize[1]),{imagePrimary:c,imageSecondary:void 0,top:y,right:v,bottom:b,left:T,collisionPadding:h}}const Yd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function vw(i){return i==="︶"||i==="﹈"||i==="︸"||i==="﹄"||i==="﹂"||i==="︾"||i==="︼"||i==="︺"||i==="︘"||i==="﹀"||i==="︐"||i==="︓"||i==="︔"||i==="`"||i===" ̄"||i==="︑"||i==="︒"}function bw(i){return i==="︵"||i==="﹇"||i==="︷"||i==="﹃"||i==="﹁"||i==="︽"||i==="︻"||i==="︹"||i==="︗"||i==="︿"}const gc=128;function Rh(i,e,t,n){const{expression:s}=e;if(s.kind==="constant")return{kind:"constant",layoutSize:s.evaluate(new zi(i+1,{worldview:t}),void 0,void 0,void 0,n)};if(s.kind==="source")return{kind:"source"};{const{zoomStops:l,interpolationType:c}=s;let h=0;for(;h<l.length&&l[h]<=i;)h++;h=Math.max(0,h-1);let p=h;for(;p<l.length&&l[p]<i+1;)p++;p=Math.min(l.length-1,p);const _=l[h],y=l[p];return s.kind==="composite"?{kind:"composite",minZoom:_,maxZoom:y,interpolationType:c}:{kind:"camera",minZoom:_,maxZoom:y,minSize:s.evaluate(new zi(_,{worldview:t}),void 0,void 0,void 0,n),maxSize:s.evaluate(new zi(y,{worldview:t}),void 0,void 0,void 0,n),interpolationType:c}}}function Hp(i,{uSize:e,uSizeT:t},{lowerSize:n,upperSize:s}){return i.kind==="source"?n/gc:i.kind==="composite"?lt(n/gc,s/gc,t):e}function Tu(i,e,t=1){let n=0,s=0;if(i.kind==="constant")s=i.layoutSize*t;else if(i.kind!=="source"){const{interpolationType:l,minZoom:c,maxZoom:h}=i,p=l?vt(zo.interpolationFactor(l,e,c,h),0,1):0;
vendor: 9,243 bytes, line 7
7i.kind==="camera"?s=lt(i.minSize,i.maxSize,p)*t:n=p*t}return{uSizeT:n,uSize:s}}const ww=Number.POSITIVE_INFINITY,Tw=Math.sqrt(2),Eu=32640;function Ph(i,e,t,n,s,l,c){const h=i.hasLayoutProperty(s)?e.getAppearanceValueAndResolveTokens(i,s,t,n,[]):null;return(Array.isArray(l)?Array.isArray(h):typeof h==typeof l)?c?c(h):h:l}function sx(i,e,t,n,s,l,c,h){return{appearanceIconOffset:Ph(i,e,t,n,"icon-offset",s),appearanceIconRotate:Ph(i,e,t,n,"icon-rotate",l),appearanceIconSize:Ph(i,e,t,n,"icon-size",c,p=>p*h)}}function ax(i,e,t,n,s,l,c){return{appearanceTextOffset:Ph(i,e,t,n,"text-offset",s,([p,_])=>[p*Mh,_*Mh]),appearanceTextRotate:Ph(i,e,t,n,"text-rotate",l),appearanceTextSize:Ph(i,e,t,n,"text-size",c)}}function lx(i,e,t,n,s,l,c,h,p,_){if(!i)return;const y=function(v,b,T,S,A,C,D){if(v.kind==="camera")return v.maxSize;if(v.kind==="composite"){const z=b.possiblyEvaluate(new zi(v.maxZoom,{worldview:C}),T,D).evaluate(A,{},T,D),O=b.possiblyEvaluate(new zi(v.minZoom,{worldview:C}),T,D).evaluate(A,{},T,D);return Math.max(z,O)}return b.possiblyEvaluate(new zi(S,{worldview:C}),T,D).evaluate(A,{},T,D)}(e,t,n,s,l,p,_);return i.scaleSelf(y*h*c)}function ng(i,e,t,n,s,l,c,h,p,_){return{iconPrimary:lx(i.getPrimary(),e,t,n,s,l,c,h,p,_),iconSecondary:lx(i.getSecondary(),e,t,n,s,l,c,h,p,_)}}function cx(i,e){return i*e/24}function ux(i,e,t,n,s,l){let c=null;return e.kind==="source"?(c=[gc*t*n],c[0]>Eu&&_i(`${i}: Value for "text-size" or "icon-size" is >= 255. Reduce your "text-size" or "icon-size".`)):e.kind==="composite"&&(c=[gc*s*n,gc*l*n],(c[0]>Eu||c[1]>Eu)&&_i(`${i}: Value for "text-size" or "icon-size" is >= 255. Reduce your "text-size" or "icon-size".`)),c}const Ew=ve([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Zp}=Ew,Sw=ve([{name:"a_pos_3",components:3,type:"Int16"}]);var og=ve([{name:"a_pos",type:"Int16",components:2}]);class Iw{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,n){const s=Wa(t,this.dir);if(Math.abs(s)<1e-6)return!1;const l=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1])/s;return n[0]=this.pos[0]+this.dir[0]*l,n[1]=this.pos[1]+this.dir[1]*l,!0}}class $p{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,n){const s=Ri(t,this.dir);if(Math.abs(s)<1e-6)return!1;const l=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/s;return n[0]=this.pos[0]+this.dir[0]*l,n[1]=this.pos[1]+this.dir[1]*l,n[2]=this.pos[2]+this.dir[2]*l,!0}closestPointOnSphere(e,t,n){if(function(T,S){var A=T[0],C=T[1],D=T[2],z=S[0],O=S[1],F=S[2];return Math.abs(A-z)<=Xn*Math.max(1,Math.abs(A),Math.abs(z))&&Math.abs(C-O)<=Xn*Math.max(1,Math.abs(C),Math.abs(O))&&Math.abs(D-F)<=Xn*Math.max(1,Math.abs(D),Math.abs(F))}(this.pos,e)||t===0)return n[0]=n[1]=n[2]=0,!1;const[s,l,c]=this.dir,h=this.pos[0]-e[0],p=this.pos[1]-e[1],_=this.pos[2]-e[2],y=s*s+l*l+c*c,v=2*(h*s+p*l+_*c),b=v*v-4*y*(h*h+p*p+_*_-t*t);if(b<0){const T=Math.max(-v/2,0),S=h+s*T,A=p+l*T,C=_+c*T,D=Math.hypot(S,A,C);return n[0]=S*t/D,n[1]=A*t/D,n[2]=C*t/D,!1}{const T=(-v-Math.sqrt(b))/(2*y);if(T<0){const S=Math.hypot(h,p,_);return n[0]=h*t/S,n[1]=p*t/S,n[2]=_*t/S,!1}return n[0]=h+s*T,n[1]=p+l*T,n[2]=_+c*T,!0}}}class sg{constructor(e,t,n,s,l){this.TL=e,this.TR=t,this.BR=n,this.BL=s,this.horizon=l}static fromInvProjectionMatrix(e,t,n){const s=[-1,1,1],l=[1,1,1],c=[1,-1,1],h=[-1,-1,1],p=hi(s,s,e),_=hi(l,l,e),y=hi(c,c,e),v=hi(h,h,e);return new sg(p,_,y,v,t/n)}}function ag(i,e,t,n){const s=e[0],l=e[1],c=e[2],h=t[0],p=t[1],_=t[2];let y=1/0,v=-1/0;for(let b=0;b<i.length;b++){const T=i[b],S=(T[0]-s)*h+(T[1]-l)*p+(T[2]-c)*_;S<y&&(y=S),S>v&&(v=S)}return n[0]=y,n[1]=v,n}function hx(i,e){let t=!0;for(let n=0;n<i.planes.length;n++){const s=i.planes[n];let l=0;for(let c=0;c<e.length;c++)l+=+(Ri(s,e[c])+s[3]>=0);if(l===0)return 0;l!==e.length&&(t=!1)}return t?2:1}const Aw=[0,0];function dx(i,e){for(const t of i.projections){const n=ag(e,i.points[0],t.axis,Aw);if(t.projection[1]<n[0]||t.projection[0]>n[1])return 0}return 1}function fx(i,e){const t=e[0],n=e[1],s=e[2],l=e[3];for(let c=0;c<i.length;c++){const h=i[c];if(t*h[0]+n*h[1]+s*h[2]+l>=0)return!0}return!1}class Cl{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=Di.fromPoints(this.points),this.projections=[],this.frustumEdges=[Pi([],this.points[2],this.points[3]),Pi([],this.points[0],this.points[3]),Pi([],this.points[4],this.points[0]),Pi([],this.points[5],this.points[1]),Pi([],this.points[6],this.points[2]),Pi([],this.points[7],this.points[3])];for(const n of this.frustumEdges){const s=[0,-n[2],n[1]],l=[n[2],0,-n[0]];this.projections.push({axis:s,projection:ag(this.points,this.points[0],s,[0,0])}),this.projections.push({axis:l,projection:ag(this.points,this.points[0],l,[0,0])})}}static fromInvProjectionMatrix(e,t,n,s){const l=Math.pow(2,n),c=[[-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(_=>{const y=lr([],_,e),v=1/y[3]/t*l;return(b=y)[0]=(T=y)[0]*(S=[v,v,s?1/y[3]:v,v])[0],b[1]=T[1]*S[1],b[2]=T[2]*S[2],b[3]=T[3]*S[3],b;var b,T,S}),h=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(_=>{const y=ei([],gr([],Pi([],c[_[0]],c[_[1]]),Pi([],c[_[2]],c[_[1]]))),v=-Ri(y,c[_[1]]);return y.concat(v)}),p=[];for(let _=0;_<c.length;_++)p.push([c[_][0],c[_][1],c[_][2]]);return new Cl(p,h)}intersectsPrecise(e,t,n){for(let p=0;p<t.length;p++)if(!fx(e,t[p]))return 0;for(let p=0;p<this.planes.length;p++)if(!fx(e,this.planes[p]))return 0;const s=this.points,l=s[0][0],c=s[0][1],h=s[0][2];for(const p of n)for(const _ of this.frustumEdges){const y=p[1]*_[2]-p[2]*_[1],v=p[2]*_[0]-p[0]*_[2],b=p[0]*_[1]-p[1]*_[0];if(y===0&&v===0&&b===0)continue;let T=1/0,S=-1/0;for(let D=0;D<s.length;D++){const z=s[D],O=(z[0]-l)*y+(z[1]-c)*v+(z[2]-h)*b;O<T&&(T=O),O>S&&(S=O)}let A=1/0,C=-1/0;for(let D=0;D<e.length;D++){const z=e[D],O=(z[0]-l)*y+(z[1]-c)*v+(z[2]-h)*b;O<A&&(A=O),O>C&&(C=O)}if(T>C||A>S)return 0}return 1}containsPoint(e){for(const t of this.planes){const n=t[3];if(Ri([t[0],t[1],t[2]],e)+n<0)return!1}return!0}}class Di{static fromPoints(e){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const s of e)Ns(t,t,s),Vs(n,n,s);return new Di(t,n)}static fromTileIdAndHeight(e,t,n){const s=1<<e.canonical.z,l=e.canonical.x,c=e.canonical.y;return new Di([l/s,c/s,t],[(l+1)/s,(c+1)/s,n])}static applyTransform(e,t){const n=e.getCorners();for(let s=0;s<n.length;++s)hi(n[s],n[s],t);return Di.fromPoints(n)}static applyTransformFast(e,t){const n=[t[12],t[13],t[14]],s=[...n];for(let l=0;l<3;l++)for(let c=0;c<3;c++){const h=t[4*c+l],p=h*e.min[c],_=h*e.max[c];n[l]+=Math.min(p,_),s[l]+=Math.max(p,_)}return new Di(n,s)}static projectAabbCorners(e,t){const n=e.getCorners();for(let s=0;s<n.length;++s)hi(n[s],n[s],t);return n}constructor(e,t){this.min=e,this.max=t,this.center=si([],Ji([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],n=ks(this.min),s=ks(this.max);for(let l=0;l<t.length;l++)n[l]=t[l]?this.min[l]:this.center[l],s[l]=t[l]?this.center[l]:this.max[l];return s[2]=this.max[2],new Di(n,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(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?hx(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?hx(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,t){return t||this.intersects(e)?dx(e,this.getCorners()):0}intersectsPreciseFlat(e,t){return t||this.intersectsFlat(e)?dx(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 t=0;t<3;++t)if(this.min[t]>e.max[t]||e.min[t]>this.max[t])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 t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}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])]}}function qp(i){return i*On/o}et(Di,"Aabb");const Cw=[new Di([_o,_o,_o],[ms,ms,ms]),new Di([_o,_o,_o],[0,0,ms]),new Di([0,_o,_o],[ms,0,ms]),new Di([_o,0,_o],[0,ms,ms]),new Di([0,0,_o],[ms,ms,ms])];function px(i,e,t,n=!0){const s=si([],i._camera.position,i.worldSize),l=[e,t,1,1];lr(l,l,i.pixelMatrixInverse),Zo(l,l,1/l[3]);const c=ei([],Pi([],l,s)),h=i.globeMatrix,p=[h[12],h[13],h[14]],_=Pi([],p,s),y=Ki(_),v=ei([],_),b=i.worldSize/(2*Math.PI),T=Ri(v,c),S=Math.asin(b/y);if(S<Math.acos(T)){if(!n)return null;const K=[],ee=[];si(K,c,y/T),ei(ee,Pi(ee,K,_)),ei(c,Ji(c,_,si(c,ee,Math.tan(S)*y)))}const A=[];new $p(s,c).closestPointOnSphere(p,b,A);
vendor: 4,742 bytes, line 7
7const C=ei([],Fr(h,0)),D=ei([],Fr(h,1)),z=ei([],Fr(h,2)),O=Ri(C,A),F=Ri(D,A),N=Ri(z,A),j=Gr(Math.asin(-F/b));let te=Gr(Math.atan2(O,N));te=i.center.lng+function(K,ee){const ae=(ee-K+180)%360-180;return ae<-180?ae+360:ae}(i.center.lng,te);const H=fo(te),W=vt($n(j),0,1);return new V(H,W)}class Mw{constructor(e,t,n){this.a=Pi([],e,n),this.b=Pi([],t,n),this.center=n;const s=ei([],this.a),l=ei([],this.b);this.angle=Math.acos(Ri(s,l))}}function lg(i,e){if(i.angle===0)return null;let t;return t=i.a[e]===0?1/i.angle*.5*Math.PI:1/i.angle*Math.atan(i.b[e]/i.a[e]/Math.sin(i.angle)-1/Math.tan(i.angle)),t<0||t>1?null:function(n,s,l,c){const h=Math.sin(l);return n*(Math.sin((1-c)*l)/h)+s*(Math.sin(c*l)/h)}(i.a[e],i.b[e],i.angle,vt(t,0,1))+i.center[e]}function za(i){if(i.z<=1)return Cw[i.z+2*i.y+i.x];const e=ug(Wp(i));return Di.fromPoints(e)}function Ml(i,e,t){return si(i,i,1-t),cn(i,i,e,t)}function mx(i,e,t){for(const n of i)hi(n,n,e),si(n,n,t)}function cg(i,e,t,n){const s=e/i.worldSize,l=i.globeMatrix;if(t.z<=1){const W=za(t).getCorners();return mx(W,l,s),Di.fromPoints(W)}const c=Wp(t,n),h=ug(c,On+qp(i._tileCoverLift));mx(h,l,s);const p=Number.MAX_VALUE,_=[-p,-p,-p],y=[p,p,p];if(c.contains(i.center)){for(const ee of h)Ns(y,y,ee),Vs(_,_,ee);_[2]=0;const W=i.point,K=[W.x*s,W.y*s,0];return Ns(y,y,K),Vs(_,_,K),new Di(y,_)}if(i._tileCoverLift>0){for(const W of h)Ns(y,y,W),Vs(_,_,W);return new Di(y,_)}const v=[l[12]*s,l[13]*s,l[14]*s],b=c.getCenter(),T=vt(i.center.lat,-85.051129,E),S=vt(b.lat,-85.051129,E),A=fo(i.center.lng),C=$n(T);let D=A-fo(b.lng);const z=C-$n(S);D>.5?D-=1:D<-.5&&(D+=1);let O=0;Math.abs(D)>Math.abs(z)?O=D>=0?1:3:(O=z>=0?0:2,cn(v,v,[l[4]*s,l[5]*s,l[6]*s],-Math.sin(Ot(z>=0?c.getSouth():c.getNorth()))*On));const F=h[O],N=h[(O+1)%4],j=new Mw(F,N,v),te=[lg(j,0)||F[0],lg(j,1)||F[1],lg(j,2)||F[2]],H=Rl(i.zoom);if(H>0){const W=function({x:ee,y:ae,z:he},be,xe,Te,Fe){const se=1/(1<<he);let fe=ee*se,ge=fe+se,Ae=ae*se,Me=Ae+se,ze=0;const Ce=(fe+ge)/2-Te;return Ce>.5?ze=-1:Ce<-.5&&(ze=1),fe=((fe+ze)*be-(Te*=be))*xe+Te,ge=((ge+ze)*be-Te)*xe+Te,Ae=(Ae*be-(Fe*=be))*xe+Fe,Me=(Me*be-Fe)*xe+Fe,[[fe,Me,0],[ge,Me,0],[ge,Ae,0],[fe,Ae,0]]}(t,e,i._pixelsPerMercatorPixel,A,C);for(let ee=0;ee<h.length;ee++)Ml(h[ee],W[ee],H);const K=Ji([],W[O],W[(O+1)%4]);si(K,K,.5),Ml(te,K,H)}for(const W of h)Ns(y,y,W),Vs(_,_,W);return y[2]=Math.min(F[2],N[2]),Ns(y,y,te),Vs(_,_,te),new Di(y,_)}function Wp({x:i,y:e,z:t},n=!1){const s=1/(1<<t),l=new f(qn(i*s),e===(1<<t)-1&&n?-90:vr((e+1)*s)),c=new f(qn((i+1)*s),e===0&&n?90:vr(e*s));return new m(l,c)}function ug(i,e=On){const t=Ot(i.getNorth()),n=Ot(i.getSouth()),s=Math.cos(t),l=Math.cos(n),c=Math.sin(t),h=Math.sin(n),p=i.getWest(),_=i.getEast();return[a(l,h,p,e),a(l,h,_,e),a(s,c,_,e),a(s,c,p,e)]}function Kd(i,e,t,n){const s=1<<t.z,l=(i/qe+t.x)/s;return r(vr((e/qe+t.y)/s),qn(l),n)}function Xp({min:i,max:e}){return 16383/Math.max(e[0]-i[0],e[1]-i[1],e[2]-i[2])}const Yp=new Float64Array(16);function Kp(i){const e=Xp(i),t=Ho(Yp,[e,e,e]);return Yi(t,t,ns([],i.min))}function hg(i){const e=1/Xp(i);return Bs(Yp,i.min),hr(Yp,Yp,[e,e,e])}function dg(i){const e=qe/(2*Math.PI);return i/(2*Math.PI)/e}function _x(i,e){return qe/(512*Math.pow(2,i))*Xp(za(e))}function gx(i,e,t,n,s){const l=dg(t),c=[i,e,-t/(2*Math.PI)],h=rr(new Float64Array(16));return Yi(h,h,c),hr(h,h,[l,l,l]),Es(h,h,Ot(-s)),Io(h,h,Ot(-n)),h}function Rl(i){return cs(5,6,i)}function yx(i,e){const t=r(e.lat,e.lng),n=function(S){const A=r(S._center.lat,S._center.lng);let C=gr([],br(0,1,0),A);const D=Kn([],-S.angle,A);C=hi(C,C,D),Kn(D,-S._pitch,C);const z=ei([],A);return si(z,z,qp(S.cameraToCenterDistance/S.pixelsPerMeter)),hi(z,z,D),Ji([],A,z)}(i);return c=(s=Jn([],n,t))[0],h=s[1],p=s[2],_=(l=t)[0],y=l[1],v=l[2],T=(b=Math.sqrt((c*c+h*h+p*p)*(_*_+y*y+v*v)))&&Ri(s,l)/b,Math.acos(Math.min(Math.max(T,-1),1));var s,l,c,h,p,_,y,v,b,T}function fg(i,e){return yx(i,e)>Math.PI/2*1.01}const xx=Ot(85),Rw=Math.cos(xx),Pw=Math.sin(xx);function vx(i,e){const t=i.fovAboveCenter,n=i.elevation?i.elevation.getMinElevationBelowMSL()*e:0,s=Math.min(n,i.isOrthographic?-10*e:0),l=(i._camera.position[2]*i.worldSize-s)/Math.cos(i._pitch),c=Math.sin(t)*l/Math.sin(Math.max(Math.PI/2-i._pitch-t,.01));let h=Math.sin(i._pitch)*c+l;const p=l*(1/i._horizonShift);if(!i.elevation||i.elevation.exaggeration()===0){let _=Math.max(i.zoom-17,0);i.isOrthographic&&(_/=10),h*=1+_}return Math.min(1.01*h,p)}class yc{constructor(e,t,n){this.z=e,this.x=t,this.y=n,this.key=xc(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){const t=this.z-e.z;return e.z===0||e.z<this.z&&e.x===this.x>>t&&e.y===this.y>>t}url(e,t){const n=function(l,c,h){const p=2**h,_=2*Math.PI*6378137,y=_*(l/p-.5),v=_*(.5-(c+1)/p);return`${y},${v}
7,${y+_/p},${v+_/p}`}(this.x,this.y,this.z),s=function(l,c,h){let p,_="";for(let y=l;y>0;y--)p=1<<y-1,_+=(c&p?1:0)+(h&p?2:0);return _}(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(t==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",s).replace("{bbox-epsg-3857}",n)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Jp{constructor(e,t){this.wrap=e,this.canonical=t,this.key=xc(e,t.z,t.z,t.x,t.y)}}class Wr{constructor(e,t,n,s,l){this.overscaledZ=e,this.wrap=t,this.canonical=new yc(n,+s,+l),this.key=t===0&&e===n?this.canonical.key:xc(t,e,n,s,l)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new Wr(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Wr(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return xc(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return xc(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=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>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Wr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,n=2*this.canonical.x,s=2*this.canonical.y;return[new Wr(t,this.wrap,t,n,s),new Wr(t,this.wrap,t,n+1,s),new Wr(t,this.wrap,t,n,s+1),new Wr(t,this.wrap,t,n+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 Wr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Wr(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 Jp(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function xc(i,e,t,n,s){const l=1<<Math.min(t,22);let c=l*(s%l)+n%l;return i&&t<22&&(c+=l*l*((i<0?-2*i-1:2*i)%(1<<2*(22-t)))),16*(32*c+t)+(e-t)}const bx=[i=>{let e=i.canonical.x-1,t=i.wrap;return e<0&&(e=(1<<i.canonical.z)-1,t--),new Wr(i.overscaledZ,t,i.canonical.z,e,i.canonical.y)},i=>{let e=i.canonical.x+1,t=i.wrap;return e===1<<i.canonical.z&&(e=0,t++),new Wr(i.overscaledZ,t,i.canonical.z,e,i.canonical.y)},i=>new Wr(i.overscaledZ,i.wrap,i.canonical.z,i.canonical.x,(i.canonical.y===0?1<<i.canonical.z:i.canonical.y)-1),i=>new Wr(i.overscaledZ,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y===(1<<i.canonical.z)-1?0:i.canonical.y+1)];function pg(i,e){if(!e.isReprojectedInTileSpace)return{scale:1<<i.z,x:i.x,y:i.y,x2:i.x+1,y2:i.y+1,projection:e};const t=Math.pow(2,-i.z),n=i.x*t,s=(i.x+1)*t,l=i.y*t,c=(i.y+1)*t,h=qn(n),p=qn(s),_=vr(l),y=vr(c),v=e.project(h,_),b=e.project(p,_),T=e.project(p,y),S=e.project(h,y);let A=Math.min(v.x,b.x,T.x,S.x),C=Math.min(v.y,b.y,T.y,S.y),D=Math.max(v.x,b.x,T.x,S.x),z=Math.max(v.y,b.y,T.y,S.y);const O=t/16;function F(j,te,H,W,K,ee){const ae=(H+K)/2,he=(W+ee)/2,be=e.project(qn(ae),vr(he)),xe=Math.max(0,A-be.x,C-be.y,be.x-D,be.y-z);A=Math.min(A,be.x),D=Math.max(D,be.x),C=Math.min(C,be.y),z=Math.max(z,be.y),xe>O&&(F(j,be,H,W,ae,he),F(be,te,ae,he,K,ee))}F(v,b,n,l,s,l),F(b,T,s,l,s,c),F(T,S,s,c,n,c),F(S,v,n,c,n,l),A-=O,C-=O,D+=O,z+=O;const N=1/Math.max(D-A,z-C);return{scale:N,x:A*N,y:C*N,x2:D*N,y2:z*N,projection:e}}function wx(i,e,t,n,s,l,c,h,p){if(p.name==="globe")return cg(i,e,new yc(t,n,s),!1);const _=pg({z:t,x:n,y:s},p);return new Di([(l+_.x/_.scale)*e,e*(_.y/_.scale),c],[(l+_.x2/_.scale)*e,e*(_.y2/_.scale),h
vendor: 146,593 bytes, line 7
7])}et(yc,"CanonicalTileID"),et(Wr,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const Dw=rr(new Float32Array(16));class vc{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,t){return{x:0,y:0,z:0}}unproject(e,t){return new f(0,0)}projectTilePoint(e,t,n){return{x:e,y:t,z:0}}locationPoint(e,t,n,s=!0){return e._coordinatePoint(e.locationCoordinate(t,n),s)}pixelsPerMeter(e,t){return x(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return vx(e,e.pixelsPerMeter)}pointCoordinate(e,t,n,s){const l=e.horizonLineFromTop(!1),c=new De(t,Math.max(l,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(c,s))}pointCoordinate3D(e,t,n){const s=new De(t,n);if(e.elevation)return e.elevation.pointCoordinate(s);{const l=this.pointCoordinate(e,s.x,s.y,0);return[l.x,l.y,l.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);const n=e.horizonLineFromTop();return t.y<n}createInversionMatrix(e,t){return Dw}createTileMatrix(e,t,n){let s,l,c;const h=n.canonical,p=rr(new Float64Array(16));if(this.isReprojectedInTileSpace){const _=pg(h,this);s=1,l=_.x+n.wrap*_.scale,c=_.y,hr(p,p,[s/_.scale,s/_.scale,e.pixelsPerMeter/t])}else s=t/e.zoomScale(h.z),l=(h.x+Math.pow(2,h.z)*n.wrap)*s,c=h.y*s;return Yi(p,p,[l,c,0]),hr(p,p,[s/qe,s/qe,1]),p}upVector(e,t,n){return[0,0,1]}upVectorScale(e,t,n){return{metersToTile:1}}}class Lw extends vc{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,n]=this.parallels=e.parallels||[29.5,45.5],s=Math.sin(Ot(t));this.n=(s+Math.sin(Ot(n)))/2,this.c=1+s*(2*this.n-s),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n,c:s,r0:l}=this,c=Ot(e-this.center[0]),h=Ot(t),p=Math.sqrt(s-2*n*Math.sin(h))/n;return{x:p*Math.sin(c*n),y:p*Math.cos(c*n)-l,z:0}}unproject(e,t){const{n,c:s,r0:l}=this,c=l+t;let h=Math.atan2(e,Math.abs(c))*Math.sign(c);c*n<0&&(h-=Math.PI*Math.sign(e)*Math.sign(c));const p=Ot(this.center[0])*n;h=xn(h,-Math.PI-p,Math.PI-p);const _=vt(Gr(h/n)+this.center[0],-180,180),y=Math.asin(vt((s-(e*e+c*c)*n*n)/(2*n),-1,1)),v=vt(Gr(y),-85.051129,E);return new f(_,v)}}const Jd=1.340264,Qd=-.081106,ef=893e-6,tf=.003796,Qp=Math.sqrt(3)/2;class zw extends vc{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const n=Math.asin(Qp*Math.sin(t)),s=n*n,l=s*s*s;return{x:.5*(e*Math.cos(n)/(Qp*(Jd+3*Qd*s+l*(7*ef+9*tf*s)))/Math.PI+.5),y:1-.5*(n*(Jd+Qd*s+l*(ef+tf*s))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let n=t=(2*(1-t)-1)*Math.PI,s=n*n,l=s*s*s;for(let y,v,b,T=0;T<12&&(v=n*(Jd+Qd*s+l*(ef+tf*s))-t,b=Jd+3*Qd*s+l*(7*ef+9*tf*s),y=v/b,n=vt(n-y,-Math.PI/3,Math.PI/3),s=n*n,l=s*s*s,!(Math.abs(y)<1e-12));++T);const c=Qp*e*(Jd+3*Qd*s+l*(7*ef+9*tf*s))/Math.cos(n),h=Math.asin(Math.sin(n)/Qp),p=vt(180*c/Math.PI,-180,180),_=vt(180*h/Math.PI,-85.051129,E);return new f(p,_)}}class Fw extends vc{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){return{x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const n=360*(e-.5),s=vt(360*(.5-t),-85.051129,E);return new f(n,s)}}const Dh=Math.PI/2;function em(i){return Math.tan((Dh+i)/2)}class Ow extends vc{constructor(e){super(e),this.center=e.center||[0,30];const[t,n]=this.parallels=e.parallels||[30,30];let s=Ot(t),l=Ot(n);this.southernCenter=s+l<0,this.southernCenter&&(s=-s,l=-l);const c=Math.cos(s),h=em(s);this.n=s===l?Math.sin(s):Math.log(c/Math.cos(l))/Math.log(em(l)/h),this.f=c*Math.pow(em(s),this.n)/this.n}project(e,t){t=Ot(t),this.southernCenter&&(t=-t),e=Ot(e-this.center[0]);const n=1e-6,{n:s,f:l}=this;l>0?t<-Dh+n&&(t=-Dh+n):t>Dh-n&&(t=Dh-n);const c=l/Math.pow(em(t),s);let h=c*Math.sin(s*e),p=l-c*Math.cos(s*e);return h=.5*(h/Math.PI+.5),p=.5*(p/Math.PI+.5),{x:h,y:this.southernCenter?p:1-p,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n,f:s}=this,l=s-t,c=Math.sign(l),h=Math.sign(n)*Math.sqrt(e*e+l*l);let p=Math.atan2(e,Math.abs(l))*c;l*n<0&&(p-=Math.PI*Math.sign(e)*c);const _=vt(Gr(p/n)+this.center[0],-180,180),y=vt(Gr(2*Math.atan(Math.pow(s/h,1/n))-Dh),-85.051129,E);return new f(_,this.southernCenter?-y:y)}}class Tx extends vc{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,t){return{x:fo(e),y:$n(t),z:0}}unproject(e,t){const n=qn(e),s=vr(t);return new f(n,s)}}const Ex=Ot(E);class Bw extends vc{project(e,t){const n=(t=Ot(t))*t,s=n*n;return{x:.5*((e=Ot(e))*(.8707-.131979*n+s*(s*(.003971*n-.001529*s)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+n*(.015085+s*(.028874*n-.044475-.005916*s)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let n=t=(2*(1-t)-1)*Math.PI,s=25,l=0,c=n*n;do{c=n*n;const _=c*c;l=(n*(1.007226+c*(.015085+_*(.028874*c-.044475-.005916*_)))-t)/(1.007226+c*(.045255+_*(.259866*c-.311325-.005916*11*_))),n=vt(n-l,-Ex,Ex)}while(Math.abs(l)>1e-6&&--s>0);c=n*n;const h=vt(Gr(e/(.8707+c*(c*(c*c*c*(.003971-.001529*c)-.013791)-.131979))),-180,180),p=Gr(n);return new f(h,p)}}const Sx=Ot(E);class kw extends vc{project(e,t){t=Ot(t),e=Ot(e);const n=Math.cos(t),s=2/Math.PI,l=Math.acos(n*Math.cos(e/2)),c=Math.sin(l)/l,h=.5*(e*s+2*n*Math.sin(e/2)/c)||0,p=.5*(t+Math.sin(t)/c)||0;return{x:.5*(h/Math.PI+.5),y:1-.5*(p/Math.PI+1),z:0}}unproject(e,t){let n=e=(2*e-.5)*Math.PI,s=t=(2*(1-t)-1)*Math.PI,l=25;const c=1e-6;let h=0,p=0;do{const _=Math.cos(s),y=Math.sin(s),v=2*y*_,b=y*y,T=_*_,S=Math.cos(n/2),A=Math.sin(n/2),C=2*S*A,D=A*A,z=1-T*S*S,O=z?1/z:0,F=z?Math.acos(_*S)*Math.sqrt(1/z):0,N=.5*(2*F*_*A+2*n/Math.PI)-e,j=.5*(F*y+s)-t,te=.5*O*(T*D+F*_*S*b)+1/Math.PI,H=O*(C*v/4-F*y*A),W=.125*O*(v*A-F*y*T*C),K=.5*O*(b*S+F*D*_)+.5,ee=H*W-K*te;h=(j*H-N*K)/ee,p=(N*W-j*te)/ee,n=vt(n-h,-Math.PI,Math.PI),s=vt(s-p,-Sx,Sx)}while((Math.abs(h)>c||Math.abs(p)>c)&&--l>0);return new f(Gr(n),Gr(s))}}class Ix extends vc{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ot(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:n,cosPhi:s}=this;return{x:Ot(e)*s*n+.5,y:-Math.sin(Ot(t))/s*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:s}=this,l=-(t-.5)/n,c=vt(Gr((e-.5)/n)/s,-180,180),h=Math.asin(vt(l*s,-1,1)),p=vt(Gr(h),-85.051129,E);return new f(c,p)}}class Nw extends Tx{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,t,n){const s=Kd(e,t,n);return hi(s,s,Kp(za(n))),{x:s[0],y:s[1],z:s[2]}}locationPoint(e,t,n){const s=r(t.lat,t.lng),l=ei([],s),c=n?e._centerAltitude+n:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;cn(s,s,l,x(1,0)*qe*c);const h=rr(new Float64Array(16));return Dt(h,e.pixelMatrix,e.globeMatrix),hi(s,s,h),new De(s[0],s[1])}pixelsPerMeter(e,t){return x(1,0)*t}pixelSpaceConversion(e,t,n){const s=x(1,e)*t,l=lt(x(1,45)*t,s,n);return this.pixelsPerMeter(e,t)/l}createTileMatrix(e,t,n){const s=hg(za(n.canonical));return Dt(new Float64Array(16),e.globeMatrix,s)}createInversionMatrix(e,t){const{center:n}=e,s=Kp(za(t));return Io(s,s,Ot(n.lng)),Es(s,s,Ot(n.lat)),hr(s,s,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(s)}pointCoordinate(e,t,n,s){return px(e,t,n,!0)||new V(0,0)}pointCoordinate3D(e,t,n){const s=this.pointCoordinate(e,t,n,0);return[s.x,s.y,s.z]}isPointAboveHorizon(e,t){return!px(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(s,l){const c=s.cameraToCenterDistance,h=s._centerAltitude*l,p=s._camera,_=s._camera.forward(),y=Ji([],si([],_,-c),[0,0,h]),v=s.worldSize/(2*Math.PI),b=[0,0,-v],T=s.width/s.height,S=Math.tan(s.fovAboveCenter),A=si([],p.up(),S),C=si([],p.right(),S*T),D=ei([],Ji([],Ji([],_,A),C)),z=[];let O;if(new $p(y,D).closestPointOnSphere(b,v,z)){const F=Ji([],z,b),N=Pi([],F,y);O=Math.cos(s.fovAboveCenter)*Ki(N)}else{const F=Pi([],y,b),N=Pi([],b,y);ei(N,N);const j=Ki(F)-v;O=Math.sqrt(j*(j+2*v));const te=Math.acos(O/(v+j))-Math.acos(Ri(_,N));O*=Math.cos(te)}return 1.01*O}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Rl(e.zoom);if(n>0){const s=vx(e,x(1,e.center.lat)*e.worldSize),l=e.worldSize/(2*Math.PI),c=Math.max(e.width,e.height)/e.worldSize*Math.PI;return lt(t,s+l*(1-Math.cos(c)),Math.pow(n,10))}return t}upVector(e,t,n){return Kd(t,n,e,1)}upVectorScale(e){return{metersToTile:qp(Xp(za(e)))}}}function tm(i){const e=i.parallels,t=!!e&&Math.abs(e[0]+e[1])<.01;switch(i.name){case"mercator":return new Tx(i);case"equirectangular":return new Fw(i);case"naturalEarth":return new Bw(i);case"equalEarth":return new zw(i);case"winkelTripel":return new kw(i);case"albers":return t?new Ix(i):new Lw(i);case"lambertConformalConic":return t?new Ix(i):new Ow(i);case"globe":return new Nw(i)}throw new Error(`Invalid projection name: ${i.name}`)}const rf=Number.MAX_SAFE_INTEGER,Vw=rf-1;function Ax(i,e,t,n){return i.order<e||i.order===rf||!(i.clipMask&t)||function(s,l){if(l.length===0)return!1;let c=s;for(;c!=="";){if(l.includes(c))return!1;c=Ip(c)}return!0}(n,i.clipScope)}function im(i,e){return i.x-e.x||i.y-e.y}function Cx(i,e){return im(i.min,e.min)===0&&im(i.max,e.max)===0}function mg(i,e){return!(i.min.x>e.max.x||i.max.x<e.min.x||i.min.y>e.max.y||i.max.y<e.min.y)}function rm(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(i[t].sourceId!==e[t].sourceId||!Cx(i[t],e[t])||i[t].order!==e[t].order||i[t].clipMask!==e[t].clipMask||!ls(i[t].clipScope,e[t].clipScope))return!1;return!0}function Mx(i,e,t){const n=1/qe,s=1/(1<<t.canonical.z),l=(e.x*n+t.canonical.x)*s+t.wrap,c=(e.y*n+t.canonical.y)*s;return{min:new De((i.x*n+t.canonical.x)*s+t.wrap,(i.y*n+t.canonical.y)*s),max:new De(l,c)}}function Uw(i,e,t){const n=1<<t.canonical.z,s=((e.x-t.wrap)*n-t.canonical.x)*qe,l=(e.y*n-t.canonical.y)*qe;return{min:new De(((i.x-t.wrap)*n-t.canonical.x)*qe,(i.y*n-t.canonical.y)*qe),max:new De(s,l)}}function _g(i,e,t,n,s,l,c){const h=i.indices,p=i.vertices,_=[];for(let y=n;y<n+s;y+=3){const v=e[t[y+0]+l],b=e[t[y+1]+l],T=e[t[y+2]+l],S=Math.min(v.x,b.x,T.x),A=Math.max(v.x,b.x,T.x),C=Math.min(v.y,b.y,T.y),D=Math.max(v.y,b.y,T.y);_.length=0,i.grid.query(new De(S,C),new De(A,D),_);for(let z=0;z<_.length;z++){const O=_[z];if(J_(p[h[3*O+0]],p[h[3*O+1]],p[h[3*O+2]],v,b,T,c))return!0}}return!1}function Rx(i,e,t,n){if(!i||!t)return!1;let s=i.vertices;if(!e.canonical.equals(n.canonical)||e.wrap!==n.wrap){if(t.vertices.length<i.vertices.length)return Rx(t,n,i,e);const l=e.canonical,c=n.canonical,h=Math.pow(2,c.z-l.z);s=i.vertices.map(p=>new De((p.x+l.x*qe)*h-c.x*qe,(p.y+l.y*qe)*h-c.y*qe))}return _g(t,s,i.indices,0,i.indices.length,0,0)}function Px(i,e,t,n){const s=Math.pow(2,n.z-t.z);return new De((i+t.x*qe)*s-n.x*qe,(e+t.y*qe)*s-n.y*qe)}function gg(i,e){const t=[];e.grid.queryPoint(i,t);const n=e.indices,s=e.vertices;for(let l=0;l<t.length;l++){const c=t[l];if(mc([s[n[3*c+0]],s[n[3*c+1]],s[n[3*c+2]]],i))return!0}return!1}const yg=4294967296,Dx=1/yg,Lx=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class nm{constructor(e){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(e,t,n=this.length){let s;for(;s=this.nextField(n);)e(s,t,this);return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*yg;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*yg;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf,n=t[this.pos++];if(n<128)return n;let s,l=127&n;return s=t[this.pos++],l|=(127&s)<<7,s<128?l:(s=t[this.pos++],l|=(127&s)<<14,s<128?l:(s=t[this.pos++],l|=(127&s)<<21,s<128?l:(s=t[this.pos],l|=(15&s)<<28,function(c,h,p){const _=p.buf;let y,v;if(v=_[p.pos++],y=(112&v)>>4,v<128||(v=_[p.pos++],y|=(127&v)<<3,v<128)||(v=_[p.pos++],y|=(127&v)<<10,v<128)||(v=_[p.pos++],y|=(127&v)<<17,v<128)||(v=_[p.pos++],y|=(127&v)<<24,v<128)||(v=_[p.pos++],y|=(1&v)<<31,v<128))return Lh(c,y,h);throw new Error("Expected varint not more than 10 bytes")}(l,e,this))))}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Lx?Lx.decode(this.buf.subarray(t,e)):function(n,s,l){let c="",h=s;for(;h<l;){const p=n[h];let _,y,v,b=null,T=p>239?4:p>223?3:p>191?2:1;if(h+T>l)break;T===1?p<128&&(b=p):T===2?(_=n[h+1],(192&_)==128&&(b=(31&p)<<6|63&_,b<=127&&(b=null))):T===3?(_=n[h+1],y=n[h+2],(192&_)==128&&(192&y)==128&&(b=(15&p)<<12|(63&_)<<6|63&y,(b<=2047||b>=55296&&b<=57343)&&(b=null))):T===4&&(_=n[h+1],y=n[h+2],v=n[h+3],(192&_)==128&&(192&y)==128&&(192&v)==128&&(b=(15&p)<<18|(63&_)<<12|(63&y)<<6|63&v,(b<=65535||b>=1114112)&&(b=null))),b===null?(b=65533,T=1):b>65535&&(b-=65536,c+=String.fromCharCode(b>>>10&1023|55296),b=56320|1023&b),c+=String.fromCharCode(b),h+=T}return c}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const n=this.readPackedEnd();for(;this.pos<n;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}nextField(e=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=e)return 0;const t=this.readVarint();return this.type=7&t,this._valueStart=this.pos,t>>>3}skip(e){const t=7&e;if(t===0)for(;this.buf[this.pos++]>127;);else if(t===2)this.pos=this.readVarint()+this.pos;else if(t===5)this.pos+=4;else{if(t!==1)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}}function Lh(i,e,t){return t?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function zx(i,e,t){const n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));t.realloc(n),t.buf.copyWithin(i+n,i,t.pos)}function jw(i,e){const t=i.length;let n=e.buf,s=e.pos,l=e.length;for(let c=0;c<t;c++){let h=i[c];if(h<0||s+10>l)e.pos=s,e.writeVarint(h),n=e.buf,s=e.pos,l=e.length;else{for(;h>127;)n[s++]=h%128|128,h=Math.floor(h/128);n[s++]=h}}e.pos=s}function Gw(i,e){for(let t=0;t<i.length;t++)e.writeSVarint(i[t])}function Hw(i,e){for(let t=0;t<i.length;t++)e.writeFloat(i[t])}function Zw(i,e){for(let t=0;t<i.length;t++)e.writeDouble(i[t])}function $w(i,e){for(let t=0;t<i.length;t++)e.writeBoolean(i[t])}function qw(i,e){for(let t=0;t<i.length;t++)e.writeFixed32(i[t])}function Ww(i,e){for(let t=0;t<i.length;t++)e.writeSFixed32(i[t])}function Xw(i,e){for(let t=0;t<i.length;t++)e.writeFixed64(i[t])}function Yw(i,e){for(let t=0;t<i.length;t++)e.writeSFixed64(i[t])}function Kw(i,e,t){let n;for(;n=i.nextField(e);)n===3?t.glyphs.push(Jw(i,i.readVarint()+i.pos)):n===4?t.ascender=i.readSVarint():n===5&&(t.descender=i.readSVarint())}function Jw(i,e){let t,n,s=0,l=0,c=0,h=0,p=0,_=0;for(;n=i.nextField(e);)n===1?s=i.readVarint():n===2?t=i.readBytes():n===3?l=i.readVarint():n===4?c=i.readVarint():n===5?h=i.readSVarint():n===6?p=i.readSVarint():n===7&&(_=i.readVarint());return{id:s,bitmap:new _c({width:l+6,height:c+6},t),metrics:{width:l,height:c,left:h,top:p,advance:_}}}function Fx(i){let e=0,t=0;for(const c of i)e+=c.w*c.h,t=Math.max(t,c.w);i.sort((c,h)=>h.h-c.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),t),h:1/0}];let s=0,l=0;for(const c of i)for(let h=n.length-1;h>=0;h--){const p=n[h];if(!(c.w>p.w||c.h>p.h)){if(c.x=p.x,c.y=p.y,l=Math.max(l,c.y+c.h),s=Math.max(s,c.x+c.w),c.w===p.w&&c.h===p.h){const _=n.pop();_&&h<n.length&&(n[h]=_)}else c.h===p.h?(p.x+=c.w,p.w-=c.w):c.w===p.w?(p.y+=c.h,p.h-=c.h):(n.push({x:p.x+c.w,y:p.y,w:p.w-c.w,h:c.h}),p.y+=c.h,p.h-=c.h);break}}return{w:s,h:l,fill:e/(s*l)||0}}function om(i,e){return i.id<e.id?-1:i.id>e.id?1:i.version<e.version?-1:i.version>e.version?1:i.sx<e.sx?-1:i.sx>e.sx?1:i.sy<e.sy?-1:i.sy>e.sy?1:0}function sm(i){let e=0;for(let t=0;t<i.length;t++)e=(e<<5)-e+i.charCodeAt(t),e&=e;return e}function ys(i,e){return(i<<5)-i+e}function Ox(i,e,t,n){for(const[s]of i.entries()){const l=n&&n.get(s)||uo.parse(s),c=l.id.toString(),h=e.get(c)||0;t.push({id:s,version:h,sx:l.sx,sy:l.sy})}}class xg{constructor(e,t,n,s,l="",c){this.scope=l,this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=t.size>0,Ox(e,n,this.iconDescriptors,c),Ox(t,n,this.patternDescriptors,c),this.iconDescriptors.sort(om),this.patternDescriptors.sort(om);let h=0;h=ys(h,sm(l)),h=ys(h,1);const p=s?s.data:"";p&&(h=ys(h,sm(p))),h=ys(h,1);for(const _ of this.iconDescriptors)h=ys(h,sm(_.id)),h=ys(h,_.version),h=ys(h,_.sx),h=ys(h,_.sy);h=ys(h,1);for(const _ of this.patternDescriptors)h=ys(h,sm(_.id)),h=ys(h,_.version),h=ys(h,_.sx),h=ys(h,_.sy);this.hash=h}subsetOf(e){return this.scope===e.scope&&this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,om)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,om)}isSubsetArray(e,t,n){let s=0,l=0;if(e.length>t.length)return!1;for(;s<e.length&&l<t.length;){const c=n(e[s],t[l]);if(c===0)s++,l++;else{if(c<0)return!1;l++}}return s===e.length}}function vg(i){switch(i){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 bg(i){switch(i){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}}et(xg,"AtlasContentDescriptor");class am{constructor(e,t,n,s){this.context=e,this.format=n,this.useMipmap=s&&s.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:s&&s.premultiply})}update(e,t){const n=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:c}=l,{x:h,y:p}=t&&t.position?t.position:{x:0,y:0},_=h+n,y=p+s;this.size&&(this.size[0]!==_||this.size[1]!==y)&&(!t||t.recreateWhenResize===void 0||t.recreateWhenResize)&&(c.bindTexture(c.TEXTURE_2D,null),c.deleteTexture(this.texture),this.texture=c.createTexture(),this.size=null),c.bindTexture(c.TEXTURE_2D,this.texture),l.pixelStoreUnpackFlipY.set(!1),l.pixelStoreUnpack.set(1),l.pixelStoreUnpackPremultiplyAlpha.set(this.format===c.RGBA8&&(!t||t.premultiply!==!1));const v=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&_>0&&y>0){const b=this.useMipmap?Math.floor(Math.log2(Math.max(_,y)))+1:1;c.texStorage2D(c.TEXTURE_2D,b,this.format,_,y),this.size=[_,y]}this.size&&(v?c.texSubImage2D(c.TEXTURE_2D,0,h,p,vg(this.format),bg(this.format),e):"data"in e&&e.data&&c.texSubImage2D(c.TEXTURE_2D,0,h,p,n,s,vg(this.format),bg(this.format),e.data)),this.useMipmap&&c.generateMipmap(c.TEXTURE_2D)}bind(e,t,n=!1){const{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&&!n?e===l.NEAREST?l.NEAREST_MIPMAP_NEAREST:l.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,t),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,n,s,l){const{context:c}=this,{gl:h}=c;h.bindTexture(h.TEXTURE_2D,this.texture),t!==this.magFilter&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,this.useMipmap?e===h.NEAREST?h.NEAREST_MIPMAP_NEAREST:h.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),n!==this.wrapS&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,n),this.wrapS=n),s!==this.wrapT&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,s),this.wrapT=s),l!==this.compareMode&&(l?(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_COMPARE_MODE,h.COMPARE_REF_TO_TEXTURE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_COMPARE_FUNC,l)):h.texParameteri(h.TEXTURE_2D,h.TEXTURE_COMPARE_MODE,h.NONE),this.compareMode=l)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Bx{constructor(e,t,n,s){this.context=e,this.format=s,this.size=n,this.texture=e.gl.createTexture();const[l,c,h]=this.size,{gl:p}=e;p.bindTexture(p.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&p.texImage3D(p.TEXTURE_3D,0,this.format,l,c,h,0,vg(this.format),bg(this.format),t.data)}bind(e,t){const{context:n}=this,{gl:s}=n;s.bindTexture(s.TEXTURE_3D,this.texture),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_3D,s.TEXTURE_MAG_FILTER,e),s.texParameteri(s.TEXTURE_3D,s.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(s.texParameteri(s.TEXTURE_3D,s.TEXTURE_WRAP_S,t),s.texParameteri(s.TEXTURE_3D,s.TEXTURE_WRAP_T,t),this.wrapS=t)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class nf{static getImagePositionScale(e,t,n){if(t&&e){const{sx:s,sy:l}=e;return{x:s,y:l}}return{x:n,y:n}}constructor(e,t,n,s){this.paddedRect=e;const{pixelRatio:l,version:c,stretchX:h,stretchY:p,content:_,sdf:y,usvg:v}=t;this.pixelRatio=l,this.stretchX=h,this.stretchY=p,this.content=_,this.version=c,this.padding=n,this.sdf=y,this.usvg=v,this.scale=nf.getImagePositionScale(s,v,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 kx(i,e,t){const n=uo.parse(i),s=function(l,c,h=[1,1]){return{x:0,y:0,w:(l.data?l.data.width:l.width*h[0])+2*c,h:(l.data?l.data.height:l.height*h[1])+2*c}}(e,t,[n.sx,n.sy]);return{bin:s,imagePosition:new nf(s,e,t,n),imageVariant:n}}function wg(i,e){const t=[];for(const[s,l]of i.entries()){const c=uo.parse(s);c&&(t.push({key:s,value:l,variant:c}),e&&e.set(s,c))}t.sort((s,l)=>{const c=s.variant.id.toString().localeCompare(l.variant.id.toString());return c!==0?c:s.variant.sx!==l.variant.sx?s.variant.sx-l.variant.sx:s.variant.sy!==l.variant.sy?s.variant.sy-l.variant.sy:s.key.localeCompare(l.key)});const n=new Map;for(const s of t)n.set(s.key,s.value);return n}class Nx{constructor(e){this.sourceAtlasHash=e}}class Vx{constructor(e,t,n,s,l=""){const c=new Map,h=new Map;this.haveRenderCallbacks=[];const p=[],_=s!==void 0,y=_?new Map:void 0,v=_?wg(e,y):e,b=_?wg(t,y):t;this.addImages(v,c,1,p),this.addImages(b,h,2,p);const{w:T,h:S}=Fx(p),A=new An({width:T||1,height:S||1});for(const[C,D]of v.entries()){const z=c.get(C).paddedRect;An.copy(D.data,A,{x:0,y:0},{x:z.x+1,y:z.y+1},D.data,null,D.sdf)}for(const[C,D]of b.entries()){const z=h.get(C),O=z.paddedRect;let F=z.padding;const N=O.x+F,j=O.y+F,te=D.data.width,H=D.data.height;F=F>1?F-1:F,An.copy(D.data,A,{x:0,y:0},{x:N,y:j},D.data,n),An.copy(D.data,A,{x:0,y:H-F},{x:N,y:j-F},{width:te,height:F},n),An.copy(D.data,A,{x:0,y:0},{x:N,y:j+H},{width:te,height:F},n),An.copy(D.data,A,{x:te-F,y:0},{x:N-F,y:j},{width:F,height:H},n),An.copy(D.data,A,{x:0,y:0},{x:N+te,y:j},{width:F,height:H},n),An.copy(D.data,A,{x:te-F,y:H-F},{x:N-F,y:j-F},{width:F,height:F},n),An.copy(D.data,A,{x:0,y:H-F},{x:N+te,y:j-F},{width:F,height:F},n),An.copy(D.data,A,{x:0,y:0},{x:N+te,y:j+H},{width:F,height:F},n),An.copy(D.data,A,{x:te-F,y:0},{x:N-F,y:j+H},{width:F,height:F},n)}this.lut=n,this.image=A,this.iconPositions=c,this.patternPositions=h,_&&(this.contentDescriptor=new xg(v,b,s,n,l,y))}addImages(e,t,n,s){for(const[l,c]of e.entries()){const{bin:h,imagePosition:p,imageVariant:_}=kx(l,c,n);t.set(l,p),s.push(h),c.hasRenderCallback&&this.haveRenderCallbacks.push(_.id)}}patchUpdatedImages(e,t,n,s){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(l=>e.hasImage(l,n)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,n);for(const l of e.getUpdatedImages(n)){for(const c of this.iconPositions.keys()){const h=uo.parse(c);if(Er.isEqual(h.id,l)){const p=e.getImage(l,n);this.patchUpdatedImage(this.iconPositions.get(c),p,t,null)}}for(const c of this.patternPositions.keys()){const h=uo.parse(c);if(Er.isEqual(h.id,l)){const p=e.getImage(l,n);this.patchUpdatedImage(this.patternPositions.get(c),p,t,s||this.lut)}}}}patchUpdatedImage(e,t,n,s=null){if(!e||!t||e.version===t.version)return;e.version=t.version;const[l,c]=e.tl,h=e.sdf;if(this.lut||h){const p={width:t.data.width,height:t.data.height},_=new An(p);An.copy(t.data,_,{x:0,y:0},{x:0,y:0},p,s,h),n.update(_,{position:{x:l,y:c},recreateWhenResize:!1})}else n.update(t.data,{position:{x:l,y:c},recreateWhenResize:!1})}}et(nf,"ImagePosition"),et(Vx,"ImageAtlas",{omit:["lut"]}),et(Nx,"ImageAtlasReference");class of{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=e&&e.fontstackCompositing||"client"}loadGlyphRange(e,t,n,s,l){if(this.fontstackCompositing==="server")return void of.loadGlyphRange(e,t,n,s,l);const c=e.split(",").map(h=>h.trim()).filter(h=>h.length>0);c.length!==0?c.length!==1?this._loadMultipleFonts(c,t,n,s,l):this._loadFont(c[0],t,n,s,l):l(new Error("Empty fontstack"))}_loadMultipleFonts(e,t,n,s,l){const c=e.map(()=>null),h={completed:0,firstError:null,callbackCalled:!1},p=(_,y,v)=>{if(!h.callbackCalled&&(y&&!h.firstError&&(h.firstError=y),v&&(c[_]=v),h.completed++,h.completed===e.length)){h.callbackCalled=!0;const b=c.filter(S=>S!==null);if(b.length===0)return void l(h.firstError||new Error("All fonts failed to load"));const T=this._composeGlyphs(b);l(null,T)}};for(let _=0;_<e.length;_++)this._loadFont(e[_],t,n,s,(y,v)=>{p(_,y,v)})}_loadFont(e,t,n,s,l){const c=`${e}:${t}`;if(this.cachedRanges.has(c)){const p=this.cachedRanges.get(c);return void X.frame(()=>l(null,p))}const h=this.pendingRequests.get(c);h?h.push(l):(this.pendingRequests.set(c,[l]),of.loadGlyphRange(e,t,n,s,(p,_)=>{p||this.cachedRanges.set(c,_||null);const y=this.pendingRequests.get(c);if(this.pendingRequests.delete(c),y)for(const v of y)v(p,_)}))}_composeGlyphs(e){const t={};let n,s;for(const l of e)if(n===void 0&&l.ascender!==void 0&&(n=l.ascender),s===void 0&&l.descender!==void 0&&(s=l.descender),l.glyphs)for(const c in l.glyphs)t[c]===void 0&&(t[c]=l.glyphs[c]);return{glyphs:t,ascender:n,descender:s}}}of.loadGlyphRange=async function(i,e,t,n,s){const l=256*e,c=l+255;let h;try{const p=await n.transformRequest(n.normalizeGlyphsURL(t).replace("{fontstack}",i).replace("{range}",`${l}-${c}`),fi.Glyphs),{data:_}=await vi(p),y={},v=function(b){return function(T){const S={glyphs:[]};let A;for(;A=T.nextField();)A===1&&Kw(T,T.readVarint()+T.pos,S);return S}(new nm(b))}(_);for(const b of v.glyphs)y[b.id]=b;h={glyphs:y,ascender:v.ascender,descender:v.descender}}catch(p){return s(p)}s(null,h)};const sf=1e20,Tg=new Float64Array(256);for(let i=0;i<256;i++){const e=.5-Math.pow(i/255,.45454545454545453);Tg[i]=e*Math.abs(e)}function Ux(i,e,t,n,s,l,c,h,p){for(let _=e;_<e+n;_++)jx(i,t*l+_,l,s,c,h,p);for(let _=t;_<t+s;_++)jx(i,_*l+e,1,n,c,h,p)}function jx(i,e,t,n,s,l,c){l[0]=0,c[0]=-sf,c[1]=sf,s[0]=i[e];for(let h=1,p=0,_=0;h<n;h++){s[h]=i[e+h*t];const y=h*h;do{const v=l[p];_=(s[h]-s[v]+y-v*v)/(h-v)/2}while(_<=c[p]&&--p>-1);p++,l[p]=h,c[p]=_,c[p+1]=sf}for(let h=0,p=0;h<n;h++){for(;c[p+1]<h;)p++;const _=l[p],y=h-_;i[e+h*t]=s[_]+y*y}}Tg[255]=-sf;const Qw=/bold/i,eT=/medium/i,tT=/light/i,Eg={none:0,ideographs:1,all:2};class lm{constructor(e,t,n,s){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=n,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new of({fontstackCompositing:s})}setURL(e){this.url=e}prefetchRange(e,t){const n=this.url||ie.GLYPHS_URL;if(!n)return;let s=this.entries[e];s||(s=this.entries[e]={glyphs:{},requests:{},ranges:{}}),s.ranges[t]||s.requests[t]||(s.requests[t]=[],this.glyphLoader.loadGlyphRange(e,t,n,this.requestManager,(l,c)=>{if(c){s.ascender=c.ascender,s.descender=c.descender;for(const h in c.glyphs)this._doesCharSupportLocalGlyph(+h)||(s.glyphs[+h]=c.glyphs[+h]);s.ranges[t]=!0}for(const h of s.requests[t]||[])h(l,c);delete s.requests[t]}))}getGlyphs(e,t){const n=[],s=this.url||ie.GLYPHS_URL;for(const l in e)for(const c of e[l])n.push({stack:l,id:c});Is(n,({stack:l,id:c},h)=>{let p=this.entries[l];p||(p=this.entries[l]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let _=p.glyphs[c];if(_!==void 0)return void h(null,{stack:l,id:c,glyph:_});if(_=this._tinySDF(p,l,c),_)return p.glyphs[c]=_,void h(null,{stack:l,id:c,glyph:_});const y=Math.floor(c/256);if(256*y>65535)return _i("glyphs > 65535 not supported"),void h(null,{stack:l,id:c,glyph:_});if(p.ranges[y])return void h(null,{stack:l,id:c,glyph:_});let v=p.requests[y];v||(v=p.requests[y]=[],this.glyphLoader.loadGlyphRange(l,y,s,this.requestManager,(b,T)=>{if(T){p.ascender=T.ascender,p.descender=T.descender;for(const S in T.glyphs)this._doesCharSupportLocalGlyph(+S)||(p.glyphs[+S]=T.glyphs[+S]);p.ranges[y]=!0}for(const S of v)S(b,T);delete p.requests[y]})),v.push((b,T)=>{b?h(b):T&&h(null,{stack:l,id:c,glyph:T.glyphs[c]||null})})},(l,c)=>{if(l)t(l);else if(c){const h={};for(const{stack:p,id:_,glyph:y}of c)h[p]===void 0&&(h[p]={}),h[p].glyphs===void 0&&(h[p].glyphs={}),h[p].glyphs[_]=y&&{id:y.id,bitmap:y.bitmap.clone(),metrics:y.metrics},h[p].ascender=this.entries[p].ascender,h[p].descender=this.entries[p].descender;t(null,h)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Eg.none&&(this.localGlyphMode===Eg.all?!!this.localFontFamily:!!this.localFontFamily&&(Ds(e)||fp(e)||dh(e)||cc(e)||lu(e)||Cd(e)||(t=e)>=131072&&t<=173791||(n=>n>=66736&&n<=66815)(e)));var t}_tinySDF(e,t,n){const s=this.localFontFamily;if(!s||!this._doesCharSupportLocalGlyph(n))return;let l=e.tinySDF;if(!l){let C="400";Qw.test(t)?C="900":eT.test(t)?C="500":tT.test(t)&&(C="200"),l=e.tinySDF=new lm.TinySDF({fontFamily:s,fontWeight:C,fontSize:48,buffer:6,radius:16}),l.fontWeight=C}const c=l.fontWeight;if(this.localGlyphs[c][n])return this.localGlyphs[c][n];const h=String.fromCodePoint(n),{data:p,width:_,height:y,glyphWidth:v,glyphHeight:b,glyphLeft:T,glyphTop:S,glyphAdvance:A}=l.draw(h);return this.localGlyphs[c][n]={id:n,bitmap:new _c({width:_,height:y},p),metrics:{width:v/2,height:b/2,left:T/2,top:S/2-27,advance:A/2,localGlyph:!0}}}}function Gx(i,e){return i+e[1]-e[0]}function Hx(i,e,t,n,s=1){const l=[],c=i.imagePrimary,h=c.pixelRatio,p=c.paddedRect.w-2,_=c.paddedRect.h-2,y=(i.right-i.left)*s,v=(i.bottom-i.top)*s,b=c.stretchX||[[0,p]],T=c.stretchY||[[0,_]],S=b.reduce(Gx,0),A=T.reduce(Gx,0),C=p-S,D=_-A;let z=0,O=S,F=0,N=A,j=0,te=C,H=0,W=D;if(c.content&&n){const ee=c.content;z=cm(b,0,ee[0]),F=cm(T,0,ee[1]),O=cm(b,ee[0],ee[2]),N=cm(T,ee[1],ee[3]),j=ee[0]-z,H=ee[1]-F,te=ee[2]-ee[0]-O,W=ee[3]-ee[1]-N}const K=(ee,ae,he,be)=>{const xe=um(ee.stretch-z,O,y,i.left*s),Te=hm(ee.fixed-j,te,ee.stretch,S),Fe=um(ae.stretch-F,N,v,i.top*s),se=hm(ae.fixed-H,W,ae.stretch,A),fe=um(he.stretch-z,O,y,i.left*s),ge=hm(he.fixed-j,te,he.stretch,S),Ae=um(be.stretch-F,N,v,i.top*s),Me=hm(be.fixed-H,W,be.stretch,A),ze=new De(xe,Fe),Ce=new De(fe,Fe),Be=new De(fe,Ae),ke=new De(xe,Ae),Ke=new De(Te/h,se/h),Ve=new De(ge/h,Me/h),$e=e*Math.PI/180;if($e){const bt=Math.sin($e),ri=Math.cos($e),jt=[ri,-bt,bt,ri];ze._matMult(jt),Ce._matMult(jt),ke._matMult(jt),Be._matMult(jt)}const dt=ee.stretch+ee.fixed,pt=he.stretch+he.fixed,yt=ae.stretch+ae.fixed,ht=be.stretch+be.fixed,wt=i.imageSecondary;return{tl:ze,tr:Ce,bl:ke,br:Be,texPrimary:{x:c.paddedRect.x+1+dt,y:c.paddedRect.y+1+yt,w:pt-dt,h:ht-yt},texSecondary:wt?{x:wt.paddedRect.x+1+dt,y:wt.paddedRect.y+1+yt,w:pt-dt,h:ht-yt}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ke,pixelOffsetBR:Ve,minFontScaleX:te/h/y,minFontScaleY:W/h/v,isSDF:t}};if(c.stretchX||c.stretchY){const ee=Zx(b,C,S),ae=Zx(T,D,A);for(let he=0;he<ee.length-1;he++){const be=ee[he],xe=ee[he+1];for(let Te=0;Te<ae.length-1;Te++)l.push(K(be,ae[Te],xe,ae[Te+1]))}}else l.push(K({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:p+1},{fixed:0,stretch:_+1}));return l}function cm(i,e,t){let n=0;for(const s of i)n+=Math.max(e,Math.min(t,s[1]))-Math.max(e,Math.min(t,s[0]));return n}function Zx(i,e,t){const n=[{fixed:-1,stretch:0}];for(const[s,l]of i){const c=n.at(-1);n.push({fixed:s-c.stretch,stretch:c.stretch}),n.push({fixed:s-c.stretch,stretch:c.stretch+(l-s)})}return n.push({fixed:e+1,stretch:t}),n}function $x(i){return 2*i.length+1}function um(i,e,t,n){return i/e*t+n}function hm(i,e,t,n){return i-e*t/n}function iT(i,e,t,n){const s=e+i.positionedLines[n].lineOffset;return n===0?t+s/2:t+(s+(e+i.positionedLines[n-1].lineOffset))/2}function qx(i,e,t,n,s,l,c,h,p,_=1){const y=[];if(e.positionedLines.length===0)return y;const v=(p!==void 0?p:n.layout.get("text-rotate").evaluate(l,{}))*Math.PI/180,b=function(D){const z=D[0],O=D[1],F=z*O;return F>0?[z,-O]:F<0?[-z,O]:z===0?[O,z]:[O,-z]}(t);let T=Math.abs(e.top-e.bottom);for(const D of e.positionedLines)T-=D.lineOffset;const S=e.positionedLines.length,A=T/S;let C=e.top-t[1];for(let D=0;D<S;++D){const z=e.positionedLines[D];C=iT(e,A,C,D);for(const O of z.positionedGlyphs){if(!O.rect)continue;const F=O.rect||{};let N=4,j=!0,te=1,H=0;if(O.image){const Be=c.get(O.image.toString());if(!Be)continue;if(Be.sdf){_i("SDF images are not supported in formatted text and will be ignored.");continue}j=!1,te=Be.pixelRatio,N=1/te,Be.usvg||(te/=_)}const W=(s||h)&&O.vertical,K=O.metrics.advance*O.scale/2,ee=O.metrics,ae=O.rect;if(ae===null)continue;h&&e.verticalizable&&(H=O.image?K-O.metrics.width*O.scale/2:0);const he=s?[O.x+K,O.y]:[0,0];let be=[0,0],xe=[0,0],Te=!1;s||(W?(xe=[O.x+K+b[0],O.y+b[1]-H],Te=!0):be=[O.x+K+t[0],O.y+t[1]-H]);const Fe=ae.w*O.scale/(te*(O.localGlyph?2:1)),se=ae.h*O.scale/(te*(O.localGlyph?2:1));let fe,ge,Ae,Me;if(W){const Be=O.y-C,ke=new De(-K,K-Be),Ke=-Math.PI/2,Ve=new De(...xe);fe=new De(-K+be[0],be[1]),fe._rotateAround(Ke,ke)._add(Ve),fe.x+=-Be+K,fe.y-=(ee.left-N)*O.scale;const $e=O.image?ee.advance*O.scale:Mh*O.scale,dt=String.fromCodePoint(O.glyph);vw(dt)?fe.x+=(1-N)*O.scale:bw(dt)?fe.x+=$e-ee.height*O.scale+(-N-1)*O.scale:fe.x+=O.image||ee.width+2*N===ae.w&&ee.height+2*N===ae.h?($e-se)/2:($e-(ee.height+2*N)*O.scale)/2,ge=new De(fe.x,fe.y-Fe),Ae=new De(fe.x+se,fe.y),Me=new De(fe.x+se,fe.y-Fe)}else{const Be=(ee.left-N)*O.scale-K+be[0],ke=(-ee.top-N)*O.scale+be[1],Ke=Be+Fe,Ve=ke+se;fe=new De(Be,ke),ge=new De(Ke,ke),Ae=new De(Be,Ve),Me=new De(Ke,Ve)}if(v){let Be;Be=s?new De(0,0):Te?new De(b[0],b[1]):new De(t[0],t[1]),fe._rotateAround(v,Be),ge._rotateAround(v,Be),Ae._rotateAround(v,Be),Me._rotateAround(v,Be)}const ze=new De(0,0),Ce=new De(0,0);y.push({tl:fe,tr:ge,bl:Ae,br:Me,texPrimary:F,texSecondary:void 0,writingMode:e.writingMode,glyphOffset:he,sectionIndex:O.sectionIndex,isSDF:j,pixelOffsetTL:ze,pixelOffsetBR:Ce,minFontScaleX:0,minFontScaleY:0})}}return y}lm.TinySDF=class{constructor({fontSize:i=24,buffer:e=3,radius:t=8,cutoff:n=.25,fontFamily:s="sans-serif",fontWeight:l="normal",fontStyle:c="normal",lang:h=null}={}){this.buffer=e,this.radius=t,this.cutoff=n,this.lang=h;const p=this.size=i+4*e,_=this._createCanvas(p),y=this.ctx=_.getContext("2d",{willReadFrequently:!0});y.font=`${c} ${l} ${i}px ${s}`,y.textBaseline="alphabetic",y.textAlign="left",y.fillStyle="black",this.gridOuter=new Float64Array(p*p),this.gridInner=new Float64Array(p*p),this.f=new Float64Array(p),this.z=new Float64Array(p+1),this.v=new Uint16Array(p)}_createCanvas(i){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(i,i);const e=document.createElement("canvas");return e.width=e.height=i,e}draw(i){const{width:e,actualBoundingBoxAscent:t,actualBoundingBoxDescent:n,actualBoundingBoxLeft:s,actualBoundingBoxRight:l}=this.ctx.measureText(i),c=Math.ceil(t),h=Math.floor(-s),p=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(l)-h)),_=Math.max(0,Math.min(this.size-this.buffer,c+Math.ceil(n))),y=p+2*this.buffer,v=_+2*this.buffer,b=Math.max(y*v,0),T=new Uint8ClampedArray(b),S={data:T,width:y,height:v,glyphWidth:p,glyphHeight:_,glyphTop:c,glyphLeft:h,glyphAdvance:e};if(p===0||_===0)return S;const{ctx:A,buffer:C,gridInner:D,gridOuter:z}=this;this.lang&&(A.lang=this.lang),A.clearRect(C,C,p,_),A.fillText(i,C-h,C+c);const O=A.getImageData(C,C,p,_);z.fill(sf,0,b),D.fill(0,0,b);let F=3;for(let H=0;H<_;H++){let W=(H+C)*y+C;for(let K=0;K<p;K++,F+=4,W++){const ee=O.data[F];if(ee===0)continue;const ae=Tg[ee];z[W]=Math.max(0,ae),D[W]=Math.max(0,-ae)}}Ux(z,0,0,y,v,y,this.f,this.v,this.z);const N=Math.min(C,1);Ux(D,C-N,C-N,p+2*N,_+2*N,y,this.f,this.v,this.z);const j=255/this.radius,te=255*(1-this.cutoff);for(let H=0;H<b;H++){const W=Math.sqrt(z[H])-Math.sqrt(D[H]);T[H]=Math.round(te-j*W)}return S}};class rT{constructor(e,t){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=t,this.appearances=e;const n=e.map(s=>function(l){if(!l.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const c=l.condition.expression;return{featureDependent:!al(c),stateDependent:!va(c),zoomDependent:!Jo(c,["zoom"]),pitchDependent:!Jo(c,["pitch"]),brightnessDependent:!Jo(c,["brightness","measure-light"]),worldviewDependent:!Jo(c,["worldview"])}}(s));this.anyFeatureDependent=n.some(s=>s.featureDependent),this.anyStateDependent=n.some(s=>s.stateDependent)}update(e,t){const n=this.lastParams,s=!n||n.zoom!==e.zoom||n.pitch!==(e.pitch||0)||n.brightness!==(e.brightness||0)||n.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};const l=t&&this.anyStateDependent;if(!s&&!l&&this.lastAllFeaturesIndex!==-2)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!l){const c=this.evaluateAllFeatures(e);return c===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=c,{kind:"all-features",appearanceIndex:c})}return{kind:"per-feature"}}evaluateAllFeatures(e){for(let t=0;t<this.appearances.length;t++){const n=this.appearances[t];if(n.condition&&n.condition.evaluate(e,void 0,void 0,void 0))return t}return-1}}const nT=pc.types,oT=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function af(i,e,t,n,s,l,c,h,p,_,y,v,b){const T=h?Math.min(Eu,Math.round(h[0])):0,S=h?Math.min(Eu,Math.round(h[1])):0;i.emplaceBack(e,t,Math.round(32*n),Math.round(32*s),l,c,(T<<1)+(p?1:0),0+(S<<1),16*_,16*y,256*v,256*b)}function lf(i,e,t){i.emplaceBack(e,t)}function cf(i,e,t,n,s,l,c){i.emplaceBack(e,t,n,s,l,c)}function dm(i,e,t,n,s){const l=5*e+2;i.float32[l+0]=t,i.float32[l+1]=n,i.float32[l+2]=s}function Su(i,e,t,n,s){i.emplaceBack(e,t,n,s),i.emplaceBack(e,t,n,s),i.emplaceBack(e,t,n,s),i.emplaceBack(e,t,n,s)}function sT(i){for(const e of i.sections)if(xp(e.text))return!0;return!1}const zh=12;class Sg{constructor(e){this.layoutVertexArray=new rt,this.indexArray=new _t,this.programConfigurations=e,this.segments=new li,this.dynamicLayoutVertexArray=new xt,this.opacityVertexArray=new Rt,this.placedSymbolArray=new mi,this.iconTransitioningVertexArray=new Mt,this.globeExtVertexArray=new ct,this.zOffsetVertexArray=new Oe,this.orientationVertexArray=new qi,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new Oe,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){const t=e.get().length===this.segments.get().length;if(t&&this.cachedBatchIndices&&this.cachedBatchSegments)return{batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};const n=new Map;for(const c of e.get()){const h=c.batchIndex!==void 0?c.batchIndex:0;n.has(h)||n.set(h,[]),n.get(h).push(c)}const s=Array.from(n.keys()).sort((c,h)=>c-h),l=new Map;for(const c of s){const h=n.get(c);l.set(c,new li(h))}return t&&(this.cachedBatchIndices=s,this.cachedBatchSegments=l),{batchIndices:s,batchSegments:l}}snapshotSymbolVertexData(e,t){const n=e*zh;return this.layoutVertexArray.uint16.slice(n,n+t*zh)}restoreSymbolVertexData(e,t){this.layoutVertexArray.uint16.set(t,e*zh)}snapshotIconTransitioningVertexData(e,t){const n=2*e;return this.iconTransitioningVertexArray.uint16.slice(n,n+2*t)}restoreIconTransitioningVertexData(e,t){this.iconTransitioningVertexArray.uint16.set(t,2*e)}updateSymbolVertexData(e,t,n,s,l,c,h,p,_,y,v,b,T){const S=this.layoutVertexArray.uint16,A=e*zh;S[A]=t,S[A+1]=n,S[A+2]=s,S[A+3]=l,S[A+4]=c,S[A+5]=h,S[A+6]=p,S[A+7]=_,S[A+8]=y,S[A+9]=v,S[A+10]=b,S[A+11]=T}upload(e,t,n,s,l,c){this.isEmpty()||(n&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,aw.members,!!c),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,cw.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,oT,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,fw.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.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,hw.members,!1))),(n||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())}}et(Sg,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class Ig{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new li,this.collisionVertexArray=new kt,this.collisionVertexArrayExt=new xt}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,pw.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.destroy())}}et(Ig,"CollisionBuffers");class fm{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(c=>c.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=rr([]),this.placementViewportMatrix=rr([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.textSizeData=Rh(this.zoom,t["text-size"],this.worldview,e.availableImages),this.iconSizeData=Rh(this.zoom,t["icon-size"],this.worldview,e.availableImages);const n=this.layers[0].layout,s=n.get("symbol-sort-key"),l=n.get("symbol-z-order");this.lut=e.lut,this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.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=n.get("text-writing-mode").map(c=>Al[c]),this.stateDependentLayerIds=this.layers.filter(c=>c.isStateDependent()).map(c=>c.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(e){const t=this.layers[0].getAppearances();if(!t||t.length===0)return!1;const n=Array.isArray(e)?e:[e];return t.some(s=>n.some(l=>s.hasLayoutProperty(l)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new Sg(new ta(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new Sg(new ta(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.text.uboBinder=new rg(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new rg(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.glyphOffsetArray=new qr,this.lineVertexArray=new Vi,this.symbolInstances=new ir}calculateGlyphDependencies(e,t,n,s,l){for(const c of e){const h=c.codePointAt(0);if(h===void 0)break;if(t[h]=!0,s&&l&&h<=65535){const p=Yd[c];p&&(t[p.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,t,n,s,l,c,h){if(!e.hasLayoutProperty("icon-size"))return h*c;let p=1;const _=e.getUnevaluatedLayoutProperty("icon-size"),y=Rh(this.zoom,_,this.worldview,l),v=Tu(y,t);if(y.kind!=="constant"&&y.kind!=="camera"||(p=v.uSize),y.kind==="composite"){const{minZoom:b,maxZoom:T}=y,S=_.possiblyEvaluate(new zi(b,{worldview:this.worldview}),s),A=_.possiblyEvaluate(new zi(T,{worldview:this.worldview}),s),C=S.evaluate(n,{},s,l);p=C+(A.evaluate(n,{},s,l)-C)*v.uSizeT}return y.kind==="source"&&(p=_.possiblyEvaluate(new zi(this.zoom,{worldview:this.worldview}),s).evaluate(n,{},s,l)),p*c}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!rm(this.activeReplacements,n)&&(this.activeReplacements=n,!0)}getResolvedImageFromTokens(e){return typeof e=="string"?fn.build(e):e}populate(e,t,n,s){const l=this.layers[0],c=l.layout,h=this.projection.name==="globe",p=c.get("text-font"),_=c.get("text-field"),y=c.get("icon-image"),[v,b]=c.get("icon-size-scale-range"),T=vt(t.scaleFactor||1,v,b),[S,A]=c.get("text-size-scale-range"),C=vt(t.scaleFactor||1,S,A),D=(_.value.kind!=="constant"||_.value.value instanceof Sr&&!_.value.value.isEmpty()||_.value.value.toString().length>0)&&(p.value.kind!=="constant"||p.value.value.length>0),z=y.value.kind!=="constant"||!!y.value.value||Object.keys(y.parameters).length>0,O=this.hasAnyAppearanceLayoutProperty("icon-image"),F=c.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!D&&!z&&!O)return;const N=t.iconDependencies,j=t.glyphDependencies,te=t.availableImages,H=new zi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),W=K=>{const ee=K.id.toString();N.has(ee)?N.get(ee).push(K):N.set(ee,[K])};for(const K of e){const{feature:ee,id:ae,index:he,sourceLayerIndex:be}=K,xe=l._featureFilter.needGeometry,Te=_e(ee,xe);if(!l._featureFilter.filter(H,Te,n))continue;if(xe||(Te.geometry=ce(ee,n,s)),h&&ee.type!==1&&n.z<=5){const Ce=Te.geometry,Be=.98078528056,ke=(Ke,Ve)=>Ri(Kd(Ke.x,Ke.y,n,1),Kd(Ve.x,Ve.y,n,1))<Be;for(let Ke=0;Ke<Ce.length;Ke++)Ce[Ke]=Y(Ce[Ke],ke)}let Fe,se;if(D){const Ce=l.getValueAndResolveTokens("text-field",Te,n,te),Be=Sr.factory(Ce);sT(Be)&&(this.hasRTLText=!0),(!this.hasRTLText||hc()==="unavailable"||this.hasRTLText&&ps.isParsed())&&(Fe=xw(Be,l,Te))}if(z){const Ce=l.getValueAndResolveTokens("icon-image",Te,n,te);se=this.getResolvedImageFromTokens(Ce)}const fe=this.layers[0];let ge=!1;if(!se&&O){const Ce=fe.getAppearances();for(const Be of Ce)if(Be.getLayoutProperty("icon-image")){const ke=fe.getAppearanceValueAndResolveTokens(Be,"icon-image",Te,n,te);if(ke){se=this.getResolvedImageFromTokens(ke),ge=!0;break}}}if(!Fe&&!se)continue;const Ae=this.sortFeaturesByKey?F.evaluate(Te,{},n):void 0,Me={id:ae,text:Fe,icon:se,index:he,sourceLayerIndex:be,geometry:Te.geometry,properties:ee.properties,type:nT[ee.type],sortKey:Ae};if(this.features.push(Me),this.featureAppearanceData.set(he,{id:ae,properties:ee.properties,usesAppearanceIconAsPlaceholder:ge}),se){const Ce=fe._unevaluatedLayout._values,{iconPrimary:Be,iconSecondary:ke}=ng(se,this.iconSizeData,Ce["icon-size"],n,this.zoom,Me,this.pixelRatio,T,this.worldview,te);W(Be),ke&&(this.hasAnySecondaryIcon=!0,W(ke))}const ze=fe.getAppearances();if(ze.length!==0&&ze.forEach(Ce=>{if(!Ce.getLayoutProperty("icon-image"))return;const{iconPrimary:Be,iconSecondary:ke}=this.getCombinedIconVariants(Ce,fe,Te,n,te,Me,T);Be&&(W(Be),ke&&(this.hasAnySecondaryIcon=!0,W(ke)))}),Fe){const Ce=p.evaluate(Te,{},n).join(","),Be=c.get("text-rotation-alignment")==="map"&&c.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(Al.vertical);for(const ke of Fe.sections)if(ke.image){const Ke=ke.image.getPrimary().scaleSelf(this.pixelRatio*C),Ve=Ke.id.toString(),$e=N.get(Ve)||[];$e.push(Ke),N.set(Ve,$e)}else{const Ke=cu(Fe.toString()),Ve=ke.fontStack||Ce,$e=j[Ve]=j[Ve]||{};this.calculateGlyphDependencies(ke.text,$e,Be,this.allowVerticalPlacement,Ke)}}}c.get("symbol-placement")==="line"&&(this.features=function(K){const ee={},ae={},he=[];let be=0;function xe(fe){he.push(K[fe]),be++}function Te(fe,ge,Ae){const Me=ae[fe];return delete ae[fe],ae[ge]=Me,he[Me].geometry[0].pop(),he[Me].geometry[0]=he[Me].geometry[0].concat(Ae[0]),Me}function Fe(fe,ge,Ae){const Me=ee[ge];return delete ee[ge],ee[fe]=Me,he[Me].geometry[0].shift(),he[Me].geometry[0]=Ae[0].concat(he[Me].geometry[0]),Me}function se(fe,ge,Ae){const Me=Ae?ge[0].at(-1):ge[0][0];return`${fe}:${Me.x}:${Me.y}`}for(let fe=0;fe<K.length;fe++){const ge=K[fe],Ae=ge.geometry,Me=ge.text?ge.text.toString():null;if(!Me||Ae.length>1){xe(fe);continue}const ze=se(Me,Ae,!1),Ce=se(Me,Ae,!0);if(ze in ae&&Ce in ee&&ae[ze]!==ee[Ce]){const Be=Fe(ze,Ce,Ae),ke=Te(ze,Ce,he[Be].geometry);delete ee[ze],delete ae[Ce],ae[se(Me,he[ke].geometry,!0)]=ke,he[Be].geometry=null}else ze in ae?Te(ze,Ce,Ae):Ce in ee?Fe(ze,Ce,Ae):(xe(fe),ee[ze]=be-1,ae[Ce]=be-1)}return he.filter(fe=>fe.geometry)}(this.features)),c.get("symbol-elevation-reference")==="hd-road-markup"?(this.elevationType="road",this.hdExt&&(this.hdExt.configureCrossSource(n,t.elevationParams,t.crossSourceElevationEnabled,t.terrainEnabled),t.elevationFeatures&&t.elevationFeatures.length>0&&this.hdExt.addElevationFeatures(t.elevationFeatures,n))):c.get("symbol-z-elevate")&&(this.elevationType="offset"),this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((K,ee)=>K.sortKey-ee.sortKey)}getCombinedIconVariants(e,t,n,s,l,c,h){let p;if(e.hasLayoutProperty("icon-image")){const _=t.getAppearanceValueAndResolveTokens(e,"icon-image",n,s,l);p=this.getResolvedImageFromTokens(_)}else{const _=t.getValueAndResolveTokens("icon-image",n,s,l);p=this.getResolvedImageFromTokens(_)}if(p){const _=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"],y=Rh(this.zoom,_,this.worldview,l),{iconPrimary:v,iconSecondary:b}=ng(p,y,_,s,this.zoom,c,this.pixelRatio,h,this.worldview,l);return{iconPrimary:v,iconSecondary:b}}return{iconPrimary:void 0,iconSecondary:void 0}}getCombinedIconPrimary(e,t,n,s,l,c,h){return this.getCombinedIconVariants(e,t,n,s,l,c,h).iconPrimary}updateSymbolInstanceIconVertices(e,t,n,s,l,c){const{canonical:h,availableImages:p,globalProperties:_,layer:y,iconScaleFactor:v,featureState:b,layoutIconOffset:T,layoutIconSize:S,layoutIconRotate:A}=c;if(e.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(t.activeAppearanceIndex===n)return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1};const C=n>=0?y.appearances[n]:null;if(C){const D={sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:t.properties,type:"Point",id:t.id},{iconPrimary:z,iconSecondary:O}=this.getCombinedIconVariants(C,y,s,h,p,D,v);if(!z)return{vertexOffsetDelta:0,hasChanges:!1};const F=z.toString(),N=this.iconAtlasPositions&&this.iconAtlasPositions.get(F);if(N){const{appearanceIconOffset:j,appearanceIconRotate:te}=sx(C,y,s,h,T,A,S,v),H=y.layout.get("icon-anchor").evaluate(s,b,h);let W=nx(N,O?this.iconAtlasPositions&&this.iconAtlasPositions.get(O.toString()):void 0,j,H);const K=N.sdf,ee=y.layout.get("icon-text-fit").constantOr("none");ee!=="none"&&t.textShaping&&t.iconTextFitPadding&&t.fontScale&&(W=ox(W,t.textShaping,ee,t.iconTextFitPadding,j,t.fontScale));const ae=this.calculateEffectiveAppearanceIconSize(C,_.zoom,s,h,p,v,S),he=0,be=1+(Math.min(Eu,Math.round(ae*gc))<<1),xe=Hx(W,te,K,ee!=="none",v),Te=this.icon.iconTransitioningVertexArray.length>0;t.isUsingAppearanceIconVertexData||(t.isUsingAppearanceIconVertexData=!0,t.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(l,e.numIconVertices),Te&&(t.layoutBasedIconTransitioningVertexData=this.icon.snapshotIconTransitioningVertexData(l,e.numIconVertices)));const Fe=Math.floor(e.numIconVertices/4),se=Math.min(xe.length,Fe);let fe=l;const ge=Te?this.icon.iconTransitioningVertexArray.uint16:null;for(let Me=0;Me<se;++Me){const ze=xe[Me],Ce=t.layoutBasedIconVertexData[0]||e.tileAnchorX,Be=t.layoutBasedIconVertexData[1]||e.tileAnchorY,ke=16*ze.pixelOffsetTL.x,Ke=16*ze.pixelOffsetTL.y,Ve=16*ze.pixelOffsetBR.x,$e=16*ze.pixelOffsetBR.y,dt=16*ze.minFontScaleX,pt=16*ze.minFontScaleY;if(this.icon.updateSymbolVertexData(fe,Ce,Be,Math.round(32*ze.tl.x),Math.round(32*ze.tl.y),ze.texPrimary.x,ze.texPrimary.y,he,be,ke,Ke,dt,pt),this.icon.updateSymbolVertexData(fe+1,Ce,Be,Math.round(32*ze.tr.x),Math.round(32*ze.tr.y),ze.texPrimary.x+ze.texPrimary.w,ze.texPrimary.y,he,be,Ve,Ke,dt,pt),this.icon.updateSymbolVertexData(fe+2,Ce,Be,Math.round(32*ze.bl.x),Math.round(32*ze.bl.y),ze.texPrimary.x,ze.texPrimary.y+ze.texPrimary.h,he,be,ke,$e,dt,pt),this.icon.updateSymbolVertexData(fe+3,Ce,Be,Math.round(32*ze.br.x),Math.round(32*ze.br.y),ze.texPrimary.x+ze.texPrimary.w,ze.texPrimary.y+ze.texPrimary.h,he,be,Ve,$e,dt,pt),ge){const yt=ze.texSecondary?ze.texSecondary:ze.texPrimary,ht=2*fe;ge[ht]=yt.x,ge[ht+1]=yt.y,ge[ht+2]=yt.x+yt.w,ge[ht+3]=yt.y,ge[ht+4]=yt.x,ge[ht+5]=yt.y+yt.h,ge[ht+6]=yt.x+yt.w,ge[ht+7]=yt.y+yt.h}fe+=4}const Ae=e.numIconVertices-4*se;for(let Me=0;Me<Ae;++Me)this.icon.updateSymbolVertexData(fe+Me,0,0,0,0,0,0,0,0,0,0,0,0);return{vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}}else{if(t.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(t.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(l,t.layoutBasedIconVertexData),t.layoutBasedIconTransitioningVertexData&&this.icon.restoreIconTransitioningVertexData(l,t.layoutBasedIconTransitioningVertexData),t.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:t.layoutBasedIconVertexData.length/zh,hasChanges:!0}}return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(e,t,n,s,l,c){const{canonical:h,layer:p,textScaleFactor:_,imageMap:y,featureState:v,layoutTextOffset:b,layoutTextSize:T,layoutTextRotate:S,layoutMinZoomSize:A,layoutMaxZoomSize:C,layoutTextSizeMinZoom:D,layoutTextSizeMaxZoom:z,availableImages:O}=c,F=e.numHorizontalGlyphVertices>0||e.numVerticalGlyphVertices>0;if(!F)return{vertexOffsetDelta:F?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(t.activeAppearanceIndex===n)return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};const N=n>=0?p.appearances[n]:null;if(N&&t.textShaping){const{appearanceTextOffset:j,appearanceTextRotate:te,appearanceTextSize:H}=ax(N,p,s,h,b,S,T);t.fontScale=cx(H,t.textScaleFactor);const W=N.getUnevaluatedLayoutProperty("text-size");let K=this.textSizeData,ee=D,ae=z;N.hasLayoutProperty("text-size")&&(K=Rh(this.zoom,W,this.worldview,O),ee=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,ae=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const he=t.textShaping.bottom-b[1],be=t.textShaping.left-b[0],xe=t.textShaping.right-b[0];t.textShaping.top=j[1]+(t.textShaping.top-b[1]),t.textShaping.bottom=j[1]+he,t.textShaping.left=j[0]+be,t.textShaping.right=j[0]+xe;const Te=qx(0,t.textShaping,j,p,!1,s,y,this.allowVerticalPlacement,te),Fe=H&&K.kind==="composite"?W.possiblyEvaluate(new zi(ee,{}),h).evaluate(s,v,h):A,se=H&&K.kind==="composite"?W.possiblyEvaluate(new zi(ae,{}),h).evaluate(s,v,h):C,fe=ux(N.name,K,H,_,Fe,se),ge=Array.isArray(fe)?fe[1]:H,Ae=0,Me=1+(Math.min(Eu,Math.round(ge*gc))<<1);t.isUsingAppearanceTextVertexData||(t.isUsingAppearanceTextVertexData=!0,t.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(l,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let ze=0;ze<Te.length&&ze<(e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices)/4;++ze){const Ce=Te[ze],Be=Ce.glyphOffset[1],ke=e.tileAnchorX,Ke=e.tileAnchorY,Ve=l+4*ze;this.text.updateSymbolVertexData(Ve,ke,Ke,Math.round(32*Ce.tl.x),Math.round(32*(Be+Ce.tl.y)),Ce.texPrimary.x,Ce.texPrimary.y,Ae,Me,Ce.pixelOffsetTL.x,Ce.pixelOffsetTL.y,Ce.minFontScaleX,Ce.minFontScaleY),this.text.updateSymbolVertexData(Ve+1,ke,Ke,Math.round(32*Ce.tr.x),Math.round(32*(Be+Ce.tr.y)),Ce.texPrimary.x+Ce.texPrimary.w,Ce.texPrimary.y,Ae,Me,Ce.pixelOffsetBR.x,Ce.pixelOffsetTL.y,Ce.minFontScaleX,Ce.minFontScaleY),this.text.updateSymbolVertexData(Ve+2,ke,Ke,Math.round(32*Ce.bl.x),Math.round(32*(Be+Ce.bl.y)),Ce.texPrimary.x,Ce.texPrimary.y+Ce.texPrimary.h,Ae,Me,Ce.pixelOffsetTL.x,Ce.pixelOffsetBR.y,Ce.minFontScaleX,Ce.minFontScaleY),this.text.updateSymbolVertexData(Ve+3,ke,Ke,Math.round(32*Ce.br.x),Math.round(32*(Be+Ce.br.y)),Ce.texPrimary.x+Ce.texPrimary.w,Ce.texPrimary.y+Ce.texPrimary.h,Ae,Me,Ce.pixelOffsetBR.x,Ce.pixelOffsetBR.y,Ce.minFontScaleX,Ce.minFontScaleY)}return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!0}}return t.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(l,t.layoutBasedTextVertexData),t.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:t.layoutBasedTextVertexData.length/zh,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,t,n,s,l,c,h,p){if(this.text.uboBinder||this.text.programConfigurations.updatePaintArrays(e,t,l,n,s,c,h,this.worldview),this.icon.uboBinder||this.icon.programConfigurations.updatePaintArrays(e,t,l,n,s,c,h,this.worldview),p){if(c)for(const _ of[this.text.uboBinder,this.icon.uboBinder])_&&!_.isLightConstant&&_.updateDynamicExpressions(l[0],t,p,n,e,h);else if(Object.keys(e).length>0){const _=l[0],y=[this.text.uboBinder,this.icon.uboBinder].filter(v=>v&&v.hasStateDependentPaint(_));if(y.length>0){const v=new Set(Object.keys(e).map(b=>{const T=Number(b);return!isNaN(T)&&Number.isSafeInteger(T)&&String(T)===b?T:b}));for(const b of y)b.updateFeatures(v,_,t,p,n,e,h)}}}}updateZOffset(){const e=(l,c,h)=>{n+=c,n>l.length&&l.resize(n);for(let p=-c;p<0;p++)l.emplace(p+n,h)},t=(l,c,h)=>{s+=c,s>l.length&&l.resize(s);for(let p=-c;p<0;p++)l.emplace(p+s,h)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let n=0,s=0;for(let l=0;l<this.symbolInstances.length;l++){const c=this.symbolInstances.get(l),{numHorizontalGlyphVertices:h,numVerticalGlyphVertices:p,numIconVertices:_}=c,y=c.zOffset,v=_>0;if((h>0||p>0)&&(e(this.text.zOffsetVertexArray,h,y),e(this.text.zOffsetVertexArray,p,y)),v){const{placedIconSymbolIndex:b,verticalPlacedIconSymbolIndex:T}=c;b>=0&&t(this.icon.zOffsetVertexArray,_,y),T>=0&&t(this.icon.zOffsetVertexArray,c.numVerticalIconVertices,y)}}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,t,n,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(c=>c.appearances&&c.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(e,t,n,s,l,c=!1){const h={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!n||!this.featureAppearanceData)return h;const p=t||{},_=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,y=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!_&&!y)return h;const v=this.layers[0],b=v.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===v.appearancesVersion||(this.featureAppearances=new rT(v.appearances,v.appearancesVersion));const T=this.featureAppearances.update(s,c);if(T.kind==="no-changes")return h;let S=1,A=0,C=!1,D=!1;if(_){const[te,H]=b.get("icon-size-scale-range");S=vt(1,te,H)}let z=1,O=0,F=!1;if(y){const[te,H]=b.get("text-size-scale-range");z=vt(1,te,H)}const N=new Map;if(l&&n)for(const te of n){const H=l.getImage(te,v.scope);if(H){const W=new uo(te.toString());N.set(W.toString(),H)}}const j=[this.text.uboBinder,this.icon.uboBinder];for(let te=0;te<this.symbolInstances.length;te++){const H=this.symbolInstances.get(te),W=this.getAppearanceFeatureData(H.featureIndex);if(!W)continue;const K=W.id,ee=K!==void 0?p[String(K)]:void 0,ae={type:"Point",id:W.id,properties:W.properties,geometry:[]};let he;if(T.kind==="all-features")he=T.appearanceIndex;else{const xe=v.appearances?v.appearances.findIndex(Te=>Te.isActive({globals:s,feature:ae,canonical:e,featureState:ee})):-1;he=xe>=0?xe:-1}const be=W.activeAppearanceIndex!==he;if(y){const xe=b.get("text-size"),Te=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,Fe=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,se={canonical:e,layer:v,featureState:ee,availableImages:n,textScaleFactor:z,imageMap:N,layoutTextOffset:b.get("text-offset").evaluate(ae,ee,e).map(ge=>ge*Mh),layoutTextSize:xe.evaluate(ae,ee,e),layoutTextRotate:b.get("text-rotate").evaluate(ae,ee,e),layoutMinZoomSize:xe.evaluate(ae,{zoom:Te},e),layoutMaxZoomSize:xe.evaluate(ae,{zoom:Fe},e),layoutTextSizeMinZoom:Te,layoutTextSizeMaxZoom:Fe},fe=this.updateSymbolInstanceTextVertices(H,W,he,ae,O,se);O+=fe.vertexOffsetDelta,F=F||fe.hasChanges}if(_){const xe={canonical:e,layer:v,featureState:ee,availableImages:n,globalProperties:s,iconScaleFactor:S,layoutIconOffset:b.get("icon-offset").evaluate(ae,ee,e),layoutIconSize:b.get("icon-size").evaluate(ae,ee,e,n),layoutIconRotate:b.get("icon-rotate").evaluate(ae,ee,e)},Te=this.updateSymbolInstanceIconVertices(H,W,he,ae,A,xe);A+=Te.vertexOffsetDelta,C=C||Te.hasChanges}if(be){const xe=H.featureIndex,Te=s?s.brightness:null,Fe=ee||{},se=he>=0?v.appearances[he]:null;for(const fe of j)fe&&(fe.layer=v,D=fe.updateFeaturePaintForAppearance(xe,ae,Fe,e,n,Te,se)||D)}W.activeAppearanceIndex=he}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),C&&this.icon.iconTransitioningVertexBuffer&&this.icon.iconTransitioningVertexArray.length>0&&this.icon.iconTransitioningVertexArray.length===this.icon.iconTransitioningVertexBuffer.length&&this.icon.iconTransitioningVertexBuffer.updateData(this.icon.iconTransitioningVertexArray),F&&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||F,hasUboChanges:D}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=tm(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const n=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:s,y:l}of t)this.lineVertexArray.emplaceBack(s,l);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z){const O=e.indexArray,F=e.layoutVertexArray,N=e.globeExtVertexArray,j=z,te=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,H=e.segments.prepareSegment(4*j,F,O,this.canOverlap?c.sortKey:void 0,te),W=this.glyphOffsetArray.length,K=H.vertexLength,ee=this.allowVerticalPlacement&&h===Al.vertical?Math.PI/2:0,ae=c.text&&c.text.sections;let he=F.length,be=-1;for(let Fe=0;Fe<t.length;Fe++){const{tl:se,tr:fe,bl:ge,br:Ae,texPrimary:Me,texSecondary:ze,pixelOffsetTL:Ce,pixelOffsetBR:Be,minFontScaleX:ke,minFontScaleY:Ke,glyphOffset:Ve,isSDF:$e,sectionIndex:dt}=t[Fe],pt=H.vertexLength,yt=Ve[1];if(af(F,_.x,_.y,se.x,yt+se.y,Me.x,Me.y,n,$e,Ce.x,Ce.y,ke,Ke),af(F,_.x,_.y,fe.x,yt+fe.y,Me.x+Me.w,Me.y,n,$e,Be.x,Ce.y,ke,Ke),af(F,_.x,_.y,ge.x,yt+ge.y,Me.x,Me.y+Me.h,n,$e,Ce.x,Be.y,ke,Ke),af(F,_.x,_.y,Ae.x,yt+Ae.y,Me.x+Me.w,Me.y+Me.h,n,$e,Be.x,Be.y,ke,Ke),p){const{x:ht,y:wt,z:bt}=p.anchor,[ri,jt,Qt]=p.up;cf(N,ht,wt,bt,ri,jt,Qt),cf(N,ht,wt,bt,ri,jt,Qt),cf(N,ht,wt,bt,ri,jt,Qt),cf(N,ht,wt,bt,ri,jt,Qt),Su(e.dynamicLayoutVertexArray,ht,wt,bt,ee)}else Su(e.dynamicLayoutVertexArray,_.x,_.y,_.z,ee);if(C){const ht=ze||Me;lf(e.iconTransitioningVertexArray,ht.x,ht.y),lf(e.iconTransitioningVertexArray,ht.x+ht.w,ht.y),lf(e.iconTransitioningVertexArray,ht.x,ht.y+ht.h),lf(e.iconTransitioningVertexArray,ht.x+ht.w,ht.y+ht.h)}if(O.emplaceBack(pt,pt+1,pt+2),O.emplaceBack(pt+1,pt+2,pt+3),H.vertexLength+=4,H.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Ve[0]),(Fe===t.length-1||dt!==t[Fe+1].sectionIndex)&&(e.uboBinder||e.programConfigurations.populatePaintArrays(F.length,c,c.index,{},T,S,A,ae&&ae[dt],this.worldview),e.uboBinder)){const ht=e.uboBinder.populateUBO(c,c.index,S,T,A,ae&&ae[dt]);be=ht;const wt=F.length-he;for(let bt=0;bt<wt;bt++)e.featureIdArray.emplaceBack(ht);he=F.length}}const xe=z-t.length;if(xe!==0&&(this._addNullVertices(xe,F,n,p,N,e,C,H,O),e.uboBinder&&be>=0)){const Fe=4*xe;for(let se=0;se<Fe;se++)e.featureIdArray.emplaceBack(be)}const Te=p?p.anchor:_;e.placedSymbolArray.emplaceBack(Te.x,Te.y,Te.z,_.x,_.y,W,this.glyphOffsetArray.length-W,K,y,v,_.segment,n?n[0]:0,n?n[1]:0,s[0],s[1],h,0,0,0,b,0),e.symbolInstanceIndices.push(D)}_addNullVertices(e,t,n,s,l,c,h,p,_){for(let y=0;y<e;y++){for(let b=0;b<4;b++)af(t,0,0,0,0,0,0,n,!1,0,0,0,0),s&&cf(l,0,0,0,0,0,0),Su(c.dynamicLayoutVertexArray,0,0,0,0),h&&lf(c.iconTransitioningVertexArray,0,0);const v=p.vertexLength;_.emplaceBack(v,v+1,v+2),_.emplaceBack(v+1,v+2,v+3),p.vertexLength+=4,p.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(e,t,n,s,l,c,h){e.emplaceBack(t,n,s,l,c,Math.round(h.x),Math.round(h.y))}_addCollisionDebugVertices(e,t,n,s,l,c,h){const p=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),_=p.vertexLength,y=h.tileAnchorX,v=h.tileAnchorY;for(let T=0;T<4;T++)n.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(n.collisionVertexArrayExt,t,e.padding,h.zOffset),this._commitLayoutVertex(n.layoutVertexArray,s,l,c,y,v,new De(e.x1,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,l,c,y,v,new De(e.x2,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,l,c,y,v,new De(e.x2,e.y2)),this._commitLayoutVertex(n.layoutVertexArray,s,l,c,y,v,new De(e.x1,e.y2)),p.vertexLength+=4;const b=n.indexArray;b.emplaceBack(_,_+1),b.emplaceBack(_+1,_+2),b.emplaceBack(_+2,_+3),b.emplaceBack(_+3,_),p.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,n,s,l,c){for(let h=s;h<l;h++){const p=n.get(h),_=this.getSymbolInstanceTextSize(e,c,t,h);this._addCollisionDebugVertices(p,_,this.textCollisionBox,p.projectedAnchorX,p.projectedAnchorY,p.projectedAnchorZ,c)}}_addIconDebugCollisionBoxes(e,t,n,s,l,c){for(let h=s;h<l;h++){const p=n.get(h),_=this.getSymbolInstanceIconSize(e,t,c.placedIconSymbolIndex);this._addCollisionDebugVertices(p,_,this.iconCollisionBox,p.projectedAnchorX,p.projectedAnchorY,p.projectedAnchorZ,c)}}generateCollisionDebugBuffers(e,t,n){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Ig(bi,Jy.members,Mt),this.iconCollisionBox=new Ig(bi,Jy.members,Mt);const s=Tu(this.iconSizeData,e),l=Tu(this.textSizeData,e,n);for(let c=0;c<this.symbolInstances.length;c++){const h=this.symbolInstances.get(c);this._addTextDebugCollisionBoxes(l,e,t,h.textBoxStartIndex,h.textBoxEndIndex,h),this._addTextDebugCollisionBoxes(l,e,t,h.verticalTextBoxStartIndex,h.verticalTextBoxEndIndex,h),this._addIconDebugCollisionBoxes(s,e,t,h.iconBoxStartIndex,h.iconBoxEndIndex,h),this._addIconDebugCollisionBoxes(s,e,t,h.verticalIconBoxStartIndex,h.verticalIconBoxEndIndex,h)}}getSymbolInstanceTextSize(e,t,n,s){const l=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:s),c=Hp(this.textSizeData,e,l)/Mh;return this.tilePixelRatio*c}getSymbolInstanceIconSize(e,t,n){const s=this.icon.placedSymbolArray.get(n),l=Hp(this.iconSizeData,e,s);return this.tilePixelRatio*l}_commitDebugCollisionVertexUpdate(e,t,n,s){e.emplaceBack(t,-n,-n,s),e.emplaceBack(t,n,-n,s),e.emplaceBack(t,n,n,s),e.emplaceBack(t,-n,n,s)}_updateTextDebugCollisionBoxes(e,t,n,s,l,c,h){for(let p=s;p<l;p++){const _=n.get(p),y=this.getSymbolInstanceTextSize(e,c,t,p);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,y,_.padding,c.zOffset)}}_updateIconDebugCollisionBoxes(e,t,n,s,l,c,h){for(let p=s;p<l;p++){const _=n.get(p),y=this.getSymbolInstanceIconSize(e,t,c.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,y,_.padding,c.zOffset)}}updateCollisionDebugBuffers(e,t,n,s){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const l=Tu(this.iconSizeData,e,s),c=Tu(this.textSizeData,e,n);for(let h=0;h<this.symbolInstances.length;h++){const p=this.symbolInstances.get(h);this._updateTextDebugCollisionBoxes(c,e,t,p.textBoxStartIndex,p.textBoxEndIndex,p,n),this._updateTextDebugCollisionBoxes(c,e,t,p.verticalTextBoxStartIndex,p.verticalTextBoxEndIndex,p,n),this._updateIconDebugCollisionBoxes(l,e,t,p.iconBoxStartIndex,p.iconBoxEndIndex,p,s),this._updateIconDebugCollisionBoxes(l,e,t,p.verticalIconBoxStartIndex,p.verticalIconBoxEndIndex,p,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,t,n,s,l,c,h,p,_){const y={};if(t<n){const{x1:v,y1:b,x2:T,y2:S,padding:A,projectedAnchorX:C,projectedAnchorY:D,projectedAnchorZ:z,tileAnchorX:O,tileAnchorY:F,featureIndex:N}=e.get(t);y.textBox={x1:v,y1:b,x2:T,y2:S,padding:A,projectedAnchorX:C,projectedAnchorY:D,projectedAnchorZ:z,tileAnchorX:O,tileAnchorY:F},y.textFeatureIndex=N}if(s<l){const{x1:v,y1:b,x2:T,y2:S,padding:A,projectedAnchorX:C,projectedAnchorY:D,projectedAnchorZ:z,tileAnchorX:O,tileAnchorY:F,featureIndex:N}=e.get(s);y.verticalTextBox={x1:v,y1:b,x2:T,y2:S,padding:A,projectedAnchorX:C,projectedAnchorY:D,projectedAnchorZ:z,tileAnchorX:O,tileAnchorY:F},y.verticalTextFeatureIndex=N}if(c<h){const{x1:v,y1:b,x2:T,y2:S,padding:A,projectedAnchorX:C,projectedAnchorY:D,projectedAnchorZ:z,tileAnchorX:O,tileAnchorY:F,featureIndex:N}=e.get(c);y.iconBox={x1:v,y1:b,x2:T,y2:S,padding:A,projectedAnchorX:C,projectedAnchorY:D,projectedAnchorZ:z,tileAnchorX:O,tileAnchorY:F},y.iconFeatureIndex=N}if(p<_){const{x1:v,y1:b,x2:T,y2:S,padding:A,projectedAnchorX:C,projectedAnchorY:D,projectedAnchorZ:z,tileAnchorX:O,tileAnchorY:F,featureIndex:N}=e.get(p);y.verticalIconBox={x1:v,y1:b,x2:T,y2:S,padding:A,projectedAnchorX:C,projectedAnchorY:D,projectedAnchorZ:z,tileAnchorX:O,tileAnchorY:F},y.verticalIconFeatureIndex=N}return y}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const n=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.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,t){const n=e.placedSymbolArray.get(t),s=n.vertexStartIndex+4*n.numGlyphs;for(let l=n.vertexStartIndex;l<s;l+=4)e.indexArray.emplaceBack(l,l+1,l+2),e.indexArray.emplaceBack(l+1,l+2,l+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const t=Math.sin(e),n=Math.cos(e),s=[],l=[],c=[];for(let h=0;h<this.symbolInstances.length;++h){c.push(h);const p=this.symbolInstances.get(h);s.push(0|Math.round(t*p.tileAnchorX+n*p.tileAnchorY)),l.push(p.featureIndex)}return c.sort((h,p)=>s[h]-s[p]||l[p]-l[h]),c}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,t)=>this.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const n=this.sortKeyRanges.at(-1);n&&n.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,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.sortFeaturesByY=!1;else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const n=this.symbolInstances.get(t);this.featureSortOrder.push(n.featureIndex);const{rightJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:l,leftJustifiedTextSymbolIndex:c,verticalPlacedTextSymbolIndex:h,placedIconSymbolIndex:p,verticalPlacedIconSymbolIndex:_}=n;s>=0&&this.addIndicesForPlacedSymbol(this.text,s),l>=0&&l!==s&&this.addIndicesForPlacedSymbol(this.text,l),c>=0&&c!==l&&c!==s&&this.addIndicesForPlacedSymbol(this.text,c),h>=0&&this.addIndicesForPlacedSymbol(this.text,h),p>=0&&this.addIndicesForPlacedSymbol(this.icon,p),_>=0&&this.addIndicesForPlacedSymbol(this.icon,_)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}et(fm,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),fm.addDynamicAttributes=Su;class Wx extends G_{constructor(e,t,n){super(e,t,n),this.elevatedLayoutVertexArray=new Oe}upload(e){const t=this.uploaded;super.upload(e),!t&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,ko.members))}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),super.destroy()}}et(Wx,"ElevatedFillBufferData");class Pl{constructor(){this.portals=[]}static isOnBorder(e,t){return e<=0&&t<=0||e>=qe&&t>=qe}static evaluate(e){if(e.length===0)return new Pl;let t=[];for(const p of e)t.push(...p.portals);if(t.length===0)return new Pl;for(const p of t){const _=p.va,y=p.vb;(Pl.isOnBorder(_.x,y.x)||Pl.isOnBorder(_.y,y.y))&&(p.type="border")}const n=t.filter(p=>p.type!=="unevaluated"),s=t.filter(p=>p.type==="unevaluated");if(s.length===0)return new Pl;s.sort((p,_)=>p.hash===_.hash?p.isTunnel===_.isTunnel?0:p.isTunnel?-1:1:p.hash<_.hash?1:-1),t=n.concat(s);let l=n.length,c=l,h=l;do if(c++,c===t.length||t[l].hash!==t[c].hash){if(c-l===2){h<l&&(t[h]=t[l],t[l]=null);const p=t[h],_=t[c-1];p.type=p.isTunnel!==_.isTunnel?"tunnel":"polygon",p.connection={a:p.connection.a,b:_.connection.a},h++}l=c}while(l!==t.length);return t.splice(h),t.sort((p,_)=>p.hash<_.hash?1:-1),{portals:t}}}et(Pl,"ElevationPortalGraph");class aT{constructor(e,t,n){this.outPositions=e,this.outNormals=t,this.outIndices=n,this.vertexLookup=new Map}addVertex(e,t,n){let s=e[2];n!=null&&(s*=n);const l=`${e[0]},${e[1]},${e[2]},${t[0]},${t[1]},${t[2]}`,c=this.vertexLookup.get(l);if(c!=null)return c;const h=this.outPositions.length;this.vertexLookup.set(l,h);const p=Math.trunc(16384*t[0]),_=Math.trunc(16384*t[1]),y=Math.trunc(16384*t[2]);return this.outPositions.emplaceBack(e[0],e[1],s),this.outNormals.emplaceBack(p,_,y),h}addTriangle(e,t,n){this.outIndices.emplaceBack(e,t,n)}addTriangles(e,t,n,s=0){if(e.length===0)return;const l=Jt(),c=Jt();for(let h=0;h<e.length;h+=3){const p=t[e[h+0]],_=t[e[h+1]],y=t[e[h+2]],v=n[e[h+1]]+s,b=n[e[h+2]]+s;Ui(l,p.x,p.y,n[e[h+0]]+s);const T=this.addVertex(l,c);Ui(l,_.x,_.y,v);const S=this.addVertex(l,c);Ui(l,y.x,y.y,b);const A=this.addVertex(l,c);this.outIndices.emplaceBack(T,S,A)}}addQuad(e,t,n,s,l,c){const h=this.addVertex(e,l,c),p=this.addVertex(t,l,c),_=this.addVertex(n,l,c),y=this.addVertex(s,l,c);this.addTriangle(h,p,_),this.addTriangle(_,y,h)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class No{constructor(e,t,n,s){this.unevaluatedPortals=new Pl,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new Xe,this.vertexNormals=new ot,this.indexArray=new _t,this.tileToMeters=B(e),this.bridgeProgramConfigurations=new ta(t,{zoom:n,lut:s},l=>l!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new ta(t,{zoom:n,lut:s},l=>l!=="fill-bridge-guard-rail-color")}addVertices(e,t){const n=this.unevalVertices.length;for(let s=0;s<e.length;s++)this.unevalVertices.push(e[s]),this.unevalHeights.push(t[s]);return n}addTriangles(e,t,n){const s=n?this.unevalTunnelTriangles:this.unevalTriangles;for(const l of e)s.push(l+t)}addRenderableRing(e,t,n,s,l,c){const h=[new De(l.min.x,l.min.y),new De(l.max.x,l.min.y),new De(l.max.x,l.max.y),new De(l.min.x,l.max.y)];for(let p=0;p<n-1;p++){const _=t+p,y=_+1,v=this.unevalVertices[_],b=this.unevalVertices[y];if(!(v.x>=l.min.x&&v.x<=l.max.x&&v.y>=l.min.y&&v.y<=l.max.y||b.x>=l.min.x&&b.x<=l.max.x&&b.y>=l.min.y&&b.y<=l.max.y||Ih(v,b,h))||this.isOnBorder(v.x,b.x)||this.isOnBorder(v.y,b.y))continue;const T=No.computeEdgeHash(this.unevalVertices[_],this.unevalVertices[y]);let S,A=this.vertexHashLookup.get(No.computePosHash(v));A!=null?S=A.next:(A=this.vertexHashLookup.get(No.computePosHash(b)),S=A!=null?A.prev:T),this.unevalEdges.push({polygonIdx:e,a:_,b:y,hash:T,portalHash:S,isTunnel:s,type:"unevaluated",featureInfo:c})}}addPortalCandidates(e,t,n,s,l){if(t.length!==0){this.vertexHashLookup.clear();for(const c of t){if(c.length===0)continue;const h=c[0];let p=No.computeEdgeHash(h[h.length-2],h.at(-1));for(let _=0;_<h.length-1;_++){const y=h[_+0],v=h[_+1],b=Zs(v.x-y.x,v.y-y.y),T=Hl(b);if(T===0)continue;let S="unevaluated";const A=s.pointElevation(y),C=s.pointElevation(v);Math.abs(A)<.01&&Math.abs(C)<.01?S="entrance":(this.isOnBorder(y.x,v.x)||this.isOnBorder(y.y,v.y))&&(S="border");const D=No.computeEdgeHash(y,v);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:y,vb:v,vab:b,length:T,hash:D,isTunnel:n,type:S});const z=No.computePosHash(y);this.vertexHashLookup.has(z)||this.vertexHashLookup.set(z,{prev:p,next:D}),p=D}}}}construct(e){if(this.unevalVertices.length===0)return;const t=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),n=b=>{b.primitiveLength=this.indexArray.length-b.primitiveOffset},s=new aT(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const l=t(),c=t(),h=t(),p=(b,T)=>{b.sort((A,C)=>A.type===T&&C.type!==T?-1:A.type!==T&&C.type===T?1:0);const S=b.findIndex(A=>A.type!==T);return S>=0?S:b.length};let _=0;this.unevalEdges.length>0&&(_=p(this.unevalEdges,"none"),this.constructBridgeStructures(s,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:_},this.tileToMeters)),n(h);const y=t(),v=t();if(this.unevalEdges.length>0){const b=this.unevalEdges.splice(_),T=p(b,"tunnel")+_;this.unevalEdges.push(...b),this.constructTunnelStructures(s,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:_},{min:_,max:T})}n(y),s.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),n(v),s.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),n(c),s.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights,4),n(l),this.maskSegments=li.simpleSegment(0,v.primitiveOffset,0,v.primitiveLength),this.depthSegments=li.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.renderableBridgeSegments=li.simpleSegment(0,h.primitiveOffset,0,h.primitiveLength),this.renderableTunnelSegments=li.simpleSegment(0,y.primitiveOffset,0,y.primitiveLength),this.shadowCasterSegments=li.simpleSegment(0,l.primitiveOffset,0,l.primitiveLength)}update(e,t,n,s,l,c,h,p){this.bridgeProgramConfigurations.updatePaintArrays(e,t,l,n,s,c,h,p),this.tunnelProgramConfigurations.updatePaintArrays(e,t,l,n,s,c,h,p)}upload(e){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,Ra.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,gs.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,t,n,s,l){const c=(h,p)=>{for(let _=0;_<p.length-1;_++){const y=p[_].featureIndex,v=p[_+1].vertexStart,b=e.feature(y);h.populatePaintArrays(v,b,y,{},n,t,s,void 0,l)}};c(this.bridgeProgramConfigurations,this.bridgeFeatureSections),c(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(e,t,n,s,l){const c=new Map;for(let h=s;h<l;h++){const p=n[h],_=p.a,y=p.b,v=No.computePosHash(e[_]),b=No.computePosHash(e[y]);let T=c.get(v);T||(T={},c.set(v,T));let S=c.get(b);S||(S={},c.set(b,S)),t[_]<=0&&t[y]<=0||(T.to=y,S.from=_)}return c}isTerminalVertex(e,t){const n=No.computePosHash(this.unevalVertices[e]),s=t.get(n);return!s||!s.from||!s.to}constructBridgeStructures(e,t,n,s,l,c){e.clearVertexLookup();const h=this.computeVertexConnections(t,n,s,l.min,l.max),p=1/c,_=.5*p,y=(xe,Te)=>Ui(xe,t[Te].x,t[Te].y,n[Te]*p),v=Jt(),b=Jt(),T=Jt(),S=Jt(),A=Jt(),C=(xe,Te)=>{const Fe=h.get(No.computePosHash(t[Te])),se=Fe.from,fe=Fe.to;if(!se||!fe)return;y(v,se),y(b,Te),y(T,fe),Rc(S),os(v,b)||(Pi(A,b,v),ei(S,A)),os(T,b)||(Pi(A,T,b),Ji(S,S,ei(A,A)));const ge=Ss(S);return ge>0?si(xe,S,1/ge):void 0};let D=Number.POSITIVE_INFINITY;this.sortSubarray(s,l.min,l.max,(xe,Te)=>xe.featureInfo.featureIndex-Te.featureInfo.featureIndex);const z=Jt(),O=Jt(),F=Jt(),N=Jt(),j=Jt(),te=Jt(),H=Jt(),W=Jt(),K=Jt(),ee=[Jt(),Jt(),Jt(),Jt()],ae=[Jt(),Jt(),Jt(),Jt()],he=[{coord:new De(0,0),height:0},{coord:new De(0,0),height:0}],be=(xe,Te)=>xe>Te;for(let xe=l.min;xe<l.max;xe++){const Te=s[xe];if(!Te.featureInfo.guardRailEnabled||!this.prepareEdgePoints(he,t,n,Te,be))continue;const[Fe,se]=he;if(Ui(z,Fe.coord.x,Fe.coord.y,p*Fe.height),Ui(O,se.coord.x,se.coord.y,p*se.height),os(z,O))continue;Pi(F,O,z),ei(F,F);const fe=C(W,Te.a)||F,ge=C(K,Te.b)||F;Ui(N,fe[1],-fe[0],0),ei(N,N),Ui(j,ge[1],-ge[0],0),ei(j,j),gr(W,N,fe),ei(te,W),gr(W,j,ge),ei(H,W),Ji(ee[0],z,si(W,Pi(W,N,te),_)),Ji(ee[1],z,si(W,Ji(W,N,te),_)),Ji(ee[2],z,si(W,te,_)),ee[3]=z,Ji(ae[0],O,si(W,Pi(W,j,H),_)),Ji(ae[1],O,si(W,Ji(W,j,H),_)),Ji(ae[2],O,si(W,H,_)),ae[3]=O,D=this.addFeatureSection(Te.featureInfo.featureIndex,D,this.bridgeFeatureSections,e);const Ae=e.addVertex(ee[0],N,c),Me=e.addVertex(ee[1],N,c),ze=e.addVertex(ae[0],j,c),Ce=e.addVertex(ae[1],j,c);e.addTriangle(Ae,Me,ze),e.addTriangle(Me,Ce,ze);const Be=e.addVertex(ee[1],te,c),ke=e.addVertex(ee[2],te,c),Ke=e.addVertex(ae[1],H,c),Ve=e.addVertex(ae[2],H,c);e.addTriangle(Be,ke,Ke),e.addTriangle(ke,Ve,Ke),ns(N,N),ns(j,j);const $e=e.addVertex(ee[2],N,c),dt=e.addVertex(ee[3],N,c),pt=e.addVertex(ae[2],j,c),yt=e.addVertex(ae[3],j,c);e.addTriangle($e,dt,pt),e.addTriangle(dt,yt,pt);const ht=this.isTerminalVertex(Te.a,h),wt=this.isTerminalVertex(Te.b,h);Fe.height<.01&&ht&&e.addQuad(ee[3],ee[2],ee[1],ee[0],ns(fe,fe),c),se.height<.01&&wt&&e.addQuad(ae[0],ae[1],ae[2],ae[3],ge,c)}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}constructTunnelStructures(e,t,n,s,l,c){e.clearVertexLookup();let h=Number.POSITIVE_INFINITY;const p=(D,z)=>D.featureInfo.featureIndex-z.featureInfo.featureIndex;this.sortSubarray(s,l.min,l.max,p),this.sortSubarray(s,c.min,c.max,p);const _=D=>ei(D,D),y=[{coord:new De(0,0),height:0},{coord:new De(0,0),height:0}],v=(D,z)=>D<z,b=Jt(),T=Jt(),S=Jt(),A=Jt(),C=Jt();for(let D=l.min;D<l.max;D++){if(!this.prepareEdgePoints(y,t,n,s[D],v))continue;const[z,O]=y,F=_(Ui(C,-(O.coord.y-z.coord.y),O.coord.x-z.coord.x,0));h=this.addFeatureSection(s[D].featureInfo.featureIndex,h,this.tunnelFeatureSections,e),e.addQuad(Ui(b,z.coord.x,z.coord.y,z.height),Ui(T,O.coord.x,O.coord.y,O.height),Ui(S,O.coord.x,O.coord.y,s[D].isTunnel?O.height+4:0),Ui(A,z.coord.x,z.coord.y,s[D].isTunnel?z.height+4:0),F)}for(let D=c.min;D<c.max;D++){const z=s[D];z.isTunnel&&([z.a,z.b]=[z.b,z.a]);const O=t[z.a],F=t[z.b],N=_(Ui(C,-(F.y-O.y),F.x-O.x,0));h=this.addFeatureSection(z.featureInfo.featureIndex,h,this.tunnelFeatureSections,e),e.addQuad(Ui(b,F.x,F.y,0),Ui(T,O.x,O.y,0),Ui(S,O.x,O.y,n[z.a]+4),Ui(A,F.x,F.y,n[z.b]+4),N),e.addQuad(Ui(b,O.x,O.y,0),Ui(T,F.x,F.y,0),Ui(S,F.x,F.y,n[z.b]+4),Ui(A,O.x,O.y,n[z.a]+4),N)}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}setElevatedPoint(e,t,n,s){e.coord.x=t,e.coord.y=n,e.height=s}prepareEdgePoints(e,t,n,s,l){let c=t[s.a].x,h=t[s.a].y,p=t[s.b].x,_=t[s.b].y,y=n[s.a],v=n[s.b];const b=l(y,0),T=l(v,0);if(b&&T)return this.setElevatedPoint(e[0],c,h,y),this.setElevatedPoint(e[1],p,_,v),!0;if(!b&&!T)return!1;if(b){if(!T){const S=v/(v-y);p=lt(p,c,S),_=lt(_,h,S),v=lt(v,y,S)}}else{const S=y/(y-v);c=lt(c,p,S),h=lt(h,_,S),y=lt(y,v,S)}return this.setElevatedPoint(e[0],c,h,y),this.setElevatedPoint(e[1],p,_,v),!0}prepareEdges(e,t){if(t.length===0)return;t.sort((h,p)=>h.hash===p.hash?p.polygonIdx-h.polygonIdx:p.hash>h.hash?1:-1);let n=0,s=0,l=0,c=t[n].polygonIdx;do s++,(s===t.length||t[n].hash!==t[s].hash)&&((s-n===1||t[s-1].polygonIdx!==c)&&(l<n&&(t[l]=t[n],t[n]=null),t[l].type="none",l++),n=s,n!==t.length&&(c=t[n].polygonIdx));while(n!==t.length);if(t.splice(l),t.length!==0&&e.length!==0){t.sort((_,y)=>_.portalHash<y.portalHash?1:-1);let h=0,p=0;for(;h!==t.length&&p!==e.length;){const _=t[h],y=e[p];_.portalHash>y.hash?h++:y.hash>_.portalHash?p++:(_.type=y.type,h++)}}}isOnBorder(e,t){return e<=0&&t<=0||e>=qe&&t>=qe}addFeatureSection(e,t,n,s){return e!==t&&(t=e,n.push({featureIndex:e,vertexStart:s.getVertexCount()}),s.clearVertexLookup()),t}sortSubarray(e,t,n,s){const l=e.slice(t,n);l.sort(s),e.splice(t,l.length,...l)}static computeEdgeHash(e,t){return(e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(No.computePosHash(e))<<32n|BigInt(No.computePosHash(t))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}class lT{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,t){return this._valid&&e(t(this._geometry)),this}require(e,t,n){return this.get(e,!0,t,n)}optional(e,t,n){return this.get(e,!1,t,n)}success(){return this._valid}get(e,t,n,s){const l=Object.hasOwn(this.feature.properties,e)?+this.feature.properties[e]:void 0;return this._valid&&l!==void 0&&!Number.isNaN(l)?n(s?s(l):l):t&&(this._valid=!1),this}}class Xx{constructor(e,t){this.featureFunc=e,this.vertexFunc=t}parseFeature(e,t,n){return this.featureFunc(e,t,n)}parseVertex(e,t,n){return this.vertexFunc(e,t,n)}}const cT=new Xx((i,e,t)=>i.reset(e).require(Il,n=>{t.id=n}).optional("fixed_height_relative",n=>{t.constantHeight=n},Dl.decodeRelativeHeight).geometry(n=>{t.bounds=n},Ka).success(),(i,e,t)=>i.reset(e).require(Il,n=>{t.id=n}).require("elevation_idx",n=>{t.idx=n}).require("extent",n=>{t.extent=n}).require("height_relative",n=>{t.height=n},Dl.decodeRelativeHeight).geometry(n=>{t.position=n},Dl.getPoint).success()),uT=new Xx((i,e,t)=>i.reset(e).require(Il,n=>{t.id=n}).optional("fixed_height",n=>{t.constantHeight=n},Dl.decodeMetricHeight).geometry(n=>{t.bounds=n},Ka).success(),(i,e,t)=>i.reset(e).require(Il,n=>{t.id=n}).require("elevation_idx",n=>{t.idx=n}).require("extent",n=>{t.extent=n}).require("height",n=>{t.height=n},Dl.decodeMetricHeight).geometry(n=>{t.position=n},Dl.getPoint).success());class Dl{static getPoint(e){return Zs(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"?uT:void 0:cT}static parse(e){const t=[],n=[],s=e.length,l=new lT;for(let c=0;c<s;c++){const h=e.feature(c),p=h.properties.version,_=Dl.getVersionSchema(p);if(_===void 0){_i(`Unknown elevation feature version number ${p||"(unknown)"}`);continue}const y=h.properties.type;if(!y)continue;const v=pc.types[h.type];if(v==="Point"&&y==="curve_point"){const b={};_.parseVertex(l,h,b)&&t.push(b)}else if(v==="Polygon"&&y==="curve_meta"){const b={};_.parseFeature(l,h,b)&&n.push(b)}}return{vertices:t,features:n}}}const hT=[Xr(),Xr(),Xr(),Xr(),Xr(),Xr(),Xr()],Iu=Xr(),Au=Xr();function pm(i){return[i[0],i[1]]}function mm(i){return Zs(i[0],i[1])}class Yx{constructor(e,t,n=null){this.feature=e,this.metersToTile=t,this.sampler=n,this.index=0}get(){const e=this.feature.vertices[this.index],t=this.feature.vertexProps[this.index].dir,n=t[1],s=-t[0],l=(e.extent+1)*this.metersToTile,c=this.sampler?this.sampler.pointTransform(e.position):e.position;return[new De(Math.trunc(c[0]+n*l),Math.trunc(c[1]+s*l)),new De(Math.trunc(c[0]-n*l),Math.trunc(c[1]-s*l))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class Ll{constructor(e,t,n,s,l,c){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this.id=e,this.heightRange={min:n,max:n},this.safeArea=t,this.constantHeight=n,this.constantHeight==null&&(this.constantHeight!=null||s.length!==0)){this.vertices=s,this.edges=l;for(let h=0;h<this.vertices.length;h++)this.vertices[h].index=this.vertices[h].index!==void 0?this.vertices[h].index:h;this.edges=this.edges.filter(h=>{return h.a<this.vertices.length&&h.b<this.vertices.length&&!((p=this.vertices[h.a].position)[0]===(_=this.vertices[h.b].position)[0]&&p[1]===_[1]);var p,_}),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(const h of this.vertices)this.vertexProps.push({dir:Zs(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,h.height),this.heightRange.max=Math.max(this.heightRange.max,h.height);for(const h of this.edges){const p=this.vertices[h.a].position,_=this.vertices[h.b].position,y=$s(Xr(),_,p),v=Hl(y),b=qa(Xr(),y,1/v);this.edgeProps.push({vec:y,dir:b,len:v});const T=this.vertexProps[h.a].dir,S=this.vertexProps[h.b].dir;ss(T,T,b),ss(S,S,b)}for(const h of this.vertexProps)h.dir[0]===0&&h.dir[1]===0||la(h.dir,h.dir);this.tessellate(c)}}pointElevation(e){if(this.constantHeight!=null)return this.constantHeight;const t=this.getClosestEdge(e);if(t==null)return 0;const[n,s]=t;return lt(this.vertices[this.edges[n].a].height,this.vertices[this.edges[n].b].height,s)}computeSlopeNormal(e,t){const n=this.getClosestEdge(e);if(!n)return br(0,0,1);const s=n[0],l=this.edges[s],c=this.edgeProps[s].vec,h=br(c[0],c[1],(this.vertices[l.b].height-this.vertices[l.a].height)*t),p=br(h[1],-h[0],0);gr(p,p,h);const _=Ki(p);return _>0?si(p,p,1/_):Ui(p,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(this.edges.length===0)return;let t=0,n=Number.POSITIVE_INFINITY,s=0;const[l,c,h,p,_,y,v]=hT;Gl(v,e.x,e.y);const b=new Iw(v,null);for(let T=0;T<this.edges.length;T++){const S=this.edges[T],A=this.edgeProps[T].dir;b.dir=A;const C=this.vertices[S.a].position,D=this.vertices[S.b].position,z=b.intersectsPlane(C,this.vertexProps[S.a].dir,l),O=b.intersectsPlane(D,this.vertexProps[S.b].dir,c);if(!z||!O)continue;$s(h,c,l),$s(p,v,l);const F=Wa(h,h),N=F>0?Wa(p,h)/F:0,j=vt(N,0,1),te=Math.abs((N-j)*this.edgeProps[T].len);$s(_,v,C),Gl(y,A[1],-A[0]);const H=te+Math.abs(Wa(_,y));H<n&&(t=T,n=H,s=j)}return[t,s]}tessellate(e){const t=Jt(),n=Jt(),s=Jt(),l=Jt();for(let c=this.edges.length-1;c>=0;--c){const h=this.edges[c].a,p=this.edges[c].b,{position:_,height:y,extent:v}=this.vertices[h],{position:b,height:T,extent:S}=this.vertices[p],A=this.vertexProps[h].dir,C=this.vertexProps[p].dir;if(Ui(t,_[0]/e,_[1]/e,y),Ui(n,b[0]/e,b[1]/e,T),Ui(s,A[1],-A[0],0),si(s,s,v),Ui(l,C[1],-C[0],0),si(l,l,S),this.distSqLines(br(t[0]+.5*s[0],t[1]+.5*s[1],t[2]+.5*s[2]),br(n[0]-.5*l[0],n[1]-.5*l[1],n[2]-.5*l[2]),br(t[0]-.5*s[0],t[1]-.5*s[1],t[2]-.5*s[2]),br(n[0]+.5*l[0],n[1]+.5*l[1],n[2]+.5*l[2]))<=.0025000000000000005)continue;const D=this.vertices.length,z=ss(Xr(),_,b);this.vertices.push({position:qa(z,z,.5),height:.5*(y+T),extent:.5*(v+S),index:.5*((this.vertices[h].index!==void 0?this.vertices[h].index:h)+(this.vertices[p].index!==void 0?this.vertices[p].index:p))});const O=ss(Xr(),A,C);this.vertexProps.push({dir:la(O,O)}),this.edges.splice(c,1),this.edgeProps.splice(c,1),this.edges.push({a:h,b:D}),this.edges.push({a:D,b:p});const F=$s(Xr(),this.vertices[D].position,_),N=Hl(F),j={vec:F,dir:qa(Xr(),F,1/N),len:N};this.edgeProps.push(j),this.edgeProps.push(j)}}distSqLines(e,t,n,s){const l=Jn(Jt(),t,e),c=Jn(Jt(),s,n),h=Jn(Jt(),e,n),p=Ri(l,l),_=Ri(l,c),y=Ri(l,h),v=Ri(c,c),b=Ri(c,h),T=p*v-_*_;if(T===0)return Us(js(l,n,s,Ri(h,c)/Ri(c,c)),e);const S=(p*b-_*y)/T;return Us(js(l,e,t,(_*b-y*v)/T),js(c,n,s,S))}static serialize(e,t){const n={id:e.id,heightRange:{min:e.heightRange.min,max:e.heightRange.max},safeArea:(s=e.safeArea,{min:{x:s.min.x,y:s.min.y},max:{x:s.max.x,y:s.max.y}})};var s;return e.constantHeight!=null?(n.constantHeight=e.constantHeight,n):e.vertices.length===0?(n.vertices=[],n.vertexProps=[],n.edges=[],n.edgeProps=[],n):(n.vertices=e.vertices.map(l=>({position:pm(l.position),height:l.height,extent:l.extent,index:l.index})),n.vertexProps=e.vertexProps.map(l=>({dir:pm(l.dir)})),n.edges=e.edges.map(l=>({a:l.a,b:l.b})),n.edgeProps=e.edgeProps.map(l=>({vec:pm(l.vec),dir:pm(l.dir),len:l.len})),n)}static deserialize(e){const t=function(s){return{min:new De(s.min.x,s.min.y),max:new De(s.max.x,s.max.y)}}(e.safeArea);if(e.constantHeight!=null)return new Ll(e.id,t,e.constantHeight);if(!e.vertices||e.vertices.length===0){const s=Object.create(Ll.prototype);return s.id=e.id,s.constantHeight=void 0,s.heightRange={min:e.heightRange.min,max:e.heightRange.max},s.safeArea=t,s.vertices=[],s.vertexProps=[],s.edges=[],s.edgeProps=[],s}const n=Object.create(Ll.prototype);return n.id=e.id,n.constantHeight=void 0,n.heightRange={min:e.heightRange.min,max:e.heightRange.max},n.safeArea=t,n.vertices=e.vertices.map(s=>({position:mm(s.position),height:s.height,extent:s.extent,index:s.index})),n.vertexProps=(e.vertexProps||[]).map(s=>({dir:mm(s.dir)})),n.edges=(e.edges||[]).map(s=>({a:s.a,b:s.b})),n.edgeProps=(e.edgeProps||[]).map(s=>({vec:mm(s.vec),dir:mm(s.dir),len:s.len})),n}}class Fh{constructor(e,t){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(t)||(this.zScale=Math.pow(2,t.z-e.z),this.xOffset=(e.x*this.zScale-t.x)*qe,this.yOffset=(e.y*this.zScale-t.y)*qe)}pointTransform(e){return Zs(e[0]*this.zScale+this.xOffset,e[1]*this.zScale+this.yOffset)}pointTransformInPlace(e){e[0]=e[0]*this.zScale+this.xOffset,e[1]=e[1]*this.zScale+this.yOffset}constantElevation(e,t){if(e.constantHeight!=null)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,n){const s=this.constantElevation(t,n);return s??(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),n))}computeBiasedHeight(e,t){return t<=0?e:e+t*cs(0,t,e>=0?e:Math.abs(.5*e))}}function dT(i){if(i===0)return[0,0,0];const e=sh(i);return[e(),e(),e()]}function Kx(i,e){let t=0,n=i.length-1;for(;t<=n;){const s=t+n>>1;i[s].feature.id<e?t=s+1:n=s-1}return t<i.length&&i[t].feature.id===e?t:-1}function uf(i,e,t,n){if(!i.properties)return;const s=+i.properties[Il];if(Number.isNaN(s))return;if(e){const c=e.find(h=>h.id===s);if(c&&n)return{tileId:n,feature:c}}if(!t||t.length===0)return;const l=Kx(t,s);if(!(l<0)){if(n){for(let c=l;c<t.length&&t[c].feature.id===s;c++)if(t[c].tileId.key===n.key)return t[c]}return t[l]}}function fT(i,e){return i>e?1:i<e?-1:0}et(Ll,"ElevationFeature");class Ag{constructor(e=fT,t=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!t}rotateLeft(e){var t=e.right;t&&(e.right=t.left,t.left&&(t.left.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.left=e),e.parent=t}rotateRight(e){var t=e.left;t&&(e.left=t.right,t.right&&(t.right.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.right=e),e.parent=t}_splay(e){for(;e.parent;){var t=e.parent;t.parent?t.left===e&&t.parent.left===t?(this.rotateRight(t.parent),this.rotateRight(t)):t.right===e&&t.parent.right===t?(this.rotateLeft(t.parent),this.rotateLeft(t)):t.left===e&&t.parent.right===t?(this.rotateRight(t),this.rotateLeft(t)):(this.rotateLeft(t),this.rotateRight(t)):t.left===e?this.rotateRight(t):this.rotateLeft(t)}}splay(e){for(var t,n,s,l,c;e.parent;)(n=(t=e.parent).parent)&&n.parent?((s=n.parent).left===n?s.left=e:s.right=e,e.parent=s):(e.parent=null,this._root=e),l=e.left,c=e.right,e===t.left?(n&&(n.left===t?(t.right?(n.left=t.right,n.left.parent=n):n.left=null,t.right=n,n.parent=t):(l?(n.right=l,l.parent=n):n.right=null,e.left=n,n.parent=e)),c?(t.left=c,c.parent=t):t.left=null,e.right=t,t.parent=e):(n&&(n.right===t?(t.left?(n.right=t.left,n.right.parent=n):n.right=null,t.left=n,n.parent=t):(c?(n.left=c,c.parent=n):n.left=null,e.right=n,n.parent=e)),l?(t.right=l,l.parent=t):t.right=null,e.left=t,t.parent=e)}replace(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.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,t){var n=this._root,s=null,l=this._compare;if(this._noDuplicates)for(;n;){if(s=n,l(n.key,e)===0)return;n=l(n.key,e)<0?n.right:n.left}else for(;n;)s=n,n=l(n.key,e)<0?n.right:n.left;return n={key:e,data:t,left:null,right:null,parent:s},s?l(s.key,n.key)<0?s.right=n:s.left=n:this._root=n,this.splay(n),this._size++,n}find(e){for(var t=this._root,n=this._compare;t;){var s=n(t.key,e);if(s<0)t=t.right;else{if(!(s>0))return t;t=t.left}}return null}contains(e){for(var t=this._root,n=this._compare;t;){var s=n(e,t.key);if(s===0)return!0;t=s<0?t.left:t.right}return!1}remove(e){var t=this.find(e);if(!t)return!1;if(this.splay(t),t.left)if(t.right){var n=this.minNode(t.right);n.parent!==t&&(this.replace(n,n.right),n.right=t.right,n.right.parent=n),this.replace(t,n),n.left=t.left,n.left.parent=n}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return!1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var n=t.left,s=t.right,l=null;n&&(n.parent=null,l=this.maxNode(n),this.splay(l),this._root=l),s&&(n?l.right=s:this._root=s,s.parent=l),this._size--}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key)}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,n=[],s=!1,l=0;!s;)t?(n.push(t),t=t.left):n.length>0?(e(t=n.pop(),l++),t=t.right):s=!0;return this}range(e,t,n,s){const l=[],c=this._compare;let h,p=this._root;for(;l.length!==0||p;)if(p)l.push(p),p=p.left;else{if(p=l.pop(),h=c(p.key,t),h>0)break;if(c(p.key,e)>=0&&n.call(s,p))return this;p=p.right}return this}keys(){for(var e=this._root,t=[],n=[],s=!1;!s;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),n.push(e.key),e=e.right):s=!0;return n}values(){for(var e=this._root,t=[],n=[],s=!1;!s;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),n.push(e.data),e=e.right):s=!0;return n}at(e){for(var t=this._root,n=[],s=!1,l=0;!s;)if(t)n.push(t),t=t.left;else if(n.length>0){if(t=n.pop(),l===e)return t;l++,t=t.right}else s=!0;return null}load(e=[],t=[],n=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");const s=e.length;return n&&Mg(e,t,0,s-1,this._compare),this._root=Cg(null,e,t,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,t,n,s,l){return new Ag(n,l).load(e,t,s)}}function Cg(i,e,t,n,s){const l=s-n;if(l>0){const c=n+Math.floor(l/2),h={key:e[c],data:t[c],parent:i};return h.left=Cg(h,e,t,n,c),h.right=Cg(h,e,t,c+1,s),h}return null}function Mg(i,e,t,n,s){if(t>=n)return;const l=i[t+n>>1];let c=t-1,h=n+1;for(;;){do c++;while(s(i[c],l)<0);do h--;while(s(i[h],l)>0);if(c>=h)break;let p=i[c];i[c]=i[h],i[h]=p,p=e[c],e[c]=e[h],e[h]=p}Mg(i,e,t,h,s),Mg(i,e,h+1,n,s)}const Jx=11102230246251565e-32,yo=134217729,pT=(3+8*Jx)*Jx;function Rg(i,e,t,n,s){let l,c,h,p,_=e[0],y=n[0],v=0,b=0;y>_==y>-_?(l=_,_=e[++v]):(l=y,y=n[++b]);let T=0;if(v<i&&b<t)for(y>_==y>-_?(c=_+l,h=l-(c-_),_=e[++v]):(c=y+l,h=l-(c-y),y=n[++b]),l=c,h!==0&&(s[T++]=h);v<i&&b<t;)y>_==y>-_?(c=l+_,p=c-l,h=l-(c-p)+(_-p),_=e[++v]):(c=l+y,p=c-l,h=l-(c-p)+(y-p),y=n[++b]),l=c,h!==0&&(s[T++]=h);for(;v<i;)c=l+_,p=c-l,h=l-(c-p)+(_-p),_=e[++v],l=c,h!==0&&(s[T++]=h);for(;b<t;)c=l+y,p=c-l,h=l-(c-p)+(y-p),y=n[++b],l=c,h!==0&&(s[T++]=h);return l===0&&T!==0||(s[T++]=l),T}function hf(i){return new Float64Array(i)}const Oh=hf(4),Qx=hf(8),ev=hf(12),tv=hf(16),Vo=hf(4);function df(i,e,t){e===null?(i.inOut=!1,i.otherInOut=!0):(i.isSubject===e.isSubject?(i.inOut=!e.inOut,i.otherInOut=e.otherInOut):(i.inOut=!e.otherInOut,i.otherInOut=e.isVertical()?!e.inOut:e.inOut),e&&(i.prevInResult=!iv(e,t)||e.isVertical()?e.prevInResult:e)),i.resultTransition=iv(i,t)?function(n,s){let l,c=!n.inOut,h=!n.otherInOut;switch(s){case 0:l=c&&h;break;case 1:l=c||h;break;case 3:l=c!==h;break;case 2:l=n.isSubject?c&&!h:h&&!c}return l?1:-1}(i,t):0}function iv(i,e){switch(i.type){case 0:switch(e){case 0:return!i.otherInOut;case 1:return i.otherInOut;case 2:return i.isSubject&&i.otherInOut||!i.isSubject&&!i.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 Bh{constructor(e,t,n,s,l){this.left=t,this.point=e,this.otherEvent=n,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){const t=this.point,n=this.otherEvent.point;return this.left?(t[0]-e[0])*(n[1]-e[1])-(n[0]-e[0])*(t[1]-e[1])>0:(n[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(n[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(){const e=new Bh(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 Fa(i,e){return i[0]===e[0]&&i[1]===e[1]}function Pg(i,e,t){const n=function(s,l,c,h,p,_){const y=(l-_)*(c-p),v=(s-p)*(h-_),b=y-v;if(y===0||v===0||y>0!=v>0)return b;const T=Math.abs(y+v);return Math.abs(b)>=33306690738754716e-32*T?b:-function(S,A,C,D,z,O,F){let N,j,te,H,W,K,ee,ae,he,be,xe,Te,Fe,se,fe,ge,Ae,Me;const ze=S-z,Ce=C-z,Be=A-O,ke=D-O;se=ze*ke,K=yo*ze,ee=K-(K-ze),ae=ze-ee,K=yo*ke,he=K-(K-ke),be=ke-he,fe=ae*be-(se-ee*he-ae*he-ee*be),ge=Be*Ce,K=yo*Be,ee=K-(K-Be),ae=Be-ee,K=yo*Ce,he=K-(K-Ce),be=Ce-he,Ae=ae*be-(ge-ee*he-ae*he-ee*be),xe=fe-Ae,W=fe-xe,Oh[0]=fe-(xe+W)+(W-Ae),Te=se+xe,W=Te-se,Fe=se-(Te-W)+(xe-W),xe=Fe-ge,W=Fe-xe,Oh[1]=Fe-(xe+W)+(W-ge),Me=Te+xe,W=Me-Te,Oh[2]=Te-(Me-W)+(xe-W),Oh[3]=Me;let Ke=function(yt,ht){let wt=ht[0];for(let bt=1;bt<4;bt++)wt+=ht[bt];return wt}(0,Oh),Ve=22204460492503146e-32*F;if(Ke>=Ve||-Ke>=Ve||(W=S-ze,N=S-(ze+W)+(W-z),W=C-Ce,te=C-(Ce+W)+(W-z),W=A-Be,j=A-(Be+W)+(W-O),W=D-ke,H=D-(ke+W)+(W-O),N===0&&j===0&&te===0&&H===0)||(Ve=11093356479670487e-47*F+pT*Math.abs(Ke),Ke+=ze*H+ke*N-(Be*te+Ce*j),Ke>=Ve||-Ke>=Ve))return Ke;se=N*ke,K=yo*N,ee=K-(K-N),ae=N-ee,K=yo*ke,he=K-(K-ke),be=ke-he,fe=ae*be-(se-ee*he-ae*he-ee*be),ge=j*Ce,K=yo*j,ee=K-(K-j),ae=j-ee,K=yo*Ce,he=K-(K-Ce),be=Ce-he,Ae=ae*be-(ge-ee*he-ae*he-ee*be),xe=fe-Ae,W=fe-xe,Vo[0]=fe-(xe+W)+(W-Ae),Te=se+xe,W=Te-se,Fe=se-(Te-W)+(xe-W),xe=Fe-ge,W=Fe-xe,Vo[1]=Fe-(xe+W)+(W-ge),Me=Te+xe,W=Me-Te,Vo[2]=Te-(Me-W)+(xe-W),Vo[3]=Me;const $e=Rg(4,Oh,4,Vo,Qx);se=ze*H,K=yo*ze,ee=K-(K-ze),ae=ze-ee,K=yo*H,he=K-(K-H),be=H-he,fe=ae*be-(se-ee*he-ae*he-ee*be),ge=Be*te,K=yo*Be,ee=K-(K-Be),ae=Be-ee,K=yo*te,he=K-(K-te),be=te-he,Ae=ae*be-(ge-ee*he-ae*he-ee*be),xe=fe-Ae,W=fe-xe,Vo[0]=fe-(xe+W)+(W-Ae),Te=se+xe,W=Te-se,Fe=se-(Te-W)+(xe-W),xe=Fe-ge,W=Fe-xe,Vo[1]=Fe-(xe+W)+(W-ge),Me=Te+xe,W=Me-Te,Vo[2]=Te-(Me-W)+(xe-W),Vo[3]=Me;const dt=Rg($e,Qx,4,Vo,ev);se=N*H,K=yo*N,ee=K-(K-N),ae=N-ee,K=yo*H,he=K-(K-H),be=H-he,fe=ae*be-(se-ee*he-ae*he-ee*be),ge=j*te,K=yo*j,ee=K-(K-j),ae=j-ee,K=yo*te,he=K-(K-te),be=te-he,Ae=ae*be-(ge-ee*he-ae*he-ee*be),xe=fe-Ae,W=fe-xe,Vo[0]=fe-(xe+W)+(W-Ae),Te=se+xe,W=Te-se,Fe=se-(Te-W)+(xe-W),xe=Fe-ge,W=Fe-xe,Vo[1]=Fe-(xe+W)+(W-ge),Me=Te+xe,W=Me-Te,Vo[2]=Te-(Me-W)+(xe-W),Vo[3]=Me;const pt=Rg(dt,ev,4,Vo,tv);return tv[pt-1]}(s,l,c,h,p,_,T)}(i[0],i[1],e[0],e[1],t[0],t[1]);return n>0?-1:n<0?1:0}function bc(i,e){const t=i.point,n=e.point;return t[0]>n[0]?1:t[0]<n[0]?-1:t[1]!==n[1]?t[1]>n[1]?1:-1:function(s,l,c){return s.left!==l.left?s.left?1:-1:Pg(c,s.otherEvent.point,l.otherEvent.point)!==0?s.isBelow(l.otherEvent.point)?-1:1:!s.isSubject&&l.isSubject?1:-1}(i,e,t)}function wc(i,e,t){const n=new Bh(e,!1,i,i.isSubject),s=new Bh(e,!0,i.otherEvent,i.isSubject);return Fa(i.point,i.otherEvent.point)&&console.warn("what is that, a collapsed segment?",i),n.contourId=s.contourId=i.contourId,bc(s,i.otherEvent)>0&&(i.otherEvent.left=!0,s.left=!1),i.otherEvent.otherEvent=s,i.otherEvent=n,t.push(s),t.push(n),t}function _m(i,e){return i[0]*e[1]-i[1]*e[0]}function Dg(i,e){return i[0]*e[0]+i[1]*e[1]}function Lg(i,e,t){const n=function(p,_,y,v){const b=[_[0]-p[0],_[1]-p[1]],T=[v[0]-y[0],v[1]-y[1]];function S(te,H,W){return[te[0]+H*W[0],te[1]+H*W[1]]}const A=[y[0]-p[0],y[1]-p[1]];let C=_m(b,T),D=C*C;const z=Dg(b,b);if(D>0){const te=_m(A,T)/C;if(te<0||te>1)return null;const H=_m(A,b)/C;return H<0||H>1?null:te===0||te===1?[S(p,te,b)]:H===0||H===1?[S(y,H,T)]:[S(p,te,b)]}if(C=_m(A,b),D=C*C,D>0)return null;const O=Dg(b,A)/z,F=O+Dg(b,T)/z,N=Math.min(O,F),j=Math.max(O,F);return N<=1&&j>=0?N===1?[S(p,N>0?N:0,b)]:j===0?[S(p,j<1?j:1,b)]:[S(p,N>0?N:0,b),S(p,j<1?j:1,b)]:null}(i.point,i.otherEvent.point,e.point,e.otherEvent.point),s=n?n.length:0;if(s===0||s===1&&(Fa(i.point,e.point)||Fa(i.otherEvent.point,e.otherEvent.point))||s===2&&i.isSubject===e.isSubject)return 0;if(s===1)return!Fa(i.point,n[0])&&!Fa(i.otherEvent.point,n[0])&&wc(i,n[0],t),!Fa(e.point,n[0])&&!Fa(e.otherEvent.point,n[0])&&wc(e,n[0],t),1;const l=[];let c=!1,h=!1;return Fa(i.point,e.point)?c=!0:bc(i,e)===1?l.push(e,i):l.push(i,e),Fa(i.otherEvent.point,e.otherEvent.point)?h=!0:bc(i.otherEvent,e.otherEvent)===1?l.push(e.otherEvent,i.otherEvent):l.push(i.otherEvent,e.otherEvent),c&&h||c?(e.type=1,i.type=e.inOut===i.inOut?2:3,c&&!h&&wc(l[1].otherEvent,l[0].point,t),2):h?(wc(l[0],l[1].point,t),3):l[0]!==l[3].otherEvent?(wc(l[0],l[1].point,t),wc(l[1],l[2].point,t),3):(wc(l[0],l[1].point,t),wc(l[3].otherEvent,l[2].point,t),3)}function mT(i,e){if(i===e)return 0;if(Pg(i.point,i.otherEvent.point,e.point)!==0||Pg(i.point,i.otherEvent.point,e.otherEvent.point)!==0)return Fa(i.point,e.point)?i.isBelow(e.otherEvent.point)?-1:1:i.point[0]===e.point[0]?i.point[1]<e.point[1]?-1:1:bc(i,e)===1?e.isAbove(i.point)?-1:1:i.isBelow(e.point)?-1:1;if(i.isSubject!==e.isSubject)return i.isSubject?-1:1;{let t=i.point,n=e.point;if(t[0]===n[0]&&t[1]===n[1])return t=i.otherEvent.point,n=e.otherEvent.point,t[0]===n[0]&&t[1]===n[1]?0:(i.contourId??0)>(e.contourId??0)?1:-1}return bc(i,e)===1?1:-1}class _T{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function gT(i,e,t,n){let s,l=i+1,c=e[i].point;const h=e.length;for(l<h&&(s=e[l].point);l<h&&s[0]===c[0]&&s[1]===c[1];){if(!t[l])return l;l++,l<h&&(s=e[l].point)}for(l=i-1;t[l]&&l>n;)l--;return l}function yT(i,e,t){const n=new _T;if(i.prevInResult!=null){const s=i.prevInResult,l=s.outputContourId;if(s.resultTransition>0){const c=e[l];if(c.holeOf!=null){const h=c.holeOf;e[h].holeIds.push(t),n.holeOf=h,n.depth=e[l].depth}else e[l].holeIds.push(t),n.holeOf=l,n.depth=e[l].depth+1}else n.holeOf=null,n.depth=e[l].depth}else n.holeOf=null,n.depth=0;return n}const rv=Math.max,nv=Math.min;let gm=0;function ov(i,e,t,n,s,l){let c,h,p,_,y,v;for(c=0,h=i.length-1;c<h;c++){if(p=i[c],_=i[c+1],y=new Bh(p,!1,void 0,e),v=new Bh(_,!1,y,e),y.otherEvent=v,p[0]===_[0]&&p[1]===_[1])continue;y.contourId=v.contourId=t,l||(y.isExteriorRing=!1,v.isExteriorRing=!1),bc(y,v)>0?v.left=!0:y.left=!0;const b=p[0],T=p[1];s[0]=nv(s[0],b),s[1]=nv(s[1],T),s[2]=rv(s[2],b),s[3]=rv(s[3],T),n.push(y),n.push(v)}}const ym=[];function sv(i,e,t){let n=i,s=e;typeof i[0][0][0]=="number"&&(n=[i]),typeof e[0][0][0]=="number"&&(s=[e]);let l=function(b,T,S){let A=null;return b.length*T.length===0&&(S===0?A=ym:S===2?A=b:(S===1||S===3)&&(A=b.length===0?T:b)),A}(n,s,t);if(l)return l===ym?null:l;const c=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],p=function(b,T,S,A,C){const D=new Gc(void 0,bc);let z,O,F,N,j,te;for(F=0,N=b.length;F<N;F++)for(z=b[F],j=0,te=z.length;j<te;j++)O=j===0,O&&gm++,ov(z[j],!0,gm,D,S,O);for(F=0,N=T.length;F<N;F++)for(z=T[F],j=0,te=z.length;j<te;j++)O=j===0,C===2&&(O=!1),O&&gm++,ov(z[j],!1,gm,D,A,O);return D}(n,s,c,h,t);if(l=function(b,T,S,A,C){let D=null;return(S[0]>A[2]||A[0]>S[2]||S[1]>A[3]||A[1]>S[3])&&(C===0?D=ym:C===2?D=b:(C===1||C===3)&&(D=b.concat(T))),D}(n,s,c,h,t),l)return l===ym?null:l;const _=function(b,T,S,A,C,D){const z=new Ag(mT),O=[],F=Math.min(A[2],C[2]);let N,j,te;for(;b.length!==0;){let H=b.pop();if(O.push(H),D===0&&H.point[0]>F||D===2&&H.point[0]>A[2])break;if(H.left){j=N=z.insert(H),te=z.minNode(),N=N!==te?z.prev(N):null,j=z.next(j);const W=N?N.key:null;let K;if(df(H,W,D),j&&Lg(H,j.key,b)===2&&(df(H,W,D),df(j.key,H,D)),N&&Lg(N.key,H,b)===2){let ee=N;ee=ee!==te?z.prev(ee):null,K=ee?ee.key:null,df(W,K,D),df(H,W,D)}}else H=H.otherEvent,j=N=z.find(H),N&&j&&(N=N!==te?z.prev(N):null,j=z.next(j),z.remove(H),j&&N&&Lg(N.key,j.key,b))}return O}(p,0,0,c,h,t),y=function(b){let T,S;const A=function(z){let O,F,N,j,te;const H=[];for(F=0,N=z.length;F<N;F++)O=z[F],(O.left&&O.inResult||!O.left&&O.otherEvent.inResult)&&H.push(O);let W=!1;for(;!W;)for(W=!0,F=0,N=H.length;F<N;F++)F+1<N&&bc(H[F],H[F+1])===1&&(j=H[F],H[F]=H[F+1],H[F+1]=j,W=!1);for(F=0,N=H.length;F<N;F++)O=H[F],O.otherPos=F;for(F=0,N=H.length;F<N;F++)O=H[F],O.left||(te=O.otherPos,O.otherPos=O.otherEvent.otherPos,O.otherEvent.otherPos=te);return H}(b),C={},D=[];for(T=0,S=A.length;T<S;T++){if(C[T])continue;const z=D.length,O=yT(A[T],D,z),F=te=>{C[te]=!0,te<A.length&&A[te]&&(A[te].outputContourId=z)};let N=T,j=T;for(O.points.push(A[T].point);F(N),N=A[N].otherPos,F(N),O.points.push(A[N].point),N=gT(N,A,C,j),!(N==j||N>=A.length)&&A[N];);D.push(O)}return D}(_),v=[];for(let b=0;b<y.length;b++){let T=y[b];if(T.isExterior()){let S=[T.points];for(let A=0;A<T.holeIds.length;A++)S.push(y[T.holeIds[A]].points);v.push(S)}}return v}function xT(i,e){const t=sv(zg(i),zg([e]),0);return t==null?[]:lv(t)}function vT(i,e,t=0){let s=zg(i,65536);const l=[];for(;e.valid();e.next()){const[c,h]=e.get();let p=c.x*65536,_=c.y*65536,y=h.x*65536,v=h.y*65536;const b=y-p,T=v-_,S=Math.hypot(b,T);if(S===0)continue;p-=b*t,_-=T*t,y+=b*t,v+=T*t;const A=Math.trunc(T/S*3),C=-Math.trunc(b/S*3);l.push([[[p,_],[y,v],[y+A,v+C],[p+A,_+C],[p,_]]])}return l.length>0&&(s=sv(s,l,2)),lv(s,1/65536,.001)}function zg(i,e=1){return[i.map(t=>t.map(n=>[n.x*e,n.y*e]))]}function av(i,e){const t=Math.floor(i)+.5;return Math.abs(i-t)<=e?Math.round(t):Math.round(i)}class bT{constructor(e){this.xs=[],this.ys=[],this.ixs=[],this.iys=[],this.buckets=new Map,this.tolerance=e}canonicalize(e,t){const n=this.tolerance,s=Math.floor(e/n),l=Math.floor(t/n);for(let p=-1;p<=1;p++){const _=this.buckets.get(s+p);if(_)for(let y=-1;y<=1;y++){const v=_.get(l+y);if(v){for(const b of v)if(Math.abs(this.xs[b]-e)<=n&&Math.abs(this.ys[b]-t)<=n){const T=this.ixs[b],S=this.iys[b];return this.xs[b]===e&&this.ys[b]===t||this.store(e,t,T,S,s,l),[T,S]}}}}const c=av(e,n),h=av(t,n);return this.store(e,t,c,h,s,l),[c,h]}store(e,t,n,s,l,c){const h=this.xs.length;this.xs.push(e),this.ys.push(t),this.ixs.push(n),this.iys.push(s);let p=this.buckets.get(l);p||(p=new Map,this.buckets.set(l,p));let _=p.get(c);_||(_=[],p.set(c,_)),_.push(h)}}function lv(i,e=1,t){const n=t!=null?new bT(t):null;return i.map(s=>s.map((l,c)=>{const h=l.map(p=>{const _=p[0]*e,y=p[1]*e;if(n){const[v,b]=n.canonicalize(_,y);return new De(v,b)}return new De(Math.round(_),Math.round(y))});return c>0&&h.reverse(),h}))}class Fg{constructor(){this.frcCoverage=new Set,this.featureTriSegments=[],this.frcPerLevel=new Map,this.frcNonRoadSegments=new li}empty(){return this.frcCoverage.size===0}}function cv(i,e,t){if(i.frcCoverage.size===0||i.featureTriSegments.length===0)return;const n=t.get(),s=e.uint16,l=[];i.featureTriSegments.sort((v,b)=>v.segIdx!==b.segIdx?v.segIdx-b.segIdx:v.frc===null&&b.frc===null?0:v.frc===null?-1:b.frc===null?1:b.frc-v.frc);const c=new Map;let h=0,p=i.featureTriSegments[0].frc,_={vertexOffset:n[h].vertexOffset,primitiveOffset:0,vertexLength:n[h].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0};const y=()=>{_.primitiveLength>0&&(c.has(p)||c.set(p,[]),c.get(p).push({..._}))};for(const v of i.featureTriSegments){v.segIdx!==h&&(y(),h=v.segIdx,p=v.frc,_={vertexOffset:n[h].vertexOffset,primitiveOffset:l.length/3,vertexLength:n[h].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0}),v.frc!==p&&(y(),p=v.frc,_={..._,primitiveOffset:l.length/3,primitiveLength:0});for(let b=v.start;b<v.end;b++)l.push(s[b]);_.primitiveLength+=(v.end-v.start)/3}y();for(let v=0;v<l.length;v++)s[v]=l[v];for(const[v,b]of c)v!==null?i.frcPerLevel.set(v,new li(b)):i.frcNonRoadSegments=new li(b);i.featureTriSegments=[]}et(Fg,"FrcSegmentData");const wT={motorway:0,motorway_link:0,trunk:1,trunk_link:1,primary:2,primary_link:2,secondary:3,secondary_link:3,tertiary:4,tertiary_link:4,unclassified:5,unclassified_link:5,street:6,street_limited:6,residential:6,service:7,living_street:7,pedestrian:8,track:8,path:8,footway:8,cycleway:8,sidewalk:8,crossing:8};function xm(i){for(const e of["class","incident_class"]){const t=i[e];if(typeof t!="string")continue;const n=wT[t];if(n!==void 0)return n}return null}function Og(i,e,t){for(const n of i)if(n.startsWith("(")){const s=n.indexOf(")");if(s===-1)continue;if(n.slice(1,s)===e&&n.slice(s+1)===t)return!0}else if(n===t)return!0;return!1}class uv{constructor(e,t,n){this.elevationMode=t,t&&(this.elevationBufferData=new Wx(e.layers,e.zoom,e.lut)),n&&(this.frcData=new Fg)}isEmpty(){const e=!this.elevationBufferData||this.elevationBufferData.isEmpty(),t=!this.frcData||this.frcData.empty();return e&&t}needsUpload(){return!!this.elevationBufferData&&this.elevationBufferData.needsUpload()}trackFeatureFrc(e){if(!this.frcData)return null;const t=xm(e||{});return t!==null&&this.frcData.frcCoverage.add(t),t}recordFeatureRange(e,t,n,s){if(!this.frcData||n<=t)return;const l=e.bufferData.triangleSegments.get();this.frcData.featureTriSegments.push({start:3*t,end:3*n,segIdx:l.length>0?l.length-1:0,frc:s})}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&cv(this.frcData,e.bufferData.indexArray,e.bufferData.triangleSegments)}handleFeature(e,t,n,s,l,c){const h=new Array;if(!this.elevationMode)return!1;const p=uf(e,l,void 0,s);if(!p)return!1;{const y=this.clipPolygonsToTile(t,1);y.length>0&&h.push({polygons:y,elevationFeature:p.feature,elevationTileID:p.tileId})}const _={guardRailEnabled:c.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},s),featureIndex:n};for(const y of h)if(y.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new No(y.elevationTileID,c.layers,c.zoom,c.lut));const b=y.elevationFeature.isTunnel();let T=0;Object.hasOwn(e.properties,Ky)&&(T=+e.properties[Ky]),this.elevatedStructures.addPortalCandidates(y.elevationFeature.id,y.polygons,b,y.elevationFeature,T)}y.elevationFeature.constantHeight==null&&(y.polygons=this.prepareElevatedPolygons(y.polygons,y.elevationFeature,y.elevationTileID));const v=new Fh(s,y.elevationTileID);this.addElevatedGeometry(c,y.polygons,v,y.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,n,_)}return!0}populatePaintArrays(e,t,n,s,l,c,h){this.elevationBufferData&&this.elevationBufferData.populatePaintArrays(e,t,n,s,l,c,h)}update(e,t,n,s,l,c,h,p){this.elevationBufferData&&this.elevationBufferData.update(e,t,n,s,l,c,h,p),this.elevatedStructures&&this.elevatedStructures.update(e,t,n,s,l,c,h,p)}updateExpressions(e){this.elevationBufferData&&this.elevationBufferData.programConfigurations.updateExpressions(e),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(e),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(e))}upload(e){this.elevationBufferData&&this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.elevationBufferData&&this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,t,n,s,l,c){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,n,s,l,c))}addElevatedGeometry(e,t,n,s,l,c,h){const p={elevation:s,elevationSampler:n,bias:l,index:c,featureInfo:h},[_,y]=e.addGeometry(t,this.elevationBufferData,p,this.elevatedStructures);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:_,max:y}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,_),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,y))}prepareElevatedPolygons(e,t,n){const s=1/B(n),l=[];for(const c of e){const h=vT(c,new Yx(t,s),.1);l.push(...h)}return l}clipPolygonsToTile(e,t){const n=-t,s=-t,l=qe+t,c=qe+t;let h=0;const p=[],_=[];for(;h<e.length;h++){const b=e[h],T=Ka(b);(T.min.x>=n&&T.max.x<=l&&T.min.y>=s&&T.max.y<=c?p:_).push(b)}if(p.length===e.length)return e;const y=[new De(n,s),new De(l,s),new De(l,c),new De(n,c),new De(n,s)],v=p;for(const b of _)v.push(...xT(b,y));return v}}function TT(i,e){return i.nextPoint.sub(e.at(-2)).unit()}function ET(i,e){return e[1].sub(i.prevPoint).unit()}et(uv,"FillHDExtension"),et(No,"ElevatedStructures");class hv{constructor(e,t){this.elevationEnabled=e,this.hasDeferredElevationFeatures=!1,t&&(this.frcData=new Fg)}isEmpty(){const e=!this.elevationEnabled||this.heightRange===void 0,t=!this.frcData||this.frcData.empty();return e&&t}trackFeatureFrc(e){if(!this.frcData)return null;const t=xm(e||{});return t!==null&&this.frcData.frcCoverage.add(t),t}recordFeatureRange(e,t,n,s){if(!this.frcData||n<=t)return;const l=e.segments.get();this.frcData.featureTriSegments.push({start:3*t,end:3*n,segIdx:l.length>0?l.length-1:0,frc:s})}buildFrcSegments(e){this.frcData&&!this.frcData.empty()&&cv(this.frcData,e.indexArray,e.segments)}handleFeature(e,t,n,s,l,c,h,p,_,y,v){if(!this.elevationEnabled)return!1;if(!v.terrainEnabled){const C=uf(e,s,l?l.registry:void 0,n),D=e.properties!=null&&Object.hasOwn(e.properties,Il)&&!Number.isNaN(+e.properties[Il]);if(!C&&D&&c&&(!l||!l.allProvidersReady))return this.hasDeferredElevationFeatures=!0,!0;if(C){let z=C.feature,O=C.tileId;if(!C.tileId.equals(n)){const j=this.mergedFeatureCache?this.mergedFeatureCache.get(z.id):void 0;if(j)z=j,O=n;else{const te=function(H,W,K){if(!H.properties||!W||W.length===0)return[];const ee=+H.properties[Il];if(Number.isNaN(ee))return[];const ae=Kx(W,ee);if(ae<0)return[];const he=[];for(let be=ae;be<W.length&&W[be].feature.id===ee;be++){const xe=W[be];(xe.tileId.isChildOf(K)||K.isChildOf(xe.tileId)||xe.feature.constantHeight!=null)&&he.push(xe)}return he}(e,l?l.registry:void 0,n);te.length>1&&(z=function(H,W){const K=W.slice().sort((se,fe)=>fe.tileId.z-se.tileId.z),ee=new De(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),ae=new De(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),he=[];for(const se of K){const fe=new Fh(se.tileId,H);for(const Ae of se.feature.vertices)he.push({position:fe.pointTransform(Ae.position),height:Ae.height,extent:Ae.extent,index:Ae.index});const ge=se.feature.safeArea;Iu[0]=ge.min.x,Iu[1]=ge.min.y,Au[0]=ge.max.x,Au[1]=ge.max.y,fe.pointTransformInPlace(Iu),fe.pointTransformInPlace(Au),ee.x=Math.min(ee.x,Iu[0],Au[0]),ee.y=Math.min(ee.y,Iu[1],Au[1]),ae.x=Math.max(ae.x,Iu[0],Au[0]),ae.y=Math.max(ae.y,Iu[1],Au[1])}const be={min:ee,max:ae};if(K[0].feature.constantHeight!=null)return new Ll(K[0].feature.id,be,K[0].feature.constantHeight);he.sort((se,fe)=>se.index-fe.index);const xe=[];for(const se of he)xe.length!==0&&xe.at(-1).index===se.index||xe.push(se);const Te=[];for(let se=1;se<xe.length;se++)xe[se].index-xe[se-1].index<=1&&Te.push({a:se-1,b:se});const Fe=1/B(H);return new Ll(K[0].feature.id,be,void 0,xe,Te,Fe)}(n,te),O=n,this.mergedFeatureCache||(this.mergedFeatureCache=new Map),this.mergedFeatureCache.set(z.id,z))}}const F=Q_(t,-1,-1,8193,8193),N=this.prepareElevatedLines(F,z,O,n);for(const j of N){const te=v.layoutVertexArray.length;v.addLine(j,e,n,h,p,_,y);const H=new Fh(n,O),W=v.showElevationIdDebug?dT(z.id):null;for(let K=te;K<v.layoutVertexArray.length;K++){const ee=new De(v.layoutVertexArray.int16[6*K]>>1,v.layoutVertexArray.int16[6*K+1]>>1),ae=H.pointElevation(ee,z,.05);this.updateHeightRange(ae),K<v.zOffsetVertexArray.length?v.zOffsetVertexArray.float32[4*K]=ae:v.zOffsetVertexArray.emplaceBack(ae,0,0,0),W?K<v.elevationIdColVertexArray.length?(v.elevationIdColVertexArray.float32[3*K]=W[0],v.elevationIdColVertexArray.float32[3*K+1]=W[1],v.elevationIdColVertexArray.float32[3*K+2]=W[2]):v.elevationIdColVertexArray.emplaceBack(W[0],W[1],W[2]):v.showElevationIdDebug&&(K<v.elevationIdColVertexArray.length?(v.elevationIdColVertexArray.float32[3*K]=0,v.elevationIdColVertexArray.float32[3*K+1]=0,v.elevationIdColVertexArray.float32[3*K+2]=0):v.elevationIdColVertexArray.emplaceBack(0,0,0))}}return!0}if(D&&c&&l&&l.allProvidersReady&&l.hasCoveringTile)return!0}const b=!(!e.properties||!Object.hasOwn(e.properties,"mapbox_line_metrics"))&&e.properties.mapbox_line_metrics,T=v.layoutVertexArray.length,S=[],A=Q_(t,-1,-1,8193,8193,S);for(let C=0;C<A.length;C++){const D=A[C],z=S[C],O={progress:{min:z.progress.min,max:z.progress.max},nextDir:TT(z,D),prevDir:ET(z,D)};v.addLine(D,e,n,h,p,_,y,O,b&&z.parentIndex>0?z.parentIndex:null)}return v.fillNonElevatedRoadSegment(T),!0}prepareElevatedLines(e,t,n,s){if(t.constantHeight!=null)return e;const l=[],c=1/B(s),h=n.equals(s)?null:new Fh(n,s);for(const p of e)ew(p,new Yx(t,c,h),0,l);return l}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}}endPopulate(){this.mergedFeatureCache=void 0}}et(hv,"LineHDExtension");class dv{constructor(){this.elevatedLayoutVertexArray=new Oe,this.hasElevation=!1}beginFeature(e,t,n){const s=uf(e,t,void 0,n);this.currentFeatureElevation=s?s.feature:void 0}writeVertexQuad(e,t){const n=this.currentFeatureElevation?this.currentFeatureElevation.pointElevation(new De(e,t)):0;this.hasElevation=this.hasElevation||n!==0;for(let s=0;s<4;s++)this.elevatedLayoutVertexArray.emplaceBack(n)}finalize(){this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}upload(e){this.elevatedLayoutVertexArray&&!this.elevatedLayoutVertexBuffer&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,ow.members))}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy()}}et(dv,"CircleHDExtension");const vm=(i,e,t,n)=>{for(let s=0;s<e;s++)i.emplaceBack(t[0],t[1],t[2],n[0],n[1],n[2])};class fv{constructor(){this.elevationFeatures=[],this.elevationFeatureTileIds=[],this.elevationFeatureIdToIndex=new Map,this.elevationStateComplete=!1,this.hasDeferredElevationFeatures=!1,this.elevationParams=null,this.crossSourceElevationEnabled=!1,this.terrainEnabled=!1}configureCrossSource(e,t,n,s){this.consumerCanonical=e,this.elevationParams=t,this.crossSourceElevationEnabled=n,this.terrainEnabled=s}addElevationFeatures(e,t){for(const n of e)this.elevationFeatureIdToIndex.set(n.id,this.elevationFeatures.length),this.elevationFeatures.push(n),this.elevationFeatureTileIds.push(t)}resolveRoadElevation(e,t){const n=this.elevationFeatureIdToIndex.get(t);if(n!==void 0)return n;if(this.terrainEnabled||!this.crossSourceElevationEnabled)return 65535;const s=uf(e,void 0,this.elevationParams?this.elevationParams.registry:void 0,this.consumerCanonical);if(s){const l=this.elevationFeatures.length;return this.elevationFeatureIdToIndex.set(t,l),this.elevationFeatures.push(s.feature),this.elevationFeatureTileIds.push(s.tileId),l}return this.elevationParams&&this.elevationParams.allProvidersReady?65535:(this.hasDeferredElevationFeatures=!0,"defer")}getElevationFeatureSampler(e,t){if(t.equals(e))return new Fh(e,t);this.elevationFeatureSamplerCache||(this.elevationFeatureSamplerCache=new Map);let n=this.elevationFeatureSamplerCache.get(t.key);return n||(n=new Fh(e,t),this.elevationFeatureSamplerCache.set(t.key,n)),n}isCrossTileRoadElevation(e,t){if(e===65535||e>=this.elevationFeatures.length)return!1;const n=this.elevationFeatureTileIds[e];return n!=null&&!n.equals(t)}getRoadFeatureHeightAtAnchor(e,t,n){if(e===65535||e>=this.elevationFeatures.length)return null;const s=this.elevationFeatures[e],l=this.elevationFeatureTileIds[e];return l.equals(n)?s.pointElevation(t):this.getElevationFeatureSampler(n,l).pointElevation(new De(t.x,t.y),s,0)}sampleRoadFeatureHeight(e,t,n){const s=this.getRoadFeatureHeightAtAnchor(e,t,n);return s===null?void 0:s}clearWorkerState(){this.consumerCanonical=void 0,this.elevationParams=null,this.crossSourceElevationEnabled=!1,this.terrainEnabled=!1,this.elevationFeatureIdToIndex.clear()}updateRoadElevation(e,t){if(this.elevationStateComplete)return;this.elevationStateComplete=!0,e.hasAnyZOffset=!1;let n=!1;const s=B(t),l=1/s;let c=!1,h=!1;for(let p=0;p<e.symbolInstances.length;p++){const _=e.symbolInstances.get(p),y=br(1,0,0),v=br(0,1,0),{numHorizontalGlyphVertices:b,numVerticalGlyphVertices:T,numIconVertices:S,numVerticalIconVertices:A}=_,C=b>0||T>0,D=S>0,z=_.elevationFeatureIndex,O=z<this.elevationFeatures.length?this.elevationFeatures[z]:void 0;if(O){const F=new De(_.tileAnchorX,_.tileAnchorY),N=this.sampleRoadFeatureHeight(z,F,t),j=N!==void 0?.075+N:.075;_.zOffset!==j&&(n=!0,_.zOffset=j),j!==0&&(e.hasAnyZOffset=!0);const te=O.computeSlopeNormal(F,l),H=Hs(it(),br(0,0,1),te);oa(y,y,H),oa(v,v,H),y[2]*=s,v[2]*=s,y[0]===1&&y[1]===0&&y[2]===0&&v[0]===0&&v[1]===1&&v[2]===0||(c=c||C,h=h||D)}if(C&&(vm(e.text.orientationVertexArray,b,y,v),vm(e.text.orientationVertexArray,T,y,v)),D){const{placedIconSymbolIndex:F,verticalPlacedIconSymbolIndex:N}=_;F>=0&&vm(e.icon.orientationVertexArray,S,y,v),N>=0&&vm(e.icon.orientationVertexArray,A,y,v)}}c||(e.text.orientationVertexArray=void 0),h||(e.icon.orientationVertexArray=void 0),n&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}getRoadFeatureHeightForPlacedSymbol(e,t,n,s,l){const c=e.symbolInstances.get(t.symbolInstanceIndices[n]);return this.getRoadFeatureHeightAtAnchor(c.elevationFeatureIndex,s,l)}getElevationFeatureForPlacedSymbol(e,t,n){const s=e.symbolInstances.get(t.symbolInstanceIndices[n]).elevationFeatureIndex;if(s<this.elevationFeatures.length)return this.elevationFeatures[s]}makeRoadSymbolElevationParams(e,t,n,s,l,c,h,p,_){const y=this.getElevationFeatureForPlacedSymbol(e,t,n),v=y!==void 0?y:null,b=e.symbolInstances.get(t.symbolInstanceIndices[n]);return this.isCrossTileRoadElevation(b.elevationFeatureIndex,s.canonical)?{getElevation:T=>{const S=this.getRoadFeatureHeightForPlacedSymbol(e,t,n,T,s.canonical);return function(A,C,D,z,O,F){const N=z.upVector(C,D.x,D.y);return si(N,N,A*z.upVectorScale(C,O,F).metersToTile),[N[0],N[1],N[2]]}(S!==null?S:0,s.canonical,T,h,p,_)},elevation:c,elevationFeature:null}:{getElevation:l,elevation:c,elevationFeature:v}}}et(fv,"SymbolHDExtension",{omit:["consumerCanonical","elevationParams","crossSourceElevationEnabled","terrainEnabled","hasDeferredElevationFeatures","elevationFeatureIdToIndex"]});let ia=null,bm=null,Bg=null,wm=null;const pv=5120,mv=5121,_v=5122,gv=5123,yv=5125,xv=5126,Tm={[pv]:Int8Array,[mv]:Uint8Array,[_v]:Int16Array,[gv]:Uint16Array,[yv]:Uint32Array,[xv]:Float32Array},ST={[pv]:"DT_INT8",[mv]:"DT_UINT8",[_v]:"DT_INT16",[gv]:"DT_UINT16",[yv]:"DT_UINT32",[xv]:"DT_FLOAT32"},ff={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function vv(i,e,t){const n=t.json.bufferViews.length,s=t.buffers.length;e.bufferView=n,t.json.bufferViews[n]={buffer:s,byteLength:i.byteLength},t.buffers[s]=i}const kg="KHR_draco_mesh_compression";function IT(i,e){const t=i.extensions&&i.extensions[kg];if(!t)return;const n=new ia.Decoder,s=Ev(e,t.bufferView),l=new ia.Mesh;if(!n.DecodeArrayToMesh(s,s.byteLength,l))throw new Error("Failed to decode Draco mesh");const c=e.json.accessors[i.indices],h=Tm[c.componentType],p=c.count*h.BYTES_PER_ELEMENT,_=ia._malloc(p);h===Uint16Array?n.GetTrianglesUInt16Array(l,p,_):n.GetTrianglesUInt32Array(l,p,_),vv(ia.memory.buffer.slice(_,_+p),c,e),ia._free(_);for(const y of Object.keys(t.attributes)){const v=n.GetAttributeByUniqueId(l,t.attributes[y]),b=e.json.accessors[i.attributes[y]],T=ST[b.componentType],S=b.count*ff[b.type]*Tm[b.componentType].BYTES_PER_ELEMENT,A=ia._malloc(S);n.GetAttributeDataArrayForAllPoints(l,v,ia[T],S,A),vv(ia.memory.buffer.slice(A,A+S),b,e),ia._free(A)}n.destroy(),l.destroy(),delete i.extensions[kg]}const Em="EXT_meshopt_compression";function AT(i,e){if(!i.extensions||!i.extensions[Em])return;const t=i.extensions[Em],n=new Uint8Array(e.buffers[t.buffer],t.byteOffset||0,t.byteLength||0),s=new Uint8Array(t.count*t.byteStride);Bg.decodeGltfBuffer(s,t.count,t.byteStride,n,t.mode,t.filter),i.buffer=e.buffers.length,i.byteOffset=0,e.buffers[i.buffer]=s.buffer,delete i.extensions[Em]}const bv=1179937895,wv=new TextDecoder("utf8");function Tv(i,e){return new URL(i,e).href}async function CT(i,e,t,n,s){const l=await fetch(Tv(i.uri,n),{signal:s}),c=await l.arrayBuffer();e.buffers[t]=c}function Ev(i,e){const t=i.json.bufferViews[e];return new Uint8Array(i.buffers[t.buffer],t.byteOffset||0,t.byteLength)}async function MT(i,e,t,n,s){if(i.uri){const l=Tv(i.uri,n),c=await fetch(l,{signal:s}),h=await c.blob(),p=await createImageBitmap(h);e.images[t]=p}else if(i.bufferView!==void 0){const l=Ev(e,i.bufferView),c=new Blob([l],{type:i.mimeType}),h=await createImageBitmap(c);e.images[t]=h}}async function Sv(i,e=0,t,n){const s={json:null,images:[],buffers:[]};if(new Uint32Array(i,e,1)[0]===bv){const T=new Uint32Array(i,e);let S=2;const A=(T[S++]>>2)-3,C=T[S++]>>2;if(S++,s.json=JSON.parse(wv.decode(T.subarray(S,S+C))),S+=C,S<A){const D=T[S++];S++;const z=e+(S<<2);s.buffers[0]=i.slice(z,z+D)}}else s.json=JSON.parse(wv.decode(new Uint8Array(i,e)));const{buffers:l,images:c,meshes:h,extensionsUsed:p,bufferViews:_}=s.json;if(l){const T=[];for(let S=0;S<l.length;S++){const A=l[S];A.uri?T.push(CT(A,s,S,t,n)):s.buffers[S]||(s.buffers[S]=null)}await Promise.all(T)}n&&n.throwIfAborted();const y=[],v=p&&p.includes(kg),b=p&&p.includes(Em);if(v&&y.push(function(){if(!ia)return bm!=null||(bm=function(T){let S,A=null;function C(){S=new Uint8Array(A.buffer)}function D(){throw new Error("Unexpected Draco error.")}return WebAssembly.instantiateStreaming(T,{a:{a:D,d:function(z,O,F){return S.copyWithin(z,O,O+F)},c:function(z){const O=S.length,F=Math.max(z>>>0,Math.ceil(1.2*O)),N=Math.ceil((F-O)/65536);try{return A.grow(N),C(),!0}catch{return!1}},b:D}}).then(z=>{const{Rb:O,Qb:F,P:N,T:j,X:te,Ja:H,La:W,Qa:K,Va:ee,Wa:ae,eb:he,jb:be,f:xe,e:Te,yb:Fe,zb:se,Ab:fe,Bb:ge,Db:Ae,Gb:Me}=z.instance.exports;A=Te;const ze=(()=>{let Ce=0,Be=0,ke=0,Ke=0;return Ve=>{ke&&(O(Ke),O(Ce),Be+=ke,ke=Ce=0),Ce||(Be+=128,Ce=F(Be));const $e=Ve.length+7&-8;let dt=Ce;$e>=Be&&(ke=$e,dt=Ke=F($e));for(let pt=0;pt<Ve.length;pt++)S[dt+pt]=Ve[pt];return dt}})();return C(),xe(),{memory:Te,_free:O,_malloc:F,Mesh:class{constructor(){this.ptr=N()}destroy(){j(this.ptr)}},Decoder:class{constructor(){this.ptr=H()}destroy(){be(this.ptr)}DecodeArrayToMesh(Ce,Be,ke){const Ke=ze(Ce),Ve=W(this.ptr,Ke,Be,ke.ptr);return!!te(Ve)}GetAttributeByUniqueId(Ce,Be){return{ptr:K(this.ptr,Ce.ptr,Be)}}GetTrianglesUInt16Array(Ce,Be,ke){ee(this.ptr,Ce.ptr,Be,ke)}GetTrianglesUInt32Array(Ce,Be,ke){ae(this.ptr,Ce.ptr,Be,ke)}GetAttributeDataArrayForAllPoints(Ce,Be,ke,Ke,Ve){he(this.ptr,Ce.ptr,Be.ptr,ke,Ke,Ve)}},DT_INT8:Fe(),DT_UINT8:se(),DT_INT16:fe(),DT_UINT16:ge(),DT_UINT32:Ae(),DT_FLOAT32:Me()}})}(fetch(ne())).then(T=>{ia=T,bm=null})),bm}()),b&&y.push(function(){var T;if(!Bg)return wm!=null||(wm=(T=fetch(le()),WebAssembly.instantiateStreaming(T,{}).then(S=>{const{sbrk:A,memory:C,meshopt_decodeVertexBuffer:D,meshopt_decodeIndexBuffer:z,meshopt_decodeIndexSequence:O,meshopt_decodeFilterOct:F,meshopt_decodeFilterQuat:N,meshopt_decodeFilterExp:j}=S.instance.exports,te={ATTRIBUTES:D,TRIANGLES:z,INDICES:O},H={OCTAHEDRAL:F,QUATERNION:N,EXPONENTIAL:j};return S.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(W,K,ee,ae,he,be){const xe=K+3&-4,Te=A(xe*ee),Fe=A(ae.length),se=new Uint8Array(C.buffer);se.set(ae,Fe);const fe=te[he](Te,K,ee,Fe,ae.length);if(fe===0&&H[be]&&H[be](Te,xe,ee),W.set(se.subarray(Te,Te+K*ee)),A(Te-A(0)),fe!==0)throw new Error(`Malformed buffer data: ${fe}`)}}})).then(S=>{Bg=S,wm=null})),wm}()),c)for(let T=0;T<c.length;T++)y.push(MT(c[T],s,T,t,n));if(y.length&&await Promise.all(y),n&&n.throwIfAborted(),v&&h)for(const{primitives:T}of h)for(const S of T)IT(S,s);if(b&&h&&_)for(const T of _)AT(T,s);return s}async function Iv(i,e){const{data:t}=await vi({url:i},e);return Sv(t,0,i,e)}class Sm{constructor(e,t,n,s){if(this.triangleCount=t.length/3,this.min=new De(0,0),this.max=new De(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;const[l,c]=[e[0].clone(),e[0].clone()];for(let v=1;v<e.length;++v){const b=e[v];l.x=Math.min(l.x,b.x),l.y=Math.min(l.y,b.y),c.x=Math.max(c.x,b.x),c.y=Math.max(c.y,b.y)}if(s){const v=Math.ceil(Math.max(c.x-l.x,c.y-l.y)/s);n=Math.max(n,v)}if(n===0)return;this.min=l,this.max=c;const h=this.max.sub(this.min);h.x=Math.max(h.x,1),h.y=Math.max(h.y,1);const p=Math.max(h.x,h.y)/n;this.cellsX=Math.max(1,Math.ceil(h.x/p)),this.cellsY=Math.max(1,Math.ceil(h.y/p)),this.xScale=1/p,this.yScale=1/p;const _=[];for(let v=0;v<this.triangleCount;v++){const b=e[t[3*v+0]].sub(this.min),T=e[t[3*v+1]].sub(this.min),S=e[t[3*v+2]].sub(this.min),A=Oa(Math.floor(Math.min(b.x,T.x,S.x)),this.xScale,this.cellsX),C=Oa(Math.floor(Math.max(b.x,T.x,S.x)),this.xScale,this.cellsX),D=Oa(Math.floor(Math.min(b.y,T.y,S.y)),this.yScale,this.cellsY),z=Oa(Math.floor(Math.max(b.y,T.y,S.y)),this.yScale,this.cellsY),O=new De(0,0),F=new De(0,0),N=new De(0,0),j=new De(0,0);for(let te=D;te<=z;++te){O.y=F.y=te*p,N.y=j.y=(te+1)*p;for(let H=A;H<=C;++H)O.x=N.x=H*p,F.x=j.x=(H+1)*p,(J_(b,T,S,O,F,j)||J_(b,T,S,O,j,N))&&_.push({cellIdx:te*this.cellsX+H,triIdx:v})}}if(_.length===0)return;_.sort((v,b)=>v.cellIdx-b.cellIdx||v.triIdx-b.triIdx);let y=0;for(;y<_.length;){const v=_[y].cellIdx,b={start:this.payload.length,len:0};for(;y<_.length&&_[y].cellIdx===v;)++b.len,this.payload.push(_[y++].triIdx);this.cells[v]=b}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(e,t){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;const n=Oa(e.x-this.min.x,this.xScale,this.cellsX),s=Oa(e.y-this.min.y,this.yScale,this.cellsY),l=this.cells[s*this.cellsX+n];if(l){this._lazyInitLookup();for(let c=0;c<l.len;c++){const h=this.payload[l.start+c],p=Math.floor(h/8),_=1<<h%8;if(!(this.lookup[p]&_)&&(this.lookup[p]|=_,t.push(h),t.length===this.triangleCount))return}}}query(e,t,n){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>t.x||e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const s=Oa(e.x-this.min.x,this.xScale,this.cellsX),l=Oa(t.x-this.min.x,this.xScale,this.cellsX),c=Oa(e.y-this.min.y,this.yScale,this.cellsY),h=Oa(t.y-this.min.y,this.yScale,this.cellsY);for(let p=c;p<=h;p++)for(let _=s;_<=l;_++){const y=this.cells[p*this.cellsX+_];if(y)for(let v=0;v<y.len;v++){const b=this.payload[y.start+v],T=Math.floor(b/8),S=1<<b%8;if(!(this.lookup[T]&S)&&(this.lookup[T]|=S,n.push(b),n.length===this.triangleCount))return}}}}function Oa(i,e,t){return Math.max(0,Math.min(t-1,Math.floor(i*e)))}et(Sm,"TriangleGridIndex");const RT=ve([{name:"a_pos_3f",components:3,type:"Float32"}]),PT=ve([{name:"a_color_3f",components:3,type:"Float32"}]),DT=ve([{name:"a_color_4f",components:4,type:"Float32"}]),LT=ve([{name:"a_uv_2f",components:2,type:"Float32"}]),zT=ve([{name:"a_normal_3f",components:3,type:"Float32"}]),FT=ve([{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"}]),OT=ve([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Av(i,e){const t=pf(i.projection,i.zoom,i.width,i.height),n=function(l,c,h,p,_){const y=new f(h.lng-180*Tc,h.lat),v=new f(h.lng+180*Tc,h.lat),b=l.project(y.lng,y.lat),T=l.project(v.lng,v.lat),S=-Math.atan2(T.y-b.y,T.x-b.x),A=V.fromLngLat(h);A.y=vt(A.y,-1+Tc,1-Tc);const C=A.toLngLat(),D=l.project(C.lng,C.lat),z=V.fromLngLat(C);z.x+=Tc;const O=z.toLngLat(),F=l.project(O.lng,O.lat),N=Mv(F.x-D.x,F.y-D.y,S),j=V.fromLngLat(C);j.y+=Tc;const te=j.toLngLat(),H=l.project(te.lng,te.lat),W=Mv(H.x-D.x,H.y-D.y,S),K=Math.abs(N.x)/Math.abs(W.y),ee=rr([]);Os(ee,ee,-S*(1-(_?0:p)));const ae=rr([]);return hr(ae,ae,[1,1-(1-K)*p,1]),ae[4]=-W.x/W.y*p,Os(ae,ae,S),Dt(ae,ee,ae),ae}(i.projection,0,i.center,t,e),s=Cv(i);return hr(n,n,[s,s,1]),n}function Cv(i){const e=i.projection,t=pf(i.projection,i.zoom,i.width,i.height),n=Ng(e,i.center),s=Ng(e,f.convert(e.center));return Math.pow(2,n*t+(1-t)*s)}function pf(i,e,t,n,s=1/0){const l=i.range;if(!l)return 0;const c=Math.min(s,Math.max(t,n)),h=Math.log2(c/1024);return cs(l[0]+h,l[1]+h,e)}const Tc=1/4e4;function Ng(i,e){const t=vt(e.lat,-85.051129,E),n=new f(e.lng-180*Tc,t),s=new f(e.lng+180*Tc,t),l=i.project(n.lng,t),c=i.project(s.lng,t),h=V.fromLngLat(n),p=V.fromLngLat(s),_=c.x-l.x,y=c.y-l.y,v=p.x-h.x,b=p.y-h.y,T=Math.sqrt((v*v+b*b)/(_*_+y*y));return Math.log2(T)}function Mv(i,e,t){const n=Math.cos(t),s=Math.sin(t);return{x:i*n-e*s,y:i*s+e*n}}const BT=new Float64Array([1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);function Rv(i,e,t){rr(i),Os(i,i,Ot(e[2])),Es(i,i,Ot(e[0])),Io(i,i,Ot(e[1])),hr(i,i,t),Dt(i,i,BT)}function Im(i,e,t,n,s,l,c,h){const p=[t[0]-e[0],t[1]-e[1],0],_=[n[0]-e[0],n[1]-e[1],0];if(Ki(p)<1e-12||Ki(_)<1e-12)return Mn(i);const y=gr([],p,_);ei(y,y),Jn(_,n,e),p[2]=(l-s)*h,_[2]=(c-s)*h;const v=p;return gr(v,p,_),ei(v,v),Hs(i,y,v)}function Am(i,e,t=!1){const n=Rl(e.zoom),s=function(l,c,h){const p=c.worldSize,_=[l[12],l[13],l[14]],y=vr(_[1]/p),v=qn(_[0]/p),b=rr([]),T=x(1,y)*p,S=x(1,0)*p*R(y,c.zoom),A=1/dg(p);let C=S*A;if(h){const F=pf(c.projection,c.zoom,c.width,c.height,1024);C=A*c.projection.pixelSpaceConversion(c.center.lat,p,F)}const D=r(y,v);Ji(D,D,si([],ei([],D),T*C*_[2]));const z=function(F){const N=[F[0],F[1],F[2]];let j=[0,1,0];const te=gr([],j,N);return gr(j,N,te),rs(j)===0&&(j=[0,1,0],gr(te,N,j)),ei(te,te),ei(j,j),ei(N,N),[te[0],te[1],te[2],0,j[0],j[1],j[2],0,N[0],N[1],N[2],0,F[0],F[1],F[2],1]}(D);
vendor: 8,997 bytes, line 7
7hr(b,b,[C,C,C*T]),Yi(b,b,[-_[0],-_[1],-_[2]]);const O=Dt([],c.globeMatrix,z);return Dt(O,O,b),Dt(O,O,l),O}(i,e,t);if(n>0){const l=function(c,h){const p=h.worldSize,_=x(1,0)*p*R(h.center.lat,h.zoom)/dg(p),y=x(1,h.center.lat)*p,v=rr([]);Io(v,v,Ot(h.center.lng)),Es(v,v,Ot(h.center.lat)),Yi(v,v,[0,0,On]),hr(v,v,[_,_,_*y]);const b=h.point;return Yi(v,v,[-b.x,-b.y,0]),Dt(v,v,c),Dt(v,h.globeMatrix,v)}(i,e);return function(c,h,p){const _=(S,A,C)=>{const D=Ki(S),z=Ki(A),O=Ml(S,A,C);return si(O,O,1/Ki(O)*lt(D,z,C))},y=_([c[0],c[1],c[2]],[h[0],h[1],h[2]],p),v=_([c[4],c[5],c[6]],[h[4],h[5],h[6]],p),b=_([c[8],c[9],c[10]],[h[8],h[9],h[10]],p),T=Ml([c[12],c[13],c[14]],[h[12],h[13],h[14]],p);return[y[0],y[1],y[2],0,v[0],v[1],v[2],0,b[0],b[1],b[2],0,T[0],T[1],T[2],1]}(s,l,n)}return s}function Vg(i,e,t,n){const s=Di.projectAabbCorners(n,t);let l=Number.MAX_VALUE;for(let h=0;h<s.length;++h){const p=s[h];p[0]=(.5*p[0]+.5)*e.width,p[1]=(.5-.5*p[1])*e.height,p[2]<l&&(l=p[2])}const c=function(h){const p=[];let _=0;for(let T=1;T<h.length;T++)(h[T][0]<h[_][0]||h[T][0]===h[_][0]&&h[T][1]<h[_][1])&&(_=T);let y,v=_;const b=new Uint8Array(h.length);do{if(b[v])break;p.push(new De(h[v][0],h[v][1])),b[v]=1,y=(v+1)%h.length;for(let T=0;T<h.length;T++){if(h[T][0]===h[y][0]&&h[T][1]===h[y][1]||h[T][0]===h[v][0]&&h[T][1]===h[v][1])continue;const S=[h[T][0]-h[v][0],h[T][1]-h[v][1]],A=[h[y][0]-h[v][0],h[y][1]-h[v][1]],C=S[0]*A[1]-S[1]*A[0];(C>0||C===0&&S[0]*A[0]+S[1]*A[1]>=0&&S[0]*S[0]+S[1]*S[1]>A[0]*A[0]+A[1]*A[1])&&(y=T)}v=y}while(v!==_);return p.length>0&&p.push(p[0]),p}(s);if($_(i,c))return l}const Cu=64,kT=[1,1,1];function Cm(i,e,t,n,s,l,c,h,p,_=!1){const y=t.zoom,v=t.project(n),b=R(n.lat,y),T=1/b;rr(i),Yi(i,i,[v.x+c[0]*T,v.y+c[1]*T,c[2]]);let S=1,A=1;const C=t.worldSize;if(_){if(t.projection.name==="mercator"){let F=0;t.elevation&&(F=t.elevation.getAtPointOrZero(new V(v.x/C,v.y/C),0));const N=lr([],[v.x,v.y,F,1],t.projMatrix)[3]/t.cameraToCenterDistance;S=N,A=N*R(t.center.lat,y)}else if(t.projection.name==="globe"){const F=Am(i,t),N=[0,0,0,1];lr(N,N,Dt([],t.projMatrix,F));const j=N[3]/t.cameraToCenterDistance,te=Rl(y),H=t.projection.pixelsPerMeter(n.lat,C)*R(n.lat,y),W=t.projection.pixelsPerMeter(t.center.lat,C)*R(t.center.lat,y);S=j/lt(H,I(t.center.lat),te),A=j*b/H,S*=W,A*=W}}else S=T;hr(i,i,[S,S,A]);const D=[...i],z=e.orientation,O=[];if(Rv(O,[z[0]+(s?s[0]:0),z[1]+(s?s[1]:0),z[2]+(s?s[2]:0)],l),Dt(i,D,O),h&&t.elevation){let F=0;const N=[];if(p&&t.elevation){F=function(te,H,W,K,ee){const ae=H.elevation;if(!ae)return 0;const he=Di.projectAabbCorners(W,K),be=x(1,ee.lat)*H.worldSize,xe=function(ke,Ke){const Ve=[0,0,1],$e=[{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(const dt of $e){const pt=ke[dt.corners[0]],yt=ke[dt.corners[1]],ht=ke[dt.corners[2]],wt=[yt[0]-pt[0],yt[1]-pt[1],Ke*(yt[2]-pt[2])],bt=gr(wt,wt,[ht[0]-pt[0],ht[1]-pt[1],Ke*(ht[2]-pt[2])]);ei(bt,bt),dt.dotProductWithUp=Ri(bt,Ve)}return $e.sort((dt,pt)=>dt.dotProductWithUp-pt.dotProductWithUp),$e[0].corners}(he,be),Te=he[xe[0]],Fe=he[xe[1]],se=he[xe[2]],fe=he[xe[3]],ge=ae.getAtPointOrZero(new V(Te[0]/H.worldSize,Te[1]/H.worldSize),0),Ae=ae.getAtPointOrZero(new V(Fe[0]/H.worldSize,Fe[1]/H.worldSize),0),Me=ae.getAtPointOrZero(new V(se[0]/H.worldSize,se[1]/H.worldSize),0),ze=ae.getAtPointOrZero(new V(fe[0]/H.worldSize,fe[1]/H.worldSize),0),Ce=(ge+ze)/2,Be=(Ae+Me)/2;return Ce>Be?Ae<Me?Im(te,Fe,fe,Te,Ae,ze,ge,be):Im(te,se,Te,fe,Me,ge,ze,be):ge<ze?Im(te,Te,Fe,se,ge,Ae,Me,be):Im(te,fe,se,Fe,ze,Me,Ae,be),Math.max(Ce,Be)}(N,t,e.aabb,i,n);const j=Dt([],Ga([],N),O);Dt(i,D,j)}else F=t.elevation.getAtPointOrZero(new V(v.x/C,v.y/C),0);F!==0&&(i[14]+=F)}}class Pv{constructor(e,t,n,s,l){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=t,this.position=n!=null?new f(n[0],n[1]):new f(0,0),this.orientation=s??[0,0,0],this.nodes=l,this.uploaded=!1,this.aabb=new Di([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,t){Dt(e.globalMatrix,t,e.localMatrix);const n=this.nodeOverrides.get(e.name);if(n!==void 0){if(n.orientation){const c=[];l=n.orientation,rr(s=c),Io(s,s,Ot(l[1])),Os(s,s,Ot(l[2])),Es(s,s,Ot(l[0])),Dt(e.globalMatrix,e.globalMatrix,c)}n.minZoom&&(e.minZoom=n.minZoom),n.maxZoom&&(e.maxZoom=n.maxZoom)}var s,l;if(e.meshes)for(const c of e.meshes){const h=Di.applyTransformFast(c.aabb,e.globalMatrix);this.aabb.encapsulate(h)}if(e.children)for(const c of e.children)this._applyTransformations(c,e.globalMatrix)}computeBoundsAndApplyParent(){const e=rr([]);this.aabb=new Di([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const t of this.nodes)this._applyTransformations(t,e)}computeModelMatrix(e,t,n,s,l,c,h=!1){Cm(this.matrix,this,e.transform,this.position,t,n,s,l,c,h)}upload(e){if(!this.uploaded){for(const t of this.nodes)Ug(t,e);for(const t of this.nodes)Mm(t);this.uploaded=!0}}destroy(){for(const e of this.nodes)jg(e)}}function mf(i,e,t=!1){i.uploaded||(i.gfxTexture=new am(e,i.image,t?e.gl.R8:e.gl.RGBA8,{useMipmap:i.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),i.uploaded=!0,i.image=null)}function Dv(i,e,t){i.indexBuffer=e.createIndexBuffer(i.indexArray,!1,!0),i.vertexBuffer=e.createVertexBuffer(i.vertexArray,RT.members,!1,!0),i.normalArray&&(i.normalBuffer=e.createVertexBuffer(i.normalArray,zT.members,!1,!0)),i.texcoordArray&&(i.texcoordBuffer=e.createVertexBuffer(i.texcoordArray,LT.members,!1,!0)),i.colorArray&&(i.colorBuffer=e.createVertexBuffer(i.colorArray,(i.colorArray.bytesPerElement===12?PT:DT).members,!1,!0)),i.featureArray&&(i.pbrBuffer=e.createVertexBuffer(i.featureArray,OT.members,!0)),i.segments=li.simpleSegment(0,0,i.vertexArray.length,i.indexArray.length);const n=i.material;n.pbrMetallicRoughness.baseColorTexture&&mf(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&mf(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&mf(n.normalTexture,e),n.occlusionTexture&&mf(n.occlusionTexture,e,t),n.emissionTexture&&mf(n.emissionTexture,e)}function Ug(i,e,t){if(i.meshes)for(const n of i.meshes)Dv(n,e,t);if(i.lodMeshes)for(const n of i.lodMeshes)Dv(n,e,t);if(i.children)for(const n of i.children)Ug(n,e,t)}function Lv(i){i.indexArray.destroy(),i.vertexArray.destroy(),i.colorArray&&i.colorArray.destroy(),i.normalArray&&i.normalArray.destroy(),i.texcoordArray&&i.texcoordArray.destroy(),i.featureArray&&i.featureArray.destroy()}function Mm(i){if(i.meshes)for(const e of i.meshes)Lv(e);if(i.lodMeshes)for(const e of i.lodMeshes)Lv(e);if(i.children)for(const e of i.children)Mm(e)}function zv(i){var e;i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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 jg(i){if(i.meshes)for(const e of i.meshes)zv(e);if(i.lodMeshes)for(const e of i.lodMeshes)zv(e);if(i.footprintDebugMesh&&(i.footprintDebugMesh.vertexBuffer.destroy(),i.footprintDebugMesh.indexBuffer.destroy(),i.footprintDebugMesh.segments.destroy()),i.children)for(const e of i.children)jg(e)}function Gg(i,e,t,n){return i[0]<=n[0]&&e[0]>=t[0]&&i[1]<=n[1]&&e[1]>=t[1]&&i[2]<=n[2]&&e[2]>=t[2]}function NT(i,e,t,n,s,l,c,h,p,_,y){const v=.5*(_[0]+y[0]),b=.5*(_[1]+y[1]),T=.5*(_[2]+y[2]),S=.5*(y[0]-_[0]),A=.5*(y[1]-_[1]),C=.5*(y[2]-_[2]),D=i-v,z=e-b,O=t-T,F=n-v,N=s-b,j=l-T,te=c-v,H=h-b,W=p-T,K=F-D,ee=N-z,ae=j-O,he=te-F,be=H-N,xe=W-j,Te=D-te,Fe=z-H,se=O-W;let fe,ge,Ae,Me,ze,Ce;if(fe=O*ee-z*ae,ge=j*ee-N*ae,Ae=W*ee-H*ae,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(ae)*A+Math.abs(ee)*C,Me>Ce||ze<-Ce||(fe=O*be-z*xe,ge=j*be-N*xe,Ae=W*be-H*xe,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(xe)*A+Math.abs(be)*C,Me>Ce||ze<-Ce)||(fe=O*Fe-z*se,ge=j*Fe-N*se,Ae=W*Fe-H*se,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(se)*A+Math.abs(Fe)*C,Me>Ce||ze<-Ce)||(fe=D*ae-O*K,ge=F*ae-j*K,Ae=te*ae-W*K,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(ae)*S+Math.abs(K)*C,Me>Ce||ze<-Ce)||(fe=D*xe-O*he,ge=F*xe-j*he,Ae=te*xe-W*he,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(xe)*S+Math.abs(he)*C,Me>
vendor: 117,580 bytes, line 7
7Ce||ze<-Ce)||(fe=D*se-O*Te,ge=F*se-j*Te,Ae=te*se-W*Te,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(se)*S+Math.abs(Te)*C,Me>Ce||ze<-Ce)||(fe=z*K-D*ee,ge=N*K-F*ee,Ae=H*K-te*ee,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(ee)*S+Math.abs(K)*A,Me>Ce||ze<-Ce)||(fe=z*he-D*be,ge=N*he-F*be,Ae=H*he-te*be,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(be)*S+Math.abs(he)*A,Me>Ce||ze<-Ce)||(fe=z*Te-D*Fe,ge=N*Te-F*Fe,Ae=H*Te-te*Fe,Me=Math.min(fe,ge,Ae),ze=Math.max(fe,ge,Ae),Ce=Math.abs(Fe)*S+Math.abs(Te)*A,Me>Ce||ze<-Ce)||(Me=Math.min(D,F,te),ze=Math.max(D,F,te),Me>S||ze<-S)||(Me=Math.min(z,N,H),ze=Math.max(z,N,H),Me>A||ze<-A)||(Me=Math.min(O,j,W),ze=Math.max(O,j,W),Me>C||ze<-C))return!1;const Be=ee*xe-ae*be,ke=ae*he-K*xe,Ke=K*be-ee*he,Ve=-(Be*D+ke*z+Ke*O);return Ce=S*Math.abs(Be)+A*Math.abs(ke)+C*Math.abs(Ke),!(Math.abs(Ve)>Ce)}const VT=[];class Fv{serializeFromGltf(e,t,n,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;const c=new DataView(e.buffer,e.byteOffset),h=c.getUint16(l,!0);if(l+=2,h===0)return;this._nodes=[];let p=0;for(let y=0;y<h;y++){const v=[t[3*p],t[3*p+1],t[3*p+2]],b=[n[3*p],n[3*p+1],n[3*p+2]];p++;const T=c.getUint16(l,!0);l+=2;let S=0,A=0;T===65535&&(S=c.getUint16(l,!0),l+=2,A=c.getUint32(l,!0),l+=4),this._nodes.push({aabbMin:v,aabbMax:b,backChild:T,indexCount:S,indexOffset:A})}const _=c.getUint32(l,!0);this._indices=s.slice(0,_)}setVertices(e){this._vertices=e}findHighestPoint(e,t){if(!this._nodes||this._nodes.length===0||!Gg(this._nodes[0].aabbMin,this._nodes[0].aabbMax,e,t))return null;const n=VT;n.length=0,n.push(0);let s=-1/0;for(;n.length>0;){const l=n.pop(),c=this._nodes[l];if(c.aabbMax[2]<=s)continue;if(c.backChild===65535){for(let T=0;T<c.indexCount;T+=3){const S=3*this._indices[c.indexOffset+T],A=3*this._indices[c.indexOffset+T+1],C=3*this._indices[c.indexOffset+T+2];NT(this._vertices[S],this._vertices[S+1],this._vertices[S+2],this._vertices[A],this._vertices[A+1],this._vertices[A+2],this._vertices[C],this._vertices[C+1],this._vertices[C+2],e,t)&&(s=Math.max(s,this._vertices[S+2],this._vertices[A+2],this._vertices[C+2]))}continue}const h=l+1,p=c.backChild,_=this._nodes[h],y=this._nodes[p],v=Gg(_.aabbMin,_.aabbMax,e,t),b=Gg(y.aabbMin,y.aabbMax,e,t);v&&b?_.aabbMax[2]<y.aabbMax[2]?(n.push(h),n.push(p)):(n.push(p),n.push(h)):v?n.push(h):b&&n.push(p)}return s>=0?s:null}}function Mu(i,e){const t=i.json.bufferViews[e.bufferView],n=Tm[e.componentType];return new n(i.buffers[t.buffer],(e.byteOffset||0)+(t.byteOffset||0),e.count*(t.byteStride&&t.byteStride!==ff[e.type]*n.BYTES_PER_ELEMENT?t.byteStride/n.BYTES_PER_ELEMENT:ff[e.type]))}function Hg(i,e,t,n){const s=Tm[e.componentType],l=function(v){switch(v){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(s),c=i.json.bufferViews[e.bufferView],h=c.byteStride?c.byteStride/s.BYTES_PER_ELEMENT:ff[e.type],p=t.float32,_=p.length/t.capacity,y=e.count*h;for(let v=0,b=0;v<y;v+=h,b+=_)for(let T=0;T<_;T++)p[b+T]=n[v+T]*l}function UT(i,e,t){const n=i.indices,s=i.attributes,l={};l.indexArray=new _t;const c=e.json.accessors[n],h=Mu(e,c);l.indexArray.resizeExact(c.count/3),l.indexArray.uint16.set(h),l.vertexArray=new We;const p=e.json.accessors[s.POSITION],_=Mu(e,p);l.vertexArray.resizeExact(p.count),l.vertexArray.float32.set(_),l.aabb=new Di(p.min,p.max);const[y,v,b]=p.min,[T,S,A]=p.max;if(l.centroid=[.5*(y+T),.5*(v+S),.5*(b+A)],s.COLOR_0!==void 0){const D=e.json.accessors[s.COLOR_0],z=ff[D.type],O=Mu(e,D);l.colorArray=z===3?new We:new xt,l.colorArray.resizeExact(D.count),Hg(e,D,l.colorArray,O)}if(s.NORMAL!==void 0){l.normalArray=new We;const D=e.json.accessors[s.NORMAL];l.normalArray.resizeExact(D.count);const z=Mu(e,D);Hg(e,D,l.normalArray,z)}if(s.TEXCOORD_0!==void 0&&t.length>0){l.texcoordArray=new Ti;const D=e.json.accessors[s.TEXCOORD_0];l.texcoordArray.resizeExact(D.count);const z=Mu(e,D);Hg(e,D,l.texcoordArray,z)}if(s._FEATURE_ID_RGBA4444!==void 0){const D=e.json.accessors[s._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(l.featureData=Mu(e,D))}s._FEATURE_RGBA4444!==void 0&&(l.featureData=new Uint32Array(Mu(e,e.json.accessors[s._FEATURE_RGBA4444]).buffer));const C=i.material;return l.material=function(D,z){const{emissiveFactor:O=[0,0,0],alphaMode:F="OPAQUE",alphaCutoff:N=.5,normalTexture:j,occlusionTexture:te,emissiveTexture:H,doubleSided:W,name:K}=D,{baseColorFactor:ee=[1,1,1,1],metallicFactor:ae=1,roughnessFactor:he=1,baseColorTexture:be,metallicRoughnessTexture:xe}=D.pbrMetallicRoughness||{},Te=te?z[te.index]:void 0;if(te&&te.extensions&&te.extensions.KHR_texture_transform&&Te){const Fe=te.extensions.KHR_texture_transform;Te.offsetScale=[Fe.offset[0],Fe.offset[1],Fe.scale[0],Fe.scale[1]]}return{name:K,pbrMetallicRoughness:{baseColorFactor:new Pt(...ee),metallicFactor:ae,roughnessFactor:he,baseColorTexture:be?z[be.index]:void 0,metallicRoughnessTexture:xe?z[xe.index]:void 0},doubleSided:W,emissiveFactor:new Pt(...O),alphaMode:F,alphaCutoff:N,normalTexture:j?z[j.index]:void 0,occlusionTexture:Te,emissionTexture:H?z[H.index]:void 0,defined:D.defined===void 0}}(C!==void 0?e.json.materials[C]:{defined:!1},t),l}function Zg(i,e,t){const{matrix:n,rotation:s,translation:l,scale:c,mesh:h,extras:p,children:_,name:y}=i,v={};if(v.name=y,v.localMatrix=n||function(b,T,S,A){var C=T[0],D=T[1],z=T[2],O=T[3],F=C+C,N=D+D,j=z+z,te=C*F,H=C*N,W=C*j,K=D*N,ee=D*j,ae=z*j,he=O*F,be=O*N,xe=O*j,Te=A[0],Fe=A[1],se=A[2];return b[0]=(1-(K+ae))*Te,b[1]=(H+xe)*Te,b[2]=(W-be)*Te,b[3]=0,b[4]=(H-xe)*Fe,b[5]=(1-(te+ae))*Fe,b[6]=(ee+he)*Fe,b[7]=0,b[8]=(W+be)*se,b[9]=(ee-he)*se,b[10]=(1-(te+K))*se,b[11]=0,b[12]=S[0],b[13]=S[1],b[14]=S[2],b[15]=1,b}([],s||[0,0,0,1],l||[0,0,0],c||[1,1,1]),v.globalMatrix=Fs(v.localMatrix),h!==void 0){v.meshes=t[h];const b=v.anchor=[0,0];for(const T of v.meshes){const{min:S,max:A}=T.aabb;b[0]+=S[0]+A[0],b[1]+=S[1]+A[1]}b[0]=Math.floor(b[0]/v.meshes.length/2),b[1]=Math.floor(b[1]/v.meshes.length/2)}if(p&&(p.id&&(v.id=p.id),p.lights&&(v.lights=function(b){if(!b.length)return[];const T=function(z){const O=atob(z),F=new Uint8Array(O.length);for(let N=0;N<O.length;N++)F[N]=O.codePointAt(N);return F}(b),S=[],A=T.length/24,C=new Uint16Array(T.buffer),D=new Float32Array(T.buffer);for(let z=0;z<A;z++){const O=C[2*z*6]/30,F=C[2*z*6+1]/30,N=C[2*z*6+10]/100,j=D[6*z+1],te=D[6*z+2],H=D[6*z+3],W=D[6*z+4],K=H-j,ee=W-te,ae=Math.hypot(K,ee);S.push({pos:[j+.5*K,te+.5*ee,F],normal:[ee/ae,-K/ae,0],width:ae,height:O,depth:N,points:[j,te,H,W]})}return S}(p.lights)),p.MAPBOX_geometry_bloom&&(v.isGeometryBloom=p.MAPBOX_geometry_bloom),p.MAPBOX_zoom_min&&(v.minZoom=p.MAPBOX_zoom_min),p.MAPBOX_zoom_max&&(v.maxZoom=p.MAPBOX_zoom_max)),_){const b=[];for(const T of _)b.push(Zg(e.json.nodes[T],e,t));v.children=b}if(i.extensions&&i.extensions.mbx_bvh&&(v.meshBVH=function(b,T,S){const A=T.binaryAccessor,C=T.positionMinAccessor,D=T.positionMaxAccessor,z=T.indexAccessor;if(!(Number.isInteger(A)&&Number.isInteger(C)&&Number.isInteger(D)&&Number.isInteger(z)))return null;const O=b.json.accessors;if(A>=O.length||C>=O.length||D>=O.length||z>=O.length)return null;const F=O[A],N=O[C],j=O[D],te=O[z];if(F.bufferView===void 0||N.bufferView===void 0||j.bufferView===void 0||te.bufferView===void 0)return null;const H=b.json.bufferViews;if(F.bufferView>=H.length||N.bufferView>=H.length||j.bufferView>=H.length||te.bufferView>=H.length)return null;const W=H[F.bufferView],K=H[N.bufferView],ee=H[j.bufferView],ae=H[te.bufferView];if(W.buffer>=b.buffers.length||K.buffer>=b.buffers.length||ee.buffer>=b.buffers.length||ae.buffer>=b.buffers.length)return null;const he=(ze,Ce,Be)=>ze>=0&&ze<=Be&&Ce<=Be-ze,be=F.byteOffset||0,xe=N.byteOffset||0,Te=j.byteOffset||0,Fe=te.byteOffset||0;if(!(he(be,0,W.byteLength)&&he(xe,3*N.count*4,K.byteLength)&&he(Te,3*j.count*4,ee.byteLength)&&he(Fe,4*te.count,ae.byteLength)))return null;const se=new Uint8Array(b.buffers[W.buffer],(W.byteOffset||0)+be,W.byteLength-be),fe=new Float32Array(b.buffers[K.buffer],(K.byteOffset||0)+xe,3*N.count),ge=new Float32Array(b.buffers[ee.buffer],(ee.byteOffset||0)+Te,3*j.count),Ae=new Uint32Array(b.buffers[ae.buffer],(ae.byteOffset||0)+Fe,te.count),Me=new Fv;if(Me.serializeFromGltf(se,fe,ge,Ae),S!==void 0&&b.json.meshes&&b.json.meshes[S]){const ze=b.json.meshes[S].primitives[0];if(ze&&ze.attributes.POSITION!==void 0&&ze.attributes.POSITION<O.length){const Ce=O[ze.attributes.POSITION];if(Ce.bufferView!==void 0&&Ce.bufferView<H.length){const Be=H[Ce.bufferView];if(Be.buffer<b.buffers.length){const ke=Ce.byteOffset||0,Ke=Be.byteStride?Be.byteStride/4:3;if(he(ke,Ce.count*Ke*4,Be.byteLength)){const Ve=(Be.byteOffset||0)+ke;if(Ke===3)Me.setVertices(new Float32Array(b.buffers[Be.buffer],Ve,3*Ce.count));else{const $e=new Float32Array(b.buffers[Be.buffer],Ve,Ce.count*Ke),dt=new Float32Array(3*Ce.count);for(let pt=0;pt<Ce.count;pt++)dt[3*pt]=$e[pt*Ke],dt[3*pt+1]=$e[pt*Ke+1],dt[3*pt+2]=$e[pt*Ke+2];Me.setVertices(dt)}}}}}}return Me}(e,i.extensions.mbx_bvh,h)),!v.meshBVH&&v.children){for(const b of v.children)if(b.meshBVH){v.meshBVH=b.meshBVH;break}}return v}function jT(i){if(i.vertices.length===0||i.indices.length===0)return null;const e=new Sm(i.vertices,i.indices,8,256),[t,n]=[e.min.clone(),e.max.clone()];return{vertices:i.vertices,indices:i.indices,grid:e,min:t,max:n}}function GT(i){if(!i.extras||!i.extras.ground)return null;const e=i.extras.ground;if(!e||!Array.isArray(e)||e.length===0)return null;const t=e[0];if(!t||!Array.isArray(t)||t.length===0)return null;const n=[];for(const c of t){if(!Array.isArray(c)||c.length!==2)continue;const h=c[0],p=c[1];typeof h=="number"&&typeof p=="number"&&n.push(new De(h,p))}if(n.length<3)return null;n.length>1&&n.at(-1).equals(n[0])&&n.pop();let s=0;for(let c=0;c<n.length;c++){const h=n[c],p=n[(c+1)%n.length],_=n[(c+2)%n.length];s+=(h.x-p.x)*(_.y-p.y)-(_.x-p.x)*(h.y-p.y)}s>0&&n.reverse();const l=ea(n.flatMap(c=>[c.x,c.y]),[]);return l.length===0?null:{vertices:n,indices:l}}function HT(i,e){const t=[],n=[];let s=0;const l=[];for(const c of i){s=t.length;const h=c.vertexArray.float32,p=c.indexArray.uint16;for(let _=0;_<c.vertexArray.length;_++)l[0]=h[3*_+0],l[1]=h[3*_+1],l[2]=h[3*_+2],hi(l,l,e),t.push(new De(l[0],l[1]));for(let _=0;_<3*c.indexArray.length;_++)n.push(p[_]+s)}if(n.length%3!=0)return null;for(let c=0;c<n.length;c+=3){const h=t[n[c+0]],p=t[n[c+1]],_=t[n[c+2]];(h.x-p.x)*(_.y-p.y)-(_.x-p.x)*(h.y-p.y)>0&&([n[c+1],n[c+2]]=[n[c+2],n[c+1]])}return{vertices:t,indices:n}}function Ov(i,e){for(let t=0;t<i.length;t++)if(i[t].name===e)return t;return-1}function $g(i){const e=function(y,v){const b=[],T=WebGL2RenderingContext;if(y.json.textures)for(const S of y.json.textures){const A={magFilter:T.LINEAR,minFilter:T.NEAREST,wrapS:T.REPEAT,wrapT:T.REPEAT};S.sampler!==void 0&&Object.assign(A,y.json.samplers[S.sampler]),b.push({image:v[S.source],sampler:A,uploaded:!1})}return b}(i,i.images),t=function(y,v){const b=[];if(!y.json.meshes)return b;for(const T of y.json.meshes){const S=[];for(const A of T.primitives)S.push(UT(A,y,v));b.push(S)}return b}(i,e),{scenes:n,scene:s,nodes:l}=i.json;let c=n?Ov(n,"Default Scene"):-1;c<0&&(c=s||0);const h=n&&n[c]?n[c].nodes||[]:[...l.keys()],p=[];for(const y of h)p.push(Zg(l[y],i,t));(function(y,v,b){const T={},S=new Set;for(let A=0;A<y.length;A++){const C=b[v[A]];if(!C.extras)continue;const D=C.extras["mapbox:footprint:version"],z=C.extras["mapbox:footprint:id"];(D||z)&&S.add(A),D==="1.0.0"&&z&&(T[z]=A)}for(let A=0;A<y.length;A++){if(S.has(A))continue;const C=y[A],D=b[v[A]];if(!D.extras)continue;let z=null;C.id in T&&(z=HT(y[T[C.id]].meshes,C.localMatrix)),z||(z=GT(D)),z&&(C.footprint=jT(z))}if(S.size>0){const A=Array.from(S.values()).sort((C,D)=>C-D);for(let C=A.length-1;C>=0;C--)y.splice(A[C],1)}})(p,h,i.json.nodes);const _=n?Ov(n,"LOD"):-1;if(_>=0){const y=n[_].nodes,v=new Map;for(const b of y){const T=Zg(l[b],i,t);T.id&&v.set(T.id,T)}for(const b of p)if(b.id){const T=v.get(b.id);T&&T.meshes&&(b.lodMeshes=T.meshes,T.meshBVH&&(b.meshBVH=T.meshBVH))}}return p}function ZT(i){i.heightmap=new Float32Array(4096),i.heightmap.fill(-1);const e=i.vertexArray.float32,t=i.aabb.min[0]-1,n=i.aabb.min[1]-1,s=Cu/(i.aabb.max[0]-t+2),l=Cu/(i.aabb.max[1]-n+2);for(let c=0;c<e.length;c+=3){const h=e[c+2],p=(e[c+0]-t)*s|0,_=(e[c+1]-n)*l|0;h>i.heightmap[_*Cu+p]&&(i.heightmap[_*Cu+p]=h)}}function Bv(i,e,t,n,s){t.reserve(t.length+4*i.length),n.reserve(n.length+10*i.length),s.reserve(s.length+10*i.length);let l=n.length;for(const c of i){const h=Math.min(10,Math.max(4,1.3*c.height))*e,p=[-c.normal[1],c.normal[0],0],_=Math.min(.29,.1*c.width/c.depth),y=c.width-2*c.depth*e*(_+.01),v=cn([],c.pos,p,y/2),b=cn([],c.pos,p,-y/2),T=[v[0],v[1],v[2]+c.height],S=[b[0],b[1],b[2]+c.height],A=cn([],c.normal,p,_);si(A,A,h);const C=cn([],c.normal,p,-_);si(C,C,h),Ji(A,v,A),Ji(C,b,C),v[2]+=.1,b[2]+=.1,n.emplaceBack(A[0],A[1],A[2]),n.emplaceBack(C[0],C[1],C[2]),n.emplaceBack(v[0],v[1],v[2]),n.emplaceBack(b[0],b[1],b[2]),n.emplaceBack(T[0],T[1],T[2]),n.emplaceBack(S[0],S[1],S[2]),n.emplaceBack(v[0],v[1],v[2]),n.emplaceBack(b[0],b[1],b[2]),n.emplaceBack(A[0],A[1],A[2]),n.emplaceBack(C[0],C[1],C[2]);const D=y/h/2;s.emplaceBack(-D-_,-1,D,.8),s.emplaceBack(D+_,-1,D,.8),s.emplaceBack(-D,0,D,1.3),s.emplaceBack(D,0,D,1.3),s.emplaceBack(D+_,-.8,D,.7),s.emplaceBack(D+_,-.8,D,.7),s.emplaceBack(0,0,D,1.3),s.emplaceBack(0,0,D,1.3),s.emplaceBack(D+_,-1.2,D,.8),s.emplaceBack(D+_,-1.2,D,.8),t.emplaceBack(6+l,4+l,8+l),t.emplaceBack(7+l,9+l,5+l),t.emplaceBack(0+l,1+l,2+l),t.emplaceBack(1+l,3+l,2+l),l+=10}}function $T(i,e){const t={};t.indexArray=new _t,t.vertexArray=new We,t.colorArray=new xt,t.indexArray.reserveExact(4*i.length),t.vertexArray.reserveExact(10*i.length),t.colorArray.reserveExact(10*i.length),Bv(i,e,t.indexArray,t.vertexArray,t.colorArray);const n={defined:!0};n.emissiveFactor=Pt.black;const s={};return s.baseColorFactor=Pt.white,n.pbrMetallicRoughness=s,t.material=n,t.aabb=new Di([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),t}et(Fv,"ModelBVH");const kv=ve([{name:"a_pos_3f",components:3,type:"Float32"}]),qT=ve([{name:"a_normal_3",components:3,type:"Int16"}]),WT=ve([{name:"a_centroid_3",components:3,type:"Int16"}]),Nv=ve([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),XT=ve([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),YT=ve([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),KT=ve([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),JT=ve([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),QT=ve([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),eE=ve([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),tE=ve([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),iE=ve([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),rE=ve([{name:"a_centroid_pos",components:2,type:"Uint16"}]),nE=ve([{name:"a_join_normal_inside",components:3,type:"Int16"}]),oE=ve([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),sE=ve([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:aE}=eE;function Rm(i,e,t,n){const s=[],l=n===0?(c,h,p,_,y,v)=>{c.push(new De(v,p+(v-h)/(_-h)*(y-p)))}:(c,h,p,_,y,v)=>{c.push(new De(h+(v-p)/(y-p)*(_-h),v))};for(const c of i){const h=[];for(const p of c){if(p.length<=2)continue;const _=[];for(let b=0;b<p.length-1;b++){const T=p[b].x,S=p[b].y,A=p[b+1].x,C=p[b+1].y,D=n===0?T:S,z=n===0?A:C;D<e?z>e&&l(_,T,S,A,C,e):D>t?z<t&&l(_,T,S,A,C,t):_.push(p[b]),z<e&&D>=e&&l(_,T,S,A,C,e),z>t&&D<=t&&l(_,T,S,A,C,t)}let y=p.at(-1);const v=n===0?y.x:y.y;v>=e&&v<=t&&_.push(y),_.length&&(y=_.at(-1),_[0].x===y.x&&_[0].y===y.y||_.push(_[0]),h.push(_))}h.length&&s.push(h)}return s}const Pm={None:0,Model:1,Symbol:2,FillExtrusion:4},qg=[new De(0,0),new De(qe,0),new De(qe,qe),new De(0,qe)];function Vv(i,e){const t=[];let n=[];if(!e||i.length<2)return[i];if(i.length===2)return Ih(i[0],i[1],qg)?[i]:[];for(let s=0;s<i.length+2;s++){const l=s===0?i.at(-1):i[(s-1)%i.length],c=i[s%i.length],h=i[(s+1)%i.length],p=Ih(l,c,qg),_=Ih(c,h,qg),y=p||_;y&&n.push(c),y&&_||n.length>0&&(n.length>1&&t.push(n),n=[])}return n.length>1&&t.push(n),t}const Wg=pc.types,lE=["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"],cE=["fill-extrusion-flood-light-ground-radius"],uE=Math.pow(2,13),hE=Math.pow(2,15)-1,Dm=new De(0,1),zl=2147483648,Lm=1073741824;function _f(i,e,t,n,s,l,c,h){i.emplaceBack((e<<1)+c,(t<<1)+l,(Math.floor(n*uE)<<1)+s,Math.round(h))}function gf(i,e,t){i.emplaceBack(e.x*qe,e.y*qe,t?1:0)}function zm(i,e,t,n,s,l){i.emplaceBack(e.x,e.y,(t.x<<1)+n,(t.y<<1)+s,l)}function yf(i,e,t){i.emplaceBack(e.x,e.y,e.z,t[0]*16384,t[1]*16384,t[2]*16384)}class Uv{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class Fm{constructor(){this.data=[]}get length(){return this.data.length}push(e){this.data.push(e)}get(e){return this.data[e]}static serialize(e,t){const n=e.data.length,s=new Uint32Array(4*n),l=[];l.length=n;for(let c=0;c<n;c++){const h=e.data[c],p=4*c;s[p]=h.vertexOffset,s[p+1]=h.vertexCount,s[p+2]=h.indexOffset,s[p+3]=h.indexCount,l[c]=h.ringIndices}return t&&t.add(s.buffer),{scalars:s,rings:l}}static deserialize(e){const{scalars:t,rings:n}=e,s=t.length/4,l=new Fm,c=[];c.length=s,l.data=c;for(let h=0;h<s;h++){const p=4*h,_=new Uv;_.vertexOffset=t[p],_.vertexCount=t[p+1],_.indexOffset=t[p+2],_.indexCount=t[p+3],_.ringIndices=n[h],l.data[h]=_}return l}}class Om{constructor(){this.centroidXY=new De(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 De(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new De(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new De(0,0)}span(){return new De(this.max.x-this.min.x,this.max.y-this.min.y)}}class Bm{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,t){const n=e.data.length,s=new Float64Array(15*n);for(let l=0;l<n;l++){const c=e.data[l],h=15*l;s[h]=c.centroidXY.x,s[h+1]=c.centroidXY.y,s[h+2]=c.min.x,s[h+3]=c.min.y,s[h+4]=c.max.x,s[h+5]=c.max.y,s[h+6]=c.groupCentroidPos.x,s[h+7]=c.groupCentroidPos.y,s[h+8]=c.vertexArrayOffset,s[h+9]=c.vertexCount,s[h+10]=c.groundVertexArrayOffset,s[h+11]=c.groundVertexCount,s[h+12]=c.footprintSegLen,s[h+13]=c.height,s[h+14]=c.buildingId}return t&&t.add(s.buffer),{buffer:s}}static deserialize(e){const t=e.buffer,n=t.length/15,s=new Bm;s.buffer=t;const l=[];l.length=n,s.data=l;let c=0;for(let h=0;h<n;h++){const p=15*h,_=new Om;_.centroidXY=new De(t[p],t[p+1]),_.min=new De(t[p+2],t[p+3]),_.max=new De(t[p+4],t[p+5]),_.groupCentroidPos=new De(t[p+6],t[p+7]),_.vertexArrayOffset=t[p+8],_.vertexCount=t[p+9],_.groundVertexArrayOffset=t[p+10],_.groundVertexCount=t[p+11],_.footprintSegLen=t[p+12],_.height=t[p+13],_.buildingId=t[p+14],_.footprintSegIdx=c,c+=_.footprintSegLen,s.data[h]=_}return s}}class Xg{constructor(){this.acc=new De(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y)}appendEdge(e,t,n){this.accCount++,this.acc._add(t);let s=!!this.borders;t.x<e.min.x?(e.min.x=t.x,s=!0):t.x>e.max.x&&(e.max.x=t.x,s=!0),t.y<e.min.y?(e.min.y=t.y,s=!0):t.y>e.max.y&&(e.max.y=t.y,s=!0),((t.x===0||t.x===qe)&&t.x===n.x)!=((t.y===0||t.y===qe)&&t.y===n.y)&&this.processBorderOverlap(t,n),s&&this.checkBorderIntersection(t,n)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,lt(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>qe!=e.x>qe&&this.addBorderIntersection(1,lt(t.y,e.y,(qe-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,lt(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>qe!=e.y>qe&&this.addBorderIntersection(3,lt(t.x,e.x,(qe-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){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]]);const n=this.borders[e];t<n[0]&&(n[0]=t),t>n[1]&&(n[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const n=e.x===0?0:1;this.addBorderIntersection(n,t.y),this.addBorderIntersection(n,e.y)}else{const n=e.y===0?2:3;this.addBorderIntersection(n,t.x),this.addBorderIntersection(n,e.x)}}centroid(){return this.accCount===0?new De(0,0):new De(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,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function jv(i,e){const t=i.add(e)._unit(),n=vt(i.x*t.x+i.y*t.y,-1,1);var s,l,c;return c=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(c)))/4*hE*((s=i).x*(l=e).y-s.y*l.x<0?-1:1)}const dE=[i=>i.x<0,i=>i.x>qe,i=>i.y<0,i=>i.y>qe];function fE(i,e,t,n){const s=[4];if(n===0)return s;t._mult(n);const l=i.sub(t),c=e.sub(t),h=[i,e,l,c];for(let p=0;p<4;p++)for(const _ of h)if(dE[p](_)){s.push(p);break}return s}class Yg{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new Ye,this.indexArray=new _t,this.programConfigurations=new ta(e.layers,{zoom:e.zoom,lut:e.lut},t=>cE.includes(t)),this._segments=new li,this.hiddenByLandmarkVertexArray=new go,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new li}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(e,t,n,s=!1){const l=e.length;if(l>2){let c=Math.max(0,this._segments.get().length-1);const h=this._segments._prepareSegment(4*l,this.vertexArray.length,2*this._segmentToGroundQuads[c].length);let p;c!==this._segments.get().length-1&&(c++,this._segmentToGroundQuads[c]=[],this._segmentToRegionTriCounts[c]=[0,0,0,0,0]);{const _=e[0],y=e[1];p=jv(_.sub(e[l-1])._perp()._unit(),y.sub(_)._perp()._unit())}for(let _=0;_<l;_++){const y=_===l-1?0:_+1,v=e[_],b=e[y],T=e[y===l-1?0:y+1],S=b.sub(v)._perp()._unit(),A=jv(S,T.sub(b)._perp()._unit()),C=p,D=A;if(Jg(v,b,t)||s&&Zv(v,t)&&Zv(b,t)){p=A;continue}const z=h.vertexLength;zm(this.vertexArray,v,b,1,1,C),zm(this.vertexArray,v,b,1,0,C),zm(this.vertexArray,v,b,0,1,D),zm(this.vertexArray,v,b,0,0,D),h.vertexLength+=4;const O=fE(v,b,S,n);for(const F of O)this._segmentToGroundQuads[c].push({id:z,region:F}),this._segmentToRegionTriCounts[c][F]+=2,h.primitiveLength+=2;p=A}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),t=e.length;for(let n=0;n<t;n++)this._segmentToGroundQuads[n].sort((s,l)=>s.region-l.region);for(let n=0;n<t;n++){const s=this._segmentToGroundQuads[n],l=e[n],c=this._segmentToRegionTriCounts[n];c.reduce((p,_)=>p+_,0);let h=0;for(let p=0;p<=4;p++){const _=c[p];if(_!==0){let y=this.regionSegments[p];y||(y=this.regionSegments[p]=new li);const v={vertexOffset:l.vertexOffset,primitiveOffset:l.primitiveOffset+h,vertexLength:l.vertexLength,primitiveLength:_};y.get().push(v)}h+=_}for(let p=0;p<s.length;p++){const _=s[p].id;this.indexArray.emplaceBack(_,_+1,_+3),this.indexArray.emplaceBack(_,_+3,_+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,t,n,s,l,c,h){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,t,n,s,l,c,void 0,h)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,tE.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.groundRadiusArray!=null&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,iE.members)))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,t,n,s,l,c,h,p){this.hasData()&&this.programConfigurations.updatePaintArrays(e,t,n,s,l,c,h,p)}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&zl||e.flags&Lm))}updateHiddenByLandmarkRange(e,t,n){if(!this.hasData())return;const s=t+e;if(t!==0){for(let l=e;l<s;++l)this.hiddenByLandmarkVertexArray.emplace(l,n?1:0);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,oE.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++){const t=this.regionSegments[e];t&&t.destroy()}}}}class km{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(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new Bm,this.footprintIndices=new _t,this.footprintVertices=new Re,this.footprintSegments=new Fm,this.layoutVertexArray=new tt,this.centroidVertexArray=new Vr,this.wallVertexArray=new es,this.indexArray=new _t,this.programConfigurations=new ta(e.layers,{zoom:e.zoom,lut:e.lut},t=>lE.includes(t)),this.segments=new li,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.groundEffect=new Yg(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,n,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,n,s){this.features=[],this.hasPattern=Gd("fill-extrusion",this.layers,this.pixelRatio,t),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=B(n),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(const{feature:l,id:c,index:h,sourceLayerIndex:p}of e){const _=this.layers[0]._featureFilter.needGeometry,y=_e(l,_);if(!this.layers[0]._featureFilter.filter(new zi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),y,n))continue;const v={id:c,sourceLayerIndex:p,index:h,geometry:_?y.geometry:ce(l,n,s),properties:l.properties,type:l.type,patterns:{}},b=this.layoutVertexArray.length,T=Wg[v.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:l.id,feature:Hd("fill-extrusion",this.layers,v,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const S of v.geometry)for(const A of Vv(S,T))this.addFeature(l.id,v,[A],h,n,{},t.availableImages,s,t.brightness);else this.addFeature(l.id,v,v.geometry,h,n,{},t.availableImages,s,t.brightness);t.featureIndex.insert(l,v.geometry,h,p,this.index,b)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,n,s,l,c){for(const{featureId:h,feature:p}of this.features){const _=Wg[p.type]==="Polygon",{geometry:y}=p;if(this.wallMode)for(const v of y)for(const b of Vv(v,_))this.addFeature(h,p,[b],p.index,t,n,s,l,c);else this.addFeature(h,p,y,p.index,t,n,s,l,c)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(e,t,n,s,l,c,h){this.programConfigurations.updatePaintArrays(e,t,l,n,s,c,h,this.worldview),this.groundEffect.update(e,t,l,n,s,c,h,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,aE),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,nE.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,sE.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,rE.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,t,n,s,l,c,h,p,_){const y=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,v=[new De(0,0),new De(qe,qe)],b=p.projection,T=b.name==="globe",S=this.wallMode||Wg[t.type]==="Polygon",A=new Xg;A.centroidDataIndex=this.centroidData.length;const C=new Om;C.buildingId=e,t.properties&&Object.hasOwn(t.properties,"building_id")&&(C.buildingId=Number(t.properties.building_id)),A.buildingId=C.buildingId;const D=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},l)<=0,z=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},l);let O;if(C.height=z,C.vertexArrayOffset=this.layoutVertexArray.length,C.groundVertexArrayOffset=this.groundEffect.vertexArray.length,T&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new ft),this.wallMode){if(T)return void _i("Non zero fill-extrusion-line-width is not yet supported on globe.");if(n.length!==1)return;O=function(K){const ee=K[0].x===K.at(-1).x&&K[0].y===K.at(-1).y;(function(Be){let ke=0;const Ke=Be.length;for(let Ve=0;Ve<Ke;Ve++)ke+=(Be[(Ve+1)%Ke].x-Be[Ve].x)*(Be[(Ve+1)%Ke].y+Be[Ve].y);return ke>=0})(K)||(K=K.reverse());const he={geometry:[],joinNormals:[],indices:[]},be=[],xe=[],Te=[];let Fe=K.length;for(;Fe>=2&&K[Fe-1].equals(K[Fe-2]);)Fe--;if(Fe<(ee?3:2))return he;let se,fe,ge,Ae,Me,ze=0;for(;ze<Fe-1&&K[ze].equals(K[ze+1]);)ze++;ee&&(se=K[Fe-2],Me=K[ze].sub(se)._unit()._perp());for(let Be=ze;Be<Fe;Be++){if(ge=Be===Fe-1?ee?K[ze+1]:void 0:K[Be+1],ge&&K[Be].equals(ge))continue;Me&&(Ae=Me),se&&(fe=se),se=K[Be],Me=ge?ge.sub(se)._unit()._perp():Ae,Ae=Ae||Me;let ke=Ae.add(Me);ke.x===0&&ke.y===0||ke._unit();const Ke=ke.x*Me.x+ke.y*Me.y,Ve=Ke!==0?1/Ke:1/0,$e=Ae.x*Me.y-Ae.y*Me.x>0;let dt="miter";const pt=2;dt==="miter"&&Ve>pt&&(dt="bevel"),dt==="bevel"&&(Ve>100&&(dt="flipbevel"),Ve<pt&&(dt="miter"));const yt=(ht,wt,bt,ri)=>{const jt=new De(ht.x,ht.y),Qt=new De(ht.x,ht.y);jt.x+=wt.x*ri,jt.y+=wt.y*ri,Qt.x-=wt.x*Math.max(bt,1),Qt.y-=wt.y*Math.max(bt,1),Te.push(wt),be.push(jt),xe.push(Qt)};if(dt==="miter")ke._mult(Ve),yt(se,ke,0,0);else if(dt==="flipbevel")ke=Me.mult(-1),yt(se,ke,0,0),yt(se,ke.mult(-1),0,0);else{const ht=-Math.sqrt(Ve*Ve-1),wt=$e?ht:0,bt=$e?0:ht;fe&&yt(se,Ae,wt,bt),ge&&yt(se,Me,wt,bt)}}he.geometry=[...be,...xe.reverse(),be[0]],he.joinNormals=[...Te,...Te.reverse(),Te.at(-1)];const Ce=he.geometry.length-1;for(let Be=0;Be<Ce/2;Be++)if(Be+1<Ce/2){let ke=Be,Ke=Be+1,Ve=Ce-1-Be,$e=Ce-2-Be;ke=ke===0?Ce-1:ke-1,Ke=Ke===0?Ce-1:Ke-1,Ve=Ve===0?Ce-1:Ve-1,$e=$e===0?Ce-1:$e-1,he.indices.push(Ve),he.indices.push(Ke),he.indices.push(ke),he.indices.push(Ve),he.indices.push($e),he.indices.push(Ke)}return he}(n[0]),n=[O.geometry]}const F=(K,ee)=>K<(ee.length-1)/2||K===ee.length-1,N=this.wallMode?[n]:Ei(n,500);for(let K=N.length-1;K>=0;K--){const ee=N[K];(ee.length===0||_E(ee[0]))&&N.splice(K,1)}let j;if(T)j=Xv(N,v,l);else{j=[];for(const K of N)j.push({polygon:K,bounds:v})}const te=S?this.edgeRadius:0,H=te>0&&this.zoom<17,W=(K,ee)=>{if(K.length===0)return!1;const ae=K.at(-1);return ee.x===ae.x&&ee.y===ae.y};for(const{polygon:K,bounds:ee}of j){let ae=0,he=0;for(const Fe of K)S&&!Fe[0].equals(Fe.at(-1))&&Fe.push(Fe[0]),he+=S?Fe.length-1:Fe.length;const be=this.segments.prepareSegment((S?5:4)*he,this.layoutVertexArray,this.indexArray);C.footprintSegIdx<0&&(C.footprintSegIdx=this.footprintSegments.length),C.polygonSegIdx<0&&(C.polygonSegIdx=this.polygonSegments.length);const xe={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Te=new Uv;if(Te.vertexOffset=this.footprintVertices.length,Te.indexOffset=3*this.footprintIndices.length,Te.ringIndices=[],S){const Fe=[],se=[];ae=be.vertexLength;for(let ge=0;ge<K.length;ge++){const Ae=K[ge];Ae.length&&ge!==0&&se.push(Fe.length/2);const Me=[];let ze,Ce;ze=Ae[1].sub(Ae[0])._perp()._unit(),Te.ringIndices.push(Ae.length-1);for(let Be=1;Be<Ae.length;Be++){const ke=Ae[Be],Ke=Ae[Be===Ae.length-1?1:Be+1],Ve=ke.clone();if(te){Ce=Nm(ke,Ke,ze);const $e=Gv(ze,Ce),dt=Kg(ze,Ce),pt=te*Math.min(4,1/dt);Ve.x+=pt*$e.x,Ve.y+=pt*$e.y,Ve.x=Math.round(Ve.x),Ve.y=Math.round(Ve.y),ze=Ce}if(!D||te!==0&&!H||W(Me,Ve)||Me.push(Ve),_f(this.layoutVertexArray,Ve.x,Ve.y,0,0,1,1,0),this.wallMode){const $e=F(Be,Ae);gf(this.wallVertexArray,O.joinNormals[Be],!$e)}be.vertexLength++,this.footprintVertices.emplaceBack(ke.x,ke.y),Fe.push(ke.x,ke.y),T&&yf(this.layoutVertexExtArray,b.projectTilePoint(Ve.x,Ve.y,l),b.upVector(l,Ve.x,Ve.y))}D&&(te===0||H)&&(Me.length!==0&&W(Me,Me[0])&&Me.pop(),this.groundEffect.addData(Me,ee,y))}const fe=this.wallMode?O.indices:ea(Fe,se);for(let ge=0;ge<fe.length;ge+=3)this.footprintIndices.emplaceBack(Te.vertexOffset+fe[ge+0],Te.vertexOffset+fe[ge+1],Te.vertexOffset+fe[ge+2]),this.indexArray.emplaceBack(ae+fe[ge],ae+fe[ge+2],ae+fe[ge+1]),be.primitiveLength++;Te.indexCount+=fe.length,Te.vertexCount+=this.footprintVertices.length-Te.vertexOffset}for(let Fe=0;Fe<K.length;Fe++){const se=K[Fe];A.startRing(C,se[0]);let fe=se.length>4&&$v(se[se.length-2],se[0],se[1]),ge=te?mE(se[se.length-2],se[0],se[1],te):0;const Ae=[];let Me,ze,Ce;ze=se[1].sub(se[0])._perp()._unit();let Be=!0;for(let ke=1,Ke=0;ke<se.length;ke++){let Ve=se[ke-1],$e=se[ke];const dt=se[ke===se.length-1?1:ke+1];if(A.appendEdge(C,$e,Ve),Jg($e,Ve,ee)){te&&(ze=dt.sub($e)._perp()._unit(),Be=!Be);continue}const pt=$e.sub(Ve)._perp(),yt=pt.x/(Math.abs(pt.x)+Math.abs(pt.y)),ht=pt.y>0?1:0,wt=Ve.dist($e);if(Ke+wt>32768&&(Ke=0),te){Ce=Nm($e,dt,ze);let Qt=Hv(Ve,$e,dt,Kg(ze,Ce),te);isNaN(Qt)&&(Qt=0);const ui=pE(Ve,$e,new De(0,0));Ve=Ve.add(ui.mult(ge))._round(),$e=$e.add(ui.mult(-Qt))._round(),ge=Qt,ze=Ce,D&&this.zoom>=17&&(W(Ae,Ve)||Ae.push(Ve),W(Ae,$e)||Ae.push($e))}const bt=be.vertexLength,ri=se.length>4&&$v(Ve,$e,dt);let jt=qv(Ke,fe,Be);if(_f(this.layoutVertexArray,Ve.x,Ve.y,yt,ht,0,0,jt),_f(this.layoutVertexArray,Ve.x,Ve.y,yt,ht,0,1,jt),this.wallMode){const Qt=F(ke-1,se),ui=O.joinNormals[ke-1];gf(this.wallVertexArray,ui,Qt),gf(this.wallVertexArray,ui,Qt)}if(Ke+=wt,jt=qv(Ke,ri,!Be),fe=ri,_f(this.layoutVertexArray,$e.x,$e.y,yt,ht,0,0,jt),_f(this.layoutVertexArray,$e.x,$e.y,yt,ht,0,1,jt),this.wallMode){const Qt=F(ke,se),ui=O.joinNormals[ke];gf(this.wallVertexArray,ui,Qt),gf(this.wallVertexArray,ui,Qt)}if(be.vertexLength+=4,this.indexArray.emplaceBack(bt+0,bt+1,bt+2),this.indexArray.emplaceBack(bt+1,bt+3,bt+2),be.primitiveLength+=2,te){const Qt=ae+(ke===1?se.length-2:ke-2),ui=ke===1?ae:Qt+1;if(this.indexArray.emplaceBack(bt+1,Qt,bt+3),this.indexArray.emplaceBack(Qt,ui,bt+3),be.primitiveLength+=2,Me===void 0&&(Me=bt),!Jg(dt,se[ke],ee)){const Rr=ke===se.length-1?Me:be.vertexLength;this.indexArray.emplaceBack(bt+2,bt+3,Rr),this.indexArray.emplaceBack(bt+3,Rr+1,Rr),this.indexArray.emplaceBack(bt+3,ui,Rr+1),be.primitiveLength+=3}Be=!Be}if(T){const Qt=this.layoutVertexExtArray,ui=b.projectTilePoint(Ve.x,Ve.y,l),Rr=b.projectTilePoint($e.x,$e.y,l),Uo=b.upVector(l,Ve.x,Ve.y),ur=b.upVector(l,$e.x,$e.y);yf(Qt,ui,Uo),yf(Qt,ui,Uo),yf(Qt,Rr,ur),yf(Qt,Rr,ur)}}S&&(ae+=se.length-1),D&&te&&this.zoom>=17&&(Ae.length!==0&&W(Ae,Ae[0])&&Ae.pop(),this.groundEffect.addData(Ae,ee,y,te>0))}this.footprintSegments.push(Te),xe.triangleCount=this.indexArray.length-xe.triangleArrayOffset,this.polygonSegments.push(xe),++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=A.borders?Dm:this.encodeCentroid(A,C),t.properties&&Object.hasOwn(t.properties,"building_id")){const K=C.buildingId;let ee=this.buildingGroups.get(K);ee||(ee={accX:0,accY:0,accCount:0,mergedMin:new De(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new De(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(K,ee)),ee.accX+=A.acc.x,ee.accY+=A.acc.y,ee.accCount+=A.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),A.borders){this.featuresOnBorder.push(A);const K=this.featuresOnBorder.length-1;for(let ee=0;ee<A.borders.length;ee++)A.borders[ee][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[ee].push(K)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,c,h,l,_,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(t,s,c,h,l,_,this.worldview),this.maxHeight=Math.max(this.maxHeight,z)}}_finalizeBuildingGroups(){for(const[,e]of this.buildingGroups){if(e.partIndices.length===0)continue;const t=new Xg;t.acc=new De(e.accX,e.accY),t.accCount=e.accCount;const n=new Om;n.min=e.mergedMin,n.max=e.mergedMax;const s=this.encodeCentroid(t,n),l=t.centroid();for(const c of e.partIndices){const h=this.centroidData.get(c);h.centroidXY.x===Dm.x&&h.centroidXY.y===Dm.y||(h.centroidXY=s),h.min=e.mergedMin,h.max=e.mergedMax,h.groupCentroidPos=l}}this.buildingGroups.clear()}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((t,n)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}splitToSubtiles(){const e=[];for(let h=0;h<this.centroidData.length;h++){const p=this.centroidData.get(h),_=+(p.min.y+p.max.y>qe),y=2*_+(+(p.min.x+p.max.x>qe)^_);for(let v=0;v<p.polygonSegLen;v++){const b=p.polygonSegIdx+v;e.push({centroidIdx:h,subtile:y,polygonSegmentIdx:b,triangleSegmentIdx:this.polygonSegments[b].triangleSegIdx})}}const t=new _t;e.sort((h,p)=>h.triangleSegmentIdx===p.triangleSegmentIdx?h.subtile-p.subtile:h.triangleSegmentIdx-p.triangleSegmentIdx);let n=0,s=0,l=0;for(const h of e){if(h.triangleSegmentIdx!==n)break;l++}const c=e.length;for(;s!==e.length;){n=e[s].triangleSegmentIdx;let h=0,p=s,_=s;for(let y=p;y<l&&e[y].subtile===h;y++)_++;for(;p!==l;){const y=e[p];h=y.subtile;const v=this.centroidData.get(y.centroidIdx).min.clone(),b=this.centroidData.get(y.centroidIdx).max.clone(),T={vertexOffset:this.segments.segments[n].vertexOffset,primitiveOffset:t.length,vertexLength:this.segments.segments[n].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let S=p;S<_;S++){const A=e[S],C=this.polygonSegments[A.polygonSegmentIdx],D=this.centroidData.get(A.centroidIdx).min,z=this.centroidData.get(A.centroidIdx).max,O=this.indexArray.uint16;for(let F=C.triangleArrayOffset;F<C.triangleArrayOffset+C.triangleCount;F++)t.emplaceBack(O[3*F],O[3*F+1],O[3*F+2]);T.primitiveLength+=C.triangleCount,v.x=Math.min(v.x,D.x),v.y=Math.min(v.y,D.y),b.x=Math.max(b.x,z.x),b.y=Math.max(b.y,z.y)}T.primitiveLength>0&&this.triangleSubSegments.push({segment:T,min:v,max:b}),p=_;for(let S=p;S<l&&e[S].subtile===e[p].subtile;S++)_++}s=l;for(let y=s;y<c&&e[y].triangleSegmentIdx===e[s].triangleSegmentIdx;y++)l++}t._trim(),this.indexArray=t}getVisibleSegments(e,t,n){const s=new li;if(this.wallMode){for(const A of this.triangleSubSegments)s.segments.push(A.segment);return s}let l=0,c=0;const h=1<<e.canonical.z;if(t){const A=t.getMinMaxForTile(e);A&&(l=A.min,c=A.max)}c+=this.maxHeight;const p=e.toUnwrapped();let _;const y=[p.canonical.x/h+p.wrap,p.canonical.y/h],v=[(p.canonical.x+1)/h+p.wrap,(p.canonical.y+1)/h],b=(A,C,D)=>[lt(A[0],C[0],D[0]),lt(A[1],C[1],D[1])],T=[],S=[];for(const A of this.triangleSubSegments){T[0]=A.min.x/qe,T[1]=A.min.y/qe,S[0]=A.max.x/qe,S[1]=A.max.y/qe;const C=b(y,v,T),D=b(y,v,S);if(new Di([C[0],C[1],l],[D[0],D[1],c]).intersectsPrecise(n)===0){_&&(s.segments.push(_),_=void 0);continue}const z=A.segment;_&&_.vertexOffset!==z.vertexOffset&&(s.segments.push(_),_=void 0),_?(_.vertexLength+=z.vertexLength,_.primitiveLength+=z.primitiveLength):_={vertexOffset:z.vertexOffset,primitiveLength:z.primitiveLength,vertexLength:z.vertexLength,primitiveOffset:z.primitiveOffset,sortKey:void 0,vaos:{}}}return _&&s.segments.push(_),s}encodeCentroid(e,t){const n=e.centroid(),s=t.span(),l=Math.min(7,Math.round(s.x*this.tileToMeter/10)),c=Math.min(6,Math.round(s.y*this.tileToMeter/10));return new De(vt(n.x,1,8191)<<3|l,vt(n.y,1,8191)<<3|c)}encodeBorderCentroid(e){if(!e.borders)return new De(0,0);const t=e.borders,n=Number.MAX_VALUE;if(t[0][0]!==n||t[1][0]!==n){const s=t[0][0]!==n?0:1;return new De(6|(t[0][0]!==n?0:65528),(t[s][0]+t[s][1])/2<<3|6)}{const s=t[2][0]!==n?2:3;return new De((t[s][0]+t[s][1])/2<<3|6,6|(t[2][0]!==n?0:65528))}}showCentroid(e){const t=this.centroidData.get(e.centroidDataIndex);if(t.flags&=zl,t.groupCentroidPos.x!==0||t.groupCentroidPos.y!==0){const n=t.span(),s=Math.min(7,Math.round(n.x*this.tileToMeter/10)),l=Math.min(6,Math.round(n.y*this.tileToMeter/10));t.centroidXY=new De(vt(t.groupCentroidPos.x,1,8191)<<3|s,vt(t.groupCentroidPos.y,1,8191)<<3|l)}else t.centroidXY=new De(0,0);this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,n=e.vertexCount+e.vertexArrayOffset,s=-1073741824&e.flags?Dm:e.centroidXY,l=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==s.y||l!==s.x){for(let c=t;c<n;++c)this.centroidVertexArray.emplace(c,s.x,s.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e)}updateReplacement(e,t,n){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const s=t.getReplacementRegionsForTile(e.toUnwrapped());if(rm(this.activeReplacements,s))return;if(this.activeReplacements=s,this.centroidVertexArray.length===0)this.createCentroidsBuffer();else for(const c of this.centroidData)c.flags&=1073741823;const l=[];for(const c of this.activeReplacements){if(c.order<n)continue;const h=Math.max(1,Math.pow(2,c.footprintTileId.canonical.z-e.canonical.z));if(c.footprint.buildingIds)for(const p of this.centroidData)p.flags&zl||p.flags&Lm||c.min.x>p.max.x||p.min.x>c.max.x||c.min.y>p.max.y||p.min.y>c.max.y||c.footprint.buildingIds.has(p.buildingId)&&(p.flags|=c.clipMask!==Pm.None?-1073741824:zl);else for(const p of this.centroidData)if(!(p.flags&zl||p.flags&Lm||c.min.x>p.max.x||p.min.x>c.max.x||c.min.y>p.max.y||p.min.y>c.max.y))for(let _=0;_<p.footprintSegLen;_++){const y=this.footprintSegments.get(p.footprintSegIdx+_);if(l.length=0,gE(this.footprintVertices,y.vertexOffset,y.vertexCount,c.footprintTileId.canonical,e.canonical,l),_g(c.footprint,l,this.footprintIndices.uint16,y.indexOffset,y.indexCount,-y.vertexOffset,-h)){p.flags|=c.clipMask!==Pm.None?-1073741824:zl;break}}}for(const c of this.centroidData)this.writeCentroidToBuffer(c);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,t,n){let s=!1;for(let l=0;l<n.footprintSegLen;l++){const c=this.footprintSegments.get(n.footprintSegIdx+l);let h=0;for(const p of c.ringIndices){for(let _=h,y=p+h-1;_<p+h;y=_++){const v=this.footprintVertices.int16[2*(_+c.vertexOffset)+0],b=this.footprintVertices.int16[2*(_+c.vertexOffset)+1],T=this.footprintVertices.int16[2*(y+c.vertexOffset)+1];b>t!=T>t&&e<(this.footprintVertices.int16[2*(y+c.vertexOffset)+0]-v)*(t-b)/(T-b)+v&&(s=!s)}h=p}}return s}getHeightAtTileCoord(e,t){let n=Number.NEGATIVE_INFINITY,s=!0;const l=4*(e+qe)*qe+(t+qe);if(Object.hasOwn(this.partLookup,l)){const p=this.partLookup[l];return p?{height:p.height,hidden:!!(p.flags&zl)}:void 0}const c=this.centroidData.buffer,h=this.centroidData.length;for(let p=0;p<h;p++){const _=15*p;if(e>c[_+4]||c[_+2]>e||t>c[_+5]||c[_+3]>t)continue;const y=c[_+13];if(y<=n)continue;const v=this.centroidData.get(p);this.footprintContainsPoint(e,t,v)&&(n=y,this.partLookup[l]=v,s=!!(v.flags&zl))}if(n!==Number.NEGATIVE_INFINITY)return{height:n,hidden:s};this.partLookup[l]=void 0}}function pE(i,e,t){return i.equals(e)?t:e.sub(i)._unit()}function Nm(i,e,t){return i.equals(e)?t:e.sub(i)._perp()._unit()}function Gv(i,e){const t=i.add(e),n=t.mag();return n===0?i:t.div(n)}function Kg(i,e){const t=Gv(i,e);return i.x*t.x+i.y*t.y}function mE(i,e,t,n){let s,l;return i.equals(e)?(l=Nm(e,t,new De(0,0)),s=l):(s=e.sub(i)._perp()._unit(),l=Nm(e,t,s)),Hv(i,e,t,Kg(s,l),n)}function Hv(i,e,t,n,s){const l=Math.sqrt(1-n*n);return Math.min(i.dist(e)/3,e.dist(t)/3,s*l/n)}function Jg(i,e,t){return i.x<t[0].x&&e.x<t[0].x||i.x>t[1].x&&e.x>t[1].x||i.y<t[0].y&&e.y<t[0].y||i.y>t[1].y&&e.y>t[1].y}function Zv(i,e){return i.x<e[0].x||i.x>e[1].x||i.y<e[0].y||i.y>e[1].y}function _E(i){return i.every(e=>e.x<=0)||i.every(e=>e.x>=qe)||i.every(e=>e.y<=0)||i.every(e=>e.y>=qe)}function $v(i,e,t){if(i.x<0||i.x>=qe||e.x<0||e.x>=qe||t.x<0||t.x>=qe)return!1;const n=t.sub(e),s=n.perp(),l=i.sub(e);return(n.x*l.x+n.y*l.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(l.x*l.x+l.y*l.y))>-.866&&s.x*l.x+s.y*l.y<0}function qv(i,e,t){const n=e?2|i:-3&i;return t?1|n:-2&n}function Wv(){const i=Math.PI/32,e=Math.tan(i),t=o;return t*Math.sqrt(1+2*e*e)-t}function Xv(i,e,t){const n=1<<t.z,s=qn(t.x/n),l=qn((t.x+1)/n),c=vr(t.y/n),h=vr((t.y+1)/n);return function(p,_,y,v,b=0,T){const S=[];if(!p.length||!y||!v)return S;const A=(j,te)=>{for(const H of j)S.push({polygon:H,bounds:te})},C=Math.ceil(Math.log2(y)),D=Math.ceil(Math.log2(v)),z=C-D,O=[];for(let j=0;j<Math.abs(z);j++)O.push(z>0?0:1);for(let j=0;j<Math.min(C,D);j++)O.push(0),O.push(1);let F=p;if(F=Rm(F,_[0].y-b,_[1].y+b,1),F=Rm(F,_[0].x-b,_[1].x+b,0),!F.length)return S;const N=[];for(O.length?N.push({polygons:F,bounds:_,depth:0}):A(F,_);N.length;){const j=N.pop(),te=j.depth,H=O[te],W=j.bounds[0],K=j.bounds[1],ee=H===0?W.x:W.y,ae=H===0?K.x:K.y,he=T?T(H,ee,ae):.5*(ee+ae),be=Rm(j.polygons,ee-b,he+b,H),xe=Rm(j.polygons,he-b,ae+b,H);if(be.length){const Te=[W,new De(H===0?he:K.x,H===1?he:K.y)];O.length>te+1?N.push({polygons:be,bounds:Te,depth:te+1}):A(be,Te)}if(xe.length){const Te=[new De(H===0?he:W.x,H===1?he:W.y),K];O.length>te+1?N.push({polygons:xe,bounds:Te,depth:te+1}):A(xe,Te)}}return S}(i,e,Math.ceil((l-s)/11.25),Math.ceil((c-h)/11.25),1,(p,_,y)=>{if(p===0)return .5*(_+y);{const v=vr((t.y+_/qe)/n);return($n(.5*(vr((t.y+y/qe)/n)+v))*n-t.y)*qe}})}function gE(i,e,t,n,s,l){const c=Math.pow(2,n.z-s.z);for(let h=0;h<t;h++){let p=i.int16[2*(h+e)+0],_=i.int16[2*(h+e)+1];p=(p+s.x*qe)*c-n.x*qe,_=(_+s.y*qe)*c-n.y*qe,l.push(new De(p,_))}}et(km,"FillExtrusionBucket",{omit:["layers","features"]}),et(Om,"PartData"),et(Bm,"PartDataArray"),et(Fm,"FootprintSegmentArray"),et(Xg,"BorderCentroidData"),et(Yg,"GroundEffect");const Qg=4096;class yE{constructor(e){this.module=e,this.memoryStack=this.module.malloc(Qg),this.memoryStackNextFree=this.memoryStack}createIntArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Qg?-1:(new Int32Array(this.module.heap32.buffer,t,e.length).set(e),t)}createFloatArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Qg?-1:(new Float32Array(this.module.heapF32.buffer,t,e.length).set(e),t)}readStringBuffer(e){let t="";for(;this.module.heapU8[e]!==0;)t+=String.fromCharCode(this.module.heapU8[e]),++e;return t}setStyle(e){const t=e.normalScale;this.module.setStyle(t[0],t[1],t[2],e.tileToMeters)}setAOOptions(e,t){this.module.setAOOptions(e?1:0,t)}setMetricOptions(e,t){this.module.setMetricOptions(e?1:0,t)}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0)}setFacadeOptions(e,t){this.module.setFacadeOptions(e,t?1:0)}setFauxFacadeOptions(e,t,n){this.module.setFauxFacadeOptions(e?1:0,t?1:0,n)}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e)}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const h of e){const p=this.createIntArray(h.ringIndices),_=this.createFloatArray(h.coordinates);if(p===-1||_===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(h.id,h.sourceId,h.minHeight,h.height,h.roofType,_,p,h.ringIndices.length-1)}for(const h of t){let p;p=h.entrances?JSON.parse(h.entrances):[];const _=this.createFloatArray(p),y=this.createFloatArray(h.coordinates);if(_===-1||y===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(h.sourceId,h.crossPerc,h.distanceToRoad,_,p.length,y,h.coordinates.length)}if(!this.module.generateMesh()){const h=this.module.getLastError();return this.readStringBuffer(h)}const n=this.module.getMeshCount(),s=new Array(n);for(let h=0;h<n;h++){const p=this.module.getPositionsPtr(h),_=this.module.getPositionsLength(h),y=new Float32Array(this.module.heapF32.buffer,p,_),v=this.module.getNormalsPtr(h),b=this.module.getNormalsLength(h),T=new Float32Array(this.module.heapF32.buffer,v,b),S=this.module.getAOPtr(h),A=this.module.getAOLength(h),C=new Float32Array(this.module.heapF32.buffer,S,A),D=this.module.getUVPtr(h),z=this.module.getUVLength(h),O=new Float32Array(this.module.heapF32.buffer,D,z),F=this.module.getFauxFacadePtr(h),N=this.module.getFauxFacadeLength(h),j=new Uint8Array(this.module.heapU8.buffer,F,N),te=this.module.getIndicesPtr(h),H=this.module.getIndicesLength(h),W=new Int16Array(this.module.heap16.buffer,te,H),K=this.module.getBuildingPart(h);s[h]={positions:y,normals:T,ao:C,uv:O,isFauxFacade:j,indices:W,buildingPart:K}}const l=this.module.getRingCount(),c=[];for(let h=0;h<l;h++){const p=this.module.getRingPtr(h),_=this.module.getRingLength(h),y=new Float32Array(this.module.heapF32.buffer,p,_);c.push(y)}return{meshes:s,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:c}}}const Yv=pc.types,Vm=32767;function xE(i,e){const t=qe+e;for(const n of i)for(const s of n)if(s.x<-e||s.x>t||s.y<-e||s.y>t)return!1;return!0}function vE(i){switch(i){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: ${i}`)}}let Kv,Jv,kh=null,Qv=null,xs=null;class ey{constructor(){this.layoutVertexArray=new We,this.layoutAttenuationArray=new xt,this.layoutColorArray=new Mt,this.indexArray=new _t,this.indexArrayForConflation=new _t,this.segmentsBucket=new li}}class ty{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new li,this.entranceBloom=new ey;const t=66560;this.layoutVertexArray=new We,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new Ue,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new Ue,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new Mt,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new Ar,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new go,this.layoutAOArray.reserve(t),this.indexArray=new _t,this.indexArray.reserve(66560),this.indexArrayForConflation=new _t,this.segmentsBucket=new li,this.entranceBloom=new ey,e&&(this.layoutFacadePaintArray=new Mt,this.layoutFacadeDataArray=new Je,this.layoutFacadeVerticalRangeArray=new Mt)}reserve(e,t,n){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(t),n&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e))}}class e0{constructor(e){this.requiresHDRuntime=!0,this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Ti,this.footprintsIndices=new ni,this.footprintsMin=new De(1/0,1/0),this.footprintsMax=new De(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new ty(!1),this.buildingWithFacade=new ty(!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(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new ta(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.projection=e.projection,this.groundEffect=new Yg(e),this.groundEffect.groundRadiusArray=new Oe,this.hasAppearances=null}updateFootprints(e,t){const n=new Sm([],[],1),s={vertices:[],indices:new Uint32Array(0),grid:n,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:s,id:e})}updateAppearances(e,t,n,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,n,s){if(!xs)return;const l=B(n);this.tileToMeter=l,this.brightness=t.brightness,xs.setStyle({normalScale:[1,-1,l],tileToMeters:l}),xs.setAOOptions(!1,.3),xs.setMetricOptions(!1,16),xs.setStructuralOptions(!0),xs.setFacadeClassifierOptions(3);const c=new Map,h=new Map;let p=0;for(const{feature:C}of e){if(Yv[C.type]!=="LineString"){c.set(C.id,C.properties.source_id);continue}const D=this.layers[0]._featureFilter.needGeometry;if(D&&!this.layers[0]._featureFilter.filter(new zi(this.zoom),C,n))continue;const z=_e(C,D);if(!D&&!this.layers[0]._featureFilter.filter(new zi(this.zoom),z,n))continue;const O=D?z.geometry:ce(C,n,s),F=[];for(const H of O)for(const W of H)F.push(W.x),F.push(W.y);const N={coordinates:F,crossPerc:C.properties.cross_perc,distanceToRoad:C.properties.distance_to_road,entrances:C.properties.entrances,sourceId:0},j=C.properties.source_id;let te=h.get(j);te||(te=[],h.set(j,te)),te.push(N),++p}this.maxHeight=0;const _=new Array,y=new Set,v=C=>{C!=null&&y.add(C)},b=(C,D)=>{C!=null&&_.push({buildingId:C,footprintIndex:D})},T=64*(e.length-p),S=T/2;this.buildingWithFacade.reserve(T,S,!0),this.buildingWithoutFacade.reserve(2*T,2*S,!1),this.footprintsIndices.reserve(16*(e.length-p)),this.footprintsVertices.reserve(8*(e.length-p));for(const{feature:C,id:D,index:z,sourceLayerIndex:O}of e){if(Yv[C.type]==="LineString")continue;const F=this.layers[0]._featureFilter.needGeometry;if(F&&!this.layers[0]._featureFilter.filter(new zi(this.zoom),C,n))continue;let N=null;if(C.properties&&Object.hasOwn(C.properties,"building_id")&&(N=Number(C.properties.building_id),y.has(N)))continue;const j=_e(C,F);if(!F&&!this.layers[0]._featureFilter.filter(new zi(this.zoom),j,n))continue;const te=F?j.geometry:ce(C,n,s),H=Ei(te,500);let W=!1;for(const Lt of H)if(Lt.length!==1){W=!0;break}if(W){v(N);continue}if(!xE(te,163)){v(N);continue}const K=this.layers[0],ee=vE(K.layout.get("building-roof-shape").evaluate(C,{},n)),ae=K.layout.get("building-base").evaluate(C,{},n),he=K.layout.get("building-height").evaluate(C,{},n),be=K.layout.get("building-flood-light-ground-radius").evaluate(C,{},n),xe=K.paint.get("building-ambient-occlusion-intensity"),Te=be/this.tileToMeter;C.properties["building-part"]="roof";const Fe=K.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),se=K.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="wall";const fe=K.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),ge=K.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="window";const Ae=K.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),Me=K.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);C.properties["building-part"]="door";const ze=K.paint.get("building-color").evaluate(C,{},this.canonical).toPremultipliedRenderColor(this.lut),Ce=K.paint.get("building-emissive-strength").evaluate(C,{},this.canonical);let Be=K.layout.get("building-flood-light-wall-radius").evaluate(C,{},n);Be=vt(Be,0,2048);const ke=Be/2048*Vm,Ke=c.get(D),Ve=h.get(Ke)||[],$e=Ve.length!==0&&K.layout.get("building-facade").evaluate(C,{},n);xs.setFacadeOptions(4,!0),xs.setFauxFacadeOptions($e,!1,1);let dt=0,pt=0,yt=0,ht=0,wt=0,bt=0,ri=0,jt=0,Qt=0,ui=0,Rr=0;if($e){let Lt=Math.round(K.layout.get("building-facade-floors").evaluate(C,{},n));if(ae===0){Lt=Math.max(1,Lt-(Ve.length>0?1:0));let Xi=4;if(he>100){const Dr=[10,13,15];Xi=Dr[C.id?C.id%Dr.length:0]}else he<=10&&(Xi=3);xs.setFacadeOptions(Xi,!0),wt=(he<15?1.3:1.61803)*Xi/l}else wt=ae/l;bt=he/l,wt=Math.min(wt,bt),yt=K.layout.get("building-facade-unit-width").evaluate(C,{},n)/l,ht=(bt-wt)/Lt,xs.setFauxFacadeOptions(!0,!0,yt);const _r=K.layout.get("building-facade-window").evaluate(C,{},n);dt=_r[0],pt=_r[1],ri=Math.floor(65535*Math.min(1,wt/qe)),jt=Math.floor(65535*Math.min(1,bt/qe)),Qt=Math.floor(255*dt)<<8|Math.floor(255*pt),ui=Math.floor(65535*Math.min(1,yt/qe)),Rr=Math.floor(65535*Math.min(1,ht/qe))}const Uo=Array(H.length),ur={x:1/0,y:1/0},Xt={x:-1/0,y:-1/0},Hi={x:0,y:0};let mr=0;for(let Lt=0;Lt<H.length;Lt++){const _r=H[Lt];if(_r.length>0){const Xi=[],Dr=Array(_r.length+1);Dr[0]=0;for(let Cn=0;Cn<_r.length;Cn++){const jo=_r[Cn];for(let ws=0;ws<jo.length;ws++){const Ts=jo[jo.length-ws-1];ur.x=Math.min(ur.x,Ts.x),ur.y=Math.min(ur.y,Ts.y),Xt.x=Math.max(Xt.x,Ts.x),Xt.y=Math.max(Xt.y,Ts.y),Hi.x+=Ts.x,Hi.y+=Ts.y,mr++,Xi.push(Ts.x),Xi.push(Ts.y)}Dr[Cn+1]=Xi.length}Uo[Lt]={id:C.id?C.id:0,height:he,minHeight:ae,sourceId:0,roofType:ee,coordinates:Xi,ringIndices:Dr}}}Hi.x/=mr||1,Hi.y/=mr||1;const Pr=xs.generateMesh(Uo,Ve);if(typeof Pr=="string"){_i(`Unable to generate building ${C.id}: ${Pr}`),v(N);continue}if(Pr.meshes.length===0||Pr.modifiedPolygonRings.length===0){v(N);continue}const St=$e?this.buildingWithFacade:this.buildingWithoutFacade;let Jr=0;for(const Lt of Pr.meshes)Jr+=Lt.positions.length/3;const Qr=St.segmentsBucket.prepareSegment(Jr,St.layoutVertexArray,St.indexArray),Bn=[];let kn=null,xo=0,vo=-1;const _n=St.layoutVertexArray.length,sn=_n+Jr;St.layoutVertexArray.resize(sn),St.layoutCentroidArray.resize(sn),St.layoutNormalArray.resize(sn),St.layoutAOArray.resize(sn),St.layoutColorArray.resize(sn),St.layoutFloodLightDataArray.resize(sn),$e&&(St.layoutFacadePaintArray.resize(sn),St.layoutFacadeDataArray.resize(sn),St.layoutFacadeVerticalRangeArray.resize(sn));const gn=St.indexArray.length;let bo=0,Zi=_n;for(const Lt of Pr.meshes){let _r,Xi;if(Lt.buildingPart===1)_r=Fe,Xi=se;else if(Lt.buildingPart===0)_r=fe,Xi=ge;else if(Lt.buildingPart===2)_r=Ae,Xi=Me;else{if(Lt.buildingPart!==3)continue;_r=ze,Xi=Ce}if(Xi=vt(Xi,0,1),Lt.buildingPart===3){const en=new Array;for(let Go=0;Go<Lt.positions.length;Go+=12){const $h=Lt.positions[Go+0],Lu=Lt.positions[Go+1],c_=Lt.positions[Go+3],Ab=Lt.positions[Go+4],Cb=Lt.positions[Go+2],BS=Lt.positions[Go+8]-Cb,kS=1,Oy=c_-$h,By=Ab-Lu,ky=Math.hypot(Oy,By);en.push({pos:[$h+.5*Oy,Lu+.5*By,Cb],normal:[By/ky,-Oy/ky,0],width:ky,height:BS,depth:kS,points:[$h,Lu,c_,Ab]})}const Vn=St.entranceBloom.segmentsBucket.prepareSegment(10*en.length,St.entranceBloom.layoutVertexArray,St.entranceBloom.indexArray),ln=St.entranceBloom.layoutVertexArray.length;xo=St.entranceBloom.indexArray.length,Bv(en,.5/this.tileToMeter,St.entranceBloom.indexArray,St.entranceBloom.layoutVertexArray,St.entranceBloom.layoutAttenuationArray);const ja=St.entranceBloom.layoutVertexArray.length-ln;vo=St.entranceBloom.indexArray.length-xo;for(let Go=0;Go<ja;Go++)St.entranceBloom.layoutColorArray.emplaceBack(255*ze.r<<8|255*ze.g,255*ze.b<<8|51*Ce);Vn.vertexLength+=ja,Vn.primitiveLength+=vo,kn={part:Lt.buildingPart,vertexOffset:ln,vertexLength:ja}}St.layoutVertexArray.float32.set(Lt.positions,3*Zi);const Dr=Lt.positions.length/3;for(let en=0;en<Dr;++en){const Vn=3*en;bo=Math.max(bo,Lt.positions[Vn+2]);const ln=Lt.normals[Vn+1]*Vm,ja=Lt.normals[Vn+2]*Vm,Go=3*(Zi+en);St.layoutNormalArray.int16[Go]=Lt.normals[Vn]*Vm,St.layoutNormalArray.int16[Go+1]=ln,St.layoutNormalArray.int16[Go+2]=ja;const $h=Lt.ao[en];St.layoutAOArray.uint8[Zi+en]=255*$h;const Lu=1+($h-1)*xe,c_=255*_r.b*Lu<<8|255*Xi;St.layoutColorArray.uint16[2*(Zi+en)]=255*_r.r*Lu<<8|255*_r.g*Lu,St.layoutColorArray.uint16[2*(Zi+en)+1]=c_}const Cn=Math.min(8191,Math.max(0,Math.floor(Hi.x))),jo=Math.min(8191,Math.max(0,Math.floor(Hi.y))),ws=Math.floor(he),Ts=20,FS=4*Cn+Math.min(3,Math.round((Xt.x-ur.x)*this.tileToMeter/Ts)),OS=4*jo+Math.min(3,Math.round((Xt.y-ur.y)*this.tileToMeter/Ts));for(let en=0;en<Dr;++en){const Vn=3*(Zi+en);St.layoutCentroidArray.int16[Vn]=FS,St.layoutCentroidArray.int16[Vn+1]=OS,St.layoutCentroidArray.int16[Vn+2]=ws}if(St.layoutFloodLightDataArray.int16.fill(Lt.buildingPart===0?ke:0,Zi,Zi+Dr),$e){const en=255*Ae.r<<8|255*Ae.g,Vn=255*Ae.b<<8|255*Me;for(let ln=0;ln<Dr;++ln){const ja=2*(Zi+ln);St.layoutFacadePaintArray.uint16[ja]=en,St.layoutFacadePaintArray.uint16[ja+1]=Vn}for(let ln=0;ln<Dr;++ln)if(Lt.isFauxFacade[ln]){const ja=Math.min(65535,Math.floor(Lt.uv[2*ln]*Pr.outerRingLength));St.layoutFacadeDataArray.emplace(Zi+ln,1|ja,Qt,ui,Rr),St.layoutFacadeVerticalRangeArray.emplace(Zi+ln,ri,jt)}else St.layoutFacadeDataArray.emplace(Zi+ln,0,0,0,0),St.layoutFacadeVerticalRangeArray.emplace(Zi+ln,0,0)}const Fy=Qr.vertexLength,Sb=Lt.indices.length/3,Ib=St.indexArray.length;St.indexArray.resize(Ib+Sb);for(let en=0;en<Sb;++en){const Vn=3*en,ln=3*Ib+Vn;St.indexArray.uint16[ln]=Fy+Lt.indices[Vn],St.indexArray.uint16[ln+1]=Fy+Lt.indices[Vn+1],St.indexArray.uint16[ln+2]=Fy+Lt.indices[Vn+2]}Lt.buildingPart!==1&&Lt.buildingPart!==0&&Lt.buildingPart!==2&&Lt.buildingPart!==3||Bn.push({part:Lt.buildingPart,vertexOffset:Zi,vertexLength:Lt.positions.length/3}),Zi+=Dr,Qr.vertexLength+=Dr,Qr.primitiveLength+=Lt.indices.length/3}this.maxHeight=Math.max(this.maxHeight,bo);const wo=St.indexArray.length-gn,To=this.footprintsIndices.length,an=this.footprintsVertices.length,Na=[],is=new De(1/0,1/0),Nn=new De(-1/0,-1/0),Ol=ae<=0,Va=this.groundEffect.vertexArray.length;for(const Lt of Pr.modifiedPolygonRings){const _r=[],Xi=new De(1/0,1/0),Dr=new De(-1/0,-1/0);for(let Cn=0;Cn<Lt.length;Cn+=2){const jo=Lt.length-Cn-2;Xi.x=Math.min(Xi.x,Lt[jo]),Xi.y=Math.min(Xi.y,Lt[jo+1]),Dr.x=Math.max(Dr.x,Lt[jo]),Dr.y=Math.max(Dr.y,Lt[jo+1]);const ws=new De(Lt[jo],Lt[jo+1]);Ol&&_r.push(ws),Na.push(ws.x,ws.y),this.footprintsVertices.emplaceBack(ws.x,ws.y)}is.x=Math.min(is.x,Xi.x),is.y=Math.min(is.y,Xi.y),Nn.x=Math.max(Nn.x,Dr.x),Nn.y=Math.max(Nn.y,Dr.y),Ol&&this.groundEffect.addData(_r,[Xi,Dr],Te)}const Ua=this.groundEffect.vertexArray.length-Va;this.groundEffect.groundRadiusArray.reserveForAdditional(Ua);for(let Lt=0;Lt<Ua;Lt++)this.groundEffect.groundRadiusArray.emplaceBack(be);(ur.x<0||Xt.x>qe||ur.y<0||Xt.y>qe)&&this.featuresOnBorder.push({featureId:C.id,footprintIndex:this.footprints.length});{const Lt=ea(Na,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Lt.length),this.footprintsIndices.uint16.set(Lt,To),this.buildingIds.add(N??C.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,is.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,is.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Nn.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Nn.y);const _r={footprintVertexOffset:an,footprintVertexLength:this.footprintsVertices.length-an,footprintIndexOffset:To,footprintIndexLength:this.footprintsIndices.length-To,min:is,max:Nn,hiddenFlags:0,indicesOffset:gn,indicesLength:wo,bloomIndicesOffset:xo,bloomIndicesLength:vo,groundEffectVertexOffset:Va,groundEffectVertexLength:Ua,hasFauxFacade:$e,height:bo,promoteId:D,feature:j,parts:Bn,buildingBloom:kn},Xi=this.footprints.length;C.id!==void 0&&this.featureFootprintLookup.set(C.id,Xi),b(N,Xi),this.footprints.push(_r)}this.programConfigurations.populatePaintArrays(St.layoutVertexArray.length,C,z,{},t.availableImages,n,t.brightness),this.groundEffect.addPaintPropertiesData(C,z,{},t.availableImages,n,t.brightness),t.featureIndex.insert(C,te,z,O,this.index,_n)}_.forEach(({buildingId:C,footprintIndex:D})=>{y.has(C)&&(this.footprints[D].hiddenFlags|=4)});const A=new Set;this.buildingIds.forEach((C,D,z)=>{y.has(C)||A.add(C)}),this.buildingIds=A,this.groundEffect.prepareBorderSegments()}update(e,t,n,s,l,c,h){this.programConfigurations.updatePaintArrays(e,t,l,n,s,c,h),this.groundEffect.update(e,t,l,n,s,c,h),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){const t=n=>{n.layoutVertexBuffer=e.createVertexBuffer(n.layoutVertexArray,kv.members),n.layoutNormalBuffer=e.createVertexBuffer(n.layoutNormalArray,qT.members),n.layoutCentroidBuffer=e.createVertexBuffer(n.layoutCentroidArray,WT.members),n.layoutFloodLightDataBuffer=e.createVertexBuffer(n.layoutFloodLightDataArray,QT.members),n.layoutFacadeDataArray&&n.layoutFacadeDataArray.length&&(n.layoutFacadeDataBuffer=e.createVertexBuffer(n.layoutFacadeDataArray,YT.members)),n.layoutFacadeVerticalRangeArray&&n.layoutFacadeVerticalRangeArray.length&&(n.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(n.layoutFacadeVerticalRangeArray,KT.members)),n.entranceBloom.layoutVertexArray.length&&(n.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(n.entranceBloom.layoutVertexArray,kv.members),n.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(n.entranceBloom.layoutAttenuationArray,JT.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e)};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){const e=t=>{t.layoutVertexBuffer&&(t.layoutVertexBuffer.destroy(),t.layoutNormalBuffer.destroy(),t.layoutColorBuffer.destroy(),t.segmentsBucket.destroy(),t.indexBuffer&&t.indexBuffer.destroy(),t.entranceBloom.layoutVertexBuffer&&(t.entranceBloom.layoutVertexBuffer.destroy(),t.entranceBloom.layoutColorBuffer.destroy(),t.entranceBloom.layoutAttenuationBuffer.destroy(),t.entranceBloom.indexBuffer.destroy(),t.entranceBloom.segmentsBucket.destroy()))};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(e,t,n=!0){let s=!1;const l=n?t:0,c=0|(n?-1:~t);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const h of e){const p=this.footprints[h],_=p.hiddenFlags&c|l;p.hiddenFlags!==_&&(p.hiddenFlags=_,s=!0,this.groundEffect.updateHiddenByLandmarkRange(p.groundEffectVertexOffset,p.groundEffectVertexLength,p.hiddenFlags!==0))}return s&&(this.indexArrayForConflationUploaded=!1),s}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=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))};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const s of this.footprints){const l=s.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,c=s.indicesOffset+s.indicesLength;if(s.hiddenFlags!==0){for(let p=s.indicesOffset;p<c;p++)l.indexArrayForConflation.uint16[3*p+0]=0,l.indexArrayForConflation.uint16[3*p+1]=0,l.indexArrayForConflation.uint16[3*p+2]=0;const h=s.bloomIndicesOffset+s.bloomIndicesLength;for(let p=s.bloomIndicesOffset;p<h;p++)l.entranceBloom.indexArrayForConflation.uint16[3*p+0]=0,l.entranceBloom.indexArrayForConflation.uint16[3*p+1]=0,l.entranceBloom.indexArrayForConflation.uint16[3*p+2]=0}}const n=s=>{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))};n(this.buildingWithoutFacade),n(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){const t=n=>{n.layoutColorBuffer?n.layoutColorBuffer.updateData(n.layoutColorArray):n.layoutColorBuffer=e.createVertexBuffer(n.layoutColorArray,Nv.members,!0),n.layoutFacadePaintArray&&(n.layoutFacadePaintBuffer?n.layoutFacadePaintBuffer.updateData(n.layoutFacadePaintArray):n.layoutFacadePaintBuffer=e.createVertexBuffer(n.layoutFacadePaintArray,XT.members,!0)),n.entranceBloom.layoutColorBuffer?n.entranceBloom.layoutColorBuffer.updateData(n.entranceBloom.layoutColorArray):n.entranceBloom.layoutColorBuffer=e.createVertexBuffer(n.entranceBloom.layoutColorArray,Nv.members,!0)};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,t){const n=e.paint.get("building-ambient-occlusion-intensity");for(const s of this.footprints){if(4&s.hiddenFlags)continue;const l=t[s.promoteId],c=s.feature;c.properties["building-part"]="roof";const h=e.paint.get("building-color").evaluate(c,l,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(c,l,this.canonical);c.properties["building-part"]="wall";const _=e.paint.get("building-color").evaluate(c,l,this.canonical).toPremultipliedRenderColor(this.lut),y=e.paint.get("building-emissive-strength").evaluate(c,l,this.canonical);c.properties["building-part"]="window";const v=e.paint.get("building-color").evaluate(c,l,this.canonical).toPremultipliedRenderColor(this.lut),b=e.paint.get("building-emissive-strength").evaluate(c,l,this.canonical);c.properties["building-part"]="door";const T=e.paint.get("building-color").evaluate(c,l,this.canonical).toPremultipliedRenderColor(this.lut),S=e.paint.get("building-emissive-strength").evaluate(c,l,this.canonical),A=s.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const D of s.parts){let z,O=h;D.part===1?(O=h,z=p):D.part===0?(O=_,z=y):D.part===2?(O=v,z=b):D.part===3&&(O=T,z=S),z=vt(z,0,1);for(let F=0;F<D.vertexLength;F++){const N=D.vertexOffset+F,j=1+(A.layoutAOArray.uint8[N]/255-1)*n;A.layoutColorArray.emplace(N,O.r*j*255<<8|O.g*j*255,O.b*j*255<<8|255*z),s.hasFauxFacade&&A.layoutFacadePaintArray.emplace(N,255*v.r<<8|255*v.g,255*v.b<<8|255*b)}}const C=s.buildingBloom;if(C)for(let D=0;D<C.vertexLength;D++)A.entranceBloom.layoutColorArray.emplace(C.vertexOffset+D,255*T.r<<8|255*T.g,255*T.b<<8|51*S)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(e,t,n){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const s=t.getReplacementRegionsForTile(e.toUnwrapped());if(rm(this.activeReplacements,s))return;this.activeReplacements=s;for(const c of this.footprints)c.hiddenFlags&=-2;const l=[];for(const c of this.activeReplacements){if(c.order<n)continue;const h=Math.max(1,Math.pow(2,c.footprintTileId.canonical.z-e.canonical.z));for(const p of this.footprints)p.min.x>c.max.x||p.max.x<c.min.x||p.min.y>c.max.y||p.max.y<c.min.y||(l.length=0,wE(this.footprintsVertices,p.footprintVertexOffset,p.footprintVertexLength,c.footprintTileId.canonical,e.canonical,l),_g(c.footprint,l,this.footprintsIndices.uint16,p.footprintIndexOffset,p.footprintIndexLength,0,-h)&&(p.hiddenFlags|=1))}this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const c of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(c.groundEffectVertexOffset,c.groundEffectVertexLength,c.hiddenFlags!==0);this.indexArrayForConflationUploaded=!1}getFootprint(e){if(e.id!==void 0){const t=this.featureFootprintLookup.get(e.id);return this.footprints[t]}return null}getHeightAtTileCoord(e,t){let n=Number.NEGATIVE_INFINITY,s=!0;const l=4*(e+qe)*qe+(t+qe);if(Object.hasOwn(this.footprintLookup,l)){const h=this.footprintLookup[l];return h?{height:h.height,hidden:h.hiddenFlags!==0}:void 0}const c=new De(e,t);for(const h of this.footprints)e>h.max.x||h.min.x>e||t>h.max.y||h.min.y>t||h.height<=n||bE(c,this.footprintsVertices.float32.subarray(2*h.footprintVertexOffset,2*(h.footprintVertexOffset+h.footprintVertexLength)),this.footprintsIndices.uint16.subarray(h.footprintIndexOffset,h.footprintIndexOffset+h.footprintIndexLength))&&(n=h.height,this.footprintLookup[l]=h,s=h.hiddenFlags!==0);if(n!==Number.NEGATIVE_INFINITY)return{height:n,hidden:s};this.footprintLookup[l]=void 0}}function bE(i,e,t){for(let n=0;n<t.length;n+=3){const s=t[n],l=t[n+1],c=t[n+2],h=e[2*s+0],p=e[2*s+1],_=e[2*l+0],y=e[2*l+1],v=e[2*c+0],b=e[2*c+1],T=(h-v)*(i.y-b)-(p-b)*(i.x-v),S=(_-h)*(i.y-p)-(y-p)*(i.x-h);if(T<0!=S<0&&T!==0&&S!==0)continue;const A=(v-_)*(i.y-y)-(b-y)*(i.x-_);if(A===0||A<0==T+S<=0)return!0}return!1}function wE(i,e,t,n,s,l){const c=Math.pow(2,n.z-s.z);for(let h=0;h<t;h++){let p=i.float32[2*(h+e)+0],_=i.float32[2*(h+e)+1];p=(p+s.x*qe)*c-n.x*qe,_=(_+s.y*qe)*c-n.y*qe,l.push(new De(p,_))}}et(e0,"BuildingBucket",{omit:["layers"]}),et(ty,"BuildingGeometry"),et(ey,"BuildingBloomGeometry");class t0{constructor(e=0,t=[]){this.frcMask=e,this.rings=t}hasGeometry(){return this.rings.length>0&&this.rings[0].length>0}}async function Um(){}function Nh(i,e,t){const n=e.paint.get(i).value;return n.kind==="constant"?n.value:t.programConfigurations.get(e.id).getMaxValue(i)}function jm(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function i0(i,e,t,n,s){if(!e[0]&&!e[1])return i;const l=De.convert(e)._mult(s);t==="viewport"&&l._rotate(-n);const c=[];for(let h=0;h<i.length;h++)c.push(i[h].sub(l));return c}function r0(i,e,t,n){const s=De.convert(i)._mult(n);return e==="viewport"&&s._rotate(-t),s}et(t0,"FrcCoveragePolygon");const TE=Yn(),n0=i=>{const e=[];return i.paint.get("circle-pitch-alignment")==="map"&&e.push("PITCH_WITH_MAP"),i.paint.get("circle-pitch-scale")==="map"&&e.push("SCALE_WITH_MAP"),e};function o0(i,e,t,n,s,l,c,h,p){if(l&&i.queryGeometry.isAboveHorizon)return!1;l&&(p*=i.pixelToTileUnitsFactor);const _=i.tileID.canonical,y=t.projection.upVectorScale(_,t.center.lat,t.worldSize).metersToTile;for(const v of e)for(const b of v){const T=b.add(h),S=s&&t.elevation?t.elevation.exaggeration()*s.getElevationAt(T.x,T.y,!0):0,A=t.projection.projectTilePoint(T.x,T.y,_);if(S>0){const O=t.projection.upVector(_,T.x,T.y);A.x+=O[0]*y*S,A.y+=O[1]*y*S,A.z+=O[2]*y*S}const C=l?T:EE(A.x,A.y,A.z,n),D=l?i.tilespaceRays.map(O=>IE(O,S)):i.queryGeometry.screenGeometry,z=lr([],[A.x,A.y,A.z,1],n);if(!c&&l?p*=z[3]/t.cameraToCenterDistance:c&&!l&&(p*=t.cameraToCenterDistance/z[3]),l){const O=vr((b.y/qe+_.y)/(1<<_.z));p/=t.projection.pixelsPerMeter(O,1)/x(1,O)}if(Yb(D,C,p))return!0}return!1}function EE(i,e,t,n){const s=lr([],[i,e,t,1],n);return new De(s[0]/s[3],s[1]/s[3])}const s0=br(0,0,0),SE=br(0,0,1);function IE(i,e){const t=Jt();return s0[2]=e,i.intersectsPlane(s0,SE,t),new De(t[0],t[1])}class a0 extends jp{}let l0,c0;et(a0,"HeatmapBucket",{omit:["layers"]});const AE=(i,e,t,n)=>lt(e,t,n==="log"?(Math.pow(10,i)-1)/9:i);function xf(i){const{expression:e,evaluationKey:t,resolution:n=256,clips:s,scale:l="linear",lut:c=null}=i,h=s?s.length:1,p=i.image||new An({width:n,height:h}),_={},y=(v,b,T)=>{_[t]=T;const S=e.evaluate(_),A=(S==null?void 0:S.toNonPremultipliedRenderColor(c))??null;A&&(p.data[v+b+0]=Math.floor(255*A.r),p.data[v+b+1]=Math.floor(255*A.g),p.data[v+b+2]=Math.floor(255*A.b),p.data[v+b+3]=Math.floor(255*A.a))};for(let v=0,b=0;v<h;++v,b+=4*n){const T=(s==null?void 0:s[v].start)??0,S=(s==null?void 0:s[v].end)??1;for(let A=0,C=0;A<n;A++,C+=4)y(b,C,AE(A/(n-1),T,S,l))}return p}let u0,h0,d0,f0,p0,m0,_0,g0,y0,x0,v0,b0;class w0{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){for(const n of this.footprints)t.push({footprint:n,id:e})}updateAppearances(e,t,n,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,n,s){const l=[];for(const{feature:c,id:h,index:p,sourceLayerIndex:_}of e){const y=this.layers[0]._featureFilter.needGeometry,v=_e(c,y);if(!this.layers[0]._featureFilter.filter(new zi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),v,n))continue;const b={id:h,properties:c.properties,type:c.type,sourceLayerIndex:_,index:p,geometry:y?v.geometry:ce(c,n,s),patterns:{}};l.push(b)}for(const c of l){const{geometry:h,index:p,sourceLayerIndex:_}=c;this.addFeature(c,h,p,n,{},t.availableImages,t.brightness),t.featureIndex.insert(e[p].feature,h,p,_,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(e){}update(e,t,n,s,l,c,h){}destroy(){}addFeature(e,t,n,s,l,c=[],h){for(const p of Ei(t,2)){const _=[],y=[],v=[],b=new De(1/0,1/0),T=new De(-1/0,-1/0);for(const C of p)if(C.length!==0){C!==p[0]&&v.push(y.length/2);for(let D=0;D<C.length;D++)y.push(C[D].x),y.push(C[D].y),_.push(C[D]),b.x=Math.min(b.x,C[D].x),b.y=Math.min(b.y,C[D].y),T.x=Math.max(T.x,C[D].x),T.y=Math.max(T.y,C[D].y)}const S=ea(y,v),A=new Sm(_,S,8,256);this.footprints.push({vertices:_,indices:S,grid:A,min:b,max:T})}}}function vf(i,e){return i.x*e.x+i.y*e.y}function T0(i,e){if(i.length===1){let t=0;const n=e[t++];let s;for(;!s||n.equals(s);)if(s=e[t++],!s)return 1/0;for(;t<e.length;t++){const l=e[t],c=i[0],h=s.sub(n),p=l.sub(n),_=c.sub(n),y=vf(h,h),v=vf(h,p),b=vf(p,p),T=vf(_,h),S=vf(_,p),A=y*b-v*v,C=(b*T-v*S)/A,D=(y*S-v*T)/A,z=n.z*(1-C-D)+s.z*C+l.z*D;if(isFinite(z))return z}return 1/0}{let t=1/0;for(const n of e)t=Math.min(t,n.z);return t}}function E0(i,e,t){let n=1/0;q_(t,e)&&(n=T0(t,e[0]));for(let s=0;s<e.length;s++){const l=e[s],c=i[s];for(let h=0;h<l.length-1;h++){const p=l[h],_=[p,l[h+1],c[h+1],c[h],p];$_(t,_)&&(n=Math.min(n,T0(t,_)))}}return n!==1/0&&n}function S0(i,e,t,n,s,l,c,h,p,_,y){return i.projection.name==="globe"?function(v,b,T,S,A,C,D,z,O,F,N){const j=[],te=[],H=v.projection.upVectorScale(N,v.center.lat,v.worldSize).metersToTile,W=[0,0,0,1],K=[0,0,0,1],ee=(he,be,xe,Te)=>{he[0]=be,he[1]=xe,he[2]=Te,he[3]=1},ae=Wv();T>0&&(T+=ae),S+=ae;for(const he of b){const be=[],xe=[];for(const Te of he){const Fe=Te.x+A.x,se=Te.y+A.y,fe=v.projection.projectTilePoint(Fe,se,N),ge=v.projection.upVector(N,Te.x,Te.y);let Ae=T,Me=S;if(D){const ze=I0(Fe,se,T,S,D,z,O,F);Ae+=ze.base,Me+=ze.top}T!==0?ee(W,fe.x+ge[0]*H*Ae,fe.y+ge[1]*H*Ae,fe.z+ge[2]*H*Ae):ee(W,fe.x,fe.y,fe.z),ee(K,fe.x+ge[0]*H*Me,fe.y+ge[1]*H*Me,fe.z+ge[2]*H*Me),hi(W,W,C),hi(K,K,C),be.push(new wu(W[0],W[1],W[2])),xe.push(new wu(K[0],K[1],K[2]))}j.push(be),te.push(xe)}return[j,te]}(i,e,t,n,s,l,c,h,p,_,y):c?function(v,b,T,S,A,C,D,z,O){const F=[],N=[],j=[0,0,0,1];for(const te of v){const H=[],W=[];for(const K of te){const ee=K.x+S.x,ae=K.y+S.y,he=I0(ee,ae,b,T,C,D,z,O);j[0]=ee,j[1]=ae,j[2]=he.base,j[3]=1,lr(j,j,A),j[3]=Math.max(j[3],1e-5);const be=new wu(j[0]/j[3],j[1]/j[3],j[2]/j[3]);j[0]=ee,j[1]=ae,j[2]=he.top,j[3]=1,lr(j,j,A),j[3]=Math.max(j[3],1e-5);const xe=new wu(j[0]/j[3],j[1]/j[3],j[2]/j[3]);H.push(be),W.push(xe)}F.push(H),N.push(W)}return[F,N]}(e,t,n,s,l,c,h,p,_):function(v,b,T,S,A){const C=[],D=[],z=A[8]*b,O=A[9]*b,F=A[10]*b,N=A[11]*b,j=A[8]*T,te=A[9]*T,H=A[10]*T,W=A[11]*T;for(const K of v){const ee=[],ae=[];for(const he of K){const be=he.x+S.x,xe=he.y+S.y,Te=A[0]*be+A[4]*xe+A[12],Fe=A[1]*be+A[5]*xe+A[13],se=A[2]*be+A[6]*xe+A[14],fe=A[3]*be+A[7]*xe+A[15],ge=Te+z,Ae=Fe+O,Me=se+F,ze=Math.max(fe+N,1e-5),Ce=Te+j,Be=Fe+te,ke=se+H,Ke=Math.max(fe+W,1e-5);ee.push(new wu(ge/ze,Ae/ze,Me/ze)),ae.push(new wu(Ce/Ke,Be/Ke,ke/Ke))}C.push(ee),D.push(ae)}return[C,D]}(e,t,n,s,l)}function I0(i,e,t,n,s,l,c,h){const p=c*s.getElevationAt(i,e,!0,!0),_=l[0]!==0,y=_?l[1]===0?c*(l[0]/7-450):c*function(v,b,T){const S=Math.floor(b[0]/8),A=Math.floor(b[1]/8),C=10*(b[0]-8*S),D=10*(b[1]-8*A),z=v.getElevationAt(S,A,!0,!0),O=v.getMeterToDEM(T),F=Math.floor(.5*(C*O-1)),N=Math.floor(.5*(D*O-1)),j=v.tileCoordToPixel(S,A),te=2*F+1,H=2*N+1,W=function(xe,Te,Fe,se,fe){return[xe.getElevationAtPixel(Te,Fe,!0),xe.getElevationAtPixel(Te+fe,Fe,!0),xe.getElevationAtPixel(Te,Fe+fe,!0),xe.getElevationAtPixel(Te+se,Fe+fe,!0)]}(v,j.x-F,j.y-N,te,H),K=Math.abs(W[0]-W[1]),ee=Math.abs(W[2]-W[3]),ae=Math.abs(W[0]-W[2])+Math.abs(W[1]-W[3]),he=Math.min(.25,.5*O*(K+ee)/te),be=Math.min(.25,.5*O*ae/H);return z+Math.max(he*C,be*D)}(s,l,h):p;return{base:p+(t===0?-1:t),top:_?Math.max(y+n,p+t+2):p+n}}function bf(i,e,t){return e*(qe/(i.tileSize*Math.pow(2,t-i.tileID.overscaledZ)))}function A0(i,e){return 1/bf(i,1,e.tileZoom)}function C0(i,e,t,n){return i.translatePosMatrix(n||e.tileID.projMatrix,e,t.paint.get("line-translate"),t.paint.get("line-translate-anchor"))}et(w0,"ClipBucket",{omit:["layers"]});const M0=i=>{const e=[];R0(i)&&e.push("RENDER_LINE_DASH"),i.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT"),i.paint.get("line-blend-mode")==="multiply"&&e.push("LINE_BLEND_MULTIPLY"),i.paint.get("line-blend-mode")==="additive"&&e.push("LINE_BLEND_ADDITIVE");const t=i.paint.get("line-trim-offset");t[0]===0&&t[1]===0||e.push("RENDER_LINE_TRIM_OFFSET");const n=i.paint.get("line-border-width").constantOr(1)!==0;n&&e.push("RENDER_LINE_BORDER"),n&&i.paint.get("line-border-gradient")&&e.push("RENDER_LINE_BORDER_GRADIENT");const s=i.layout.get("line-join").constantOr("miter")==="none",l=!!i.paint.get("line-pattern").constantOr(1);return s&&l&&e.push("LINE_JOIN_NONE"),e};function R0(i){const e=i.paint.get("line-dasharray").value;return e.kind!=="constant"||e.value}let iy;const P0=()=>iy||(iy={layout:v0||(v0=new ki({"line-cap":new Ze(de.layout_line["line-cap"]),"line-join":new Ze(de.layout_line["line-join"]),"line-miter-limit":new He(de.layout_line["line-miter-limit"]),"line-round-limit":new He(de.layout_line["line-round-limit"]),"line-sort-key":new Ze(de.layout_line["line-sort-key"]),"line-z-offset":new Ze(de.layout_line["line-z-offset"]),"line-elevation-reference":new He(de.layout_line["line-elevation-reference"]),"line-cross-slope":new He(de.layout_line["line-cross-slope"]),visibility:new He(de.layout_line.visibility),"line-width-unit":new He(de.layout_line["line-width-unit"]),"line-elevation-ground-scale":new Ze(de.layout_line["line-elevation-ground-scale"])})),paint:b0||(b0=new ki({"line-opacity":new Ze(de.paint_line["line-opacity"]),"line-color":new Ze(de.paint_line["line-color"]),"line-translate":new He(de.paint_line["line-translate"]),"line-translate-anchor":new He(de.paint_line["line-translate-anchor"]),"line-width":new Ze(de.paint_line["line-width"]),"line-gap-width":new Ze(de.paint_line["line-gap-width"]),"line-offset":new Ze(de.paint_line["line-offset"]),"line-blur":new Ze(de.paint_line["line-blur"]),"line-dasharray":new Ze(de.paint_line["line-dasharray"]),"line-pattern":new Ze(de.paint_line["line-pattern"]),"line-pattern-cross-fade":new He(de.paint_line["line-pattern-cross-fade"]),"line-gradient":new Aa(de.paint_line["line-gradient"]),"line-trim-offset":new He(de.paint_line["line-trim-offset"]),"line-trim-fade-range":new He(de.paint_line["line-trim-fade-range"]),"line-trim-color":new He(de.paint_line["line-trim-color"]),"line-emissive-strength":new Ze(de.paint_line["line-emissive-strength"]),"line-border-width":new Ze(de.paint_line["line-border-width"]),"line-border-color":new Ze(de.paint_line["line-border-color"]),"line-border-gradient":new Aa(de.paint_line["line-border-gradient"]),"line-occlusion-opacity":new He(de.paint_line["line-occlusion-opacity"]),"line-blend-mode":new He(de.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new He(de.paint_line["line-blend-additive-clamp"]),"line-cutout-depth":new He(de.paint_line["line-cutout-depth"]),"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"}),"line-border-gradient-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},iy);class CE extends Ze{possiblyEvaluate(e,t){return t=new zi(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,s){return t={...t,zoom:Math.floor(t.zoom)},super.evaluate(e,t,n,s)}}let wf,D0,L0,ry;function z0(i,e){return e>0?e+2*i:i}function F0(i,e){return e.replace(/{([^{}]+)}/g,(t,n)=>n in i?String(i[n]):"")}class O0{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:fa,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.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}}et(O0,"FormatSectionOverride",{omit:["defaultValue"]});const ny=()=>ry||(ry={layout:D0||(D0=new ki({"symbol-placement":new He(de.layout_symbol["symbol-placement"]),"symbol-spacing":new He(de.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new He(de.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ze(de.layout_symbol["symbol-sort-key"]),"symbol-z-order":new He(de.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new He(de.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new He(de.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new He(de.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new He(de.layout_symbol["icon-ignore-placement"]),"icon-optional":new He(de.layout_symbol["icon-optional"]),"icon-rotation-alignment":new He(de.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ze(de.layout_symbol["icon-size"]),"icon-size-scale-range":new He(de.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Ze(de.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ze(de.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ze(de.layout_symbol["icon-image"]),"icon-image-use-theme":new He({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Ze(de.layout_symbol["icon-rotate"]),"icon-padding":new He(de.layout_symbol["icon-padding"]),"icon-keep-upright":new He(de.layout_symbol["icon-keep-upright"]),"icon-offset":new Ze(de.layout_symbol["icon-offset"]),"icon-anchor":new Ze(de.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new He(de.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new He(de.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new He(de.layout_symbol["text-rotation-alignment"]),"text-field":new Ze(de.layout_symbol["text-field"]),"text-font":new Ze(de.layout_symbol["text-font"]),"text-size":new Ze(de.layout_symbol["text-size"]),"text-size-scale-range":new He(de.layout_symbol["text-size-scale-range"]),"text-max-width":new Ze(de.layout_symbol["text-max-width"]),"text-line-height":new Ze(de.layout_symbol["text-line-height"]),"text-letter-spacing":new Ze(de.layout_symbol["text-letter-spacing"]),"text-justify":new Ze(de.layout_symbol["text-justify"]),"text-radial-offset":new Ze(de.layout_symbol["text-radial-offset"]),"text-variable-anchor":new He(de.layout_symbol["text-variable-anchor"]),"text-anchor":new Ze(de.layout_symbol["text-anchor"]),"text-max-angle":new He(de.layout_symbol["text-max-angle"]),"text-writing-mode":new He(de.layout_symbol["text-writing-mode"]),"text-rotate":new Ze(de.layout_symbol["text-rotate"]),"text-padding":new He(de.layout_symbol["text-padding"]),"text-keep-upright":new He(de.layout_symbol["text-keep-upright"]),"text-transform":new Ze(de.layout_symbol["text-transform"]),"text-offset":new Ze(de.layout_symbol["text-offset"]),"text-allow-overlap":new He(de.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new He(de.layout_symbol["text-ignore-placement"]),"text-optional":new He(de.layout_symbol["text-optional"]),visibility:new He(de.layout_symbol.visibility)})),paint:L0||(L0=new ki({"icon-opacity":new Ze(de.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Ze(de.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Ze(de.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ze(de.paint_symbol["text-emissive-strength"]),"icon-color":new Ze(de.paint_symbol["icon-color"]),"icon-halo-color":new Ze(de.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ze(de.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ze(de.paint_symbol["icon-halo-blur"]),"icon-translate":new He(de.paint_symbol["icon-translate"]),"icon-translate-anchor":new He(de.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new He(de.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Ze(de.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Ze(de.paint_symbol["text-occlusion-opacity"]),"text-color":new Ze(de.paint_symbol["text-color"],{runtimeType:nn,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Ze(de.paint_symbol["text-halo-color"]),"text-halo-width":new Ze(de.paint_symbol["text-halo-width"]),"text-halo-blur":new Ze(de.paint_symbol["text-halo-blur"]),"text-translate":new He(de.paint_symbol["text-translate"]),"text-translate-anchor":new He(de.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new He(de.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new He(de.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new He(de.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new He(de.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Ze(de.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"})}))},ry);class Gm extends Fn{constructor(e,t,n,s){super(e,ny(),t,n,s,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=rr([]),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,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(s=>{s.recalculate(e,t,this.iconImageUseTheme)}),this.appearances.length!==0&&delete this.layout._values["text-variable-anchor"],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"));const n=this.layout.get("text-writing-mode");if(n){const s=[];for(const l of n)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,t,n,s){return this._saturation===e&&this._contrast===t&&this._brightnessMin===n&&this._brightnessMax===s||(this._colorAdjustmentMatrix=function(l,c,h,p){l=Yl(l),c=Gu(c);const _=Yn(),y=l/3,v=1-2*y,b=[v,y,y,0,y,v,y,0,y,y,v,0,0,0,0,1],T=.5-.5*c,S=p-h;return Dt(_,[S,0,0,0,0,S,0,0,0,0,S,0,h,h,h,1],[c,0,0,0,0,c,0,0,0,0,c,0,T,T,T,1]),Dt(_,_,b),_}(e,t,n,s),this._saturation=e,this._contrast=t,this._brightnessMin=n,this._brightnessMax=s),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,n,s){const l=this.layout.get(e).evaluate(t,{},n,s),c=this._unevaluatedLayout._values[e];return c.isDataDriven()||nu(c.value)||!l?l:F0(t.properties,l)}getAppearanceValueAndResolveTokens(e,t,n,s,l){const c=e.getLayoutProperty(t);if(!c)return;const h=c.evaluate(n,{},s,l),p=e.getUnevaluatedLayoutProperties()._values[t];return p.isDataDriven()||nu(p.value)||!h||typeof h!="string"?h:F0(n.properties,h)}createBucket(e){return new fm(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of ny().paint.overridableProperties){if(!Gm.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new O0(t),s=new ah(n,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let l=null;l=t.value.kind==="constant"||t.value.kind==="source"?new lh("source",s):new Fo("composite",s,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new Qs(t.property,l,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&Gm.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),s=ny().paint.properties[t];let l=!1;const c=h=>{for(const p of h)if(s.overrides&&s.overrides.hasOverride(p))return void(l=!0)};if(n.value.kind==="constant"&&n.value.value instanceof Sr)c(n.value.value.sections);else if(n.value.kind==="source"){const h=_=>{l||(_ instanceof Ko&&Nr(_.value)===fs?c(_.value.sections):_ instanceof Zn?c(_.sections):_.eachChild(h))},p=n.value;p._styleExpression&&h(p._styleExpression.expression)}return l}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,t,n){return{config:new bu(this,{zoom:t,lut:n}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}mayUse(e){return e==="HD"&&vh(this,"symbol-elevation-reference",t=>t==="hd-road-markup")}prepare(){return this.mayUse("HD")?Um():Promise.resolve()}}let B0,k0,N0,V0;const oy=1024,ME=(Math.pow(oy,2)-1)/268170240;class U0 extends Fn{constructor(e,t,n,s){super(e,{layout:N0||(N0=new ki({visibility:new He(de.layout_raster.visibility)})),paint:V0||(V0=new ki({"raster-opacity":new He(de.paint_raster["raster-opacity"]),"raster-color":new Aa(de.paint_raster["raster-color"]),"raster-color-mix":new He(de.paint_raster["raster-color-mix"]),"raster-color-range":new He(de.paint_raster["raster-color-range"]),"raster-color-scale":new He(de.paint_raster["raster-color-scale"]),"raster-hue-rotate":new He(de.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new He(de.paint_raster["raster-brightness-min"]),"raster-brightness-max":new He(de.paint_raster["raster-brightness-max"]),"raster-saturation":new He(de.paint_raster["raster-saturation"]),"raster-contrast":new He(de.paint_raster["raster-contrast"]),"raster-resampling":new He(de.paint_raster["raster-resampling"]),"raster-fade-duration":new He(de.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new He(de.paint_raster["raster-emissive-strength"]),"raster-array-band":new He(de.paint_raster["raster-array-band"]),"raster-elevation":new He(de.paint_raster["raster-elevation"]),"raster-elevation-reference":new He(de.paint_raster["raster-elevation-reference"]),"raster-allow-draping":new He(de.paint_raster["raster-allow-draping"]),"raster-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},t,n,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){const t=e?e._source:null;return(!t||t.type!=="image"&&t.type!=="video"&&t.type!=="canvas"||!t.onNorthPole&&!t.onSouthPole)&&this.paint.get("raster-elevation")===0&&this.paint.get("raster-allow-draping")}_handleSpecialPaintPropertyUpdate(e){e!=="raster-color"&&e!=="raster-color-range"&&e!=="raster-color-scale"||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}updateColorRamp(e){if(!this.hasColorMap()||!this._curRampRange)return;const t=this._transitionablePaint._values["raster-color"].value.expression,[n,s]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];if(isNaN(n)&&isNaN(s)||n===this._curRampRange[0]&&s===this._curRampRange[1])return;const l=this._transitionablePaint._values["raster-color-scale"].value.expression.evaluate({zoom:0});this.colorRamp=xf({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:n,end:s}],resolution:oy,scale:l}),this.colorRampTexture=null,this._curRampRange=[n,s]}is3D(e){return this.paint.get("raster-elevation")>0||!this.paint.get("raster-allow-draping")}}let j0,G0,H0,Z0,$0,q0,W0;class X0 extends Fn{constructor(e,t,n,s){super(e,{layout:j0||(j0=new ki({visibility:new He(de["layout_raster-particle"].visibility)})),paint:G0||(G0=new ki({"raster-particle-array-band":new He(de["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new He(de["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new Aa(de["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new He(de["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new He(de["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new He(de["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new He(de["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new He(de["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},t,n,s),this._updateColorRamp(),this.lastInvalidatedAt=X.now()}mayUse(e){return e==="HD"}_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;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=xf({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=X.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class RE extends Fn{constructor(e,t){super(e,{},t,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 sy(i,e,t){const n=[0,0,1],s=Mn([]);return sa(s,s,t?-Ot(i)+Math.PI:Ot(i)),Gs(s,s,-Ot(e)),oa(n,n,s),ei(n,n)}class Y0{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class K0{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new ii,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(e){const t=16*e,n=this.instancedDataArray.float32;let s=Math.floor(n[t+2]);const l=1.05*(n[t+2]-s);return s/=100,[n[t]%1*1.05,n[t+1]%1*1.05,l,s]}tileCoordinatesForInstance(e){const t=16*e,n=this.instancedDataArray.float32;let s=n[t+0];return s=s>qe?s-qe:s,new De(Math.trunc(s),Math.trunc(n[t+1]))}translationForInstance(e){const t=16*e,n=this.instancedDataArray.float32;return[n[t+4],n[t+5],n[t+6]]}rotationScaleForInstance(e){const t=16*e,n=this.instancedDataArray.float32;return[n[t+7],n[t+8],n[t+9],n[t+10],n[t+11],n[t+12],n[t+13],n[t+14],n[t+15]]}transformForInstance(e){const t=16*e,n=this.instancedDataArray.float32;return[n[t+7],n[t+8],n[t+9],n[t+4],n[t+10],n[t+11],n[t+12],n[t+5],n[t+13],n[t+14],n[t+15],n[t+6],0,0,0,1]}}class ay{constructor(e){this.requiresStandardRuntime=!0,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(t=>t.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.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,t){}updateAppearances(e,t,n,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,n,s){this.tileToMeter=B(n);const l=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const c=this.layers[0].paint.get("model-elevation-reference")==="hd-road-markup"?t.elevationFeatures:void 0;for(const{feature:h,id:p,index:_,sourceLayerIndex:y}of e){const v=p??(h.properties&&Object.hasOwn(h.properties,"id")?h.properties.id:void 0),b=_e(h,l);if(!this.layers[0]._featureFilter.filter(new zi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),b,n))continue;const T={id:v,sourceLayerIndex:y,index:_,geometry:l?b.geometry:ce(h,n,s),properties:h.properties,type:h.type,patterns:{}},S=this.addFeature(T,T.geometry,b,c,n);S&&t.featureIndex.insert(h,T.geometry,_,y,this.index,this.instancesPerModel[S].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let n=0;for(const s of this.modelUris){const l=e.getModel(s,t);if(!l)continue;const c=this.instancesPerModel[s];if(c){const h=.5*Za(l.aabb.max,l.aabb.min)*c.maxScale+c.maxXYTranslationDistance,p=Math.min(qe,Math.max(h/this.tileToMeter,256));n=Math.max(p,n)}}return n}update(e,t,n,s){for(const l in this.instancesPerModel){const c=this.instancesPerModel[l];for(const h in e)Object.hasOwn(c.idToFeaturesIndex,h)&&(this.evaluate(c.features[c.idToFeaturesIndex[h]],e[h],c,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const t in this.instancesPerModel){const n=this.instancesPerModel[t];for(const s of n.features){const l=this.layers[0],c=s.feature,h=this.canonical,p=l.paint.get("model-rotation").evaluate(c,{},h),_=l.paint.get("model-scale").evaluate(c,{},h),y=l.paint.get("model-translation").evaluate(c,{},h);os(s.rotation,p)&&os(s.scale,_)&&os(s.translation,y)||(this.evaluate(s,s.featureStates,n,!0),e=!0)}}return e}updateReplacement(e,t,n,s){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const l=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(rm(this.activeReplacements,l))return!1;this.activeReplacements=l;let c=!1;for(const h in this.instancesPerModel){const p=this.instancesPerModel[h],_=p.instancedDataArray;for(const y of p.features){const v=y.instancedDataOffset,b=y.instancedDataCount;for(let T=0;T<b;T++){const S=16*(T+v);let A=_.float32[S+0];const C=A>qe;A=C?A-qe:A;const D=Math.floor(A),z=Math.floor(_.float32[S+1]);let O=!1;for(const F of this.activeReplacements)if(!Ax(F,n,Pm.Model,s)&&!(F.min.x>D||D>F.max.x||F.min.y>z||z>F.max.y)&&(O=gg(Px(D,z,e.canonical,F.footprintTileId.canonical),F.footprint),O))break;_.float32[S]=O?A+qe:A,c=c||O!==C}}}return c}isEmpty(){for(const 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(const t in this.instancesPerModel){const n=this.instancesPerModel[t];n.instancedDataArray.length<0||n.instancedDataArray.length===0||(n.instancedDataBuffer?n.instancedDataBuffer.updateData(n.instancedDataArray):n.instancedDataBuffer=e.createVertexBuffer(n.instancedDataArray,FT.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(e){for(const n in this.instancesPerModel){const s=this.instancesPerModel[n];s.instancedDataArray.length!==0&&s.instancedDataBuffer&&s.instancedDataBuffer.destroy()}const t=this.layers[0].modelManager;if(e&&t&&this.modelUris&&this.modelsRequested)for(const n of this.modelUris)t.removeModel(n,"",!0)}addFeature(e,t,n,s,l){const c=this.layers[0],h=c.layout.get("model-id"),p=c.layout.get("model-allow-density-reduction"),_=h.evaluate(n,{},this.canonical);if(!_)return _i(`modelId is not evaluated for layer ${c.id} and it is not going to get rendered.`),_;!_.includes("://")&&!this.styleDefinedModelURLs[_]||this.modelUris.includes(_)||this.modelUris.push(_),this.instancesPerModel[_]||(this.instancesPerModel[_]=new K0);const y=this.instancesPerModel[_],v=y.instancedDataArray,b=new Y0(n,v.length);let T;if(s){const S=uf(e,s,void 0,l);T=S?S.feature:void 0}for(const S of t)for(const A of S){if(A.x<0||A.x>=qe||A.y<0||A.y>=qe)continue;if(this.lookupDim!==0&&p){const D=(this.lookupDim-1)/qe,z=this.lookupDim*(A.y*D|0)+A.x*D|0;if(this.lookup){if(this.lookup[z]!==0)continue;this.lookup[z]=1}}this.instanceCount++;const C=v.length;if(v.resize(C+1),s){y.instancesRoadElevation||(y.instancesRoadElevation=[]);const D=T?T.pointElevation(new De(A.x,A.y)):0;y.instancesRoadElevation.push(D)}y.instancesEvaluatedElevation.push(0),v.float32[16*C]=A.x,v.float32[16*C+1]=A.y}return b.instancedDataCount=y.instancedDataArray.length-b.instancedDataOffset,b.instancedDataCount>0&&(e.id&&(y.idToFeaturesIndex[e.id]=y.features.length),y.features.push(b),this.evaluate(b,{},y,!1)),_}getModelUris(){return this.modelUris}evaluate(e,t,n,s){const l=this.layers[0],c=e.feature,h=this.canonical,p=e.rotation=l.paint.get("model-rotation").evaluate(c,t,h),_=e.scale=l.paint.get("model-scale").evaluate(c,t,h),y=e.translation=l.paint.get("model-translation").evaluate(c,t,h),{r:v,g:b,b:T}=l.paint.get("model-color").evaluate(c,t,h),S=l.paint.get("model-color-mix-intensity").evaluate(c,t,h),A=[];this.maxVerticalOffset<y[2]&&(this.maxVerticalOffset=y[2]);const C=y[0]*y[0]+y[1]*y[1],D=C>0?Math.sqrt(C):0;n.maxScale=Math.max(Math.max(n.maxScale,_[0]),Math.max(_[1],_[2])),n.maxXYTranslationDistance=Math.max(n.maxXYTranslationDistance,D),this.maxScale=Math.max(Math.max(this.maxScale,_[0]),Math.max(_[1],_[2])),Rv(A,p,_);const z=Math.round(100*S)+T/1.05;for(let O=0;O<e.instancedDataCount;++O){const F=e.instancedDataOffset+O,N=16*F,j=n.instancedDataArray.float32;let te=0;s&&(te=j[N+6]-n.instancesEvaluatedElevation[F]);const H=0|j[N+1];j[N]=(0|j[N])+v/1.05,j[N+1]=H+b/1.05,j[N+2]=z,j[N+3]=1/(h.z>10?this.tileToMeter:B(h,H)),j[N+4]=y[0],j[N+5]=y[1],j[N+6]=y[2]+(n.instancesRoadElevation?n.instancesRoadElevation[F]:0)+te,j[N+7]=A[0],j[N+8]=A[1],j[N+9]=A[2],j[N+10]=A[4],j[N+11]=A[5],j[N+12]=A[6],j[N+13]=A[8],j[N+14]=A[9],j[N+15]=A[10],n.instancesEvaluatedElevation[F]=y[2]}}}et(ay,"ModelBucket",{omit:["layers"]}),et(K0,"PerModelAttributes"),et(Y0,"ModelFeature");class Vh{constructor(e,t,n){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=n}static create(e,t,n){const s=n||e.findDEMTileFor(t);if(!s||!s.dem)return;const l=s.dem,c=s.tileID,h=1<<t.canonical.z-c.canonical.z;return new Vh(s,l.dim/qe/h,[(t.canonical.x/h-c.canonical.x)*l.dim,(t.canonical.y/h-c.canonical.y)*l.dim])}tileCoordToPixel(e,t){const n=t*this._scale+this._offset[1];return new De(Math.floor(e*this._scale+this._offset[0]),Math.floor(n))}getElevationAt(e,t,n,s){const l=e*this._scale+this._offset[0],c=t*this._scale+this._offset[1],h=Math.floor(l),p=Math.floor(c),_=this._dem;return s=!!s,n?lt(lt(_.get(h,p,s),_.get(h,p+1,s),c-p),lt(_.get(h+1,p,s),_.get(h+1,p+1,s),c-p),l-h):_.get(h,p,s)}getElevationAtPixel(e,t,n){return this._dem.get(e,t,!!n)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*x(1,e)*this._dem.stride}}const ly=new Float32Array(262144),Ru=new Uint8Array(262144),Hm=[0,0,0],Zm=[0,0,0];function J0(i){let e=0;if(i.meshes)for(const t of i.meshes)e=Math.max(e,t.aabb.max[2]);if(i.children)for(const t of i.children)e=Math.max(e,J0(t));return e}function Q0(i,e,t){if(i.meshes)for(const n of i.meshes){if(n.aabb.min[0]===1/0)continue;const s=Di.applyTransform(n.aabb,i.globalMatrix);t.insert(e,s.min[0],s.min[1],s.max[0],s.max[1])}if(i.children)for(const n of i.children)Q0(n,e,t)}const $m=["","wall","door","roof","window","lamp","logo"];class e1{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:J0(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new Di([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new Di([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const n of this.node.meshes)this.node.lightMeshIndex!==e&&(n.transformedAabb=Di.applyTransformFast(n.aabb,this.node.globalMatrix),t.encapsulate(n.transformedAabb)),e++;this.aabb=t}return this.aabb}}class t1{constructor(e,t,n,s,l,c,h,p){this.requiresStandardRuntime=!0,this.isTiled3dModelBucket=!0,this.id=n,this.layers=e,this.layerIds=this.layers.map(_=>_.fqid),this.stateDependentLayerIds=this.layers.filter(_=>_.isStateDependent()).map(_=>_.id),this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,s&&(this.modelTraits|=4),l&&(this.modelTraits|=8),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=c,this.worldview=p,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const _ of t)this.nodesInfo.push(new e1(_)),Q0(_,h.featureIndexArray.length,h.grid),h.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,h.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,t){for(const n of this.getNodesInfo()){const s=n.node;s.footprint&&t.push({footprint:s.footprint,id:e})}}updateAppearances(e,t,n,s){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(e){const t=Object.keys(e).length!==0;if(t&&!this.stateDependentLayers.length)return;const n=t?this.stateDependentLayers:this.layers;if(!ls(e,this.states))for(const s of n)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;const t=this.getNodesInfo();for(const n of t){const s=n.node;this.uploaded?this.updatePbrBuffer(s):Ug(s,e,!0)}for(const n of t)Mm(n.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const n of e.meshes)n.pbrBuffer&&(n.pbrBuffer.updateData(n.featureArray),t=!0);if(e.lodMeshes)for(const n of e.lodMeshes)n.pbrBuffer&&(n.pbrBuffer.updateData(n.featureArray),t=!0);return t}needsReEvaluation(e,t,n){const s=e.transform.projectionOptions,l=e.style.getBrightness(),c=this.brightness!==l;if(!this.uploaded||this.dirty||s.name!==this.projection.name||Tf(n.paint.get("model-color").value,c)||Tf(n.paint.get("model-color-mix-intensity").value,c)||Tf(n.paint.get("model-roughness").value,c)||Tf(n.paint.get("model-emissive-strength").value,c)||Tf(n.paint.get("model-height-based-emissive-strength-multiplier").value,c)){this.projection=s,this.brightness=l;const h=this.getNodesInfo();for(const p of h)p.state=null;return!0}return!1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const n=this.getNodesInfo(),s=this.id.canonical;for(const l of n){const c=l.feature;l.evaluatedTranslation=t.paint.get("model-translation").evaluate(c,{},s),l.evaluatedScale=t.paint.get("model-scale").evaluate(c,{},s)}}evaluate(e,t){const n=this.getNodesInfo();for(const s of n){if(!s.node.meshes)continue;const l=s.feature,c=t&&t[l.id];if(ls(c,s.state))continue;s.state=structuredClone(c);const h=s.node.meshes&&s.node.meshes[0].featureData,p=s.evaluatedColor[2],_=s.evaluatedRMEA[2],y=this.id.canonical;if(s.hasTranslucentParts=!1,h){for(let v=0;v<$m.length;v++){const b=$m[v];b.length&&(l.properties.part=b);const T=e.paint.get("model-color").evaluate(l,c,y).toPremultipliedRenderColor(null),S=e.paint.get("model-color-mix-intensity").evaluate(l,c,y);s.evaluatedColor[v]=[T.r,T.g,T.b,S],s.evaluatedRMEA[v][0]=e.paint.get("model-roughness").evaluate(l,c,y),s.evaluatedRMEA[v][2]=e.paint.get("model-emissive-strength").evaluate(l,c,y),s.evaluatedRMEA[v][3]=T.a,s.emissionHeightBasedParams[v]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(l,c,y),!s.hasTranslucentParts&&T.a<1&&(s.hasTranslucentParts=!0)}delete l.properties.part,DE(s,p!==s.evaluatedColor[2]||_!==s.evaluatedRMEA[2],this.modelTraits)}else s.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(l,c,y);s.evaluatedTranslation=e.paint.get("model-translation").evaluate(l,c,y),s.evaluatedScale=e.paint.get("model-scale").evaluate(l,c,y),this.updatePbrBuffer(s.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,t,n,s){const l=e.findDEMTileFor(n);if(l&&(l.tileID.canonical!==this.terrainTile||t!==this.terrainExaggeration)){if
7(l.dem&&l.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=l.tileID.overscaledZ;const c=Vh.create(e,n,l);if(!c)return;4&this.modelTraits&&this.updateDEM(e,c,n,s);for(const h of this.getNodesInfo()){const p=h.node;if(!p.footprint||!p.footprint.vertices||!p.footprint.vertices.length)continue;const _=p.footprint.vertices;let y=c.getElevationAt(_[0].x,_[0].y,!0,!0);for(let v=1;v<_.length;v++)y=Math.min(y,c.getElevationAt(_[v].x,_[v].y,!0,!0));p.elevation=y}}this.terrainTile=l.tileID.canonical,this.terrainExaggeration=t}}updateDEM(e,t,n,s){let l=t._dem._modifiedForSources[s];if(l===void 0&&(t._dem._modifiedForSources[s]=[],l=t._dem._modifiedForSources[s]),l.includes(n.canonical))return;const c=t._dem.dim;l.push(n.canonical);let h=!1;for(const p of this.getNodesInfo()){const _=p.node;if(!_.footprint||!_.footprint.grid)continue;const y=_.footprint.grid,v=t.tileCoordToPixel(y.min.x,y.min.y),b=t.tileCoordToPixel(y.max.x,y.max.y),T=Math.min(Math.min(c-b.y,v.x),Math.min(v.y,c-b.x));if(T<0)continue;const S=vt(T,2,5);let A=Math.max(0,v.x-S),C=Math.max(0,v.y-S),D=Math.min(b.x+S,c-1),z=Math.min(b.y+S,c-1);for(let j=C;j<=z;++j)for(let te=A;te<=D;++te)Ru[j*c+te]=255;let O=0,F=0;for(let j=0;j<y.cellsY;++j)for(let te=0;te<y.cellsX;++te){if(!y.cells[j*y.cellsX+te])continue;const H=t.tileCoordToPixel(y.min.x+te/y.xScale,y.min.y+j/y.yScale),W=t.tileCoordToPixel(y.min.x+(te+1)/y.xScale,y.min.y+(j+1)/y.yScale);for(let K=H.y;K<=Math.min(W.y+1,c-1);++K)for(let ee=H.x;ee<=Math.min(W.x+1,c-1);++ee)Ru[K*c+ee]===255&&(Ru[K*c+ee]=0,O+=t.getElevationAtPixel(ee,K),F++)}const N=O/F;A=Math.max(1,v.x-S),C=Math.max(1,v.y-S),D=Math.min(b.x+S,c-2),z=Math.min(b.y+S,c-2),h=!0;for(let j=C;j<=z;++j)for(let te=A;te<=D;++te)Ru[j*c+te]===0&&(ly[j*c+te]=t._dem.set(te,j,N));for(let j=1;j<S;++j){A=Math.max(1,v.x-j),C=Math.max(1,v.y-j),D=Math.min(b.x+j,c-2),z=Math.min(b.y+j,c-2);for(let te=C;te<=z;++te)for(let H=A;H<=D;++H){const W=te*c+H;if(Ru[W]===255){let K=0,ee=0,ae=-1,he=-1;for(let be=-1;be<=1;++be)for(let xe=-1;xe<=1;++xe){const Te=(te+be)*c+H+xe;if(Ru[Te]>=j)continue;const Fe=ly[Te],se=Math.abs(Fe);se>ee&&(K=Fe,ee=se,ae=xe,he=be)}if(ee>.1){const be=1-(j+.5*Math.abs(ae*he))/S;let xe=t._dem.get(H,te)+K*be;const Te=t._dem.get(H+ae,te+he),Fe=t._dem.get(H-ae,te-he,!0);(xe-Te)*(xe-Fe)>0&&(xe=(Te+Fe)/2),ly[W]=t._dem.set(H,te,xe),Ru[W]=j}}}}}h&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=X.now())}setFilter(e){this.filter=e?du(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new zi(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)Mm(t.node),jg(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped());for(const s of this.getNodesInfo()){const l=s.node.footprint;s.hiddenByReplacement=!!l&&!n.some(c=>c.footprint===l)}}getHeightAtTileCoord(e,t){const n=[0,0,0],s=rr([]);for(const l of this.getNodesInfo()){const c=l.node.meshes[0],h=c.transformedAabb;if(e<h.min[0]||t<h.min[1]||e>h.max[0]||t>h.max[1])continue;if(l.node.hidden===!0)return{height:1/0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};if(yn(s,l.node.globalMatrix),n[0]=e,n[1]=t,n[2]=0,hi(n,n,s),l.node.meshBVH){const v=n[0],b=n[1];Hm[0]=v-1,Hm[1]=b-1,Hm[2]=-1e3,Zm[0]=v+1,Zm[1]=b+1,Zm[2]=1e3;const T=l.node.meshBVH.findHighestPoint(Hm,Zm);if(T!==null)return{height:T,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]};continue}const p=(n[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Cu|0,_=Math.min(63,(n[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Cu|0)*Cu+Math.min(63,p),y=c.heightmap[_];if(y<0&&l.node.footprint){const v=[];if(l.node.footprint.grid.query(new De(e,t),new De(e,t),v),v.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:y,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]}}}}function Tf(i,e){return i instanceof lh&&!i.isLightConstant&&e}function PE(i){const e=vt(i,0,2);return Math.min(Math.round(.5*e*255),255)}const i1=new Float64Array(10*$m.length);function r1(i,e,t,n,s,l){if(!i.featureData)return;const c=i.featureArray=new Ni;c.reserveExact(i.featureData.length),function(y,v,b){const T=b-v;for(let S=0;S<$m.length;S++){const A=y.evaluatedRMEA[S],C=y.evaluatedColor[S],D=y.emissionHeightBasedParams[S],z=vt(D[0],0,1),O=vt(D[1],0,1);let F=65535,N=0,j=1,te=1;if(z!==O&&T!==0){const K=vt(D[2],0,1),ee=vt(D[3],0,1),ae=T*(O-z);N=1/ae,j=-(v+T*z)/ae,te=Math.pow(10,vt(D[4],-1,1)),F=255*K<<8|255*ee}const H=i1,W=10*S;H[W]=255*C[0],H[W+1]=255*C[1],H[W+2]=255*C[2],H[W+3]=C[3],H[W+4]=Math.floor(255*A[3]),H[W+5]=PE(A[2])<<8|15*A[0]<<4|15*A[1],H[W+6]=F,H[W+7]=N,H[W+8]=j,H[W+9]=te}}(e,i.aabb.min[2],i.aabb.max[2]);const h=i1,p=e.node;let _=s&&!!p.lights;for(const y of i.featureData){const v=y>>t&65535,b=y>>n&15,T=b<8?b:0,S=10*T;let A=(61440&v|(61440&v)>>4)>>8,C=(3840&v|(3840&v)>>4)>>4,D=240&v|(240&v)>>4;const z=(15&v|(15&v)<<4)/255,O=h[S+3];O>0&&(A=lt(A,h[S],O),C=lt(C,h[S+1],O),D=lt(D,h[S+2],O)),l&&(A*=z,C*=z,D*=z);
vendor: 6,077 bytes, line 7
7const F=A<<8|C,N=D<<8|h[S+4],j=h[S+5],te=h[S+6],H=h[S+7],W=h[S+8],K=h[S+9];if(c.emplaceBack(F,N,j,te,H,W,K),_&&T===2){_=!1;const ee=10*p.lights.length,ae=new Ni;ae.reserveExact(ee);for(let he=0;he<ee;he++)ae.emplaceBack(F,N,j,te,H,W,K);p.meshes[p.lightMeshIndex].featureArray=ae}}}function DE(i,e,t){const n=i.node,s=8&t,l=s?0:16,c=s?16:0;for(let h=0;h<n.meshes.length;h++)n.lights&&n.lightMeshIndex===h||r1(n.meshes[h],i,l,c,e,!1);if(n.lodMeshes)for(const h of n.lodMeshes)r1(h,i,l,c,!1,!0)}et(t1,"Tiled3dModelBucket",{omit:["layers"]}),et(e1,"Tiled3dModelFeature");class n1{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const n=e[t];this._stringToNumber[n]=t,this._numberToString[t]=n}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const LE=["id","tile","layer","source","sourceLayer","state"];class Pu{constructor(e,t,n,s,l){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=n,this._y=s,this.properties=e?e.properties:{},this.id=l}clone(){const e=new Pu(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state={...this.state}),this.layer&&(e.layer={...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(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const t of LE)this[t]!==void 0&&(e[t]=this[t]);return e}}const Wn={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11},cy=new Float32Array(rr([])),o1=[0,0,0],uy=(i,e,t,n,s,l,c,h,p,_,y,v,b,T=[0,0,0],S,A,C,D=1,z=!1)=>{let O=o1,F=0,N=o1;if(!z){const W=s.style.light,K=W.properties.get("position");if(O=[-K.x,-K.y,K.z],W.properties.get("anchor")==="viewport"){const ae=Bl();So(ae,-s.transform.angle),Ao(O,O,ae)}const ee=W.properties.get("color").toNonPremultipliedRenderColor(null);F=W.properties.get("intensity"),N=[ee.r,ee.g,ee.b]}const j=y.alphaMode==="MASK",te=b.paint.get("model-ambient-occlusion-intensity"),H=b.paint.get("model-color").constantOr(Pt.white).toNonPremultipliedRenderColor(null);return H.a=b.paint.get("model-color-mix-intensity").constantOr(0),C&&(H.r=C[0],H.g=C[1],H.b=C[2],H.a=C[3]),A&&(H.r=A.color.r,H.g=A.color.g,H.b=A.color.b,H.a=A.colorMix,v=A.emissionStrength,l*=A.opacity),{u_matrix:i,u_lighting_matrix:e,u_normal_matrix:t,u_node_matrix:n||cy,u_lightpos:O,u_lightintensity:F,u_lightcolor:N,u_camera_pos:T,u_opacity:l,u_baseTextureIsAlpha:0,u_alphaMask:+j,u_alphaCutoff:y.alphaCutoff,u_baseColorFactor:c.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:h.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:p,u_roughnessFactor:_,u_baseColorTexture:Wn.BaseColor,u_metallicRoughnessTexture:Wn.MetallicRoughness,u_normalTexture:Wn.Normal,u_occlusionTexture:Wn.Occlusion,u_emissionTexture:Wn.Emission,u_lutTexture:Wn.LUT,u_color_mix:H.toArray01(),u_aoIntensity:te,u_emissive_strength:v,u_occlusionTextureTransform:S||[0,0,0,0],u_dithered_discard_threshold:D}},s1=(i,e=cy,t=cy)=>({u_matrix:i,u_instance:e,u_node_matrix:t}),hy=7680;class vs{constructor(e,t,n,s,l,c){this.test=e,this.ref=t,this.mask=n,this.fail=s,this.depthFail=l,this.pass=c}}vs.disabled=new vs({func:519,mask:0},0,0,hy,hy,hy);const qm=770,Uh=771;class er{constructor(e,t,n,s){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=n,this.blendEquation=s}}er.Replace=[1,0,1,0],er.disabled=new er(er.Replace,Pt.transparent,[!1,!1,!1,!1]),er.unblended=new er(er.Replace,Pt.transparent,[!0,!0,!0,!0]),er.alphaBlended=new er([1,Uh,1,Uh],Pt.transparent,[!0,!0,!0,!0]),er.alphaBlendedNonPremultiplied=new er([qm,Uh,qm,Uh],Pt.transparent,[!0,!0,!0,!0]),er.multiply=new er([774,0,774,0],Pt.transparent,[!0,!0,!0,!0]),er.multiplyAccumulateAlpha=new er([774,0,1,Uh],Pt.transparent,[!0,!0,!0,!0]),er.additive=new er([1,1,1,1],Pt.transparent,[!0,!0,!0,!0]),er.additiveAlphaWeighted=new er([qm,1,773,1],Pt.transparent,[!0,!0,!0,!0]),er.additiveAlphaWeightedUnboundedAlpha=new er([qm,1,1,1],Pt.transparent,[!0,!0,!0,!0]);class pn{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}pn.ReadOnly=!1,pn.ReadWrite=!0,pn.disabled=new pn(519,pn.ReadOnly,[0,1]);const dy=1029,fy=2305;class mn{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}mn.disabled=new mn(!1,dy,fy),mn.backCCW=new mn(!0,dy,fy),mn.backCW=new mn(!0,dy,2304),mn.frontCW=new mn(!0,1028,2304),mn.frontCCW=new mn(!0,1028,fy);class py{constructor(e=0,t=0,n=0,s=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(s)||s<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=n,this.right=s}interpolate(e,t,n){return t.top!=null&&e.top!=null&&(this.top=lt(e.top,t.top,n)),t.bottom!=null&&e.bottom!=null&&(this.bottom=lt(e.bottom,t.bottom,n)),t.left!=null&&e.left!=null&&(this.left=lt(e.left,t.left,n)),t.right!=null&&e.right!=null&&(this.right=lt(e.right,t.right,n)),this}getCenter(e,t){return new De(vt((this.left+e-this.right)/2,0,e),vt((this.top+t-this.bottom)/2,0,t))}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new py(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function a1(i,e){const t=Fr(i,3);Ga(i,e),io(i,3,t)}function my(i,e){const t=Mn([]);return Co(t,t,-e),Gs(t,t,-i),t}function l1(i,e){const t=[i[0],i[1],0],n=[e[0],e[1],0];if(Ki(t)>=1e-15){const c=ei([],t);si(n,c,Ri(n,c)),e[0]=n[0],e[1]=n[1]}const s=gr([],e,i);if(Ss(s)<1e-15)return null;const l=Math.atan2(-s[1],s[0]);return my(Math.atan2(Math.sqrt(i[0]*i[0]+i[1]*i[1]),-i[2]),l)}class c1{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(e){if(e){const t=e instanceof V?e:new V(e[0],e[1],e[2]);
vendor: 1,744 bytes, line 7
7this._renderWorldCopies&&(t.x=xn(t.x,0,1)),this._position=t}else this._position=null}lookAtPoint(e,t,n){if(this.orientation=null,!this.position)return;const s=this.position,l=n||(this._elevation?this._elevation.getAtPointOrZero(V.fromLngLat(e)):0),c=V.fromLngLat(e,l),h=[c.x-s.x,c.y-s.y,c.z-s.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=l1(h,t)}setPitchBearing(e,t){this.orientation=my(Ot(e),Ot(-t))}}class Wm{constructor(e,t){this._transform=rr([]),this.orientation=t,this.position=e}get mercatorPosition(){const e=this.position;return new V(e[0],e[1],e[2])}get position(){const e=Fr(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var t;e&&io(this._transform,3,[(t=e)[0],t[1],t[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||Mn([]),e&&a1(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=my(e,t),a1(this._transform,this._orientation)}forward(){const e=Fr(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=Fr(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=Fr(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,t){const n=new Float64Array(16);return yn(n,this.getWorldToCamera(e,t)),n}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,t,n){const s=this.position;si(s,s,-e);const l=new Float64Array(16);return Ho(l,[n,n,n]),Yi(l,l,s),l[10]*=t,l}getWorldToCamera(e,t){const n=new Float64Array(16),s=new Float64Array(4),l=this.position;var c,h;return(c=s)[0]=-(h=this._orientation)[0],c[1]=-h[1],c[2]=-h[2],c[3]=h[3],si(l,l,-e),Ga(n,s),Yi(n,n,l),n[1]
vendor: 60,368 bytes, lines 7-36
7*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=t,n[9]*=t,n[10]*=t,n[11]*=t,n}getCameraToClipPerspective(e,t,n,s){const l=new Float64Array(16);return Vl(l,e,t,n,s),l}getCameraToClipOrthographic(e,t,n,s,l,c){const h=new Float64Array(16);return Fu(h,e,t,n,s,l,c),h}getDistanceToElevation(e,t=!1){const n=e===0?0:x(e,t?vr(this.position[1]):this.position[1]),s=this.forward();return(n-this.position[2])/s[2]}clone(){return new Wm([...this.position],[...this.orientation])}}const zE=Math.tan(85*Math.PI/180);function _y(i,e,t,n,s,l,c){const h=Yn();if(t)if(l.name==="globe"){const p=function(_,y){const{x:v,y:b}=_.point,T=gx(v,b,_.worldSize/_._pixelsPerMercatorPixel,0,0);return Dt(T,T,hg(za(y)))}(s,e);Dt(h,h,p)}else{const p=Ac([],c);h[0]=p[0],h[1]=p[1],h[4]=p[2],h[5]=p[3],n||Os(h,h,s.angle)}else Dt(h,s.labelPlaneMatrix,i);return h}function Ec(i,e,t,n){const s=[i,e,t,1];t?lr(s,s,n):g1(s,s,n);const l=s[3];return s[0]/=l,s[1]/=l,s[2]/=l,s}function u1(i,e){return Math.min(.5+i/e*.5,1.5)}function FE(i,e){const t=i[0]/i[3],n=i[1]/i[3];return t>=-e[0]&&t<=e[0]&&n>=-e[1]&&n<=e[1]}function h1(i,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D){const{lineStartIndex:z,glyphStartIndex:O,segment:F}=h,N=O+h.numGlyphs,j=z+h.lineLength,te=e.getoffsetX(O),H=e.getoffsetX(N-1),W=Xm(i*te,t,n,s,l,c,F,z,j,p,_,y,v,b,!0,T,S,A,C,D);if(!W)return null;const K=Xm(i*H,t,n,s,l,c,F,z,j,p,_,y,v,b,!0,T,S,A,C,D);return K?{first:W,last:K}:null}function d1(i,e,t,n){return i===Al.horizontal&&Math.abs(n)>Math.abs(t)?{useVertical:!0}:i===Al.vertical?n>0?{needsFlipping:!0}:null:e!==0&&function(s,l){return s===0||Math.abs(l/s)>zE}(t,n)?e===1?{needsFlipping:!0}:null:t<0?{needsFlipping:!0}:null}function f1(i,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O,F){const N=e/24,j=i.lineOffsetX*N,te=i.lineOffsetY*N,{lineStartIndex:H,glyphStartIndex:W,numGlyphs:K,segment:ee,writingMode:ae,flipState:he}=i,be=H+i.lineLength,xe=Te=>{if(y){const[ge,Ae,Me]=Te.up,ze=_.length;dm(y,ze+0,ge,Ae,Me),dm(y,ze+1,ge,Ae,Me),dm(y,ze+2,ge,Ae,Me),dm(y,ze+3,ge,Ae,Me)}const[Fe,se,fe]=Te.point;Su(_,Fe,se,fe,Te.angle)};if(K>1){const Te=h1(N,h,j,te,t,v,b,i,p,l,T,A,!1,C,D,z,O,F);if(!Te)return{notEnoughRoom:!0};if(n&&!t){let[Fe,se,fe]=Te.first.point,[ge,Ae,Me]=Te.last.point;[Fe,se]=Ec(Fe,se,fe,c),[ge,Ae]=Ec(ge,Ae,Me,c);const ze=d1(ae,he,(ge-Fe)*S,Ae-se);if(i.flipState=ze&&ze.needsFlipping?1:2,ze)return ze}xe(Te.first);for(let Fe=W+1;Fe<W+K-1;Fe++){const se=Xm(N*h.getoffsetX(Fe),j,te,t,v,b,ee,H,be,p,l,T,A,!1,!1,C,D,z,O,F);if(!se)return _.length-=4*(Fe-W),{notEnoughRoom:!0};xe(se)}xe(Te.last)}else{if(n&&!t){const Fe=Ec(b.x,b.y,0,s),se=H+ee+1,fe=new De(p.getx(se),p.gety(se)),ge=Ec(fe.x,fe.y,0,s),Ae=ge[3]>0?ge:_1(b,fe,Fe,1,s,void 0,C,D.canonical),Me=d1(ae,he,(Ae[0]-Fe[0])*S,Ae[1]-Fe[1]);if(i.flipState=Me&&Me.needsFlipping?1:2,Me)return Me}const Te=Xm(N*h.getoffsetX(W),j,te,t,v,b,ee,H,be,p,l,T,A,!1,!1,C,D,z,O,F);if(!Te)return{notEnoughRoom:!0};xe(Te)}return{}}function p1(i,e,t){const n=1<<e.z;let s=(i.x/qe+e.x)/n-t.mercCenter[0];const l=(i.y/qe+e.y)/n-t.mercCenter[1];s-=Math.round(s);const c=[s*qe,l*qe,qe/(2*Math.PI),1];return lr(c,c,t.invMatrix),[c[0],c[1],c[2]]}function m1(i,e,t,n,s,l){let{x:c,y:h,z:p}=n.projectTilePoint(i.x,i.y,e);if(l){const[b,T,S]=p1(i,e,l);c+=(b-c)*l.t,h+=(T-h)*l.t,p+=(S-p)*l.t}if(!s)return Ec(c,h,p,t);const[_,y,v]=s.getElevation(i,s.elevation,s.elevationFeature);return Ec(c+_,h+y,p+v,t)}function _1(i,e,t,n,s,l,c,h,p){const _=m1(i.sub(e)._unit()._add(i),h,s,c,l,p);return Pi(_,t,_),ei(_,_),cn(_,t,_,n)}function Xm(i,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O){const F=n?i-e:i+e;let N=F>0?1:-1,j=0;n&&(N*=-1,j=Math.PI),N<0&&(j+=Math.PI);let te=h+c+(N>0?0:1)|0,H=s,W=s,K=0,ee=0;const ae=Math.abs(F),he=[],be=[];let xe=l,Te=xe,Fe=Rc([]);const se=()=>_1(Te,xe,W,ae-K+1,y,b,A,C.canonical,O);for(;K+ee<=ae;){if(te+=N,te<h||te>=p)return null;if(W=H,Te=xe,he.push(W),T&&be.push(Te),xe=new De(_.getx(te),_.gety(te)),H=v[te],!H){const Ve=m1(xe,C.canonical,y,A,b,O);H=Ve[3]>0?v[te]=Ve:se()}K+=ee;const ke=Pi([],H,W),Ke=Za(W,H);if(t&&Ke>0&&ee>0&&Ri(Fe,ke)/(ee*Ke)<z)return null;ee=Ke,Fe=ke}S&&b&&(v[te]&&(H=se(),ee=Za(W,H),Fe=Pi([],H,W)),v[te]=H);const fe=(ae-K)/ee,ge=xe.sub(Te)._mult(fe)._add(Te),Ae=cn([],W,Fe,fe);let Me=[0,0,1],ze=Fe[0],Ce=Fe[1];if(D&&(Me=A.upVector(C.canonical,ge.x,ge.y),Me[0]!==0||Me[1]!==0||Me[2]!==1)){const ke=[Me[2],0,-Me[0]],Ke=gr([],Me,ke);ei(ke,ke),ei(Ke,Ke),ze=Ri(Fe,ke),Ce=Ri(Fe,Ke)}if(t){const ke=gr([],Me,Fe);ei(ke,ke),cn(Ae,Ae,ke,t*N)}const Be=j+Math.atan2(Ce,ze);return he.push(Ae),T&&be.push(ge),{point:Ae,angle:Be,path:he,tilePath:be,up:Me}}function Ef(i,e){const t=e.length,n=t+4*i;e.resize(n),e.float32.fill(-1/0,4*t,4*n)}function g1(i,e,t){const n=e[0],s=e[1];return i[0]=t[0]*n+t[4]*s+t[12],i[1]=t[1]*n+t[5]*s+t[13],i[3]=t[3]*n+t[7]*s+t[15],i}const jh=15;class gy{constructor(e,t,n,s,l,c,h){this.tileSize=512,this._renderWorldCopies=l===void 0||l,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=n??0,this._maxPitch=s??60,this.setProjection(c),this.setMaxBounds(h),this.width=0,this.height=0,this._center=new f(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 py,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Wm,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.labelPlaneMatrix=new Float32Array(16),this.glCoordMatrix=new Float32Array(16),this.pixelMatrix=new Float64Array(16),this.pixelMatrixInverse=new Float64Array(16)}clone(){const e=new gy(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._nearClipOffset=this._nearClipOffset,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e._allowWorldUnderZoom=this._allowWorldUnderZoom,e}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<jh}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(e){this._nearClipOffset=e,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(e,t=!1){const n=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||n)&&this._updateCameraOnTerrain(),(e||n)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return Qa(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=tm(this.projectionOptions);const n=!ls(t,this.getProjection());return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=tm({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return x(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new De(this.width,this.height)}get bearing(){return xn(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;if(this.angle===t)return;this._unmodified=!1,this.angle=t,this._calcMatrices();const n=Math.sin(this.angle),s=Math.cos(this.angle);this.rotationMatrix=[s,n,-n,s]}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=vt(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=Ot(e),this._calcMatrices())}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}get horizontalFov(){return Gr(2*Math.atan(Math.tan(.5*this._fov)*this.aspect))}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const n=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&n.exaggeration()&&this._centerAltitudeValidForExaggeration!==n.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*n.exaggeration(),this._centerAltitudeValidForExaggeration=n.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=n.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e)}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let s=0,l=0;for(let c=0;c<t.length;c++){const h=new De(t[c][0]*this.width,n+t[c][1]*(this.height-n)),p=e.pointCoordinate(h);if(!p)continue;const _=1/Math.hypot(p[0]-this._camera.position[0],p[1]-this._camera.position[1]);s+=p[3]*_,l+=_}return l===0?NaN:s/l}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),n=this.pixelsPerMeter/this.worldSize*t,s=this._mercatorZfromZoom(e),l=this._mercatorZfromZoom(this._maxZoom),c=Math.max(s-n,l);this._setZoom(this._zoomFromMercatorZ(c))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}equals(e){const t=this.elevation,n=e.elevation,s=t!=null!=(n!=null)||t&&n&&t.exaggeration()!==n.exaggeration();return this.width===e.width&&this.height===e.height&&this.center.lng===e.center.lng&&this.center.lat===e.center.lat&&this.zoom===e.zoom&&this.bearing===e.bearing&&this.pitch===e.pitch&&this.fov===e.fov&&this.projection.name===e.projection.name&&this._edgeInsets.equals(e.padding)&&!s}computeZoomRelativeTo(e){const t=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let n;n=e.z<this._camera.position[2]?[t.x,t.y,t.z]:[e.x,e.y,e.z];const s=Ki(Pi([],this._camera.position,n));return vt(this._zoomFromMercatorZ(s),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height||!e.position&&!e.orientation)return;this._updateCameraState();let t=!1;if(e.orientation&&!((n=e.orientation)[0]===(s=this._camera.orientation)[0]&&n[1]===s[1]&&n[2]===s[2]&&n[3]===s[3])&&(t=this._setCameraOrientation(e.orientation)),e.position){const l=[e.position.x,e.position.y,e.position.z];os(l,this._camera.position)||(this._setCameraPosition(l),t=!0)}var n,s;t&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,t=new c1;return t.position=new V(e[0],e[1],e[2]),t.orientation=this._camera.orientation,t._elevation=this.elevation,t._renderWorldCopies=this.renderWorldCopies,t}_setCameraOrientation(e){if(!function(l){var c=l[0],h=l[1],p=l[2],_=l[3];return Math.sqrt(c*c+h*h+p*p+_*_)}(e))return!1;$a(e,e);const t=oa([],[0,0,-1],e),n=oa([],[0,-1,0],e);if(n[2]<0)return!1;const s=l1(t,n);return!!s&&(this._camera.orientation=s,!0)}_setCameraPosition(e){const t=this.zoomScale(this.minZoom)*this.tileSize,n=this.zoomScale(this.maxZoom)*this.tileSize,s=this.cameraToCenterDistance;e[2]=vt(e[2],s/n,s/t),this._camera.position=e}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,n){this._unmodified=!1,this._edgeInsets.interpolate(e,t,n),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(e){const t=[new Jp(0,e)];if(this.renderWorldCopies){const n=this.pointCoordinate(new De(0,0)),s=this.pointCoordinate(new De(this.width,0)),l=this.pointCoordinate(new De(this.width,this.height)),c=this.pointCoordinate(new De(0,this.height)),h=Math.floor(Math.min(n.x,s.x,l.x,c.x)),p=Math.floor(Math.max(n.x,s.x,l.x,c.x)),_=1;for(let y=h-_;y<=p+_;y++)y!==0&&t.push(new Jp(y,e))}return t}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(e,t,n,s){let l=[];const c=n!=null,h=!c;if(h&&this.zoom<t||c&&n[0]===0&&n[1]===0)return l;const p=new Set,_=(v,b,T,S,A)=>{const C=xc(b,v,T,S,A);p.has(C)||(l.push(new Wr(v,b,T,S,A)),p.add(C))};for(let v=0;v<e.length;v++){const b=e[v];if(h&&b.canonical.z!==t||c&&s!==void 0&&s>b.canonical.z)continue;const T=b.canonical,S=b.overscaledZ,A=b.wrap,C=1<<T.z,D=T.x+1<C,z=T.x>0,O=T.y+1<C,F=T.y>0,N=b.wrap-(z?0:1),j=b.wrap+(D?0:1),te=z?T.x-1:C-1,H=D?T.x+1:0;if(c)n[0]<0?(_(S,j,T.z,H,T.y),n[1]<0&&O&&(_(S,A,T.z,T.x,T.y+1),_(S,j,T.z,H,T.y+1)),n[1]>0&&F&&(_(S,A,T.z,T.x,T.y-1),_(S,j,T.z,H,T.y-1))):n[0]>0?(_(S,N,T.z,te,T.y),n[1]<0&&O&&(_(S,A,T.z,T.x,T.y+1),_(S,N,T.z,te,T.y+1)),n[1]>0&&F&&(_(S,A,T.z,T.x,T.y-1),_(S,N,T.z,te,T.y-1))):n[1]<0&&O?_(S,A,T.z,T.x,T.y+1):F&&_(S,A,T.z,T.x,T.y-1);else{const W=b.visibleQuadrants;1&W&&(_(S,N,T.z,te,T.y),F&&(_(S,A,T.z,T.x,T.y-1),_(S,N,T.z,te,T.y-1))),2&W&&(_(S,j,T.z,H,T.y),F&&(_(S,A,T.z,T.x,T.y-1),_(S,j,T.z,H,T.y-1))),4&W&&(_(S,N,T.z,te,T.y),O&&(_(S,A,T.z,T.x,T.y+1),_(S,N,T.z,te,T.y+1))),8&W&&(_(S,j,T.z,H,T.y),O&&(_(S,A,T.z,T.x,T.y+1),_(S,j,T.z,H,T.y+1)))}}const y=[];for(const v of l)l.some(b=>v.isChildOf(b))||y.push(v);if(l=y.filter(v=>!e.some(b=>!!(v.overscaledZ<t&&b.isChildOf(v))||v.equals(b)||v.isChildOf(b))),h){const v=1<<t,b=this.projection.name==="globe"?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),T=[v*b.x,v*b.y],S=4,A=S*S;l=l.filter(C=>{const D=C.canonical.x+.5-T[0],z=C.canonical.y+.5-T[1];return D*D+z*z<A})}return l}extendTileCoverToNearPlane(e,t,n){const s=[],l=new Set;for(const z of e)l.add(z.key);const c=(z,O,F,N,j)=>{const te=xc(O,z,F,N,j);l.has(te)||(s.push(new Wr(z,O,F,N,j)),l.add(te))},h=e.reduce((z,O)=>Math.max(z,O.overscaledZ),n),p=1<<n,_=[new De(0,0),new De(qe,0),new De(qe,qe),new De(0,qe)],y=new De(0,0),v=new De(0,0),b=(z,O)=>{const F=Math.floor(z[0]),N=Math.floor(z[1]),j=(z[0]-F)*qe,te=(z[1]-N)*qe,H=Math.floor(O[0]),W=Math.floor(O[1]),K=(O[0]-H)*qe,ee=(O[1]-W)*qe;for(let ae=-1;ae<=1;ae++){const he=F+ae;if(!(he<0||he>=p)){y.x=j-ae*qe,v.x=K-(he-H)*qe;for(let be=-1;be<=1;be++){const xe=N+be;y.y=te-be*qe,v.y=ee-(xe-W)*qe,Ih(y,v,_)&&c(h,0,n,he,xe)}}}},T=t.points,S=T[3],A=T[2],C=this._projectToGround(S,T[7]),D=this._projectToGround(A,T[6]);return b(S,C),b(A,D),s}_projectToGround(e,t){return js(Jt(),e,t,e[2]/(e[2]-t[2]))}_projectToZ(e,t,n){const s=e[2]-t[2];return Math.abs(s)<1e-6?ks(e):js(Jt(),e,t,(e[2]-n)/s)}extendTileCoverForTunnels(e,t,n,s){if(n<18)return[];const l=t.points,c=l[0],h=l[1],p=l[4],_=l[5];if(p[2]>=0&&_[2]>=0||c[2]<=0||h[2]<=0)return[];const y=p[2]<0?this._projectToZ(c,p,0):p,v=_[2]<0?this._projectToZ(h,_,0):_,b=-s,T=p[2]<b?this._projectToZ(c,p,b):p,S=_[2]<b?this._projectToZ(h,_,b):_,A=this._findExtensionTilesInQuad(e,n,[S,T,v,y],[.5*(y[0]+v[0]),.5*(y[1]+v[1])]);return A.length>3&&(A.length=3),A}_findExtensionTilesInQuad(e,t,n,s){const l=[],c=new Set;for(const H of e)c.add(H.key);const h=e.reduce((H,W)=>Math.max(H,W.overscaledZ),t),p=1<<t,_=[new De(n[0][0],n[0][1]),new De(n[1][0],n[1][1]),new De(n[3][0],n[3][1]),new De(n[2][0],n[2][1]),new De(n[0][0],n[0][1])],y=n[0][0],v=n[1][0],b=n[2][0],T=n[3][0],S=n[0][1],A=n[1][1],C=n[2][1],D=n[3][1],z=Math.max(0,Math.floor(Math.min(y,v,b,T))),O=Math.min(p-1,Math.ceil(Math.max(y,v,b,T))-1),F=Math.max(0,Math.floor(Math.min(S,A,C,D))),N=Math.min(p-1,Math.ceil(Math.max(S,A,C,D))-1);for(let H=F;H<=N;H++)for(let W=z;W<=O;W++){if(!K_(_,W,H,W+1,H+1))continue;const K=xc(0,h,t,W,H);c.has(K)||(l.push(new Wr(h,0,t,W,H)),c.add(K))}const j=s[0],te=s[1];return l.sort((H,W)=>{const K=H.canonical.x+.5-j,ee=H.canonical.y+.5-te,ae=W.canonical.x+.5-j,he=W.canonical.y+.5-te;return K*K+ee*ee-(ae*ae+he*he)||H.canonical.x-W.canonical.x||H.canonical.y-W.canonical.y}),l}coveringTiles(e){let t=this.coveringZoomLevel(e);const n=t,s=this.elevation&&this.elevation.exaggeration(),l=s&&!e.isTerrainDEM,c=this.projection.name==="mercator";if(e.minzoom!==void 0&&t<e.minzoom)return[];e.maxzoom!==void 0&&t>e.maxzoom&&(t=e.maxzoom);const h=this.locationCoordinate(this.center),p=this.center.lat,_=1<<t,y=[_*h.x,_*h.y,0],v=this.projection.name==="globe",b=!v,T=Cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,b),S=v?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),A=_*x(1,this.center.lat),C=this._camera.position[2]/x(1,this.center.lat),D=[_*S.x,_*S.y,C*(b?1:A)],z=v||s,O=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),F=this.isLODDisabled(!0)?t:0;let N;if(this._elevation&&e.isTerrainDEM)N=1e4*this._elevation.exaggeration();else if(this._elevation){const se=this._elevation.getMinMaxForVisibleTiles();N=se?se.max:this._centerAltitude}else N=this._centerAltitude;const j=e.isTerrainDEM?-N:this._elevation?this._elevation.getMinElevationBelowMSL():0,te=this.projection.isReprojectedInTileSpace?Cv(this):1,H=se=>{const ge=new V(se.x+25e-6,se.y,se.z),Ae=new V(se.x,se.y+25e-6,se.z),Me=se.toLngLat(),ze=ge.toLngLat(),Ce=Ae.toLngLat(),Be=this.locationCoordinate(Me),ke=this.locationCoordinate(ze),Ke=this.locationCoordinate(Ce),Ve=Math.hypot(ke.x-Be.x,ke.y-Be.y),$e=Math.hypot(Ke.x-Be.x,Ke.y-Be.y);return Math.sqrt(Ve*$e)*te/25e-6},W=se=>{const fe=N,ge=j;return{aabb:wx(this,_,0,0,0,se,ge,fe,this.projection),zoom:0,x:0,y:0,minZ:ge,maxZ:fe,wrap:se,fullyVisible:!1}},K=[];let ee=[];const ae=t,he=e.reparseOverscaled?n:t,be=(C-this._centerAltitude)*A,xe=se=>{if(!this._elevation||!se.tileID||!c)return;const fe=this._elevation.getMinMaxForTile(se.tileID),ge=se.aabb;fe?(ge.min[2]=fe.min,ge.max[2]=fe.max,ge.center[2]=(ge.min[2]+ge.max[2])/2):(se.shouldSplit=Fe(se),se.shouldSplit||(ge.min[2]=ge.max[2]=ge.center[2]=this._centerAltitude))},Te=(se,fe)=>{if(.707*fe<se)return 1;const ge=fe/se;return ge/(1.4144271570014144+(Math.pow(1.1,ge-1.4144271570014144+1)-1)/(1.1-1)-1)},Fe=se=>{if(se.zoom<F)return!0;if(se.zoom===ae)return!1;if(se.shouldSplit!=null)return se.shouldSplit;const fe=se.aabb.distanceX(D),ge=se.aabb.distanceY(D);let Ae=be,Me=1;if(v){Ae=se.aabb.distanceZ(D);const $e=Math.pow(2,se.zoom),dt=vr((se.y+1)/$e),pt=vr(se.y/$e),yt=Math.min(Math.max(p,dt),pt),ht=g(yt)/g(p);if(Me=yt===p?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,ht/this._mercatorScaleRatio),this.zoom<=5&&se.zoom===ae-1&&ht>=.9)return!0}else if(l&&(Ae=se.aabb.distanceZ(D)*A),this.projection.isReprojectedInTileSpace&&n<=5){const $e=Math.pow(2,se.zoom),dt=H(new V((se.x+.5)/$e,(se.y+.5)/$e));Me=dt>.85?1:dt}if(!c&&!v){const $e=Math.sqrt(fe*fe+ge*ge+Ae*Ae);let dt=(1<<ae-se.zoom)*O*Me;return dt*=Te(Math.max(Ae,be),$e),$e<dt}let ze=Number.MAX_VALUE,Ce=0;const Be=se.aabb.getCorners(),ke=[0,0,0];for(const $e of Be){Pi(ke,$e,D),v||(l?ke[2]*=A:ke[2]=be);const dt=Ri(ke,this._camera.forward());dt<ze&&(ze=dt,Ce=Math.abs(ke[2]))}let Ke=(1<<ae-se.zoom)*O*Me;if(Ke*=Te(Math.max(Ce,be),ze),ze<Ke)return!0;const Ve=se.aabb.closestPoint(y);return Ve[0]===y[0]&&Ve[1]===y[1]};if(this.renderWorldCopies)for(let se=1;se<=3;se++)K.push(W(-se)),K.push(W(se));for(K.push(W(0));K.length>0;){const se=K.pop(),fe=se.x,ge=se.y;let Ae=se.fullyVisible;const Me=()=>this.projection.name==="globe"&&(se.y===0||se.y===(1<<se.zoom)-1);if(!Ae){let ze=z?se.aabb.intersects(T):se.aabb.intersectsFlat(T);if(ze===0&&Me()){const Ce=new yc(se.zoom,fe,ge);ze=cg(this,_,Ce,!0).intersects(T)}if(ze===0)continue;Ae=ze===2}if(se.zoom===ae||!Fe(se)){const ze=se.zoom===ae?he:se.zoom;if(e.minzoom&&e.minzoom>ze)continue;let Ce=0;if(!Ae){let Ve=z?se.aabb.intersectsPrecise(T):se.aabb.intersectsPreciseFlat(T);if(Ve===0&&Me()){const $e=new yc(se.zoom,fe,ge);Ve=cg(this,_,$e,!0).intersectsPrecise(T)}if(Ve===0)continue;if(e.calculateQuadrantVisibility)if(T.containsPoint(se.aabb.center))Ce=15;else for(let $e=0;$e<4;$e++)se.aabb.quadrant($e).intersects(T)!==0&&(Ce|=1<<$e)}const Be=y[0]-(.5+fe+(se.wrap<<se.zoom))*(1<<t-se.zoom),ke=y[1]-.5-ge,Ke=se.tileID?se.tileID:new Wr(ze,se.wrap,se.zoom,fe,ge);e.calculateQuadrantVisibility&&(Ke.visibleQuadrants=Ce),ee.push({tileID:Ke,distanceSq:Be*Be+ke*ke});continue}for(let ze=0;ze<4;ze++){const Ce=(fe<<1)+ze%2,Be=(ge<<1)+(ze>>1),ke={aabb:c?se.aabb.quadrant(ze):wx(this,_,se.zoom+1,Ce,Be,se.wrap,se.minZ,se.maxZ,this.projection),zoom:se.zoom+1,x:Ce,y:Be,wrap:se.wrap,fullyVisible:Ae,tileID:void 0,shouldSplit:void 0,minZ:se.minZ,maxZ:se.maxZ};l&&!v&&(ke.tileID=new Wr(se.zoom+1===ae?he:se.zoom+1,se.wrap,se.zoom+1,Ce,Be),xe(ke)),K.push(ke)}}if(this.fogCullDistSq){const se=this.fogCullDistSq,fe=this.horizonLineFromTop();ee=ee.filter(ge=>{const Ae=[0,0,0,1],Me=[qe,qe,0,1],ze=this.calculateFogTileMatrix(ge.tileID.toUnwrapped());lr(Ae,Ae,ze),lr(Me,Me,ze);const Ce=(Ve=Ae,$e=Me,(Ke=[])[0]=Math.min(Ve[0],$e[0]),Ke[1]=Math.min(Ve[1],$e[1]),Ke[2]=Math.min(Ve[2],$e[2]),Ke[3]=Math.min(Ve[3],$e[3]),Ke),Be=function(yt,ht,wt){return yt[0]=Math.max(ht[0],wt[0]),yt[1]=Math.max(ht[1],wt[1]),yt[2]=Math.max(ht[2],wt[2]),yt[3]=Math.max(ht[3],wt[3]),yt}([],Ae,Me),ke=function(yt,ht){let wt=0;for(let bt=0;bt<2;++bt)yt[bt]>0&&(wt+=(yt[bt]-0)*(yt[bt]-0)),ht[bt]<0&&(wt+=(0-ht[bt])*(0-ht[bt]));return wt}(Ce,Be);var Ke,Ve,$e;if(ke===0)return!0;let dt=!1;const pt=this._elevation;if(pt&&ke>se&&fe!==0){const yt=this.calculateProjMatrix(ge.tileID.toUnwrapped());let ht;e.isTerrainDEM||(ht=pt.getMinMaxForTile(ge.tileID)),ht||(ht={min:j,max:N});const wt=function(ri){const jt=Math.round((ri+45+360)%360/90)%4;return Ja[jt]}(this.rotation),bt=[wt[0]*qe,wt[1]*qe,ht.max];hi(bt,bt,yt),dt=(1-bt[1])*this.height*.5<fe}return ke<se||dt})}return ee.sort((se,fe)=>se.distanceSq-fe.distanceSq).map(se=>se.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log2(e)}project(e){const t=vt(e.lat,-85.051129,E),n=this.projection.project(e.lng,t);return new De(n.x*this.worldSize,n.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/x(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,t){let n,s;const l=this.centerPoint;if(this.projection.name==="globe"){const h=this.worldSize;n=(t.x-l.x)/h,s=(t.y-l.y)/h}else{const h=this.pointCoordinate(t),p=this.pointCoordinate(l);n=h.x-p.x,s=h.y-p.y}const c=this.locationCoordinate(e);this.setLocation(new V(c.x-n,c.y-s))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(e,t){const n=t?x(t,e.lat):void 0,s=this.projection.project(e.lng,e.lat);return new V(s.x,s.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const n=t??this._centerAltitude,s=[e.x,e.y,0,1],l=[e.x,e.y,1,1];lr(s,s,this.pixelMatrixInverse),lr(l,l,this.pixelMatrixInverse);const c=l[3];Zo(s,s,1/s[3]),Zo(l,l,1/c);const h=s[2],p=l[2];return{p0:s,p1:l,t:h===p?0:(n-h)/(p-h)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],n=[e.x,e.y,1,1];return lr(t,t,this.pixelMatrixInverse),lr(n,n,this.pixelMatrixInverse),Zo(t,t,1/t[3]),Zo(n,n,1/n[3]),t[2]=x(t[2],this._center.lat)*this.worldSize,n[2]=x(n[2],this._center.lat)*this.worldSize,Zo(t,t,1/this.worldSize),Zo(n,n,1/this.worldSize),new $p([t[0],t[1],t[2]],ei([],Pi([],n,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:n,t:s}=e,l=x(t[2],this._center.lat),c=x(n[2],this._center.lat);return new V(lt(t[0],n[0],s)/this.worldSize,lt(t[1],n[1],s)/this.worldSize,lt(l,c,s))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e,t){if(!this.elevation)return this.pointCoordinate(e,t);let n=this.projection.pointCoordinate3D(this,e.x,e.y);if(n)return new V(n[0],n[1],n[2]);let s=0,l=this.horizonLineFromTop();if(e.y>l)return this.pointCoordinate(e,t);const c=.02*l,h=e.clone();for(let p=0;p<10&&l-s>c;p++){h.y=lt(s,l,.66);const _=this.projection.pointCoordinate3D(this,h.x,h.y);_?(l=h.y,n=_):s=h.y}return n?new V(n[0],n[1],n[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return!1;if(this.elevation||this.zoom>=6)return!this.isPointAboveHorizon(e);const t=this.pointCoordinate(e);return t.y>=0&&t.y<=1}_coordinatePoint(e,t){const n=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,s=[e.x*this.worldSize,e.y*this.worldSize,n+e.toAltitude(),1];return lr(s,s,this.pixelMatrix),s[3]>0?new De(s[0]/s[3],s[1]/s[3]):new De(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:t}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,l=this.pointLocation3D(new De(t,e)),c=this.pointLocation3D(new De(s,e)),h=this.pointLocation3D(new De(s,n)),p=this.pointLocation3D(new De(t,n));let _=Math.min(l.lng,c.lng,h.lng,p.lng),y=Math.max(l.lng,c.lng,h.lng,p.lng),v=Math.min(l.lat,c.lat,h.lat,p.lat),b=Math.max(l.lat,c.lat,h.lat,p.lat);const T=Math.pow(2,-this.zoom)/16*270,S=this.projection.name==="globe"?1:4,A=(C,D,z,O,F)=>{const N=(C+z)/2,j=(D+O)/2,te=new De(N,j),{lng:H,lat:W}=this.pointLocation3D(te),K=Math.max(0,_-H,v-W,H-y,W-b);_=Math.min(_,H),y=Math.max(y,H),v=Math.min(v,W),b=Math.max(b,W),(F<S||K>T)&&(A(C,D,N,j,F+1),A(N,j,z,O,F+1))};if(A(t,e,s,e,1),A(s,e,s,n,1),A(s,n,t,n,1),A(t,n,t,e,1),this.projection.name==="globe"){const[C,D]=function(z){const O=rr(new Float64Array(16));Dt(O,z.pixelMatrix,z.globeMatrix);const F=[0,_o,0],N=[0,ms,0];return hi(F,F,O),hi(N,N,O),[F[0]>0&&F[0]<=z.width&&F[1]>0&&F[1]<=z.height&&!fg(z,new f(z.center.lat,90)),N[0]>0&&N[0]<=z.width&&N[1]>0&&N[1]<=z.height&&!fg(z,new f(z.center.lat,-90))]}(this);C?(b=90,y=180,_=-180):D&&(v=-90,y=180,_=-180)}return new m(new f(_,v),new f(y,b))}_getBoundsRectangular(e,t){const{top:n,left:s}=this._edgeInsets,l=this.height-this._edgeInsets.bottom,c=this.width-this._edgeInsets.right,h=new De(s,n),p=new De(c,n),_=new De(c,l),y=new De(s,l);let v=this.pointCoordinate(h,e),b=this.pointCoordinate(p,e);const T=this.pointCoordinate(_,t),S=this.pointCoordinate(y,t),A=(C,D)=>(D.y-C.y)/(D.x-C.x);return v.y>1&&b.y>=0?v=new V((1-S.y)/A(S,v)+S.x,1):v.y<0&&b.y<=1&&(v=new V(-S.y/A(S,v)+S.x,0)),b.y>1&&v.y>=0?b=new V((1-T.y)/A(T,b)+T.x,1):b.y<0&&v.y<=1&&(b=new V(-T.y/A(T,b)+T.x,0)),new m().extend(this.coordinateLocation(v)).extend(this.coordinateLocation(b)).extend(this.coordinateLocation(S)).extend(this.coordinateLocation(T))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce((n,s)=>{if(s.dem){const l=s.dem.tree;n.min=Math.min(n.min,l.minimums[0]),n.max=Math.max(n.max,l.maximums[0])}return n},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,n=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-85.051129,this.maxLat=E,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=fo(this.minLng)*this.tileSize,this.worldMaxX=fo(this.maxLng)*this.tileSize,this.worldMinY=$n(this.maxLat)*this.tileSize,this.worldMaxY=$n(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(e){const t=e.key,n=this._distanceTileDataCache;if(n[t])return n[t];const s=e.canonical,l=1/this.height,c=this.cameraWorldSize,h=c/this.zoomScale(s.z),p=(s.x+Math.pow(2,s.z)*e.wrap)*h,_=s.y*h,y=this.point;y.x*=c/this.worldSize,y.y*=c/this.worldSize;const v=this.angle,b=Math.sin(-v),T=-Math.cos(-v);return n[t]={bearing:[b,T],center:[(y.x-p)*l,(y.y-_)*l],scale:h/qe*l},n[t]}calculateFogTileMatrix(e){const t=e.key,n=this._fogTileMatrixCache;if(n[t])return n[t];const s=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,e);return Dt(s,this.worldToFogMatrix,s),n[t]=new Float32Array(s),n[t]}calculateProjMatrix(e,t=!1,n=!1){const s=e.key;let l;if(l=n?this._expandedProjMatrixCache:t?this._alignedProjMatrixCache:this._projMatrixCache,l[s])return l[s];const c=this.calculatePosMatrix(e,this.worldSize);let h;return h=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:n?this.expandedFarZProjMatrix:t?this.alignedProjMatrix:this.projMatrix,Dt(c,h,c),l[s]=new Float32Array(c),l[s]}calculatePixelsToTileUnitsMatrix(e){const t=e.tileID.key,n=this._pixelsToTileUnitsCache;if(n[t])return n[t];const s=function(l,c){const{scale:h}=l.tileTransform,p=h*qe/(l.tileSize*Math.pow(2,c.zoom-l.tileID.overscaledZ+l.tileID.canonical.z)),_=c.inverseAdjustmentMatrix;return new Float32Array([_[0]*p,_[1]*p,_[2]*p,_[3]*p])}(e,this);return n[t]=s,n[t]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const e=1/this.worldSize,t=Ho([],[e,e,e]);return Dt(t,t,this.globeMatrix),t}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const e=this._elevation;this._updateCameraState();const t=x(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(t),s=this._camera.forward(),l=x(1,this._center.lat);n[2]/=l,s[2]/=l,ei(s,s);const c=e.raycast(n,s,e.exaggeration());if(c){const h=cn([],n,s,c),p=new V(h[0],h[1],x(h[2],vr(h[1]))),_=(p.z+Ki([p.x-n[0],p.y-n[1],p.z-n[2]*l]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(_),this._centerAltitude=p.toAltitude(),this._center=this.coordinateLocation(p),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(e=!1){if(!this._elevation)return;const t=this._elevation,n=x(1,this._center.lat)*this.worldSize,s=this._computeCameraPosition(n),l=t.getAtPointOrZero(new V(...s)),c=this.pixelsPerMeter/this.worldSize*l,h=this._minimumHeightOverTerrain(),p=s[2]-c;if(p<=h)if(p<0||e){const _=this.locationCoordinate(this._center,this._centerAltitude),y=[s[0],s[1],_.z-s[2]],v=Ki(y);y[2]-=(h-p)/this._pixelsPerMercatorPixel;const b=Ki(y);if(b===0)return;si(y,y,v/b*this._pixelsPerMercatorPixel),this._camera.position=[s[0],s[1],_.z*this._pixelsPerMercatorPixel-y[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const b=this.center;return b.lat=vt(b.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(b.lng=vt(b.lng,this.minLng,this.maxLng)),this.center=b,void(this._constraining=!1)}const t=this._unmodified,{x:n,y:s}=this.point;let l=0,c=n,h=s;const p=this.width/2,_=this.height/2,y=this.worldMinY*this.scale,v=this.worldMaxY*this.scale;if(s-_<y&&(h=y+_),s+_>v&&(h=v-_),v-y<this.height&&(l=Math.max(l,this.height/(v-y)),h=(v+y)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const b=this.worldMinX*this.scale,T=this.worldMaxX*this.scale,S=this.worldSize/2-(b+T)/2;c=(n+S+this.worldSize)%this.worldSize-S,c-p<b&&(c=b+p),c+p>T&&(c=T-p),T-b<this.width&&(l=Math.max(l,this.width/(T-b)),c=(T+b)/2)}c===n&&h===s||this._allowWorldUnderZoom||(this.center=this.unproject(new De(c,h))),l&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(l)),this._constrainCamera(),this._unmodified=t,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,t=this.projection.name==="globe",n=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=x(1,this.center.lat)/x(1,45));const s=pf(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,s),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;const l=this.projection.zAxisUnit==="meters"?n:1,c=this._camera.getWorldToCamera(this.worldSize,l);let h;const p=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(p[8]=2*-e.x/this.width,p[9]=2*e.y/this.height,this.isOrthographic){let N=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),j=N*this.aspect,te=-j,H=-N;j-=e.x,te-=e.x,N+=e.y,H+=e.y,h=this._camera.getCameraToClipOrthographic(te,j,H,N,this._nearZ+this._nearClipOffset,this._farZ),((W,K,ee,ae)=>{for(let he=0;he<16;he++)W[he]=lt(K[he],ee[he],ae)})(h,h,p,Nc(this.pitch>=jh?1:this.pitch/jh))}else h=p;const _=Ha([],p,c),y=Ha([],h,c);if(this.projection.isReprojectedInTileSpace){const N=this.locationCoordinate(this.center);rr(this._mat4Scratch);const j=this._mat4Scratch;Yi(j,j,[N.x*this.worldSize,N.y*this.worldSize,0]),Dt(j,j,Av(this)),Yi(j,j,[-N.x*this.worldSize,-N.y*this.worldSize,0]),Dt(y,y,j),Dt(_,_,j),this.inverseAdjustmentMatrix=function(te){const H=Av(te,!0);return Ac([],[H[0],H[1],H[4],H[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(hr(this.mercatorMatrix,y,[this.worldSize,this.worldSize,this.worldSize/l,1]),this.projMatrix=y,yn(this.invProjMatrix,this.projMatrix),t){const N=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);N[8]=2*-e.x/this.width,N[9]=2*e.y/this.height,Ha(this._expandedFarZProjMatrixBuf,N,c),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf}else this.expandedFarZProjMatrix=this.projMatrix;yn(this._mat4Scratch,h),this.frustumCorners=sg.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=Cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!t),Ho(this.skyboxMatrix,[1,-1,1]),Es(this.skyboxMatrix,this.skyboxMatrix,this._pitch),Os(this.skyboxMatrix,this.skyboxMatrix,this.angle),Vl(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);const v=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;Cc(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=2*-e.x/this.width,this._mat4Scratch[9]=2*(e.y+v)/this.height,Dt(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);const b=this.point,T=b.x,S=b.y,A=this.width%2/2,C=this.height%2/2,D=Math.cos(this.angle),z=Math.sin(this.angle),O=T-Math.round(T)+D*A+z*C,F=S-Math.round(S)+D*C+z*A;if(Cc(this.alignedProjMatrix,y),Yi(this.alignedProjMatrix,this.alignedProjMatrix,[O>.5?O-1:O,F>.5?F-1:F,0]),Ho(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),Yi(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),Ho(this.glCoordMatrix,[1,-1,1]),Yi(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),hr(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),Dt(this.pixelMatrix,this.labelPlaneMatrix,_),this._calcFogMatrices(),this._distanceTileDataCache={},!yn(this.pixelMatrixInverse,this.pixelMatrix))throw new Error("failed to invert matrix");if(this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=function(j){const{x:te,y:H}=j.point,{lng:W,lat:K}=j._center;return gx(te,H,j.worldSize,W,K)}(this);const N=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=hi(N,N,c),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,t=this.cameraPixelsPerMeter,n=this._camera.position,s=1/this.height/this._pixelsPerMercatorPixel,l=[e,e,t];si(l,l,s),si(n,n,-1),Mc(n,n,l),Bs(this.mercatorFogMatrix,n),hr(this.mercatorFogMatrix,this.mercatorFogMatrix,l),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,s)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),s=this.point,l=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[s.x/this.worldSize-n[0]*l,s.y/this.worldSize-n[1]*l,e/this.worldSize*this._centerAltitude-n[2]*l]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=this._camera.position[2],s=e[2];let l=1;this.projection.wrap&&(this.center=this.center.wrap()),s>0&&(l=Math.min((t-n)/s,1)),this._camera.position=cn([],this._camera.position,e,l),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:n,bearing:s}=this._camera.getPitchBearing(),l=x(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,c=this._mercatorZfromZoom(this._maxZoom)*Math.cos(Ot(this._maxPitch)),h=Math.max((e[2]-l)/Math.cos(n),c),p=this._zoomFromMercatorZ(h);cn(e,e,t,h),this._pitch=vt(n,Ot(this.minPitch),Ot(this.maxPitch)),this.angle=xn(s,-Math.PI,Math.PI),this._setZoom(vt(p,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new V(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(this._seaLevelZoom??this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(e){let t=0,n=6,s=0,l=1/0;for(;n-t>1e-6&&n>t;){const c=t+.5*(n-t),h=this.tileSize*Math.pow(2,c),p=this.getCameraToCenterDistance(this.projection,c,h),_=this.scaleZoom(p/(Math.max(0,e)*this.tileSize)),y=Math.abs(c-_);y<l&&(l=y,s=c),c<_?t=c:n=c}return s}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(_i("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,t){const n=Math.min(e.x,t.x),s=Math.max(e.x,t.x),l=Math.min(e.y,t.y),c=Math.max(e.y,t.y);if(l<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const h=[new De(n,l),new De(s,c),new De(n,c),new De(s,l)],p=this.renderWorldCopies?-3:0,_=this.renderWorldCopies?4:1;for(const y of h){const v=this.pointRayIntersection(y);if(v.t<0)return!0;const b=this.rayIntersectionCoordinate(v);if(b.x<p||b.y<0||b.x>_||b.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+Gr(this.fovAboveCenter)>88||this.anyCornerOffEdge(new De(0,0),new De(this.width,this.height))}zoomDeltaToMovement(e,t){const n=Ki(Pi([],this._camera.position,e)),s=this._zoomFromMercatorZ(n)+t;return n-this._mercatorZfromZoom(s)}getCameraPoint(){if(this.projection.name==="globe"){const e=function([t,n,s],l){const c=[t,n,s,1];lr(c,c,l);const h=c[3]=Math.max(c[3],1e-6);return c[0]/=h,c[1]/=h,c[2]/=h,c}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new De(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new De(0,e))}}getCameraToCenterDistance(e,t=this.zoom,n=this.worldSize){const s=pf(e,t,this.width,this.height,1024),l=e.pixelSpaceConversion(this.center.lat,n,s);let c=.5/Math.tan(.5*this._fov)*this.height*l;return this.isOrthographic&&(c=lt(1,c,Nc(this.pitch>=jh?1:this.pitch/jh))),c}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&Dt(e,e,this.globeMatrix),e}getFrustum(e){return Cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,this.projection.zAxisUnit==="meters")}}const Gh=(i,e)=>{if(e<=0||i.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const t=i.transform,n=t.pitch,s=t.isLODDisabled(!1)?60:30;if(n<s-15)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const l=t._farZ-t._nearZ,c=e*t.height*1.3,h=Math.pow(2,.85*Math.max(t._zoom-i.minCutoffZoom,0)),p=1.4*t.cameraToCenterDistance*h,_=cs(s-15,s,n),y=lt(t._farZ+c,p,_),v=Math.min(c,y-t._nearZ);return{shouldRenderCutoff:_>0,uniformValues:{u_cutoff_params:[t._nearZ,t._farZ,(y-t._nearZ)/l,(y-v-t._nearZ)/l]}}},Sf=.05;function Ym(i,e,t){const n=cs(45,65,t),[s,l]=i.range;let c=1-Math.min(1,Math.exp((e-s)/(l-s)*-6));return c*=c*c,c=Math.min(1,1.00747*c),c*n*i.alpha}function y1(i,e,t,n,s){return Ym(i,Ki(hi([],[e,t,n],s.mercatorFogMatrix)),s.pitch)}function yy(i,e,t,n){const s=1<<i.z;e.lat=vr((n/qe+i.y)/s),e.lng=qn((t/qe+i.x)/s)}const x1=(i,e,t=1)=>({u_matrix:i,u_color:e,u_overlay:0,u_overlay_scale:t}),Ba=new Float64Array(16),Sc=new Float64Array(16),v1=new Float64Array(16),xy=new Float64Array(16),vy=new Float64Array(16),Km=new Float64Array(16),OE=new Float64Array(16),Jm=[0,0,0],BE=new Float32Array(16),Qm=[0,0,0],kE=[0,0,0],by=[];function b1(i,e,t){const n=t.cameraWorldSizeForFog/t.worldSize;return hr(i,t.worldToFogMatrix,[n,n,1]),Dt(i,i,e),i}function If(i,e,t,n){return Yi(i,e,t),os(n,kT)||hr(i,i,n),i}function wy(i,e,t,n,s){const l=t.material,c=n.context,{baseColorTexture:h,metallicRoughnessTexture:p}=l.pbrMetallicRoughness,{normalTexture:_,occlusionTexture:y,emissionTexture:v}=l;function b(S,A,C){if(S&&(i.push(A),c.activeTexture.set(c.gl.TEXTURE0+C),S.gfxTexture)){const{minFilter:D,magFilter:z,wrapS:O,wrapT:F}=S.sampler;S.gfxTexture.bindExtraParam(D,z,O,F)}}b(h,"HAS_TEXTURE_u_baseColorTexture",Wn.BaseColor),b(p,"HAS_TEXTURE_u_metallicRoughnessTexture",Wn.MetallicRoughness),b(_,"HAS_TEXTURE_u_normalTexture",Wn.Normal),b(y,"HAS_TEXTURE_u_occlusionTexture",Wn.Occlusion),b(v,"HAS_TEXTURE_u_emissionTexture",Wn.Emission),s&&(s.texture||(s.texture=new Bx(n.context,s.image,[s.image.height,s.image.height,s.image.height],c.gl.RGBA8)),c.activeTexture.set(c.gl.TEXTURE0+Wn.LUT),s.texture&&s.texture.bind(c.gl.LINEAR,c.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU")),t.texcoordBuffer&&(i.push("HAS_ATTRIBUTE_a_uv_2f"),e.push(t.texcoordBuffer)),t.colorBuffer&&(i.push(t.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),e.push(t.colorBuffer)),t.normalBuffer&&(i.push("HAS_ATTRIBUTE_a_normal_3f"),e.push(t.normalBuffer)),t.pbrBuffer&&(i.push("HAS_ATTRIBUTE_a_pbr"),i.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),e.push(t.pbrBuffer)),l.alphaMode!=="OPAQUE"&&l.alphaMode!=="MASK"||i.push("UNPREMULT_TEXTURE_IN_SHADER"),l.defined||i.push("DIFFUSE_SHADED");const T=n.shadowRenderer;T&&(i.push("RENDER_SHADOWS"),T.useNormalOffset&&i.push("NORMAL_OFFSET"))}function Ty(i,e,t,n,s,l){const c=i.modelOpacity,h=e.context,p=new pn(e.context.gl.LEQUAL,i.isLightMesh?pn.ReadOnly:pn.ReadWrite,e.depthRangeFor3D),_=e.transform,y=i.mesh,v=y.material,b=v.pbrMetallicRoughness,T=e.style.fog;e.transform.projection.zAxisUnit==="pixels"?Ba.set(i.nodeModelMatrix):Dt(Ba,n.zScaleMatrix,i.nodeModelMatrix),Dt(Ba,n.negCameraPosMatrix,Ba),yn(Sc,Ba),kl(Sc,Sc);const S=t.paint.get("model-color-use-theme").constantOr("default")==="none",A=t.paint.get("model-emissive-strength").constantOr(0),C={defines:[]},D=[],z=e.shadowRenderer;z&&(z.useNormalOffset=!1),wy(C.defines,D,y,e,S?null:t.lut);let O=null;if(T&&(O=b1(v1,i.nodeModelMatrix,e.transform),_.projection.name!=="globe")){const te=y.aabb.min,H=y.aabb.max,[W,K]=T.getOpacityForBounds(O,te[0],te[1],H[0],H[1]);C.overrideFog=W>=Sf||K>=Sf}const F=Gh(e,t.paint.get("model-cutoff-fade-range"));F.shouldRenderCutoff&&C.defines.push("RENDER_CUTOFF");const N=e.getOrCreateProgram("model",C),j=uy(i.worldViewProjection,Ba,Sc,null,e,c,b.baseColorFactor,v.emissiveFactor,b.metallicFactor,b.roughnessFactor,v,A,t,void 0,void 0,i.materialOverride,i.modelColor,1,N.fixedDefines.includes("LIGHTING_3D_MODE"));e.uploadCommonUniforms(h,N,null,O,F,i.lightOverrides),e.renderPass!=="shadow"&&z&&z.setupShadowsFromMatrix(i.nodeModelMatrix,N),N.draw(e,h.gl.TRIANGLES,p,s,l,y.material.doubleSided?mn.disabled:mn.backCCW,j,t.id,y.vertexBuffer,y.indexBuffer,y.segments,t.paint,e.transform.zoom,void 0,D)}function w1(i,e){return i.style._importedAsBasemap?"basemap":e.scope}function Ey(i,e,t,n,s,l,c,h,p,_,y){const v=i.transform,b=!!e.isGeometryBloom&&e.isGeometryBloom;if(e.minZoom!==void 0&&i.transform.zoom<e.minZoom||e.maxZoom!==void 0&&i.transform.zoom>e.maxZoom||b&&i.renderPass==="shadow")return;const T=v.projection.name==="globe"?Am(t,v):[...t];Dt(T,T,e.globalMatrix);const S=Dt([],n,T);if(e.meshes)for(const A of e.meshes){const C=h.get(A.material.name);if(C&&C.opacity<=0)continue;if(A.material.alphaMode!=="BLEND"){c.push({mesh:A,depth:0,modelIndex:s,worldViewProjection:S,nodeModelMatrix:T,isLightMesh:b,materialOverride:C,modelOpacity:p,modelColor:_,lightOverrides:y,node:e,modelMatrix:t});continue}const D=hi([],A.centroid,S);!v.isOrthographic&&D[2]<=0||l.push({mesh:A,depth:D[2],modelIndex:s,worldViewProjection:S,nodeModelMatrix:T,isLightMesh:b,materialOverride:C,modelOpacity:p,modelColor:_,lightOverrides:y,node:e,modelMatrix:t})}if(e.children)for(const A of e.children)Ey(i,A,t,n,s,l,c,h,p,_,y)}function Af(i,e,t,n,s){const l=t.shadowRenderer;if(!l)return;const c=l.getShadowPassDepthMode(),h=s||l.calculateShadowPassMatrixFromMatrix(e),p=s1(h);t.getOrCreateProgram("modelDepth").draw(t,t.context.gl.TRIANGLES,c,vs.disabled,er.disabled,mn.disabled,p,n.id,i.vertexBuffer,i.indexBuffer,i.segments,n.paint,t.transform.zoom,void 0,void 0)}function T1(i,e,t,n){const s=function(y,v){if(v.footprintDebugMesh)return v.footprintDebugMesh;if(!v.footprint)return null;const b=y.context,T=v.footprint.vertices,S=v.footprint.indices,A=new Re;A.reserve(T.length);for(const K of T)A.emplaceBack(K.x,K.y);const C=new _t;C.reserve(S.length);for(let K=0;K<S.length;K+=3)C.emplaceBack(S[K],S[K+1],S[K+2]);const D=b.createVertexBuffer(A,og.members),z=b.createIndexBuffer(C),O=li.simpleSegment(0,0,T.length,S.length),F=v.id||v.name||"footprint";let N;const j=parseInt(F,10);N=isNaN(j)?function(K){let ee=0;for(let ae=0;ae<K.length;ae++)ee=(ee<<5)-ee+K.charCodeAt(ae)|0;return ee}(F):j;const te=Kl(N),H=Kl(N+1),W=Kl(N+2);return v.footprintDebugMesh={vertexBuffer:D,indexBuffer:z,segments:O,color:new Pt(te,H,W,.5)},v.footprintDebugMesh}(i,t);if(!s)return;const l=i.context,c=l.gl,h=i.getOrCreateProgram("debug"),p=s.color,_=pn.disabled;l.activeTexture.set(c.TEXTURE0),i.emptyTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),h.draw(i,c.TRIANGLES,_,vs.disabled,er.alphaBlended,mn.disabled,x1(n,p.toPremultipliedRenderColor(null)),"$debug",s.vertexBuffer,s.indexBuffer,s.segments)}function NE(i,e,t,n,s,l){for(const c of s){const h={...n};h.part=c;const p={type:"Unknown",id:e,properties:h},_={orientation:i.paint.get("model-rotation").evaluate(p,t)};l.set(c,_)}}function VE(i,e,t,n,s,l){for(const c of s){const h={...n};h.part=c;const p={type:"Unknown",id:e,properties:h},_={color:i.paint.get("model-color").evaluate(p,t),colorMix:i.paint.get("model-color-mix-intensity").evaluate(p,t),opacity:i.paint.get("model-opacity").evaluate(p,t),emissionStrength:i.paint.get("model-emissive-strength").evaluate(p,t)};l.set(c,_)}}function E1(i,e,t,n,s){let l=!1;for(const h of n)h.modelOpacity!==1&&(Ty(h,i,e,s[h.modelIndex],vs.disabled,er.disabled),l=!0);for(const h of n)Ty(h,i,e,s[h.modelIndex],h.modelOpacity!==1?i.stencilModeFor3D():vs.disabled,i.colorModeForRenderPass());l&&i.resetStencilClippingMasks();const c=er.additive;for(const h of t)Ty(h,i,e,s[h.modelIndex],vs.disabled,h.isLightMesh?c:i.colorModeForRenderPass())}function UE(i,e,t){const n=e.updateZoomBasedPaintProperties(),s=function(l,c,h){let p,_,y,v=l.terrain?l.terrain.exaggeration():0;if(l.terrain&&v>0){const b=l.terrain,T=b.findDEMTileFor(h);T&&T.dem?p=Vh.create(b,h,T):v=0}if(v===0&&(c.terrainElevationMin=0,c.terrainElevationMax=0),v===c.validForExaggeration&&(v===0||p&&p._demTile&&p._demTile.tileID===c.validForDEMTile.id&&p._dem._timestamp===c.validForDEMTile.timestamp))return!1;for(const b in c.instancesPerModel){const T=c.instancesPerModel[b];for(let S=0;S<T.instancedDataArray.length;++S){const A=(p?v*p.getElevationAt(0|T.instancedDataArray.float32[16*S],0|T.instancedDataArray.float32[16*S+1],!0,!0):0)+T.instancesEvaluatedElevation[S];T.instancedDataArray.float32[16*S+6]=A,_=_?Math.min(c.terrainElevationMin,A):A,y=y?Math.max(c.terrainElevationMax,A):A}}return c.terrainElevationMin=_||0,c.terrainElevationMax=y||0,c.validForExaggeration=v,c.validForDEMTile=p&&p._demTile?{id:p._demTile.tileID,timestamp:p._dem._timestamp}:{id:void 0,timestamp:0},!0}(i,e,t);(n||s)&&(e.uploaded=!1,e.upload(i.context))}const ka={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new Di([0,0,0],[qe,qe,0])};function jE(i,e){const t=1<<i.canonical.z,n=e.getFreeCameraOptions().position,s=e.elevation,l=i.canonical.x/t,c=(i.canonical.x+1)/t,h=i.canonical.y/t,p=(i.canonical.y+1)/t;let _=e._centerAltitude;if(s){const T=s.getMinMaxForTile(i);T&&T.max>_&&(_=T.max)}const y=vt(n.x,l,c)-n.x,v=vt(n.y,h,p)-n.y,b=x(_,e.center.lat)-n.z;return e._zoomFromMercatorZ(Math.sqrt(y*y+v*v+b*b))}function S1(i,e,t,n,s,l,c){const h=i.context,p=i.renderPass==="shadow",_=i.shadowRenderer,y=p&&_?_.getShadowPassDepthMode():new pn(h.gl.LEQUAL,pn.ReadWrite,i.depthRangeFor3D),v=i.isTileAffectedByFog(l),b=i.transform.projection.name==="globe";if(t.meshes)for(const T of t.meshes){const S=b?[]:["MODEL_POSITION_ON_GPU"],A=[];let C,D,z;const O=!b&&n.instancedDataArray.length>20;O&&S.push("INSTANCED_ARRAYS");const F=Gh(i,e.paint.get("model-cutoff-fade-range"));if(F.shouldRenderCutoff&&S.push("RENDER_CUTOFF"),p&&_)C=i.getOrCreateProgram("modelDepth",{defines:S}),D=s1(c.shadowTileMatrix,c.shadowTileMatrix,t.globalMatrix),z=er.disabled;else{wy(S,A,T,i,e.paint.get("model-color-use-theme").constantOr("default")==="none"?null:e.lut),C=i.getOrCreateProgram("model",{defines:S,overrideFog:v});const j=T.material,te=j.pbrMetallicRoughness,H=e.paint.get("model-opacity").constantOr(1),W=e.paint.get("model-emissive-strength").constantOr(0);D=uy(l.expandedProjMatrix,t.globalMatrix,BE,null,i,H,te.baseColorFactor,j.emissiveFactor,te.metallicFactor,te.roughnessFactor,j,W,e,s,void 0,void 0,void 0,1,C.fixedDefines.includes("LIGHTING_3D_MODE")),_&&(c.shadowUniformsInitialized?C.setShadowUniformValues(h,_.getShadowUniformValues()):(_.setupShadows(l.toUnwrapped(),C,"model-tile"),c.shadowUniformsInitialized=!0)),z=F.shouldRenderCutoff||H<1||j.alphaMode!=="OPAQUE"?er.alphaBlended:er.unblended}i.uploadCommonUniforms(h,C,l.toUnwrapped(),null,F);const N=T.material.doubleSided?mn.disabled:mn.backCCW;if(O)A.push(n.instancedDataBuffer),C.draw(i,h.gl.TRIANGLES,y,vs.disabled,z,N,D,e.id,T.vertexBuffer,T.indexBuffer,T.segments,e.paint,i.transform.zoom,void 0,A,n.instancedDataArray.length);else{const j=p?"u_instance":"u_normal_matrix";for(let te=0;te<n.instancedDataArray.length;++te)D[j]=new Float32Array(n.instancedDataArray.arrayBuffer,64*te,16),C.draw(i,h.gl.TRIANGLES,y,vs.disabled,z,N,D,e.id,T.vertexBuffer,T.indexBuffer,T.segments,e.paint,i.transform.zoom,void 0,A)}}if(t.children)for(const T of t.children)S1(i,e,T,n,s,l,c)}function GE(i,e,t,n,s){const l=i.node;if(l.lodMeshes&&l.lodMeshes.length>0)if(i.targetLod<0)i.targetLod=e>n?1:0;else{const c=s>0?t/1e3/s:1;i.targetLod=vt(e>n?i.targetLod+c:i.targetLod-c,0,1)}else i.targetLod=0}function HE(i,e,t,n){if(!t.modelManager)return!0;const s=t.modelManager;if(!t.shadowRenderer)return!0;const l=t.shadowRenderer,c=e.aabb;let h=!0,p=i.maxHeight;if(p===0){let y=0;for(const v in i.instancesPerModel){const b=s.getModel(v,n);b?y=Math.max(y,Math.max(Math.max(b.aabb.max[0],b.aabb.max[1]),b.aabb.max[2])):h=!1}p=i.maxScale*y*1.41+i.maxVerticalOffset,h&&(i.maxHeight=p)}c.max[2]=p,c.min[2]+=i.terrainElevationMin,c.max[2]+=i.terrainElevationMax,hi(c.min,c.min,e.tileMatrix),hi(c.max,c.max,e.tileMatrix);const _=c.intersects(l.getCurrentCascadeFrustum());return t.currentShadowCascade===0&&(i.isInsideFirstShadowMapFrustum=_===2),_===0}function ZE(i,e){const t=i.uniformValues.u_cutoff_params[0],n=i.uniformValues.u_cutoff_params[1],s=i.uniformValues.u_cutoff_params[2],l=i.uniformValues.u_cutoff_params[3];return n===t||l===s?1:vt(((e-t)/(n-t)-s)/(l-s),0,1)}function $E(i,e,t,n){if(e.pitch<20)return 1;const s=e.getWorldToCameraMatrix();Dt(s,s,i);const l=Pc(t.min[0],t.min[1],t.min[2],1);let c=lr(Qn(),l,s),h=c,p=c;l[1]=t.max[1],c=lr(Qn(),l,s),h=c[1]<h[1]?c:h,p=c[1]>p[1]?c:p,l[0]=t.max[0],c=lr(Qn(),l,s),h=c[1]<h[1]?c:h,p=c[1]>p[1]?c:p,l[1]=t.min[1],c=lr(Qn(),l,s),h=c[1]<h[1]?c:h,p=c[1]>p[1]?c:p;const _=vt(n[0],0,1),y=100*e.pixelsPerMeter*vt(n[1],0,1),v=vt(n[2],0,1),b=(A=Qn(),F=(C=h)[1],N=C[2],j=C[3],A[0]=(O=C[0])+(z=_)*((D=p)[0]-O),A[1]=F+z*(D[1]-F),A[2]=N+z*(D[2]-N),A[3]=j+z*(D[3]-j),A),T=Math.tan(.5*e.fovX),S=-b[2]*T;var A,C,D,z,O,F,N,j;if(y===0)return b[1]<-Math.abs(S)?v:1;const te=vt(lt(1,v,(-Math.abs(S)-b[1])/y),v,1);return lt(1,te,vt((e.pitch-20)/20,0,1))}var Sy=`
8#define EPSILON 0.0000001
9#define PI 3.141592653589793
10#ifdef RENDER_CUTOFF
11float 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);}
12#endif`,I1=`
13#if defined(VIEWPORT_ORIGIN_TOP_LEFT) || defined(FLIP_Y)
14#define FLIP_VIEWPORT_UV_Y(uv) (uv).y=1.0-(uv).y
15#else
16#define FLIP_VIEWPORT_UV_Y(uv)
17#endif
18#ifdef DUAL_SOURCE_BLENDING
19layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;
20#elif defined(FLOAT_RENDER_TARGET)
21layout(location=0) out highp vec4 glFragColor;
22#else
23layout(location=0) out vec4 glFragColor;
24#endif
25#ifdef USE_MRT1
26layout(location=1) out vec4 out_Target1;
27#endif
28highp float unpack_depth(highp vec4 rgba_depth)
29{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) {
30#ifdef CLIP_ZERO_TO_ONE
31highp float depth=ndc_z;
32#else
33highp float depth=ndc_z*0.5+0.5;
34#endif
35const 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;}const float DITHER_THRESHOLDS[16]=float[16](
361.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
36/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0
37);int viewport_dither_index(vec2 fragCoordXY) {return (int(fragCoordXY.x) % 4)*4+(int(fragCoordXY.y) % 4);}
38#ifdef DEBUG_WIREFRAME
39#define HANDLE_WIREFRAME_DEBUG \\
40glFragColor=vec4(0.7,0.0,0.0,0.7); \\
41gl_FragDepth=gl_FragCoord.z-0.0001;
42#else
43#define HANDLE_WIREFRAME_DEBUG
44#endif
45#ifdef RENDER_CUTOFF
46uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;
47#endif
48vec4 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);}`,A1=`
49#define EXTENT 8192.0
50#define RAD_TO_DEG 180.0/PI
51#define DEG_TO_RAD PI/180.0
52#define GLOBE_RADIUS EXTENT/PI/2.0
53float 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;}
54#ifdef PROJECTION_GLOBE_VIEW
55vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
56#ifndef PROJECTED_POS_ON_VIEWPORT
57float 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;
58#else
59return vec3(0.0);
60#endif
61}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);}
62#endif
63vec2 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(
64unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
65);}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);return (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);}
66#ifdef RENDER_CUTOFF
67uniform vec4 u_cutoff_params;out float v_cutoff_opacity;
68#endif
69const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)
70{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
71#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer
72#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib
73#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib
74#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib
75#define DECLARE_MATERIAL_TABLE_INFO
76#endif`,C1="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;
76void 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;}",M1=`
77#define ELEVATION_SCALE 7.0
78#define ELEVATION_OFFSET 450.0
79#ifdef PROJECTION_GLOBE_VIEW
80uniform 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;
81#endif
82vec3 elevationVector(vec2 pos) {
83#ifdef PROJECTION_GLOBE_VIEW
84vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
85mix(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;
86#else
87return vec3(0,0,1);
88#endif
89}
90#ifdef TERRAIN
91uniform 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) {
92#ifdef TERRAIN_DEM_FLOAT_FORMAT
93vec2 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;
94#else
95float 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);
96#endif
97}float prevElevation(vec2 apos) {
98#ifdef TERRAIN_DEM_FLOAT_FORMAT
99vec2 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;
100#else
101float 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);
102#endif
103}vec4 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);}
104#endif
105float elevation(vec2 apos) {
106#ifdef TERRAIN
107#ifdef ZERO_EXAGGERATION
108return 0.0;
109#endif
110#ifdef TERRAIN_VERTEX_MORPHING
111float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);
112#else
113return currentElevation(apos);
114#endif
115#else
116return 0.0;
117#endif
118}
119#ifdef DEPTH_OCCLUSION
120uniform 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;
121#ifdef DEPTH_D24
122float 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);}
123#else
124highp float unpack_depth_rgba(vec4 rgba_depth)
125{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;}
126#endif
127bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;
128#ifdef CLIP_ZERO_TO_ONE
129coord.z=-1.0+2.0*coord.z; 
130#endif
131#ifdef DEPTH_D24
132float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);
133#else
134float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));
135#endif
136return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_
136size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;
137#ifdef DEPTH_D24
138highp vec4 depth=vec4(
139texture(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
140);depth=unpack_depth4(depth);
141#else
142highp vec4 depth=vec4(
143unpack_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))
144);
145#endif
146return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;
147#ifdef CLIP_ZERO_TO_ONE
148coord.z=-1.0+2.0*coord.z; 
149#endif
150int 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) {
151#ifdef DEPTH_D24
152highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);
153#else
154highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));
155#endif
156res+=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;
157#ifdef CLIP_ZERO_TO_ONE
158coord.z=-1.0+2.0*coord.z; 
159#endif
160highp 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));}
161#else
162bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }
163#endif`,R1=`#ifdef FOG
164uniform 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);}
165#endif`,P1=`#ifdef FOG
166uniform 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;FLIP_VIEWPORT_UV_Y(uv);highp vec3 ray_dir=mix(
167mix(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;}
167vec3 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);}
168#endif`,Iy=`
169#ifdef LIGHTING_3D_MODE
170uniform 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);}
171#endif`,D1=`#ifdef RASTER_ARRAY
172uniform 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);}
172vec2 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)
173);}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)
174);}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);}
175#endif`,L1=`#ifdef RENDER_SHADOWS
176uniform 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];}
177#endif`,z1=`#ifdef RENDER_SHADOWS
178precision 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;highp vec2 shadow_map_ndc_to_uv(highp vec2 ndc_xy) {
179#ifdef SHADOW_MAP_FLIP_Y
180return ndc_xy*vec2(0.5,-0.5)+0.5;
181#else
182return ndc_xy*0.5+0.5;
183#endif
184}highp vec3 shadow_map_ndc_to_sample_space(highp vec3 ndc) {
185#ifdef CLIP_ZERO_TO_ONE
186return vec3(shadow_map_ndc_to_uv(ndc.xy),ndc.z);
187#else
188return vec3(shadow_map_ndc_to_uv(ndc.xy),ndc.z*0.5+0.5);
189#endif
190}float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {
191#ifdef CLIP_ZERO_TO_ONE
192highp vec3 coord=vec3(shadow_map_ndc_to_uv(pos.xy),pos.z-bias);
193#else
194highp vec3 coord=vec3(shadow_map_ndc_to_uv(pos.xy),pos.z*0.5+0.5-bias);
195#endif
196return 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;
197#ifdef SHADOWS_SINGLE_CASCADE
198vec2 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);
199#else
200light_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);
201#endif
202}highp float calculate_shadow_bias(float NDotL) {
203#ifdef NORMAL_OFFSET
204return 0.5*u_shadow_bias.x;
205#else
206return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));
207#endif
208}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)
209{highp vec2 biasUV=vec2(
210pos_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=shadow_map_ndc_to_sample_space(light_view_pos0.xyz/light_view_pos0.w);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);}
211#endif`;const F1=/^#include\s+"([^"]+)"\s*\r?\n/gm,O1=/#pragma mapbox: ([\
211w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,qE=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,WE=new Set(["ifdef","ifndef","elif","if","defined"]),e_=new Set;Hh(Sy,e_),Hh(A1,e_),Hh(I1,e_);const B1={"_prelude_fog.vertex.glsl":R1,"_prelude_terrain.vertex.glsl":M1,"_prelude_shadow.vertex.glsl":L1,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer
212#define MATERIAL_TABLE_DEBUG 0
213uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;
214#if MATERIAL_TABLE_DEBUG
215vec4 colorDebug;
216#endif
217};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++) { 
218if (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; 
219}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 { 
220iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;
221#if MATERIAL_TABLE_DEBUG
222const 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;
223#endif
224uint offset=0u;
225#if MATERIAL_TABLE_DEBUG
226bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}
227#endif
228offset++;
229#if MATERIAL_TABLE_DEBUG
230uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}
231#endif
232offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);
233#if MATERIAL_TABLE_DEBUG
234if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}
235#endif
236uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);
237#if MATERIAL_TABLE_DEBUG
238if(keepFinding)
239{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;}}}
240#endif
241offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;
242#if MATERIAL_TABLE_DEBUG
243if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}
244#endif
245info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)
246{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);}
247#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)
248#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)
249#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)
250#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));
251#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;
252#endif`,"_prelude_fog.fragment.glsl":P1,"_prelude_shadow.fragment.glsl":z1,"_prelude_lighting.glsl":Iy,"_prelude_raster_array.glsl":D1,"_prelude_indicator_cutout.fragment.glsl":`
253#ifdef INDICATOR_CUTOUT
254uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;
255#endif
256vec4 applyCutout(vec4 color,float height) {
257#ifdef INDICATOR_CUTOUT
258float 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;
258float 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);
259#else
260return color;
261#endif
262}float cutoutGroundRoofOpacity(vec4 groundRoof) {
263#ifdef INDICATOR_CUTOUT
264float 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);
265#else
266return 1.0;
267#endif
268}`,"_prelude_feature_cutout.fragment.glsl":`// feature cutout (gl-native only)
269`,"_prelude_feature_cutout.vertex.glsl":`// feature cutout (gl-native only)
270`},t_={},k1="precision highp float;",N1="precision mediump float;",V1=`
271#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)
272#extension GL_EXT_blend_func_extended : require
273#endif`,U1={preludeTerrain:ci("",M1),preludeFog:ci(P1,R1),preludeShadow:ci(z1,L1),preludeRasterArray:ci(D1,""),preludeLighting:ci(Iy,Iy),preludePrecisionQualifiers:ci(N1,k1),prelude:ci(I1,A1),preludeExtensions:ci(V1,"")},XE=[V1,N1,Sy,U1.prelude.fragmentSource].join(`
274`),YE=[k1,Sy,U1.prelude.vertexSource].join(`
275`);var KE={background:ci(`#include "_prelude_fog.fragment.glsl"
276#include "_prelude_feature_cutout.fragment.glsl"
277uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;
278#ifdef LIGHTING_3D_MODE
279in vec4 v_color;
280#endif
281void main() {vec4 out_color;
282#ifdef FEATURE_CUTOUT
283vec2 uv=fragcoord_to_viewport_uv(gl_FragCoord.xy,u_inv_viewport_size.xy);float 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);
284#else
285#ifdef LIGHTING_3D_MODE
286out_color=v_color;
287#else
288out_color=u_color;
289#endif
290#ifdef FOG
291out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
292#endif
293#endif
294glFragColor=out_color*u_opacity;
295#ifdef USE_MRT1
296out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
297#endif
298#ifdef OVERDRAW_INSPECTOR
299glFragColor=vec4(1.0);
300#endif
301HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
302#include "_prelude_lighting.glsl"
303in ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;
304#ifdef LIGHTING_3D_MODE
305uniform mediump vec4 u_color;out vec4 v_color;
306#endif
307void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
308#ifndef FEATURE_CUTOUT
309#ifdef LIGHTING_3D_MODE
310v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);
311#endif
312#ifdef FOG
313v_fog_pos=fog_position(vec2(a_pos));
314#endif
315#endif
316}`),backgroundPattern:ci(`#include "_prelude_fog.fragment.glsl"
317#include "_prelude_lighting.glsl"
318uniform 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);
319#ifdef LIGHTING_3D_MODE
320out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
321#endif
322#ifdef FOG
323out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
324#endif
325glFragColor=out_color*u_opacity;
326#ifdef USE_MRT1
327out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
328#endif
329#ifdef OVERDRAW_INSPECTOR
330glFragColor=vec4(1.0);
331#endif
332HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
333uniform 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);
334#ifdef FOG
335v_fog_pos=fog_position(pos);
336#endif
337}`),circle:ci
vendor: 7,212 bytes, lines 337-463
337(`#include "_prelude_fog.fragment.glsl"
338#include "_prelude_lighting.glsl"
339in vec3 v_data;in float v_visibility;
340#pragma mapbox: define highp vec4 color
341#pragma mapbox: define mediump float radius
342#pragma mapbox: define lowp float blur
343#pragma mapbox: define lowp float opacity
344#pragma mapbox: define highp vec4 stroke_color
345#pragma mapbox: define mediump float stroke_width
346#pragma mapbox: define lowp float stroke_opacity
347uniform float u_emissive_strength;void main() {
348#pragma mapbox: initialize highp vec4 color
349#pragma mapbox: initialize mediump float radius
350#pragma mapbox: initialize lowp float blur
351#pragma mapbox: initialize lowp float opacity
352#pragma mapbox: initialize highp vec4 stroke_color
353#pragma mapbox: initialize mediump float stroke_width
354#pragma mapbox: initialize lowp float stroke_opacity
355vec2 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 ? 
356smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : 
357smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
358antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
359);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
360#ifdef LIGHTING_3D_MODE
361out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
362#endif
363#ifdef FOG
364out_color=fog_apply_premultiplied(out_color,v_fog_pos);
365#endif
366glFragColor=out_color*(v_visibility*opacity_t);
367#ifdef OVERDRAW_INSPECTOR
368glFragColor=vec4(1.0);
369#endif
370}`,`#include "_prelude_fog.vertex.glsl"
371#include "_prelude_terrain.vertex.glsl"
372#define NUM_VISIBILITY_RINGS 2
373#define INV_SQRT2 0.70710678
374#define ELEVATION_BIAS 0.0001
375#define NUM_SAMPLES_PER_RING 16
376uniform 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;
377#ifdef PROJECTION_GLOBE_VIEW
378in 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;
379#endif
380#ifdef ELEVATED_ROADS
381in float a_circle_z_offset;
382#endif
383out vec3 v_data;out float v_visibility;
384#pragma mapbox: define highp vec4 color
385#pragma mapbox: define mediump float radius
386#pragma mapbox: define lowp float blur
387#pragma mapbox: define lowp float opacity
388#pragma mapbox: define highp vec4 stroke_color
389#pragma mapbox: define mediump float stroke_width
390#pragma mapbox: define lowp float stroke_opacity
391vec2 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) {
392#if defined(TERRAIN)
393return elevation(pos)+ELEVATION_BIAS;
394#else
395return 0.0;
396#endif
397}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);
398#ifdef PITCH_WITH_MAP
399#ifdef PROJECTION_GLOBE_VIEW
400return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
401#else
402return u_matrix*( world_center+vec4(sample_offset,0,0) );
403#endif
404#else
405return projected_center+vec4(sample_offset,0,0);
406#endif
407}float get_sample_step() {
408#ifdef PITCH_WITH_MAP
409return 2.0*PI/float(NUM_SAMPLES_PER_RING);
410#else
411return PI/float(NUM_SAMPLES_PER_RING);
412#endif
413}void main() {
414#pragma mapbox: initialize highp vec4 color
415#pragma mapbox: initialize mediump float radius
416#pragma mapbox: initialize lowp float blur
417#pragma mapbox: initialize lowp float opacity
418#pragma mapbox: initialize highp vec4 stroke_color
419#pragma mapbox: initialize mediump float stroke_width
420#pragma mapbox: initialize lowp float stroke_opacity
421vec2 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;
422#ifdef PROJECTION_GLOBE_VIEW
423surface_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);
424#else 
425surface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);
426#endif
427#ifdef ELEVATED_ROADS
428world_center.z+=a_circle_z_offset+ELEVATION_BIAS;
429#endif
430vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
431#ifdef PITCH_WITH_MAP
432#ifdef SCALE_WITH_MAP
433view_scale=1.0;
434#else
435view_scale=projected_center.w/u_camera_to_center_distance;
436#endif
437#else
438#ifdef SCALE_WITH_MAP
439view_scale=u_camera_to_center_distance;
440#else
441view_scale=projected_center.w;
442#endif
443#endif
444gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
445#ifdef TERRAIN
446float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
447#ifdef PITCH_WITH_MAP
448float 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;
449#else
450occlusion_world_center=world_center;occlusion_projected_center=projected_center;
451#endif
452for(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);
453#else
454visibility=1.0;
455#endif
456#ifdef PROJECTION_GLOBE_VIEW
457visibility=1.0;
458#endif
459v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
460#ifdef FOG
461v_fog_pos=fog_position(world_center.xyz);
462#endif
463}`),clippingMask:
463ci("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:ci(`#include "_prelude_fog.fragment.glsl"
464uniform highp float u_intensity;in vec2 v_extrude;
465#pragma mapbox: define highp float weight
466#define GAUSS_COEF 0.3989422804014327
467void main() {
468#pragma mapbox: initialize highp float weight
469float 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);
470#ifdef FOG
471if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
472#endif
473#ifdef OVERDRAW_INSPECTOR
474glFragColor=vec4(1.0);
475#endif
476HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
477#include "_prelude_fog.vertex.glsl"
478uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_intensity;in ivec2 a_pos;
479#ifdef PROJECTION_GLOBE_VIEW
480in 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;
481#endif
482out vec2 v_extrude;
483#pragma mapbox: define highp float weight
484#pragma mapbox: define mediump float radius
485const highp float ZERO=1.0/255.0/16.0;
486#define GAUSS_COEF 0.3989422804014327
487void main() {
488#pragma mapbox: initialize highp float weight
489#pragma mapbox: initialize mediump float radius
490vec2 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;
491#ifdef PROJECTION_GLOBE_VIEW
492vec3 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);
493#else
494pos=vec3(tilePos+extrude,elevation(tilePos));
495#endif
496gl_Position=u_matrix*vec4(pos,1);
497#ifdef FOG
498v_fog_pos=fog_position(pos);
499#endif
500}`),heatmapTexture:ci(`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;
501#ifdef OVERDRAW_INSPECTOR
502glFragColor=vec4(0.0);
503#endif
504HANDLE_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:ci("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"
505in 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;
506#ifdef PROJECTION_GLOBE_VIEW
507uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;
508#endif
509out 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);
510#ifdef PROJECTION_GLOBE_VIEW
511#ifndef PROJECTED_POS_ON_VIEWPORT
512vec3 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);
513#endif
514#endif
515vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
5160.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:ci("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(
517mix(-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(
5180.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:ci("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"
519in ivec2 a_pos;
520#ifdef PROJECTION_GLOBE_VIEW
521in ivec4 a_pos_3;
522#endif
523out 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;
524#ifdef PROJECTION_GLOBE_VIEW
525gl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);
526#else
527gl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);
528#endif
529}`),fill:ci(`#include "_prelude_fog.fragment.glsl"
530#include "_prelude_lighting.glsl"
531#include "_prelude_shadow.fragment.glsl"
532#include "_prelude_indicator_cutout.fragment.glsl"
533#include "_prelude_feature_cutout.fragment.glsl"
534#pragma mapbox: define highp vec4 color
535#pragma mapbox: define lowp float opacity
536uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;
537#ifdef RENDER_SHADOWS
538uniform 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;
539#endif
540#ifdef ELEVATED_ROADS
541in highp float v_road_z_offset;
542#endif
543#ifdef INDICATOR_CUTOUT
544in highp float v_z_offset;
545#endif
546void main() {
547#pragma mapbox: initialize highp vec4 color
548#pragma mapbox: initialize lowp float opacity
549vec2 cutout_factors=vec2(0.0);
550#ifdef FEATURE_CUTOUT
551cutout_factors=get_cutout_factors(gl_FragCoord);
552#endif
553vec4 out_color=color;
554#ifdef LIGHTING_3D_MODE
555out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
556#ifdef RENDER_SHADOWS
557float 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);
558#endif
559#endif
560#ifdef FOG
561out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
562#endif
563out_color*=(opacity*u_opacity_multiplier);
564#ifdef INDICATOR_CUTOUT
565if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}
566#endif
567#ifdef FEATURE_CUTOUT
568float z=0.0;
569#ifdef ELEVATED_ROADS
570z=v_road_z_offset;
571#endif
572out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
573#endif
574glFragColor=out_color;
575#ifdef USE_MRT1
576out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
577#endif
578#ifdef OVERDRAW_INSPECTOR
579glFragColor=vec4(1.0);
580#endif
581HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
582#include "_prelude_shadow.vertex.glsl"
583in ivec2 a_pos;
584#ifdef ELEVATED_ROADS
585in float a_road_z_offset;out highp float v_road_z_offset;
586#endif
587#ifdef RENDER_SHADOWS
588uniform 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;
589#endif
590#ifdef INDICATOR_CUTOUT
591out highp float v_z_offset;
592#endif
593uniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;
594#pragma mapbox: define highp vec4 color
595#pragma mapbox: define lowp float opacity
596#pragma mapbox: define highp float z_offset
597void main() {
598#pragma mapbox: initialize highp vec4 color
599#pragma mapbox: initialize lowp float opacity
600#pragma mapbox: initialize highp float z_offset
601#ifdef ELEVATED_ROADS
602z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
603#endif
604float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
605#ifdef RENDER_SHADOWS
606vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
607#ifdef NORMAL_OFFSET
608vec3 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();
609#endif
610v_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;
611#endif
612#ifdef FOG
613v_fog_pos=fog_position(vec2(a_pos));
614#endif
615#ifdef INDICATOR_CUTOUT
616v_z_offset=z_offset;
617#endif
618}`),fillOutline:ci(`#include "_prelude_fog.fragment.glsl"
619#include "_prelude_lighting.glsl"
620#include "_prelude_shadow.fragment.glsl"
621#include "_prelude_feature_cutout.fragment.glsl"
622in highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;
623#ifdef ELEVATED_ROADS
624in highp float v_road_z_offset;
625#endif
626#ifdef RENDER_SHADOWS
627uniform 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;
628#endif
629#pragma mapbox: define highp vec4 outline_color
630#pragma mapbox: define lowp float opacity
631void main() {
632#pragma mapbox: initialize highp vec4 outline_color
633#pragma mapbox: initialize lowp float opacity
634float 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);
635#ifdef FEATURE_CUTOUT
636cutout_factors=get_cutout_factors(gl_FragCoord);
637#endif
638#ifdef LIGHTING_3D_MODE
639out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
640#ifdef RENDER_SHADOWS
641float 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);
642#endif
643#endif
644#ifdef FOG
645out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
646#endif
647#ifdef FEATURE_CUTOUT
648float z=0.0;
649#ifdef ELEVATED_ROADS
650z=v_road_z_offset;
651#endif
652out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
653#endif
654glFragColor=out_color*(alpha*opacity*u_opacity_multiplier);
655#ifdef USE_MRT1
656out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
657#endif
658#ifdef OVERDRAW_INSPECTOR
659glFragColor=vec4(1.0);
660#endif
661HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
662#include "_prelude_shadow.vertex.glsl"
663in ivec2 a_pos;
664#ifdef ELEVATED_ROADS
665in float a_road_z_offset;out highp float v_road_z_offset;
666#endif
667#ifdef RENDER_SHADOWS
668uniform 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;
669#endif
670uniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;out highp vec2 v_pos;
671#pragma mapbox: define highp vec4 outline_color
672#pragma mapbox: define lowp float opacity
673#pragma mapbox: define highp float z_offset
674void main() {
675#pragma mapbox: initialize highp vec4 outline_color
676#pragma mapbox: initialize lowp float opacity
677#pragma mapbox: initialize highp float z_offset
678#ifdef ELEVATED_ROADS
679z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
680#endif
681float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
682#ifdef FLIP_Y
683v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
684#else
685v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
686#endif
687#ifdef RENDER_SHADOWS
688vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
689#ifdef NORMAL_OFFSET
690vec3 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();
691#endif
692v_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;
693#endif
694#ifdef FOG
695v_fog_pos=fog_position(vec2(a_pos));
696#endif
697}`),fillOutlinePattern:ci(`#include "_prelude_fog.fragment.glsl"
698#include "_prelude_lighting.glsl"
699#include "_prelude_shadow.fragment.glsl"
700#include "_prelude_feature_cutout.fragment.glsl"
701uniform vec2 u_texsize;uniform sampler2D u_image;
702#ifdef FILL_PATTERN_TRANSITION
703uniform float u_pattern_transition;
704#endif
705uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;
706#ifdef APPLY_LUT_ON_GPU
707uniform highp sampler3D u_lutTexture;
708#endif
709#ifdef RENDER_SHADOWS
710uniform 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;
711#endif
712#ifdef ELEVATED_ROADS
713in highp float v_road_z_offset;
714#endif
715in highp vec2 v_pos;in highp vec2 v_pos_world;
716#pragma mapbox: define lowp float opacity
717#pragma mapbox: define lowp uvec4 pattern
718#ifdef FILL_PATTERN_TRANSITION
719#pragma mapbox: define mediump uvec4 pattern_b
720#endif
721void main() {
722#pragma mapbox: initialize lowp float opacity
723#pragma mapbox: initialize mediump uvec4 pattern
724#ifdef FILL_PATTERN_TRANSITION
725#pragma mapbox: initialize mediump uvec4 pattern_b
726#endif
727vec2 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);
728#ifdef APPLY_LUT_ON_GPU
729out_color=applyLUT(u_lutTexture,out_color);
730#endif
731#ifdef FILL_PATTERN_TRANSITION
732vec2 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;
733#endif
734vec2 cutout_factors=vec2(0.0);
735#ifdef FEATURE_CUTOUT
736cutout_factors=get_cutout_factors(gl_FragCoord);
737#endif
738#ifdef LIGHTING_3D_MODE
739out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
740#ifdef RENDER_SHADOWS
741float 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);
742#endif
743#endif
744#ifdef FEATURE_CUTOUT
745float z=0.0;
746#ifdef ELEVATED_ROADS
747z=v_road_z_offset;
748#endif
749out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
750#endif
751#ifdef FOG
752out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
753#endif
754glFragColor=out_color*(alpha*opacity*u_opacity_multiplier);
755#ifdef USE_MRT1
756out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
757#endif
758#ifdef OVERDRAW_INSPECTOR
759glFragColor=vec4(1.0);
760#endif
761HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
762#include "_prelude_shadow.vertex.glsl"
763uniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;
764#ifdef ELEVATED_ROADS
765in float a_road_z_offset;out highp float v_road_z_offset;
766#endif
767#ifdef RENDER_SHADOWS
768uniform 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;
769#endif
770out highp vec2 v_pos;out highp vec2 v_pos_world;
771#pragma mapbox: define lowp float opacity
772#pragma mapbox: define lowp uvec4 pattern
773#ifdef FILL_PATTERN_TRANSITION
774#pragma mapbox: define mediump uvec4 pattern_b
775#endif
776#pragma mapbox: define lowp float pixel_ratio
777#pragma mapbox: define highp float z_offset
778void main() {
779#pragma mapbox: initialize lowp float opacity
780#pragma mapbox: initialize mediump uvec4 pattern
781#ifdef FILL_PATTERN_TRANSITION
782#pragma mapbox: initialize mediump uvec4 pattern_b
783#endif
784#pragma mapbox: initialize lowp float pixel_ratio
785#pragma mapbox: initialize highp float z_offset
786vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);
787#ifdef ELEVATED_ROADS
788z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
789#endif
790float 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);
791#ifdef FLIP_Y
792v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
793#else
794v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
795#endif
796#ifdef RENDER_SHADOWS
797vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);
798#ifdef NORMAL_OFFSET
799vec3 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();
800#endif
801v_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;
802#endif
803#ifdef FOG
804v_fog_pos=fog_position(pos);
805#endif
806}`),fillPattern:ci(`#include "_prelude_fog.fragment.glsl"
807#include "_prelude_lighting.glsl"
808#include "_prelude_shadow.fragment.glsl"
809#include "_prelude_feature_cutout.fragment.glsl"
810uniform vec2 u_texsize;uniform sampler2D u_image;
811#ifdef FILL_PATTERN_TRANSITION
812uniform float u_pattern_transition;
813#endif
814in highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;
815#ifdef RENDER_SHADOWS
816uniform 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;
817#endif
818#ifdef ELEVATED_ROADS
819in highp float v_road_z_offset;
820#endif
821#ifdef APPLY_LUT_ON_GPU
822uniform highp sampler3D u_lutTexture;
823#endif
824#pragma mapbox: define lowp float opacity
825#pragma mapbox: define lowp uvec4 pattern
826#ifdef FILL_PATTERN_TRANSITION
827#pragma mapbox: define mediump uvec4 pattern_b
828#endif
829void main() {
830#pragma mapbox: initialize lowp float opacity
831#pragma mapbox: initialize mediump uvec4 pattern
832#ifdef FILL_PATTERN_TRANSITION
833#pragma mapbox: initialize mediump uvec4 pattern_b
834#endif
835vec2 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);
836#ifdef APPLY_LUT_ON_GPU
837out_color=applyLUT(u_lutTexture,out_color);
838#endif
839#ifdef FILL_PATTERN_TRANSITION
840vec2 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;
841#endif
842vec2 cutout_factors=vec2(0.0);
843#ifdef FEATURE_CUTOUT
844cutout_factors=get_cutout_factors(gl_FragCoord);
845#endif
846#ifdef LIGHTING_3D_MODE
847out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
848#ifdef RENDER_SHADOWS
849float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);
850#ifdef ELEVATED_ROADS
851out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
852#else
853out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
854#endif
855#endif
856#endif
857#ifdef FEATURE_CUTOUT
858float z=0.0;
859#ifdef ELEVATED_ROADS
860z=v_road_z_offset;
861#endif
862out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
863#endif
864#ifdef FOG
865out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
866#endif
867glFragColor=out_color*(opacity*u_opacity_multiplier);
868#ifdef USE_MRT1
869out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
870#endif
871#ifdef OVERDRAW_INSPECTOR
872glFragColor=vec4(1.0);
873#endif
874HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
875#include "_prelude_shadow.vertex.glsl"
876uniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;
877#ifdef ELEVATED_ROADS
878in float a_road_z_offset;out highp float v_road_z_offset;
879#endif
880#ifdef RENDER_SHADOWS
881uniform 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;
882#endif
883out highp vec2 v_pos;
884#pragma mapbox: define lowp float opacity
885#pragma mapbox: define lowp uvec4 pattern
886#ifdef FILL_PATTERN_TRANSITION
887#pragma mapbox: define mediump uvec4 pattern_b
888#endif
889#pragma mapbox: define lowp float pixel_ratio
890#pragma mapbox: define highp float z_offset
891void main() {
892#pragma mapbox: initialize lowp float opacity
893#pragma mapbox: initialize mediump uvec4 pattern
894#pragma mapbox: initialize lowp float pixel_ratio
895#pragma mapbox: initialize highp float z_offset
896#ifdef FILL_PATTERN_TRANSITION
897#pragma mapbox: initialize mediump uvec4 pattern_b
898#endif
899vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;
900#ifdef ELEVATED_ROADS
901z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
902#endif
903float 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);
904#ifdef RENDER_SHADOWS
905vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);
906#ifdef NORMAL_OFFSET
907vec3 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();
908#endif
909v_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;
910#e
910ndif
911#ifdef FOG
912v_fog_pos=fog_position(pos);
913#endif
914}`),lineBlendComposite:ci(`uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos;
915#define ADDITIVE 1
916void 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);}
917#ifdef OVERDRAW_INSPECTOR
918glFragColor=vec4(0.0);
919#endif
920HANDLE_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:ci("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:ci(`#include "_prelude_fog.fragment.glsl"
921#include "_prelude_shadow.fragment.glsl"
922#include "_prelude_lighting.glsl"
923#include "_prelude_indicator_cutout.fragment.glsl"
924#include "_prelude_feature_cutout.fragment.glsl"
925in vec4 v_color;in vec4 v_flat;
926#ifdef RENDER_SHADOWS
927in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
928#endif
929uniform lowp float u_opacity;
930#ifdef RENDER_FRONT_CUTOFF
931in float v_front_cutoff_opacity;
932#endif
933#ifdef INDICATOR_CUTOUT
934#ifdef FEATURE_CUTOUT
935in vec4 v_ground_roof;
936#endif
937#endif
938#ifdef FAUX_AO
939uniform lowp vec2 u_ao;in vec2 v_ao;
940#endif
941#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
942in vec4 v_roof_color;
943#endif
944#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
945in highp vec3 v_normal;
946#endif
947uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;
948#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
949in float v_flood_radius;in float v_has_floodlight;
950#endif
951in float v_height;
952#pragma mapbox: define highp float emissive_strength
953void main() {
954#pragma mapbox: initialize highp float emissive_strength
955#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
956vec3 normal=normalize(v_normal);
957#endif
958float z;vec4 color=v_color;
959#ifdef ZERO_ROOF_RADIUS
960z=float(normal.z > 0.00001);
961#ifdef LIGHTING_3D_MODE
962normal=mix(normal,vec3(0.0,0.0,1.0),z);
963#else
964color=mix(v_color,v_roof_color,z);
965#endif
966#endif
967float h=max(0.0,v_height);float ao_shade=1.0;
968#ifdef FAUX_AO
969float 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),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;
970#ifdef ZERO_ROOF_RADIUS
971concave*=(1.0-z);
972#endif
973float 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);
974#ifdef LIGHTING_3D_MODE
975#ifdef FLOOD_LIGHT
976color.rgb*=mix(ao_shade,1.0,v_has_floodlight);
977#else
978color.rgb*=ao_shade;
979#endif
980#else
981color.rgb*=ao_shade;
982#endif
983#endif
984#ifdef LIGHTING_3D_MODE
985float flood_radiance=0.0;
986#ifdef FLOOD_LIGHT
987flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;
988#endif
989#ifdef RENDER_SHADOWS
990#ifdef FLOOD_LIGHT
991float 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);
992#else
993float shadowed_lighting_factor;
994#ifdef RENDER_CUTOFF
995shadowed_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;}
996#else
997shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
998#endif
999color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);
1000#endif
1001#else
1002color.rgb=apply_lighting(color.rgb,normal);
1003#ifdef FLOOD_LIGHT
1004color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);
1005#endif
1006#endif
1007color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;
1008#endif
1009#ifdef FOG
1010color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));
1011#endif
1012#ifdef INDICATOR_CUTOUT
1013#ifdef FEATURE_CUTOUT
1014{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}
1015#else
1016color=applyCutout(color,h);
1017#endif
1018#endif
1019#ifdef RENDER_FRONT_CUTOFF
1020if (v_front_cutoff_opacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}
1021#endif
1022#ifdef FEATURE_CUTOUT
1023color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);
1024#endif
1025glFragColor=color;
1026#ifdef OVERDRAW_INSPECTOR
1027glFragColor=vec4(1.0);
1028#endif
1029HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1030#include "_prelude_terrain.vertex.glsl"
1031#include "_prelude_shadow.vertex.glsl"
1032#include "_prelude_lighting.glsl"
1033#include "_prelude_material_table.vertex.glsl"
1034uniform mat4 u_matrix;
1035#ifndef LIGHTING_3D_MODE
1036uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;
1037#endif
1038uniform 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;
1039#if defined(HAS_CENTROID) || defined(TERRAIN)
1040in uvec2 a_centroid_pos;
1041#endif
1042#ifdef RENDER_WALL_MODE
1043in ivec4 a_join_normal_inside;
1044#endif
1045#ifdef PROJECTION_GLOBE_VIEW
1046in 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;
1047#endif
1048#ifdef TERRAIN
1049uniform int u_height_type;uniform int u_base_type;
1050#endif
1051uniform highp float u_vertical_scale;
1052#ifdef RENDER_FRONT_CUTOFF
1053uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;
1054#endif
1055out vec4 v_color;out vec4 v_flat;
1056#ifdef RENDER_SHADOWS
1057uniform 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;
1058#endif
1059#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
1060out vec4 v_roof_color;
1061#endif
1062#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
1063out highp vec3 v_normal;
1064#endif
1065#ifdef FAUX_AO
1066uniform lowp vec2 u_ao;out vec2 v_ao;
1067#endif
1068#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
1069out float v_flood_radius;out float v_has_floodlight;
1070#endif
1071out float v_height;
1072#ifdef INDICATOR_CUTOUT
1073#ifdef FEATURE_CUTOUT
1074out vec4 v_ground_roof;
1075#endif
1076#endif
1077vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
1078#pragma mapbox: define highp float base
1079#pragma mapbox: define highp float height
1080#pragma mapbox: define highp vec4 color
1081#pragma mapbox: define highp float flood_light_wall_radius
1082#pragma mapbox: define highp float line_width
1083#pragma mapbox: define highp float emissive_strength
1084void main() {DECLARE_MATERIAL_TABLE_INFO
1085#pragma mapbox: initialize highp float base
1086#pragma mapbox: initialize highp float height
1087#pragma mapbox: initialize highp vec4 color
1088#pragma mapbox: initialize highp float flood_light_wall_radius
1089#pragma mapbox: initialize highp float line_width
1090#pragma mapbox: initialize highp float emissive_strength
1091base*=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));
1092#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
1093v_normal=normal;
1094#endif
1095base=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);
1096#if defined(HAS_CENTROID) || defined(TERRAIN)
1097centroid_pos=vec2(a_centroid_pos);
1098#endif
1099float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;
1100#ifdef TERRAIN
1101bool 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;
1102#else
1103h=t > 0.0 ? height : base;
1104#endif
1105pos=vec3(pos_nx.xy,h);
1106#ifdef PROJECTION_GLOBE_VIEW
1107float 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);
1108#endif
1109float cutoff=1.0;vec3 scaled_pos=pos;
1110#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
1111vec2 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);}}
1112#endif
1113#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
1114vec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);
1115#endif
1116#ifdef RENDER_CUTOFF
1117#ifdef CLIP_ZERO_TO_ONE
1118cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);
1119#else
1120cutoff=cutoff_opacity(u_cutoff_params,ground.z);
1121#endif
1122if (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);
1123#endif
1124float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));
1125#ifdef RENDER_FRONT_CUTOFF
1126v_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.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;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);}
1127#endif
1128#ifdef RENDER_WALL_MODE
1129vec3 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;
1130#endif
1131gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;
1132#ifdef RENDER_SHADOWS
1133vec3 shd_pos0=pos;vec3 shd_pos1=pos;
1134#ifdef NORMAL_OFFSET
1135vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
1136#endif
1137v_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);
1138#endif
1139float NdotL=0.0;float colorvalue=0.0;
1140#ifndef LIGHTING_3D_MODE
1141colorvalue=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*=(
1142(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
1143#endif
1144#ifdef FAUX_AO
1145float 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;
1146#ifdef TERRAIN
1147top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(ce
1147ntroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
1148#endif
1149v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);
1150#ifdef PROJECTION_GLOBE_VIEW
1151top_height+=u_height_lift;
1152#endif
1153gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
1154#endif
1155#ifdef LIGHTING_3D_MODE
1156#ifdef FLOOD_LIGHT
1157float 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;
1158#endif
1159v_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);
1160#else
1161v_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;
1162#endif
1163#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
1164float 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;
1165#endif
1166#ifdef FOG
1167v_fog_pos=fog_position(pos);
1168#endif
1169#ifdef INDICATOR_CUTOUT
1170#ifdef FEATURE_CUTOUT
1171vec4 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);
1172#endif
1173#endif
1174}`),fillExtrusionPattern:ci(`#include "_prelude_fog.fragment.glsl"
1175#include "_prelude_lighting.glsl"
1176#include "_prelude_indicator_cutout.fragment.glsl"
1177uniform vec2 u_texsize;uniform sampler2D u_image;
1178#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1179uniform float u_pattern_transition;
1180#endif
1181#ifdef FAUX_AO
1182uniform lowp vec2 u_ao;in vec3 v_ao;
1183#endif
1184#ifdef LIGHTING_3D_MODE
1185in vec3 v_normal;
1186#endif
1187#ifdef APPLY_LUT_ON_GPU
1188uniform highp sampler3D u_lutTexture;
1189#endif
1190in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;
1191#pragma mapbox: define highp float base
1192#pragma mapbox: define highp float height
1193#pragma mapbox: define mediump uvec4 pattern
1194#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1195#pragma mapbox: define mediump uvec4 pattern_b
1196#endif
1197#pragma mapbox: define highp float pixel_ratio
1198void main() {
1199#pragma mapbox: initialize highp float base
1200#pragma mapbox: initialize highp float height
1201#pragma mapbox: initialize mediump uvec4 pattern
1202#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1203#pragma mapbox: initialize mediump uvec4 pattern_b
1204#endif
1205#pragma mapbox: initialize highp float pixel_ratio
1206vec2 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);
1207#ifdef APPLY_LUT_ON_GPU
1208out_color=applyLUT(u_lutTexture,out_color);
1209#endif
1210#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1211vec2 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;
1212#endif
1213#ifdef LIGHTING_3D_MODE
1214out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;
1215#else
1216out_color=out_color*v_lighting;
1217#endif
1218#ifdef FAUX_AO
1219float 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),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;
1220#endif
1221#ifdef FOG
1222out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
1223#endif
1224#ifdef INDICATOR_CUTOUT
1225out_color=applyCutout(out_color,height);
1226#endif
1227glFragColor=out_color;
1228#ifdef OVERDRAW_INSPECTOR
1229glFragColor=vec4(1.0);
1230#endif
1231HANDLE_WIREFRAME_DEBUG;}`,
vendor: 5,532 bytes, lines 1231-1327
1231`#include "_prelude_fog.vertex.glsl"
1232#include "_prelude_terrain.vertex.glsl"
1233#include "_prelude_lighting.glsl"
1234#include "_prelude_material_table.vertex.glsl"
1235uniform 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;
1236#ifndef LIGHTING_3D_MODE
1237uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;
1238#endif
1239in ivec4 a_pos_normal_ed;
1240#if defined(HAS_CENTROID) || defined(TERRAIN)
1241in uvec2 a_centroid_pos;
1242#endif
1243#ifdef RENDER_WALL_MODE
1244in ivec4 a_join_normal_inside;
1245#endif
1246#ifdef PROJECTION_GLOBE_VIEW
1247in 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;
1248#endif
1249#ifdef TERRAIN
1250uniform int u_height_type;uniform int u_base_type;
1251#endif
1252out highp vec2 v_pos;out vec4 v_lighting;
1253#ifdef FAUX_AO
1254uniform lowp vec2 u_ao;out vec3 v_ao;
1255#endif
1256#ifdef LIGHTING_3D_MODE
1257out vec3 v_normal;
1258#endif
1259#pragma mapbox: define highp float base
1260#pragma mapbox: define highp float height
1261#pragma mapbox: define highp vec4 color
1262#pragma mapbox: define mediump uvec4 pattern
1263#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1264#pragma mapbox: define mediump uvec4 pattern_b
1265#endif
1266#pragma mapbox: define highp float pixel_ratio
1267#pragma mapbox: define highp float line_width
1268void main() {DECLARE_MATERIAL_TABLE_INFO
1269#pragma mapbox: initialize highp float base
1270#pragma mapbox: initialize highp float height
1271#pragma mapbox: initialize highp vec4 color
1272#pragma mapbox: initialize mediump uvec4 pattern
1273#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
1274#pragma mapbox: initialize mediump uvec4 pattern_b
1275#endif
1276#pragma mapbox: initialize highp float pixel_ratio
1277#pragma mapbox: initialize highp float line_width
1278vec2 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);
1279#if defined(HAS_CENTROID) || defined(TERRAIN)
1280centroid_pos=vec2(a_centroid_pos);
1281#endif
1282float ele=0.0;float h=z;vec3 p;float c_ele;
1283#ifdef TERRAIN
1284bool 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);
1285#else
1286p=vec3(pos_nx.xy,z);
1287#endif
1288#ifdef PROJECTION_GLOBE_VIEW
1289float 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);
1290#endif
1291#ifdef RENDER_WALL_MODE
1292vec3 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;
1293#endif
1294float 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
1295? pos_nx.xy
1296: 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;
1297#ifdef LIGHTING_3D_MODE
1298NdotL=calculate_NdotL(normal);
1299#else
1300NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
1301#endif
1302if (normal.y !=0.0) {float r=0.84;
1303#ifndef LIGHTING_3D_MODE
1304r=mix(0.7,0.98,1.0-u_lightintensity);
1305#endif
1306NdotL*=(
1307(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
1308#ifdef FAUX_AO
1309float 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;
1310#ifdef TERRAIN
1311top_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);
1312#endif
1313v_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]);
1314#ifdef PROJECTION_GLOBE_VIEW
1315top_height+=u_height_lift;
1316#endif
1317gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
1318#endif
1319#ifdef LIGHTING_3D_MODE
1320v_normal=normal;
1321#else
1322v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
1323#endif
1324#ifdef FOG
1325v_fog_pos=fog_position(p);
1326#endif
1327}`),
1327hillshadePrepare:ci(`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(
1328(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
1329)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(
1330deriv.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:ci(`#include "_prelude_fog.fragment.glsl"
1331#include "_prelude_lighting.glsl"
1332uniform 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;
1333#ifdef LIGHTING_3D_MODE
1334glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);
1335#endif
1336#ifdef FOG
1337glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));
1338#endif
1339#ifdef USE_MRT1
1340out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1341#endif
1342#ifdef OVERDRAW_INSPECTOR
1343glFragColor=vec4(1.0);
1344#endif
1345HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1346uniform 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;
1347#ifdef VIEWPORT_ORIGIN_TOP_LEFT
1348v_pos.y=1.0-v_pos.y;
1349#endif
1350#ifdef FOG
1351v_fog_pos=fog_position(vec2(a_pos));
1352#endif
1353}`),line:ci(`#include "_prelude_fog.fragment.glsl"
1354#include "_prelude_lighting.glsl"
1355#include "_prelude_shadow.fragment.glsl"
1356#include "_prelude_indicator_cutout.fragment.glsl"
1357#include "_prelude_feature_cutout.fragment.glsl"
1358uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;uniform bool u_clip_to_tile_borders;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in vec2 v_tile_pos;
1359#ifdef ELEVATED_ROADS
1360in highp float v_road_z_offset;
1361#endif
1362#ifdef VARIABLE_LINE_WIDTH
1363in float stub_side;
1364#endif
1365#ifdef RENDER_LINE_DASH
1366uniform sampler2D u_dash_image;uniform highp float u_floor_width_scale;in highp vec2 v_tex;
1367#endif
1368#ifdef DEBUG_ELEVATION_ID
1369in vec3 v_elevation_id_col;
1370#endif
1371#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
1372in highp vec3 v_uv;
1373#endif
1374#ifdef RENDER_LINE_GRADIENT
1375uniform sampler2D u_gradient_image;
1376#endif
1377#ifdef RENDER_LINE_BORDER_GRADIENT
1378uniform sampler2D u_border_gradient_image;
1379#endif
1380#ifdef RENDER_LINE_TRIM_OFFSET
1381uniform 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;
1382#endif
1383#ifdef INDICATOR_CUTOUT
1384in highp float v_z_offset;
1385#endif
1386#ifdef RENDER_SHADOWS
1387uniform bool u_emissive_in_shadows;uniform 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;
1388#endif
1389float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
1390#pragma mapbox: define highp vec4 color
1391#pragma mapbox: define lowp float floorwidth
1392#pragma mapbox: define mediump uvec4 dash
1393#pragma mapbox: define lowp float blur
1394#pragma mapbox: define lowp float opacity
1395#pragma mapbox: define mediump float side_z_offset
1396#pragma mapbox: define lowp float border_width
1397#pragma mapbox: define lowp vec4 border_color
1398#pragma mapbox: define lowp float emissive_strength
1399float linearstep(float edge0,float edge1,float x) {return  clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
1400#pragma mapbox: initialize highp vec4 color
1401#pragma mapbox: initialize lowp float floorwidth
1402#pragma mapbox: initialize mediump uvec4 dash
1403#pragma mapbox: initialize lowp float blur
1404#pragma mapbox: initialize lowp float opacity
1405#pragma mapbox: initialize mediump float side_z_offset
1406#pragma mapbox: initialize lowp float border_width
1407#pragma mapbox: initialize lowp vec4 border_color
1408#pragma mapbox: initialize lowp float emissive_strength
1409float dist=length(v_normal)*v_width2_dilute.x;float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;
1410#ifdef RENDER_LINE_BORDER
1411#ifndef VARIABLE_LINE_WIDTH
1412ANTIALIASING*=8.0;
1413#endif
1414#endif
1415#ifdef VARIABLE_LINE_WIDTH
1416blur=mix(blur,0.0,stub_side);
1417#endif
1418float 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);float pxStep;float delta;
1419#ifdef RENDER_LINE_BORDER
1420#ifndef VARIABLE_LINE_WIDTH
1421pxStep=fwidth(dist);float out_edge=v_width2_dilute.x-dist;float in_edge=dist-(v_width2_dilute.y-2.0*ANTIALIASING);delta=v_width2_dilute.y > 0.0 ? min(in_edge,out_edge) : out_edge;float edge=ANTIALIASING;alpha=delta > 0.0 ? smoothstep(edge-pxStep,u_width_scale*blur+edge+pxStep,delta) : 0.0;
1422#endif
1423#endif
1424#ifdef RENDER_LINE_DASH
1425highp float dash_w=float(dash.w);highp float dash_len=float(dash.z)+dash_w/65535.0;float sdfgamma=ANTIALIASING/float(dash_len);float scaled_floorwidth=(floorwidth*u_floor_width_scale);float periods_per_pixel=fwidth(v_tex.x);float dash_coverage=float(dash.y >> 4u)/4095.0;float fade=linearstep(0.25,0.5,periods_per_pixel);float gamma=max(sdfgamma/scaled_floorwidth,0.5*periods_per_pixel);if (fade >=1.0) {alpha*=dash_coverage;} else if (periods_per_pixel < 0.1) {float sdfdist=texture(u_dash_image,v_tex).r;alpha*=linearstep(0.5-gamma,0.5+gamma,sdfdist);} else {float span=min(periods_per_pixel,1.0);float tap_offset=span*0.25;float sdf0=texture(u_dash_image,vec2(v_tex.x-tap_offset,v_tex.y)).r;float sdf1=texture(u_dash_image,vec2(v_tex.x+tap_offset,v_tex.y)).r;alpha*=mix(0.5*(
1426linearstep(0.5-gamma,0.5+gamma,sdf0)+linearstep(0.5-gamma,0.5+gamma,sdf1)
1427),dash_coverage,fade);}
1428#endif
1429highp vec4 out_color;
1430#ifdef RENDER_LINE_GRADIENT
1431out_color=texture(u_gradient_image,v_uv.xy);
1432#else
1433out_color=color;
1434#endif
1435float trim_alpha=1.0;
1436#ifdef RENDER_LINE_TRIM_OFFSET
1437highp 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;
1438#ifdef RENDER_LINE_GRADIENT
1439gradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);
1440#endif
1441highp 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;}
1442#endif
1443if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}
1444#ifdef RENDER_LINE_BORDER
1445#ifndef VARIABLE_LINE_WIDTH
1446float edge2=border_width*u_width_scale+ANTIALIASING;float alpha2=smoothstep(edge2-pxStep,edge2+pxStep,delta);if (alpha2 < 1.) {
1447#ifdef RENDER_LINE_BORDER_GRADIENT
1448vec4 border_gradient_color=texture(u_border_gradient_image,v_uv.xy);out_color=mix(border_gradient_color*trim_alpha,out_color,alpha2);
1449#else
1450if (border_color.a==0.0) {
1451#ifndef RENDER_LINE_GRADIENT
1452float 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-alpha2));} else {out_color.rgb*=(0.6+0.4*alpha2);}
1453#else
1454out_color.rgb*=(0.6+0.4*alpha2);
1455#endif
1456} else {out_color=mix(border_color*trim_alpha,out_color,alpha2);}
1457#endif
1458out_color*=v_width2_dilute.w;}
1459#endif
1460#endif
1461vec2 cutout_factors=vec2(0.0);
1462#ifdef FEATURE_CUTOUT
1463cutout_factors=get_cutout_factors(gl_FragCoord);
1464#endif
1465#ifdef LIGHTING_3D_MODE
1466out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
1467#ifdef RENDER_SHADOWS
1468float 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;
1469#ifdef ELEVATED_ROADS
1470out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
1471#else
1472out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
1473#endif
1474#endif
1475#endif
1476#ifdef FOG
1477out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
1478#endif
1479out_color*=(alpha*diluted_opacity*u_opacity_multiplier);
1480#ifdef INDICATOR_CUTOUT
1481out_color=applyCutout(out_color,v_z_offset);
1482#endif
1483#ifdef FEATURE_CUTOUT
1484float z=0.0;
1485#ifdef ELEVATED_ROADS
1486z=v_road_z_offset;
1487#endif
1488out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);
1489#endif
1490#ifdef LINE_BLEND_ADDITIVE
1491{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);}
1492#else
1493#ifdef LINE_BLEND_MULTIPLY
1494glFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);
1495#else
1496glFragColor=out_color;
1497#endif
1498#endif
1499#ifdef DUAL_SOURCE_BLENDING
1500glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
1501#else
1502#ifdef USE_MRT1
1503out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1504#endif
1505#endif
1506#ifdef OVERDRAW_INSPECTOR
1507glFragColor=vec4(1.0);
1508#endif
1509#ifdef DEBUG_ELEVATION_ID
1510glFragColor=vec4(v_elevation_id_col,1.0);
1511#endif
1512if (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"
1513#include "_prelude_shadow.vertex.glsl"
1514#include "_prelude_terrain.vertex.glsl"
1515#define EXTRUDE_SCALE 0.015873016
1516in ivec2 a_pos_normal;in uvec4 a_data;
1517#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) || defined(VARIABLE_LINE_EMISSIVE_STRENGTH)
1518in vec4 a_z_offset_width;
1519#endif
1520#ifdef DEBUG_ELEVATION_ID
1521in vec3 a_elevation_id_col;
1522#endif
1523#ifdef DEBUG_ELEVATION_ID
1524out vec3 v_elevation_id_col;
1525#endif
1526#ifdef ELEVATION_GROUND_SCALE
1527in float a_elevation_ground_scale;
1528#endif
1529#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)
1530in highp vec3 a_packed;
1531#endif
1532#ifdef RENDER_LINE_DASH
1533in float a_linesofar;
1534#endif
1535uniform 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_road_view_depth_bias;uniform highp vec4 u_road_clip_to_view;
1536#ifdef RENDER_LINE_CURVE
1537uniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;
1538#endif
1539#ifdef ELEVATED
1540uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
1541#ifdef ELEVATION_REFERENCE_SEA
1542return 0.0;
1543#else
1544return elevation(apos);
1545#endif
1546}
1547#endif
1548out vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out vec2 v_tile_pos;
1549#ifdef ELEVATED_ROADS
1550out highp float v_road_z_offset;
1551#endif
1552#ifdef VARIABLE_LINE_WIDTH
1553out float stub_side;
1554#endif
1555#ifdef RENDER_LINE_DASH
1556uniform highp float u_floor_width_scale;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out highp vec2 v_tex;
1557#endif
1558#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
1559out highp vec3 v_uv;
1560#endif
1561#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT)
1562uniform float u_image_height;
1563#endif
1564#ifdef INDICATOR_CUTOUT
1565out highp float v_z_offset;
1566#endif
1567#ifdef RENDER_SHADOWS
1568uniform 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;
1569#endif
1570#pragma mapbox: define highp vec4 color
1571#pragma mapbox: define lowp float floorwidth
1572#pragma mapbox: define mediump uvec4 dash
1573#pragma mapbox: define lowp float blur
1574#pragma mapbox: define lowp float opacity
1575#pragma mapbox: define mediump float gapwidth
1576#pragma mapbox: define lowp float offset
1577#pragma mapbox: define mediump float width
1578#pragma mapbox: define mediump float side_z_offset
1579#pragma mapbox: define lowp float border_width
1580#pragma mapbox: define lowp vec4 border_color
1581#pragma mapbox: define lowp float emissive_strength
1582#ifdef RENDER_LINE_CURVE
1583vec3 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
1583=t*t;float t3=t2*t;return 0.5*(
15842.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
1585);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(
1586(-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
1587);}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;}
1588#endif
1589void main() {
1590#pragma mapbox: initialize highp vec4 color
1591#pragma mapbox: initialize lowp float floorwidth
1592#pragma mapbox: initialize mediump uvec4 dash
1593#pragma mapbox: initialize lowp float blur
1594#pragma mapbox: initialize lowp float opacity
1595#pragma mapbox: initialize mediump float gapwidth
1596#pragma mapbox: initialize lowp float offset
1597#pragma mapbox: initialize mediump float width
1598#pragma mapbox: initialize mediump float side_z_offset
1599#pragma mapbox: initialize lowp float border_width
1600#pragma mapbox: initialize lowp vec4 border_color
1601#pragma mapbox: initialize lowp float emissive_strength
1602#ifdef VARIABLE_LINE_EMISSIVE_STRENGTH
1603emissive_strength=a_z_offset_width.w;
1604#endif
1605float a_z_offset=u_z_offset;
1606#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1607a_z_offset+=a_z_offset_width.x;
1608#endif
1609#ifdef DEBUG_ELEVATION_ID
1610v_elevation_id_col=a_elevation_id_col;
1611#endif
1612highp float line_progress=0.0;
1613#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)
1614line_progress=a_packed[2];
1615#endif
1616float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;
1617#ifdef RENDER_LINE_BORDER
1618#ifndef VARIABLE_LINE_WIDTH
1619ANTIALIASING*=8.0;
1620#endif
1621#endif
1622vec2 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;
1623#ifdef RENDER_LINE_CURVE
1624CurveResult 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;
1625#endif
1626gapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;float symmetric_outset=0.0;
1627#ifdef VARIABLE_LINE_WIDTH
1628float left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=u_width_scale*(left ? left_width : right_width);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*=apply;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale : 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;symmetric_outset=zero_right_width ? u_width_scale*left_width : halfwidth;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;
1629#else
1630halfwidth=(u_width_scale*width)/2.0;
1631#endif
1632float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth > 0.0 ? ANTIALIASING : 0.0);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;
1632vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
1633#ifdef ELEVATED_ROADS
1634v_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);
1635#else
1636#ifdef ELEVATED
1637vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;
1638#ifdef ELEVATION_GROUND_SCALE
1639scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);
1640#endif
1641#ifdef CROSS_SLOPE_VERTICAL
1642float 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);
1643#else
1644#ifdef CROSS_SLOPE_HORIZONTAL
1645float 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;
1646#else
1647float 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;
1648#endif
1649#endif
1650v_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);
1651#else
1652v_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0);
1653#endif
1654#endif
1655#ifndef ELEVATED
1656#ifndef VARIABLE_LINE_WIDTH
1657#ifndef RENDER_TO_TEXTURE
1658float 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
1659{
1660#ifdef RENDER_LINE_BORDER
1661float 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);
1662#endif
1663}}
1664#endif
1665#endif
1666v_tile_pos=(v_tile_pos+extrude)/EXTENT;
1667#ifdef ELEVATED_ROADS
1668gl_Position=gl_Position+projected_extrude;
1669#ifdef VARIABLE_LINE_WIDTH
1670#ifndef ELEVATED
1671if (u_road_view_depth_bias > 0.0) {highp float z_in=gl_Position.z/gl_Position.w*0.5+0.5;highp float a=u_road_clip_to_view.x;highp float b=u_road_clip_to_view.y;highp float c=u_road_clip_to_view.z;highp float d=u_road_clip_to_view.w;highp float view=(a*z_in+b)/(c*z_in+d);highp float view_new=view+u_road_view_depth_bias;highp float z_new=(view_new*d-b)/(a-view_new*c);z_new=clamp(z_new,0.0,1.0);gl_Position.z=(z_new*2.0-1.0)*gl_Position.w;}
1672#endif
1673#endif
1674#else
1675gl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);
1676#endif
1677#endif
1678#ifdef ELEVATED_ROADS
1679#ifdef RENDER_SHADOWS
1680vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
1681#ifdef NORMAL_OFFSET
1682vec3 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();
1683#endif
1684v_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;
1685#endif
1686#endif
1687#ifndef RENDER_TO_TEXTURE
1688float 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));
1689#else
1690v_gamma_scale=1.0;
1691#endif
1692#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
1693highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];
1694#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_BORDER_GRADIENT)
1695highp 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);
1696#else
1697v_uv=vec3(a_uv_x,0.0,line_progress);
1698#endif
1699#endif
1700#ifdef RENDER_LINE_DASH
1701vec4 dashf=vec4(dash);highp float dash_w=float(dash.w);highp float totalLength=float(dash.z)+dash_w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;float dash_half_height=float(dash.y & 15u);v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dash_half_height+dashf.x+0.5)/u_texsize.y);
1702#endif
1703v_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);
1704#ifdef VARIABLE_LINE_WIDTH
1705v_width2_dilute.x=symmetric_outset;
1706#endif
1707#ifdef FOG
1708v_fog_pos=fog_position(pos);
1709#endif
1710#ifdef INDICATOR_CUTOUT
1711v_z_offset=a_z_offset;
1712#endif
1713}`),linePattern:ci(`#include "_prelude_fog.fragment.glsl"
1714#include "_prelude_lighting.glsl"
1715#include "_prelude_shadow.fragment.glsl"
1716#include "_prelude_indicator_cutout.fragment.glsl"
1717uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;
1717uniform highp float u_alpha_discard_threshold;uniform lowp float u_opacity_multiplier;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;
1718#ifdef APPLY_LUT_ON_GPU
1719uniform highp sampler3D u_lutTexture;
1720#endif
1721#ifdef LINE_PATTERN_TRANSITION
1722uniform float u_pattern_transition;
1723#endif
1724in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;
1725#ifdef RENDER_LINE_TRIM_OFFSET
1726in highp vec3 v_uv;
1727#endif
1728#ifdef ELEVATED_ROADS
1729in highp float v_road_z_offset;
1730#endif
1731#ifdef LINE_JOIN_NONE
1732in vec2 v_pattern_data;
1733#endif
1734#ifdef INDICATOR_CUTOUT
1735in highp float v_z_offset;
1736#endif
1737#ifdef RENDER_SHADOWS
1738uniform 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;
1739#endif
1740#pragma mapbox: define mediump uvec4 pattern
1741#ifdef LINE_PATTERN_TRANSITION
1742#pragma mapbox: define mediump uvec4 pattern_b
1743#endif
1744#pragma mapbox: define mediump float pixel_ratio
1745#pragma mapbox: define mediump float blur
1746#pragma mapbox: define mediump float opacity
1747#pragma mapbox: define lowp float emissive_strength
1748void main() {
1749#pragma mapbox: initialize mediump uvec4 pattern
1750#ifdef LINE_PATTERN_TRANSITION
1751#pragma mapbox: initialize mediump uvec4 pattern_b
1752#endif
1753#pragma mapbox: initialize mediump float pixel_ratio
1754#pragma mapbox: initialize mediump float blur
1755#pragma mapbox: initialize mediump float opacity
1756#pragma mapbox: initialize lowp float emissive_strength
1757vec2 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);
1758#ifdef APPLY_LUT_ON_GPU
1759color=applyLUT(u_lutTexture,color);
1760#endif
1761#ifdef LINE_PATTERN_TRANSITION
1762vec2 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;
1763#endif
1764#ifdef RENDER_LINE_TRIM_OFFSET
1765highp 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);}
1766#endif
1767#ifdef LINE_JOIN_NONE
1768highp 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);}
1769#endif
1770#ifdef LIGHTING_3D_MODE
1771color=apply_lighting_with_emission_ground(color,emissive_strength);
1772#ifdef RENDER_SHADOWS
1773float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);
1774#ifdef ELEVATED_ROADS
1775color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
1776#else
1777color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
1778#endif
1779#endif
1780#endif
1781#ifdef FOG
1782color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
1783#endif
1784color*=(alpha*opacity*u_opacity_multiplier);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}
1785#ifdef INDICATOR_CUTOUT
1786color=applyCutout(color,v_z_offset);
1787#endif
1788glFragColor=color;
1789#ifdef DUAL_SOURCE_BLENDING
1790glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
1791#else
1792#ifdef USE_MRT1
1793out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1794#endif
1795#endif
1796#ifdef OVERDRAW_INSPECTOR
1797glFragColor=vec4(1.0);
1798#endif
1799HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1800#include "_prelude_shadow.vertex.glsl"
1801#include "_prelude_terrain.vertex.glsl"
1802#define scale 0.015873016
1803in ivec2 a_pos_normal;in uvec4 a_data;
1804#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1805in vec4 a_z_offset_width;
1806#endif
1807#ifdef ELEVATION_GROUND_SCALE
1808in float a_elevation_ground_scale;
1809#endif
1810#ifdef RENDER_LINE_TRIM_OFFSET
1811in highp vec3 a_packed;
1812#endif
1813in highp float a_linesofar;
1814#ifdef LINE_JOIN_NONE
1815in highp vec3 a_pattern_data;out vec2 v_pattern_data;
1816#endif
1817#ifdef INDICATOR_CUTOUT
1818out highp float v_z_offset;
1819#endif
1820uniform 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;
1821#ifdef ELEVATED
1822uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
1823#ifdef ELEVATION_REFERENCE_SEA
1824return 0.0;
1825#else
1826return elevation(apos);
1827#endif
1828}
1829#endif
1830out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;
1831#ifdef RENDER_LINE_TRIM_OFFSET
1832out highp vec3 v_uv;
1833#endif
1834#ifdef ELEVATED_ROADS
1835out highp float v_road_z_offset;
1836#endif
1837#ifdef RENDER_SHADOWS
1838uniform 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;
1839#endif
1840#pragma mapbox: define mediump float blur
1841#pragma mapbox: define mediump float opacity
1842#pragma mapbox: define mediump float offset
1843#pragma mapbox: define mediump float gapwidth
1844#pragma mapbox: define mediump float width
1845#pragma mapbox: define mediump float floorwidth
1846#pragma mapbox: define mediump uvec4 pattern
1847#ifdef LINE_PATTERN_TRANSITION
1848#pragma mapbox: define mediump uvec4 pattern_b
1849#endif
1850#pragma mapbox: define mediump float pixel_ratio
1851#pragma mapbox: define lowp float emissive_strength
1852void main() {
1853#pragma mapbox: initialize mediump float blur
1854#pragma mapbox: initialize mediump float opacity
1855#pragma mapbox: initialize mediump float offset
1856#pragma mapbox: initialize mediump float gapwidth
1857#pragma mapbox: initialize mediump float width
1858#pragma mapbox: initialize mediump float floorwidth
1859#pragma mapbox: initialize mediump uvec4 pattern
1860#ifdef LINE_PATTERN_TRANSITION
1861#pragma mapbox: initialize mediump uvec4 pattern_b
1862#endif
1863#pragma mapbox: initialize mediump float pixel_ratio
1864#pragma mapbox: initialize lowp float emissive_strength
1865float a_z_offset;
1866#if defined(ELEVATED) || defined(ELEVATED_ROADS)
1867a_z_offset=a_z_offset_width.x;
1868#endif
1869float 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;
1869vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
1870#ifdef ELEVATED_ROADS
1871v_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;
1872#else
1873#ifdef ELEVATED
1874vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;
1875#ifdef ELEVATION_GROUND_SCALE
1876scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);
1877#endif
1878#ifdef CROSS_SLOPE_VERTICAL
1879float 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);
1880#else
1881#ifdef CROSS_SLOPE_HORIZONTAL
1882float 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;
1883#else
1884float 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;
1885#endif
1886#endif
1887gl_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);
1888#else
1889gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);
1890#endif
1891#endif
1892#ifdef ELEVATED_ROADS
1893#ifdef RENDER_SHADOWS
1894vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
1895#ifdef NORMAL_OFFSET
1896vec3 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();
1897#endif
1898v_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;
1899#endif
1900#endif
1901#ifndef RENDER_TO_TEXTURE
1902float 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));
1903#else
1904v_gamma_scale=1.0;
1905#endif
1906#ifdef RENDER_LINE_TRIM_OFFSET
1907highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);
1908#endif
1909v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);
1910#ifdef LINE_JOIN_NONE
1911v_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);
1912#endif
1913#ifdef FOG
1914v_fog_pos=fog_position(pos);
1915#endif
1916#ifdef INDICATOR_CUTOUT
1917v_z_offset=a_z_offset;
1918#endif
1919}`),raster:ci(`#include "_prelude_fog.fragment.glsl"
1920#include "_prelude_lighting.glsl"
1921#include "_prelude_raster_array.glsl"
1922uniform 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;
1923#ifdef PROJECTION_GLOBE_VIEW
1924in float v_split_fade;
1925#endif
1926uniform 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;
1927#ifndef RASTER_ARRAY
1928uniform highp sampler2D u_image0;uniform sampler2D u_image1;
1929#endif
1930#ifdef RASTER_COLOR
1931uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;uniform highp float u_color_ramp_size;
1932#endif
1933void main() {vec4 color0,color1,color;vec2 value;
1934#ifdef RASTER_COLOR
1935#ifdef RASTER_ARRAY
1936#ifdef RASTER_ARRAY_LINEAR
1937value=mix(
1938raTexture2D_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
1939);
1940#else
1941value=mix(
1942raTexture2D_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
1943);
1944#endif
1945if (value.y > 0.0) value.x/=value.y;
1946#ifdef RASTER_COLOR_SCALE_LOG
1947float N=u_color_ramp_size;float vNorm=max((value.x-0.5/N)*N/(N-1.0),0.0);vNorm=log(vNorm*(10.0-1.0)+1.0)/log(10.0);value.x=0.5/N+vNorm*(N-1.0)/N;
1948#endif
1949#else
1950color=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);
1951#endif
1952color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;
1953#else
1954color0=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);
1955#endif
1956color.a*=u_opacity;
1957#ifdef GLOBE_POLES
1958color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);
1959#endif
1960vec3 rgb=color.rgb;rgb=vec3(
1961dot(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);
1962#ifdef LIGHTING_3D_MODE
1963out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;
1964#endif
1965#ifdef FOG
1966highp 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));
1967#endif
1968glFragColor=vec4(out_color*color.a,color.a);
1969#ifdef PROJECTION_GLOBE_VIEW
1970glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));
1971#endif
1972#ifdef RENDER_CUTOFF
1973glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);
1974#endif
1975#ifdef OVERDRAW_INSPECTOR
1976glFragColor=vec4(1.0);
1977#endif
1978#ifdef USE_MRT1
1979out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
1980#endif
1981HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
1982#include "_prelude_terrain.vertex.glsl"
1983uniform 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;
1984#ifdef ELEVATED
1985uniform lowp float u_zbias_factor;
1986#endif
1987#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
1988#ifdef GLOBE_POLES
1989in vec3 a_globe_pos;in vec2 a_uv;
1990#else
1991in ivec2 a_pos;in uvec2 a_texture_pos;
1992#endif
1993out vec2 v_pos0;out vec2 v_pos1;out float v_depth;
1994#ifdef PROJECTION_GLOBE_VIEW
1995out float v_split_fade;
1996#endif
1997void main() {vec2 uv;
1998#ifdef GLOBE_POLES
1999vec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;
2000#ifdef ELEVATION_REFERENCE_GROUND
2001ele+=elevation(uv*EXTENT);
2002#endif
2003globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);
2004#ifdef FOG
2005v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);
2006#endif
2007#else
2008vec4 world_pos;
2009#ifdef PROJECTION_GLOBE_VIEW
2010vec2 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]);  
2011float tiles=u_grid_matrix[0][2];
2011if (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;
2012#ifdef ELEVATION_REFERENCE_GROUND
2013ele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;
2014#endif
2015vec4 merc_world_pos=vec4(0.0);   
2016v_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);
2017#ifdef FOG
2018v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
2019#endif
2020#else
2021float ele=0.0;vec2 decodedPos=vec2(a_pos);
2022#ifdef ELEVATION_REFERENCE_GROUND
2023vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;
2024#else
2025uv=vec2(a_texture_pos)/8192.0;
2026#endif
2027world_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);
2028#ifdef FOG
2029v_fog_pos=fog_position(decodedPos);
2030#endif
2031#endif
2032float w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;
2033#endif
2034v_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;
2035#ifdef ELEVATED
2036float 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);
2037#endif
2038#ifdef RENDER_CUTOFF
2039v_depth=gl_Position.z;
2040#endif
2041}`),symbol:ci(`#include "_prelude_lighting.glsl"
2042#include "_prelude_shadow.fragment.glsl"
2043#include "_prelude_indicator_cutout.fragment.glsl"
2044#include "_prelude_feature_cutout.fragment.glsl"
2045#define SDF_PX 8.0
2046#define SDF 1.0
2047#define ICON 0.0
2048uniform sampler2D u_texture;
2049#ifdef RENDER_TEXT_AND_SYMBOL
2050uniform sampler2D u_texture_icon;
2051#endif
2052uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_sdf;uniform lowp float u_scale_factor;uniform lowp float u_opacity_multiplier;
2053#ifdef ICON_TRANSITION
2054uniform float u_icon_transition;
2055#endif
2056#ifdef COLOR_ADJUSTMENT
2057uniform mat4 u_color_adj_mat;
2058#endif
2059#ifdef INDICATOR_CUTOUT
2060in highp float v_z_offset;
2061#else
2062#ifdef RENDER_SHADOWS
2063in highp float v_z_offset;
2064#endif
2065#endif
2066in vec2 v_tex_a;
2067#ifdef ICON_TRANSITION
2068in vec2 v_tex_b;
2069#endif
2070in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;
2071#ifdef RENDER_TEXT_AND_SYMBOL
2072in float is_sdf;in vec2 v_tex_a_icon;
2073#endif
2074#ifdef RENDER_SHADOWS
2075uniform 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;
2076#endif
2077#ifdef APPLY_LUT_ON_GPU
2078uniform highp sampler3D u_lutTexture;
2079#endif
2080in lowp float v_opacity;in 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;
2081#ifdef LIGHTING_3D_MODE
2082in lowp float v_emissive_strength;
2083#endif
2084void main() {lowp 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;if (u_is_sdf) {fill_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;}lowp float emissive_strength=0.0;
2085#ifdef LIGHTING_3D_MODE
2086emissive_strength=v_emissive_strength;
2087#endif
2088vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];
2089#ifdef RENDER_TEXT_AND_SYMBOL
2090if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity*u_opacity_multiplier;
2090glFragColor=texture(u_texture_icon,tex_icon)*alpha;
2091#ifdef OVERDRAW_INSPECTOR
2092glFragColor=vec4(1.0);
2093#endif
2094return;}
2095#endif
2096vec2 cutout_factors=vec2(0.0);
2097#ifdef FEATURE_CUTOUT
2098cutout_factors=get_cutout_factors(gl_FragCoord);
2099#endif
2100if (u_is_sdf) {float 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;} else {
2101#ifdef ICON_TRANSITION
2102vec4 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);
2103#else
2104out_color=texture(u_texture,v_tex_a);
2105#endif
2106#ifdef APPLY_LUT_ON_GPU
2107out_color=applyLUT(u_lutTexture,out_color);
2108#endif
2109#ifdef COLOR_ADJUSTMENT
2110out_color=u_color_adj_mat*out_color;
2111#endif
2112}out_color*=opacity*fade_opacity*u_opacity_multiplier;
2113#ifdef LIGHTING_3D_MODE
2114out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
2115#ifdef RENDER_SHADOWS
2116float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);
2117#ifdef TERRAIN
2118out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
2119#else
2120out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
2121#endif
2122#endif
2123#endif
2124#ifdef INDICATOR_CUTOUT
2125out_color=applyCutout(out_color,v_z_offset);
2126#endif
2127#ifdef FEATURE_CUTOUT
2128out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,0.0);
2129#endif
2130glFragColor=out_color;
2131#ifdef OVERDRAW_INSPECTOR
2132glFragColor=vec4(1.0);
2133#endif
2134HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
2135#include "_prelude_shadow.vertex.glsl"
2136#define USING_APPEARANCE 1.0
2137in ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;
2138#ifdef Z_OFFSET
2139in float a_auto_z_offset;
2140#endif
2141#ifdef PROJECTION_GLOBE_VIEW
2142in ivec4 a_globe_anchor;in vec3 a_globe_normal;
2143#endif
2144#ifdef ICON_TRANSITION
2145in uvec2 a_texb;
2146#endif
2147#ifdef OCCLUSION_QUERIES
2148in float a_occlusion_query_opacity;
2149#endif
2150#ifdef ELEVATED_ROADS
2151in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;
2152#endif
2153#ifdef INDICATOR_CUTOUT
2154out highp float v_z_offset;
2155#else
2156#ifdef RENDER_SHADOWS
2157out highp float v_z_offset;
2158#endif
vendor: 9,979 bytes, lines 2158-2243
2158
2159#endif
2160uniform 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;
2161#ifdef RENDER_SHADOWS
2162uniform mat4 u_inv_matrix;
2163#endif
2164uniform 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;
2165#ifdef PROJECTION_GLOBE_VIEW
2166uniform vec3 u_up_vector;
2167#endif
2168#ifdef RENDER_TEXT_AND_SYMBOL
2169uniform vec2 u_texsize_icon;
2170#endif
2171uniform bool u_is_halo;
2172#ifdef PROJECTION_GLOBE_VIEW
2173uniform 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;
2174#endif
2175out vec2 v_tex_a;
2176#ifdef ICON_TRANSITION
2177out vec2 v_tex_b;
2178#endif
2179out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;
2180#ifdef RENDER_TEXT_AND_SYMBOL
2181out float is_sdf;out vec2 v_tex_a_icon;
2182#endif
2183#ifdef RENDER_SHADOWS
2184uniform 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;
2185#endif
2186#ifndef MAX_UBO_SIZE_VEC4
2187#define MAX_UBO_SIZE_VEC4 1024u
2188#endif
2189#define SPP_HEADER_SIZE_VEC4 4u
2190struct 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;};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;uniform highp float u_spp_zoom_fraction;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;out 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;
2191#ifdef LIGHTING_3D_MODE
2192out lowp float v_emissive_strength;
2193#endif
2194float zoomFactor(float zm,float zM) {if (zm==zM) return u_spp_zoom_fraction-zm >=0.0 ? 1.0 : 0.0;return clamp((u_spp_zoom_fraction-zm)/(zM-zm),0.0,1.0);}vec4 readColor(uint base,bool isDataDriven,uint offsetVec4,uint dzr,vec2 headerZoom,vec4 fallbackValue) {if (!isDataDriven) return fallbackValue;vec4 value=u_spp_properties.properties[base+offsetVec4];vec2 blockZoom=u_spp_properties.properties[base+offsetVec4+dzr].xy;vec2 zr=mix(headerZoom,blockZoom,float(dzr));return unpack_mix_color(value,zoomFactor(zr.x,zr.y));}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :
2195(index==1u) ? v.y :
2196(index==2u) ? v.z : v.w;}float readScalar(uint base,bool isDataDriven,uint offsetVec4,float fallbackValue) {if (!isDataDriven) return fallbackValue;vec4 slot=u_spp_properties.properties[base+offsetVec4];return unpack_mix_vec2(slot.xy,zoomFactor(slot.z,slot.w));}vec2 readTranslate(uint base,bool isDataDriven,uint offsetVec4,uint dzr) {if (!isDataDriven) return vec2(0.0);vec4 value=u_spp_properties.properties[base+offsetVec4];vec2 blockZoom=u_spp_properties.properties[base+offsetVec4+dzr].xy;float t=zoomFactor(blockZoom.x,blockZoom.y)*float(dzr);return mix(value.xy,value.zw,t);}SymbolPaintProperties readSymbolPaintProperties() {uint dataDrivenMask=u_spp_header.header[0][0];uint dzrMask       =u_spp_header.header[0][1];uint blockSizeVec4 =u_spp_header.header[0][2];uint fillColorDzr=dzrMask & 1u;uint haloColorDzr=(dzrMask >> 1u) & 1u;vec2 fillColorHeaderZoom=uintBitsToFloat(u_spp_header.header[3].xy);vec2 haloColorHeaderZoom=uintBitsToFloat(u_spp_header.header[3].zw);uint featureIndex=uint(a_feature_index);uvec4 indexSlot=u_spp_index.block_indices[featureIndex/4u];uint base=uvec4At(indexSlot,featureIndex % 4u)*blockSizeVec4;SymbolPaintProperties props;props.fill_np_color    =readColor(base,(dataDrivenMask & (1u << 0u)) !=0u,u_spp_header.header[0][3],fillColorDzr,fillColorHeaderZoom,u_spp_fill_np_color);props.halo_np_color    =readColor(base,(dataDrivenMask & (1u << 1u)) !=0u,u_spp_header.header[1][0],haloColorDzr,haloColorHeaderZoom,u_spp_halo_np_color);props.opacity          =readScalar(base,(dataDrivenMask & (1u << 2u)) !=0u,u_spp_header.header[1][1],u_spp_opacity);props.halo_width       =readScalar(base,(dataDrivenMask & (1u << 3u)) !=0u,u_spp_header.header[1][2],u_spp_halo_width);props.halo_blur        =readScalar(base,(dataDrivenMask & (1u << 4u)) !=0u,u_spp_header.header[1][3],u_spp_halo_blur);props.emissive_strength=readScalar(base,(dataDrivenMask & (1u << 5u)) !=0u,u_spp_header.header[2][0],u_spp_emissive_strength);props.occlusion_opacity=readScalar(base,(dataDrivenMask & (1u << 6u)) !=0u,u_spp_header.header[2][1],u_spp_occlusion_opacity);props.z_offset         =readScalar(base,(dataDrivenMask & (1u << 7u)) !=0u,u_spp_header.header[2][2],u_spp_z_offset);uint translateDzr=(dzrMask >> 8u) & 1u;props.translate        =readTranslate(base,(dataDrivenMask & (1u << 8u)) !=0u,u_spp_header.header[2][3],translateDzr);return props;}vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;v_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;
2197#ifdef LIGHTING_3D_MODE
2198v_emissive_strength=paint_properties.emissive_strength;
2199#endif
2200lowp float occlusion_opacity=paint_properties.occlusion_opacity;highp float z_offset=paint_properties.z_offset;vec2 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);
2201#ifdef Z_OFFSET
2202e+=a_auto_z_offset;
2203#endif
2204vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;
2205#ifdef PROJECTION_GLOBE_VIEW
2206mercator_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;
2207#else
2208world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
2209#endif
2210vec4 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 ?
2211camera_to_anchor_distance/u_camera_to_center_distance :
2212u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
22130.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;
2214#ifdef PROJECTION_GLOBE_VIEW
2215vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_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;
2216#else
2217offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;
2218#endif
2219vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
2220#ifdef PROJECTION_GLOBE_VIEW
2221#ifdef PROJECTED_POS_ON_VIEWPORT
2222projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);
2223#else
2224vec3 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);
2225#endif
2226#else
2227projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
2228#endif
2229highp 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);
2230#ifdef TERRAIN
2231#ifdef PITCH_WITH_MAP_TERRAIN
2232vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
2233#endif
2234#endif
2235#ifdef Z_OFFSET
2236z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;
2237#else
2238z+=u_pitch_with_map ? z_offset : 0.0;
2239#endif
2240float 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));
2241#ifdef DEPTH_OCCLUSION
2242float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;
2243#endif
2244#ifdef OCCLUSION_QUERIES
2245float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;
2246#endif
2247#ifdef Z_TEST_OCCLUSION
2248out_fade_opacity*=occlusion_opacity;
2249#endif
2250float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;
2251#ifdef PROJECTION_GLOBE_VIEW
2252vec3 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;
2253#else
2254#ifdef ELEVATED_ROADS
2255vec3 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;
2256#else
2257pos=vec3(projected_pos.xy/projected_pos.w+offset,z);
2258#endif
2259#endif
2260gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(
2261u_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
2262);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}float 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;
2263#ifdef RENDER_TEXT_AND_SYMBOL
2264is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;
2265#endif
2266#ifdef ICON_TRANSITION
2267v_tex_b=vec2(a_texb)/u_texsize;
2268#endif
2269#ifdef RENDER_SHADOWS
2270vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;
2271#ifdef NORMAL_OFFSET
2272vec3 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();
2273#endif
2274v_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;
2275#endif
2276#ifdef INDICATOR_CUTOUT
2277v_z_offset=e;
2278#else
2279#ifdef RENDER_SHADOWS
2280v_z_offset=e;
2281#endif
2282#endif
2283}`),terrainRaster:ci(`#include "_prelude_fog.fragment.glsl"
2284#include "_prelude_shadow.fragment.glsl"
2285#include "_prelude_lighting.glsl"
2286uniform sampler2D u_image0;
2287#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2288uniform sampler2D u_image1;uniform float u_emissive_texture_available;
2289#endif
2290in vec2 v_pos0;
2291#ifdef FOG
2292in float v_fog_opacity;
2293#endif
2294#ifdef RENDER_SHADOWS
2295in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
2296#endif
2297uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;
2298#ifdef LIGHTING_3D_MODE
2299const vec3 normal=vec3(0.0,0.0,1.0);
2300#ifdef RENDER_SHADOWS
2301float cutoffOpacity=1.0;
2302#ifdef RENDER_CUTOFF
2303cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);
2304#endif
2305#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2306float 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;
2307#else
2308float 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));
2309#endif
2310#else
2311float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);
2312#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2313float 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;
2314#endif
2315#endif
2316#else
2317color=image_color;
2318#endif
2319#ifdef FOG
2320#ifdef ZERO_EXAGGERATION
2321color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
2322#else
2323color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
2324#endif
2325#endif
2326glFragColor=color;
2327#ifdef OVERDRAW_INSPECTOR
2328glFragColor=vec4(1.0);
2329#endif
2330HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2331#include "_prelude_terrain.vertex.glsl"
2332uniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;
2333#ifdef FOG
2334out float v_fog_opacity;
2335#endif
2336#ifdef RENDER_SHADOWS
2337uniform 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;
2338#endif
2339void 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;
2340#ifdef VIEWPORT_ORIGIN_TOP_LEFT
2341v_pos0.y=1.0-v_pos0.y;
2342#endif
2343gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
2344#ifdef FOG
2345#ifdef ZERO_EXAGGERATION
2346v_fog_pos=fog_position(decodedPos);
2347#else
2348v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
2349#endif
2350#endif
2351#ifdef RENDER_SHADOWS
2352vec3 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.);
2353#endif
2354}`),terrainDepth:ci("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl"
2355uniform 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:ci(`#include "_prelude_fog.fragment.glsl"
2356in 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(
2357cos_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
2357nd-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;
2358#ifdef FOG
2359sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
2360#endif
2361sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);
2362#ifdef OVERDRAW_INSPECTOR
2363glFragColor=vec4(1.0);
2364#endif
2365}`,C1),skyboxGradient:ci(`#include "_prelude_fog.fragment.glsl"
2366in 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));
2367#ifdef FOG
2368color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
2369#endif
2370color*=u_opacity;glFragColor=color;
2371#ifdef OVERDRAW_INSPECTOR
2372glFragColor=vec4(1.0);
2373#endif
2374}`,C1),skyboxCapture:ci(`
2375in 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;
2376#define BETA_R                  vec3(5.5e-6,13.0e-6,22.4e-6)
2377#define BETA_M                  vec3(21e-6,21e-6,21e-6)
2378#define MIE_G                   0.76
2379#define DENSITY_HEIGHT_SCALE_R  8000.0
2380#define DENSITY_HEIGHT_SCALE_M  1200.0
2381#define PLANET_RADIUS           6360e3
2382#define ATMOSPHERE_RADIUS       6420e3
2383#define SAMPLE_STEPS            10
2384#define DENSITY_STEPS           4
2385float 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);}
2385float 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))/(e
2385nd-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;
2386#ifndef VIEWPORT_ORIGIN_TOP_LEFT
2387v_position.y*=-1.0;
2388#endif
2389v_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);}`),globeRaster:ci(`#include "_prelude_fog.fragment.glsl"
2390#include "_prelude_lighting.glsl"
2391uniform sampler2D u_image0;
2392#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2393uniform sampler2D u_image1;uniform float u_emissive_texture_available;
2394#endif
2395uniform float u_far_z_cutoff;in vec2 v_pos0;
2396#ifndef FOG
2397uniform 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;
2398#endif
2399void main() {vec4 color;
2400#ifdef CUSTOM_ANTIALIASING
2401highp vec2 uv=gl_FragCoord.xy/u_viewport;FLIP_VIEWPORT_UV_Y(uv);highp vec3 ray_dir=mix(
2402mix(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);
2403#ifdef LIGHTING_3D_MODE
2404#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2405float 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);
2406#else
2407raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);
2408#endif
2409#else
2410color=vec4(raster.rgb*antialias,raster.a*antialias);
2411#endif
2412#else
2413color=texture(u_image0,v_pos0);
2414#ifdef LIGHTING_3D_MODE
2415#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
2416float 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;
2417#else
2418color=apply_lighting_ground(color);
2419#endif
2420#endif
2421#endif
2422#ifdef FOG
2423color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
2424#endif
2425color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;
2426#ifdef OVERDRAW_INSPECTOR
2427glFragColor=vec4(1.0);
2428#endif
2429HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2430#include "_prelude_terrain.vertex.glsl"
2431uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;
2432#ifndef GLOBE_POLES
2433uniform mat4 u_merc_matrix;
2434#endif
2435uniform float u_zoom_transition;uniform vec2 u_merc_center;
2436#ifndef GLOBE_POLES
2437uniform mat3 u_grid_matrix;
2438#endif
2439uniform float u_skirt_height;
2440#ifdef GLOBE_POLES
2441in vec3 a_globe_pos;in vec2 a_uv;
2442#else
2443in ivec2 a_pos;
2444#endif
2445out vec2 v_pos0;void main() {
2446#ifdef GLOBE_POLES
2447vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
2448#else
2449float 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);
2450#endif
2451v_pos0=uv;
2452#ifdef VIEWPORT_ORIGIN_TOP_LEFT
2453v_pos0.y=1.0-v_pos0.y;
2454#endif
2455vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
2456#ifdef GLOBE_POLES
2457vec3 up_vector=globe_derived_up_vector;
2458#else
2459vec3 up_vector=elevationVector(tile_pos);
2460#endif
2461float height=elevation(tile_pos);globe_pos+=up_vector*height;
2462#ifndef GLOBE_POLES
2463globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
2464#endif
2465#ifdef GLOBE_POLES
2466vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
2467#else
2468vec4 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);
2469#endif
2470gl_Position=u_proj_matrix*interpolated_pos;
2471#ifdef FOG
2472v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
2473#endif
2474}`),globeAtmosphere:ci(`#include "_prelude_fog.fragment.glsl"
2475uniform 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;
2476#ifdef PROJECTION_GLOBE_VIEW
2477globe_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) {
2478#ifdef ALPHA_PASS
2479glFragColor=vec4(0,0,0,0);return;
2480#else
2481#ifdef NATIVE
2482glFragColor=vec4(1,1,1,1);
2483#else
2484glFragColor=vec4(0,0,0,1);
2485#endif
2486return;
2487#endif
2488}
2489#endif
2490highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
24910.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;
2492#ifdef PROJECTION_GLOBE_VIEW
2493highp 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 ?
2494PI-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);
2495#else
2496horizon_angle=horizon_angle_mercator;
2497#endif
2498horizon_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;
2498vec3 color_stop_2=u_space_color.rgb;
2499#ifdef ALPHA_PASS
2500float 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);
2501#else
2502vec3 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);
2503#endif
2504}`,`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(
2505mix(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(
2506mix(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);}`),stars:ci(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)
2507{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;}`,`
2508in 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:ci("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl"
2509in 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;
2510#ifdef TERRAIN
2511float e=elevation(world_pos.xy);world_pos.z+=e;
2512#endif
2513vec4 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 Hh(i,e){const t=i.split(`
2514`);for(let n of t){if(n=n.trimStart(),n[0]!=="#"||!n.includes("if")||n.startsWith("#endif"))continue;const s=n.match(qE);if(s)for(const l of s)WE.has(l)||e.add(l)}}function j1(i){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(i)}function ci(i,e){const t=new Set,n=[],s=[];i=i.replace(F1,(c,h)=>(s.push(h),"")),e=e.replace(F1,(c,h)=>(n.push(h),""));let l=new Set(e_);Hh(i,l),Hh(e,l);for(const c of[...n,...s])t_[c]||(t_[c]=new Set,Hh(B1[c],t_[c])),l=new Set([...l,...t_[c]]);return{fragmentSource:i=i.replace(O1,(c,h,p,_,y)=>(t.add(y),h==="define"?`
2515#ifndef HAS_UNIFORM_u_${y}
2516${j1(_)?"flat ":""}in ${p} ${_} ${y};
2517#else
2518uniform ${p} ${_} u_${y};
2519#endif
2520`:h==="initialize"?`
2521#ifdef HAS_UNIFORM_u_${y}
2522    ${p} ${_} ${y} = u_${y};
2523#endif
2524`:h==="define-attribute"?`
2525#ifdef HAS_ATTRIBUTE_a_${y}
2526    in ${p} ${_} ${y};
2527#endif
2528`:h==="initialize-attribute"?"":void 0)),vertexSource:e=e.replace(O1,(c,h,p,_,y)=>{const v=`MATERIAL_ATTRIBUTE_OFFSET_${y}`,b=_==="float"?"vec2":_,T=`GET_ATTRIBUTE_${b}(a_${y}, materialInfo, ${v})`,S=y.includes("color")?"color":b;return h==="define-attribute-vertex-shader-only"?`
2529#ifdef HAS_ATTRIBUTE_a_${y}
2530in ${p} ${_} a_${y};
2531#endif
2532`:t.has(y)?h==="define"?`
2533#ifndef HAS_UNIFORM_u_${y}
2534uniform lowp float u_${y}_t;
2535    #if !defined(${v})
2536        in ${p} ${b} a_${y};
2537    #endif
2538${j1(_)?"flat ":""}out ${p} ${_} ${y};
2539#else
2540uniform ${p} ${_} u_${y};
2541#endif
2542`:h==="initialize"?S==="vec4"||S==="uvec4"?`
2543#ifndef HAS_UNIFORM_u_${y}
2544    ${y} = a_${y};
2545#else
2546    ${p} ${_} ${y} = u_${y};
2547#endif
2548`:`
2549#if !defined(HAS_UNIFORM_u_${y})
2550    #ifdef ${v}
2551        ${y} = unpack_mix_${S}(${T}, u_${y}_t);
2552    #else
2553        ${y} = unpack_mix_${S}(a_${y}, u_${y}_t);
2554    #endif
2555#else
2556    ${p} ${_} ${y} = u_${y};
2557#endif
2558`:h==="define-attribute"?`
2559#ifdef HAS_ATTRIBUTE_a_${y}
2560    in ${p} ${_} a_${y};
2561    out ${p} ${_} ${y};
2562#endif
2563`:h==="initialize-attribute"?`
2564#ifdef HAS_ATTRIBUTE_a_${y}
2565    ${y} = a_${y};
2566#endif
2567`:void 0:h==="define"?`
2568#ifndef HAS_UNIFORM_u_${y}
2569uniform lowp float u_${y}_t;
2570    #if !defined(${v})
2571        in ${p} ${b} a_${y};
2572    #endif
2573#else
2574uniform ${p} ${_} u_${y};
2575#endif
2576`:h==="define-instanced"?S==="mat4"?`
2577#ifdef INSTANCED_ARRAYS
2578in vec4 a_${y}0;
2579in vec4 a_${y}1;
2580in vec4 a_${y}2;
2581in vec4 a_${y}3;
2582#else
2583uniform ${p} ${_} u_${y};
2584#endif
2585`:`
2586#ifdef INSTANCED_ARRAYS
2587in ${p} ${b} a_${y};
2588#else
2589uniform ${p} ${_} u_${y};
2590#endif
2591`:h==="initialize-attribute-custom"?`
2592#ifdef HAS_ATTRIBUTE_a_${y}
2593    ${p} ${_} ${y} = a_${y};
2594#endif
2595`:S==="vec4"||S==="uvec4"?`
2596#ifndef HAS_UNIFORM_u_${y}
2597    #ifdef ${v}
2598        ${p} ${_} ${y} = ${T};
2599    #else
2600        ${p} ${_} ${y} = a_${y};
2601    #endif
2602#else
2603    ${p} ${_} ${y} = u_${y};
2604#endif
2605`:`
2606#ifndef HAS_UNIFORM_u_${y}
2607    #ifdef ${v}
2608        ${p} ${_} ${y} = unpack_mix_${S}(${T}, u_${y}_t);
2609    #else
2610        ${p} ${_} ${y} = unpack_mix_${S}(a_${y}, u_${y}_t);
2611    #endif
2612#else
2613    ${p} ${_} ${y} = u_${y};
2614#endif
2615`}),usedDefines:l,vertexIncludes:n,fragmentIncludes:s}}var JE={model:ci(`#include "_prelude_fog.fragment.glsl"
2616#include "_prelude_shadow.fragment.glsl"
2617#include "_prelude_lighting.glsl"
2618#include "_prelude_indicator_cutout.fragment.glsl"
2619#include "_prelude_feature_cutout.fragment.glsl"
2620uniform float u_opacity;
2621#ifdef DITHERED_DISCARD
2622uniform float u_dithered_discard_threshold;
2623#endif
2624#ifndef LIGHTING_3D_MODE
2625uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;
2626#endif
2627uniform 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;
2628#ifdef RENDER_SHADOWS
2629in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;
2630#endif
2631#ifdef OCCLUSION_TEXTURE_TRANSFORM
2632uniform vec4 u_occlusionTextureTransform;
2633#endif
2634#pragma mapbox: define-attribute highp vec3 normal_3f
2635#pragma mapbox: define-attribute highp vec3 color_3f
2636#pragma mapbox: define-attribute highp vec4 color_4f
2637#pragma mapbox: define-attribute highp vec2 uv_2f
2638#pragma mapbox: initialize-attribute highp vec3 normal_3f
2639#pragma mapbox: initialize-attribute highp vec3 color_3f
2640#pragma mapbox: initialize-attribute highp vec4 color_4f
2641#pragma mapbox: initialize-attribute highp vec2 uv_2f
2642#ifdef HAS_ATTRIBUTE_a_pbr
2643in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;
2644#endif
2645#ifdef HAS_TEXTURE_u_baseColorTexture
2646uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;
2646uniform float u_alphaCutoff;
2647#endif
2648#ifdef HAS_TEXTURE_u_metallicRoughnessTexture
2649uniform sampler2D u_metallicRoughnessTexture;
2650#endif
2651#ifdef HAS_TEXTURE_u_occlusionTexture
2652uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;
2653#endif
2654#ifdef HAS_TEXTURE_u_normalTexture
2655uniform sampler2D u_normalTexture;
2656#endif
2657#ifdef HAS_TEXTURE_u_emissionTexture
2658uniform sampler2D u_emissionTexture;
2659#endif
2660#ifdef APPLY_LUT_ON_GPU
2661uniform highp sampler3D u_lutTexture;
2662#endif
2663#ifdef FEATURE_CUTOUT_VERTEX
2664in highp float v_cutout_factor;
2665#endif
2666#ifdef TERRAIN_FRAGMENT_OCCLUSION
2667in highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;
2668#ifdef DEPTH_D24
2669highp float unpack_depth(highp float depth) {return  depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}
2670#else
2671highp float unpack_depth_rgba(highp vec4 rgba_depth)
2672{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;}
2673#endif
2674bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;
2675#ifdef FLIP_Y
2676coord.y=1.0-coord.y;
2677#endif
2678#ifdef DEPTH_D24
2679highp float depth=unpack_depth(texture(u_depthTexture,coord).r);
2680#else
2681highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));
2682#endif
2683return v_depth > depth+0.0005;}
2684#endif
2685#define saturate(_x) clamp(_x,0.,1.)
2686vec3 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)
2687{
2688#ifdef LIGHTING_3D_MODE
2689vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;
2690#ifdef RENDER_SHADOWS
2691lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
2692#else
2693lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));
2694#endif
2695return apply_lighting(albedo,transformed_normal,lighting_factor);
2696#else
2697vec3 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)-lightColor),vec3(1.0));return c3;
2698#endif
2699}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;
2700#ifdef HAS_ATTRIBUTE_a_color_3f
2701albedo*=vec4(color_3f,1.0);
2702#endif
2703#ifdef HAS_ATTRIBUTE_a_pbr
2704#else
2705#ifdef HAS_ATTRIBUTE_a_color_4f
2706albedo*=color_4f;
2707#endif
2708#endif
2709#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)
2710vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}
2711#ifdef UNPREMULT_TEXTURE_IN_SHADER
2712texColor=vec4(unpremultiplyColor(texColor),1.0);
2713#endif
2714if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}
2715#endif
2716vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);
2717#ifdef APPLY_LUT_ON_GPU
2718color=applyLUT(u_lutTexture,color);
2719#endif
2720return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {
2721#ifdef HAS_TEXTURE_u_normalTexture
2722highp 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;
2723#ifdef FLIP_Y
2724T=-T;B=-B;
2725#endif
2726highp 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;
2727#else
2728return mat3(1.0);
2729#endif
2730}highp vec3 getNormal(){highp vec3 n;
2731#ifdef HAS_ATTRIBUTE_a_normal_3f
2732n=normalize(normal_3f);
2733#else
2734highp 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));
2735#ifdef FLIP_Y
2736n=normalize(cross(fdx,fdy));
2737#else
2738n=normalize(cross(fdx,fdy))*-1.0;
2739#endif
2740#endif
2741#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2742vec3 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);
2743#endif
2744return 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;
2745#ifdef HAS_ATTRIBUTE_a_pbr
vendor: 4,221 bytes, lines 2745-2780
2745
2746mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;
2747#endif
2748#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2749vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;
2750#endif
2751const 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)
2752{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)
2753{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)
2754{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)
2755{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)
2756{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)
2757{
2758#ifdef LIGHTING_3D_MODE
2759return mat.diffuseColor;
2760#else
2761return mat.diffuseColor/PI;
2762#endif
2763}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)
2764{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)
2765{vec3 env_light=vec3(0.65,0.65,0.65);
2766#ifdef LIGHTING_3D_MODE
2767float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;
2768#endif
2769vec3 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)
2770{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;
2771#ifdef RENDER_SHADOWS
2772lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
2773#else
2774lighting_factor=NdotL;
2775#endif
2776vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;
2777#if !defined(LIGHTING_3D_MODE)
2778const 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);
2779#endif
2780color*=intensityFactor;return color;}void main() {
2780
2781#ifdef TERRAIN_FRAGMENT_OCCLUSION
2782if (isOccluded()) {discard;}
2783#endif
2784vec3 lightDir;vec3 lightColor;
2785#ifdef LIGHTING_3D_MODE
2786lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;
2787#else
2788lightDir=u_lightpos;lightColor=u_lightcolor;
2789#endif
2790vec4 finalColor;
2791#ifdef DIFFUSE_SHADED
2792vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);
2793#ifdef HAS_TEXTURE_u_occlusionTexture
2794float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;
2795#endif
2796finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;
2797#else
2798Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;
2799#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2800#ifdef OCCLUSION_TEXTURE_TRANSFORM
2801vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;
2802#else
2803vec2 uv=uv_2f;
2804#endif
2805ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;
2806#endif
2807vec4 emissive=u_emissiveFactor;
2808#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
2809emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);
2810#endif
2811#ifdef APPLY_LUT_ON_GPU
2812float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;
2813#endif
2814color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;
2815#ifdef HAS_ATTRIBUTE_a_pbr
2816float 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;
2817#ifdef APPLY_LUT_ON_GPU
2818color_mix=applyLUT(u_lutTexture,color_mix);
2819#endif
2820color=mix(color,color_mix,min(1.0,resEmission));
2821#ifdef HAS_ATTRIBUTE_a_color_4f
2822float distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.
2822y));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);
2823#endif
2824#endif
2825vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);
2826#endif
2827#ifdef DITHERED_DISCARD
2828if (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;}}
2829#endif
2830#ifdef FOG
2831finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));
2832#endif
2833#ifdef RENDER_CUTOFF
2834finalColor*=v_cutoff_opacity;
2835#endif
2836#ifdef INDICATOR_CUTOUT
2837finalColor=applyCutout(finalColor,v_position_height.w);
2838#endif
2839#ifdef FEATURE_CUTOUT_VERTEX
2840apply_feature_cutout_dither(gl_FragCoord,v_cutout_factor);
2841#else
2842#ifdef FEATURE_CUTOUT
2843finalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);
2844#endif
2845#endif
2846glFragColor=finalColor;
2847#ifdef OVERDRAW_INSPECTOR
2848glFragColor=vec4(1.0);
2849#endif
2850HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
2851#include "_prelude_shadow.vertex.glsl"
2852#include "_prelude_feature_cutout.vertex.glsl"
2853in vec3 a_pos_3f;
2854#pragma mapbox: define-attribute highp vec3 normal_3f
2855#pragma mapbox: define-attribute highp vec2 uv_2f
2856#pragma mapbox: define-attribute highp vec3 color_3f
2857#pragma mapbox: define-attribute highp vec4 color_4f
2858#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr
2859#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength
2860uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;
2861#ifdef INSTANCED_ARRAYS
2862in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
2863#else
2864uniform highp mat4 u_normal_matrix;
2865#endif
2866#ifdef RENDER_SHADOWS
2867uniform 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;
2868#endif
2869out vec4 v_position_height;out lowp vec4 v_color_mix;
2870#ifdef TERRAIN_FRAGMENT_OCCLUSION
2871out highp float v_depth;
2872#endif
2873#ifdef FEATURE_CUTOUT_VERTEX
2874out highp float v_cutout_factor;
2875#endif
2876#ifdef HAS_ATTRIBUTE_a_pbr
2877out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;
2878#endif
2879vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
2880#pragma mapbox: initialize-attribute highp vec3 normal_3f
2881#pragma mapbox: initialize-attribute highp vec2 uv_2f
2882#pragma mapbox: initialize-attribute highp vec3 color_3f
2883#pragma mapbox: initialize-attribute highp vec4 color_4f
2884#pragma mapbox: initialize-attribute-custom highp uvec4 pbr
2885#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength
2886highp mat4 normal_matrix;
2887#ifdef INSTANCED_ARRAYS
2888normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
2889#else
2890normal_matrix=u_normal_matrix;
2891#endif
2892#ifdef FEATURE_CUTOUT_VERTEX
2893v_cutout_factor=1.0;
2894#endif
2895vec3 local_pos;mat3 rs;
2896#ifdef MODEL_POSITION_ON_GPU
2897vec3 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;
2898#ifdef FEATURE_CUTOUT_VERTEX
2899highp vec4 ground_pos=vec4(pos_a.xy,0.0,1.0);highp vec4 cutout_clip_pos=mix(u_matrix*ground_pos,AWAY,hidden);highp vec3 cutout_ndc=cutout_clip_pos.xyz/cutout_clip_pos.w;vec2 uv=cutout_ndc.xy*0.5+0.5;highp float fragDepthNDC=cutout_ndc.z*0.5+0.5;
2900#ifdef FLIP_Y
2901fragDepthNDC=cutout_ndc.z;
2902#endif
2903highp float cutoutFactor=get_cutout_factors_vert(uv).x;highp float cutoutDepthNDC=sample_cutout_depth(u_cutout_depth_image,uv);highp float groundThreshold=0.001;
2903highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);v_cutout_factor=mix(1.0-cutoutFactor,1.0,groundLimit);
2904#endif
2905#else
2906local_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);
2907#endif
2908v_position_height.w=a_pos_3f.z;
2909#ifdef HAS_ATTRIBUTE_a_pbr
2910vec4 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;
2911#endif
2912#ifdef FOG
2913v_fog_pos=fog_position(local_pos);
2914#endif
2915#ifdef RENDER_CUTOFF
2916v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
2917#endif
2918#ifdef TERRAIN_FRAGMENT_OCCLUSION
2919v_depth=gl_Position.z/gl_Position.w;
2920#ifdef CLIP_ZERO_TO_ONE
2921v_depth=-1.0+2.0*v_depth; 
2922#endif
2923#endif
2924#ifdef HAS_ATTRIBUTE_a_normal_3f
2925#ifdef MODEL_POSITION_ON_GPU
2926float 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);
2927#else
2928normal_3f=vec3(normal_matrix*vec4(normal_3f,0));
2929#endif
2930#endif
2931#ifdef HAS_ATTRIBUTE_a_pbr
2932#ifdef HAS_ATTRIBUTE_a_color_4f
2933v_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);
2934#endif
2935#endif
2936#ifdef RENDER_SHADOWS
2937vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);
2938#ifdef NORMAL_OFFSET
2939#ifdef HAS_ATTRIBUTE_a_normal_3f
2940#ifdef MODEL_POSITION_ON_GPU
2941vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
2942#else
2943vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
2944#endif
2945#endif
2946#endif
2947v_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;
2948#endif
2949}`),modelDepth:ci("void main() {}",`in vec3 a_pos_3f;uniform mat4 u_matrix;
2950#ifdef MODEL_POSITION_ON_GPU
2951#ifdef INSTANCED_ARRAYS
2952in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
2953#else
2954uniform highp mat4 u_instance;
2955#endif
2956uniform highp mat4 u_node_matrix;
2957#endif
2958void main() {
2959#ifdef MODEL_POSITION_ON_GPU
2960highp mat4 instance;
2961#ifdef INSTANCED_ARRAYS
2962instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
2963#else
2964instance=u_instance;
2965#endif
2966vec3 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;
2966rs[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);
2967#else
2968gl_Position=u_matrix*vec4(a_pos_3f,1);
2969#endif
2970}`),fillExtrusionDepth:ci("void main() {}",`#include "_prelude_terrain.vertex.glsl"
2971#include "_prelude_material_table.vertex.glsl"
2972uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;
2973#ifdef TERRAIN
2974uniform int u_height_type;uniform int u_base_type;
2975#endif
2976in ivec4 a_pos_normal_ed;
2977#if defined(HAS_CENTROID) || defined(TERRAIN)
2978in uvec2 a_centroid_pos;
2979#endif
2980#ifdef RENDER_WALL_MODE
2981in ivec4 a_join_normal_inside;
2982#endif
2983#pragma mapbox: define highp float base
2984#pragma mapbox: define highp float height
2985#pragma mapbox: define highp float line_width
2986#pragma mapbox: define highp vec4 color
2987void main() {DECLARE_MATERIAL_TABLE_INFO
2988#pragma mapbox: initialize highp float base
2989#pragma mapbox: initialize highp float height
2990#pragma mapbox: initialize highp float line_width
2991#pragma mapbox: initialize highp vec4 color
2992base*=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);
2993#if defined(HAS_CENTROID) || defined(TERRAIN)
2994centroid_pos=vec2(a_centroid_pos);
2995#endif
2996vec3 pos;
2997#ifdef TERRAIN
2998bool 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);
2999#else
3000pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
3001#endif
3002#ifdef RENDER_WALL_MODE
3003vec3 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;
3004#endif
3005float 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);}`),fillExtrusionGroundEffect:ci(`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;
3006#ifdef SDF_SUBPASS
3007in 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);}
3008#ifdef FOG
3009in highp float v_fog;
3010#endif
3011#endif
3012void main() {
3013#ifdef CLEAR_SUBPASS
3014vec4 color=vec4(1.0);
3015#ifdef CLEAR_FROM_TEXTURE
3016color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));
3017#endif
3018glFragColor=color;
3019#else
3020#ifdef SDF_SUBPASS
3021highp 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;
3022#ifdef FOG
3023fog=v_fog;
3024#endif
3025#ifdef RENDER_CUTOFF
3026fog*=v_cutoff_opacity;
3027#endif
3028glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));
3029#else
3030#ifdef USE_MRT1
3031out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);
3032#else
3033vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);
3034#ifdef OVERDRAW_INSPECTOR
3035color=vec4(1.0);
3036#endif
3037glFragColor=color;
3038#endif
3039#endif
3040HANDLE_WIREFRAME_DEBUG;
3041#endif
3042}`,`#include "_prelude_fog.vertex.glsl"
3043in highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;
3044#ifdef SDF_SUBPASS
3045out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;
3046#ifdef FOG
3047out highp float v_fog;
3048#endif
3049#endif
3050uniform 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;
3051#pragma mapbox: define highp float flood_light_ground_radius
3052const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {
3053#pragma mapbox: initialize highp float flood_light_ground_radius
3054vec4 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;
3055#ifdef SDF_SUBPASS
3056v_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);
3057#ifdef FOG
3058v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);
3059#endif
3060#endif
3061float hidden_by_landmark=0.0;
3062#ifdef HAS_CENTROID
3063hidden_by_landmark=float(a_hidden_by_landmark);
3064#endif
3065float 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));
3066#ifdef RENDER_CUTOFF
3067v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
3068#endif
3069}`),groundShadow:ci(`#include "_prelude_shadow.fragment.glsl"
3070#include "_prelude_indicator_cutout.fragment.glsl"
3071#include "_prelude_feature_cutout.fragment.glsl"
3072precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
3073#ifdef FOG
3074in float v_fog_opacity;
3075#endif
3076void 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);
3077#ifdef RENDER_CUTOFF
3078shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));
3079#endif
3080#ifdef FOG
3081shadow=mix(shadow,vec3(1.0),v_fog_opacity);
3082#endif
3083#ifdef INDICATOR_CUTOUT
3084shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);
3085#endif
3086#ifdef FEATURE_CUTOUT
3087vec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;
3088#ifdef FLIP_Y
3089uv.y=1.0-uv.y;
3090#endif
3091highp float cutoutFactor=get_cutout_factors(gl_FragCoord).y;highp float cutoutDepthNDC=sample_cutout_depth_bilinear(u_cutout_depth_image,uv);highp float fragDepthNDC=gl_FragCoord.z/u_feature_cutout_params.w;highp float groundThreshold=-0.001;highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);cutoutFactor=mix(0.0,cutoutFactor,groundLimit);shadow=mix(shadow,vec3(1.0),cutoutFactor);
3092#endif
3093glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl"
3094uniform 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;
3095#ifdef FOG
3096out float v_fog_opacity;
3097#endif
3098void 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);
3099#ifdef FOG
3100v_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);
3101#endif
3102}`)};const QE=(i,e)=>({u_matrix:i,u_ground_shadow_factor:e});
vendor: 72,520 bytes, line 3102
3102function G1(i,e,t=0){const n=Math.pow(2,e.tileID.overscaledZ),s=e.tileSize*Math.pow(2,i.transform.tileZoom)/n,l=s*(e.tileID.canonical.x+e.tileID.wrap*n),c=s*e.tileID.canonical.y;return{u_image:0,u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/bf(e,1,i.transform.tileZoom),u_pixel_coord_upper:[l>>16,c>>16],u_pixel_coord_lower:[65535&l,65535&c],u_pattern_transition:t}}const i_={terrain:0,flat:1},eS=Yn(),H1=[0,0,0],Z1=(i,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z=[0,0,1],O=!1)=>{let F=H1,N=0,j=H1;if(!O){const W=e.style.light,K=W.properties.get("position");if(F=[K.x,K.y,K.z],W.properties.get("anchor")==="viewport"){const ae=Bl();So(ae,-e.transform.angle),Ao(F,F,ae)}const ee=W.properties.get("color").toPremultipliedRenderColor(null);N=W.properties.get("intensity"),j=[ee.r,ee.g,ee.b]}const te=e.transform,H={u_matrix:i,u_lightpos:F,u_lightintensity:N,u_lightcolor:j,u_vertical_gradient:+t,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:eS,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:i_[_],u_base_type:i_[y],u_ao:s,u_edge_radius:l,u_width_scale:c,u_flood_light_color:S,u_vertical_scale:A,u_flood_light_intensity:C,u_ground_shadow_factor:D,u_front_cutoff_params:z};return te.projection.name==="globe"&&(H.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],H.u_zoom_transition=v,H.u_inv_rot_matrix=T,H.u_merc_center=b,H.u_up_dir=te.projection.upVector(new yc(0,0,0),b[0]*qe,b[1]*qe),H.u_height_lift=p),H},$1=new Float32Array(16);function q1(i,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z,O,F){const N=e.context,j=N.gl,te=e.transform,H=e.transform.zoom,W=[],K=i.translate,ee=i.translateAnchor,ae=i.edgeRadius,he=Gh(e,i.cutoffFadeRange);y==="clear"?(W.push("CLEAR_SUBPASS"),O&&(W.push("CLEAR_FROM_TEXTURE"),N.activeTexture.set(j.TEXTURE0),O.bind(j.LINEAR,j.CLAMP_TO_EDGE))):y==="sdf"?W.push("SDF_SUBPASS"):y==="emissive"&&(W.push("USE_MRT1"),N.activeTexture.set(j.TEXTURE0),O.bind(j.LINEAR,j.CLAMP_TO_EDGE)),D&&W.push("HAS_CENTROID"),he.shouldRenderCutoff&&W.push("RENDER_CUTOFF");const be=(xe,Te,Fe,se,fe)=>{let ge=W;Te.groundRadiusBuffer!=null&&(ge=W.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Ae=Te.programConfigurations.get(n.id),Me=e.isTileAffectedByFog(xe),ze=e.getOrCreateProgram("fillExtrusionGroundEffect",{config:Ae,defines:ge,overrideFog:Me}),Ce=((ke,Ke,Ve,$e,dt,pt,yt,ht,wt,bt)=>({u_matrix:ke,u_opacity:Ke,u_ao_pass:Ve?1:0,u_meter_to_tile:$e,u_ao:dt,u_flood_light_intensity:pt,u_flood_light_color:yt,u_attenuation:ht,u_edge_radius:wt,u_fb:0,u_fb_size:bt,u_dynamic_offset:1}))(se,v,_,fe,[b,T*fe],S,A,C,H>=17?0:ae*fe,O?O.size[0]:0),Be=[];D&&Be.push(Te.hiddenByLandmarkVertexBuffer),Te.groundRadiusBuffer!=null&&Be.push(Te.groundRadiusBuffer),e.uploadCommonUniforms(N,ze,xe.toUnwrapped(),null,he),ze.draw(e,N.gl.TRIANGLES,l,c,h,p,Ce,n.id,Te.vertexBuffer,Te.indexBuffer,Fe,n.paint,H,Ae,Be)};for(const xe of s){const Te=t.getTile(xe),Fe=Te.getBucket(n);if(!Fe||Fe.projection.name!==te.projection.name||!Fe.groundEffect||Fe.groundEffect&&!Fe.groundEffect.hasData())continue;const se=Fe.groundEffect,fe=1/Fe.tileToMeter;{const ge=e.translatePosMatrix(xe.projMatrix,Te,K,ee),Ae=se.getDefaultSegment();be(xe,se,Ae,ge,fe)}if(z)for(let ge=0;ge<4;ge++){const Ae=bx[ge](xe),Me=t.getTile(Ae);if(!Me)continue;const ze=Me.getBucket(n);if(!ze||ze.projection.name!==te.projection.name||!ze.groundEffect||ze.groundEffect&&!ze.groundEffect.hasData())continue;const Ce=ze.groundEffect;let Be,ke;ge===0?(Be=[-8192,0,0],ke=1):ge===1?(Be=[qe,0,0],ke=0):ge===2?(Be=[0,-8192,0],ke=3):(Be=[0,qe,0],ke=2);const Ke=Ce.regionSegments[ke];Ke&&(Yi($1,xe.projMatrix,Be),be(xe,Ce,Ke,e.translatePosMatrix($1,Te,K,ee),fe))}}}const tS={model:i=>({u_matrix:new Kr(i),u_lighting_matrix:new Kr(i),u_normal_matrix:new Kr(i),u_node_matrix:new Kr(i),u_lightpos:new Ur(i),u_lightintensity:new Et(i),u_lightcolor:new Ur(i),u_camera_pos:new Ur(i),u_opacity:new Et(i),u_baseColorFactor:new El(i),u_emissiveFactor:new El(i),u_metallicFactor:new Et(i),u_roughnessFactor:new Et(i),u_baseTextureIsAlpha:new pr(i),u_alphaMask:new pr(i),u_alphaCutoff:new Et(i),u_baseColorTexture:new pr(i),u_metallicRoughnessTexture:new pr(i),u_normalTexture:new pr(i),u_occlusionTexture:new pr(i),u_emissionTexture:new pr(i),u_lutTexture:new pr(i),u_color_mix:new El(i),u_aoIntensity:new Et(i),u_emissive_strength:new Et(i),u_occlusionTextureTransform:new El(i),u_dithered_discard_threshold:new Et(i)}),modelDepth:i=>({u_matrix:new Kr(i),u_instance:new Kr(i),u_node_matrix:new Kr(i)}),groundShadow:i=>({u_matrix:new Kr(i),u_ground_shadow_factor:new Ur(i)}),fillExtrusionDepth:i=>({u_matrix:new Kr(i),u_edge_radius:new Et(i),u_width_scale:new Et(i),u_vertical_scale:new Et(i),u_height_type:new pr(i),u_base_type:new pr(i)}),fillExtrusionGroundEffect:i=>({u_matrix:new Kr(i),u_opacity:new Et(i),u_ao_pass:new Et(i),u_meter_to_tile:new Et(i),u_ao:new on(i),u_flood_light_intensity:new Et(i),u_flood_light_color:new Ur(i),u_attenuation:new Et(i),u_edge_radius:new Et(i),u_fb:new pr(i),u_fb_size:new Et(i),u_dynamic_offset:new Et(i)})};function W1(i){const e=i.properties.get("direction"),t=el(e.x,e.y,e.z);t[2]=vt(t[2],0,75);const n=kc([t[0],t[1],t[2]]);return br(n.x,n.y,n.z)}function X1(i,e,t){const n=e.properties.get("color-use-theme")==="none",s=e.properties.get("color"),l=e.properties.get("intensity"),c=e.properties.get("direction"),h=[c.x,c.y,c.z],p=t.properties.get("color-use-theme")==="none",_=t.properties.get("color"),y=t.properties.get("intensity"),v=Math.max(Ri([0,0,1],h),0),b=[0,0,0];si(b,_.toPremultipliedRenderColor(p?null:i.getLut(e.scope)).toArray01Linear().slice(0,3),y);const T=[0,0,0];return si(T,s.toPremultipliedRenderColor(n?null:i.getLut(t.scope)).toArray01Linear().slice(0,3),v*l),ju([b[0]>0?b[0]/(b[0]+T[0]):0,b[1]>0?b[1]/(b[1]+T[1]):0,b[2]>0?b[2]/(b[2]+T[2]):0])}const r_=[];function Y1(i){return r_[i]=r_[i]||new Float64Array(16)}const n_=[],iS=new Float32Array(16);class rS{constructor(e,t){this.aabb=e,this.lastCascade=t}}class nS{add(e,t){const n=this.receivers[e.key];n!==void 0?(n.aabb.min[0]=Math.min(n.aabb.min[0],t.min[0]),n.aabb.min[1]=Math.min(n.aabb.min[1],t.min[1]),n.aabb.min[2]=Math.min(n.aabb.min[2],t.min[2]),n.aabb.max[0]=Math.max(n.aabb.max[0],t.max[0]),n.aabb.max[1]=Math.max(n.aabb.max[1],t.max[1]),n.aabb.max[2]=Math.max(n.aabb.max[2],t.max[2])):this.receivers[e.key]=new rS(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(e,t,n){const s=Di.fromPoints(e.points);let l=0;for(const c in this.receivers){const h=this.receivers[c];if(!h||!s.intersectsAabb(h.aabb))continue;h.aabb.min=s.closestPoint(h.aabb.min),h.aabb.max=s.closestPoint(h.aabb.max);const p=h.aabb.getCorners();for(let _=0;_<n.length;_++){let y=!0;for(const v of p){const b=[v[0]*t,v[1]*t,v[2]];if(hi(b,b,n[_].matrix),b[0]<-1||b[0]>1||b[1]<-1||b[1]>1){y=!1;break}}if(h.lastCascade=_,l=Math.max(l,_),y)break}}return l+1}}function o_(i,e,t){const n=gr([],Pi([],t,e),Pi([],i,e)),s=Ki(n);return s===0?[0,0,1,0]:(si(n,n,1/s),[n[0],n[1],n[2],-Ri(n,e)])}function oS(i,e,t,n,s,l){const c=i.zoom,h=i.scale,p=i.worldSize,_=1/p,y=i.aspect,v=Math.sqrt(1+y*y)*Math.tan(.5*i.fovX),b=v*v,T=n-t,S=n+t;let A,C;b>T/S?(A=n,C=n*v):(A=.5*S*(1+b),C=.5*Math.sqrt(T*T+2*(n*n+t*t)*b+S*S*b*b));const D=i.projection.pixelsPerMeter(i.center.lat,p),z=[0,0,-A*_];hi(z,z,i._camera.getCameraToWorldMercator());let O=C*_;const F=function(fe){return fe[0]/=h,fe[1]/=h,fe[2]=x(fe[2],i._center.lat),fe},N=i._edgeInsets;if(!(N.left===0&&N.top===0&&N.right===0&&N.bottom===0||N.left===N.right&&N.top===N.bottom)){const fe=i._camera.getWorldToCamera(i.worldSize,i.projection.zAxisUnit==="meters"?D:1),ge=i._camera.getCameraToClipPerspective(i._fov,i.width/i.height,t,n);ge[8]=2*-i.centerOffset.x/i.width,ge[9]=2*i.centerOffset.y/i.height;const Ae=new Float64Array(16);Ha(Ae,ge,fe);const Me=new Float64Array(16);yn(Me,Ae);const ze=Cl.fromInvProjectionMatrix(Me,p,c,!0);for(const Ce of ze.points){const Be=F(Ce);O=Math.max(O,Ss(Jn([],z,Be)))}}O*=s/(s-1);const j=Math.acos(e[2]),te=Math.atan2(-e[0],-e[1]),H=new Wm;H.position=z,H.setPitchBearing(j,te);const W=H.getWorldToCamera(p,D),K=O*p,ee=Math.min(i._mercatorZfromZoom(17)*p*-2,-2*K),ae=H.getCameraToClipOrthographic(-K,K,-K,K,ee,(K+l*D)/e[2]),he=new Float64Array(16);Dt(he,ae,W);const be=.5*s,xe=[0,0,0];hi(xe,br(Math.floor(1e6*z[0])/1e6*p,Math.floor(1e6*z[1])/1e6*p,0),he),si(xe,xe,be);const Te=[Math.floor(xe[0]),Math.floor(xe[1]),Math.floor(xe[2])],Fe=[0,0,0];Pi(Fe,xe,Te),si(Fe,Fe,-1/be);const se=new Float64Array(16);return rr(se),Yi(se,se,Fe),Dt(he,se,he),[he,K]}class Fl extends Dn{constructor(e,t,n,s){super(),this.id=e,this.type="model",this.models=[],this._options=t,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}async loadGLTFFromURI(e,t){return Iv((await this.map._requestManager.transformRequest(e,fi.Model,t)).url,t)}async loadModel(e,t,n){try{const s=await this.loadGLTFFromURI(t.uri,n);if(n.aborted)return;const l=this._modelsInfo.get(e);if(!l)return;const c=$g(s),h=l.modelSpec,p=new Pv(e,h.uri,h.position,h.orientation,c);Fl.applyModelSpecification(p,h),p.computeBoundsAndApplyParent(),this.models.push(p),l.model=p}catch(s){if(n.aborted)return;this.fire(new wn(new Error(`Could not load model ${e} from ${t.uri}`,{cause:s})))}}async load(){this._abortController||(this._abortController=new AbortController);const e=this._abortController.signal,t=[];for(const n in this._options.models){const s=this._options.models[n],l=this._modelsInfo.get(n);if(l&&l.model){l.modelSpec=s;const c=l.model;c.position=s.position!=null?new f(s.position[0],s.position[1]):new f(0,0),c.orientation=s.orientation??[0,0,0],Fl.applyModelSpecification(c,s),c.computeBoundsAndApplyParent(),this.models.push(c)}else l?l.modelSpec=s:(this._modelsInfo.set(n,{modelSpec:s,model:null}),t.push(this.loadModel(n,s,e)))}t.length!==0?(await Promise.allSettled(t),e.aborted||this.fire(new Mo("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new Mo("data",{dataType:"source",sourceDataType:"metadata"}))}static arrayFromColorSpecification(e){const t=e;if(t===void 0)return;if(Array.isArray(t))return[t[0],t[1],t[2]];const n=Pt.parse(t);return n?[n.r,n.g,n.b]:void 0}static applyModelSpecification(e,t){if(t.nodeOverrides&&Fl.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&Fl.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties),t.lightOverrides){const n=t.lightOverrides,s=Fl.arrayFromColorSpecification(n["light-ambient-color"]),l=Fl.arrayFromColorSpecification(n["light-directional-color"]);e.lightOverrides={ambientIntensity:n["light-ambient-intensity"],ambientColor:s,directionalIntensity:n["light-directional-intensity"],directionalColor:l}}else e.lightOverrides=void 0}static convertNodeOverrides(e,t){if(Array.isArray(t)&&t.every(n=>typeof n=="string")){e.nodeOverrideNames=[];for(const n of t)e.nodeOverrideNames.push(n)}else Object.entries(t).forEach(([n,s])=>{const l={orientation:[0,0,0],minZoom:void 0,maxZoom:void 0};if(Object.hasOwn(s,"orientation")){const c=s.orientation;c&&(l.orientation=c)}Object.hasOwn(s,"minzoom")&&(l.minZoom=s.minzoom),Object.hasOwn(s,"maxzoom")&&(l.maxZoom=s.maxzoom),e.nodeOverrides.set(n,l)})}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(n=>typeof n=="string")){e.materialOverrideNames=[];for(const n of t)e.materialOverrideNames.push(n)}else Object.entries(t).forEach(([n,s])=>{const l=Fl.arrayFromColorSpecification(s["model-color"]),c={color:l!==void 0?new Pt(l[0],l[1],l[2]):new Pt(1,1,1),colorMix:0,emissionStrength:0,opacity:1},h=s["model-color-mix-intensity"];h!==void 0&&(c.colorMix=h);const p=s["model-emissive-strength"];p!==void 0&&(c.emissionStrength=p);const _=s["model-opacity"];_!==void 0&&(c.opacity=_),e.materialOverrides.set(n,c)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){if(this._modelsInfo.size===0)return!0;for(const e of this._modelsInfo.values())if(e.model==null)return!1;return!0}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return!1}reload(){this.cancelModelRequests();const e=yh(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(e){this.cancelModelRequests()}setModels(e){this.models=[];const t=new Map;for(const n in e){const s=e[n],l=this._modelsInfo.get(n);l&&l.modelSpec.uri===s.uri&&t.set(n,l)}if(this._modelsInfo.size!==t.size){this.cancelModelRequests();for(const[n,s]of t)s.model||t.delete(n)}this._modelsInfo=t,this._options.models=e,this.load()}}function K1(i,e,t){try{e=function(s){if(!s.variants)return s;if(!Array.isArray(s.variants))throw new Error("variants must be an array");for(const 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})}const n=Qa({...e,...i},["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return i.url&&e.tiles&&i.tiles&&(n.tiles=e.tiles),n.tiles=t.canonicalizeTileset(n,i.url),n}function J1(i,e,t,n,s){const l=function(h,p){if(h)return s(h);if(p){i.url&&p.tiles&&i.tiles&&delete i.tiles;const _=K1(i,p,e);if(_ instanceof Error)return s(_);s(null,_)}},c=function(h,p,_){if(!h)return null;if(!p&&!_)return h;_=_||h.worldview_default;const y=Object.values(h.language||{});if(y.length===0)return null;const v=Object.values(h.worldview||{});if(v.length===0)return null;const b=y.every(S=>S===p),T=v.every(S=>S===_);return b&&T?h:p in(h.language_options||{})||_ in(h.worldview_options||{})?null:h.language_options&&h.worldview_options?h:null}(i.data,t,n);if(c)return X.frame(()=>l(null,c));if(i.url){const h=new AbortController;return(async()=>{const p=await e.transformRequest(e.normalizeSourceURL(i.url,null,t,n),fi.Source,h.signal),{data:_}=await yr(p,h.signal);l(null,_)})().catch(p=>{h.signal.aborted||l(p)}),{cancel:()=>h.abort()}}return X.frame(()=>{const{data:h,...p}=i;l(null,p)})}function Q1(i,e){const t=Math.pow(2,e.z),n=Math.floor(fo(i.getWest())*t),s=Math.floor($n(i.getNorth())*t),l=Math.ceil(fo(i.getEast())*t),c=Math.ceil($n(i.getSouth())*t);return e.x>=n&&e.x<l&&e.y>=s&&e.y<c}class s_{constructor(e,t,n){this.bounds=e?m.convert(this.validateBounds(e)):null,this.minzoom=t||0,this.maxzoom=n||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}addExtraBounds(e){if(e){this.extraBounds||(this.extraBounds=[]);for(const t of e)this.extraBounds.push(m.convert(this.validateBounds(t)))}}contains(e){if(e.z>this.maxzoom||e.z<this.minzoom||this.bounds&&!Q1(this.bounds,e))return!1;if(!this.extraBounds)return!0;for(const t of this.extraBounds)if(Q1(t,e))return!0;return!1}static fromTileJSON(e){if(!e.bounds&&!e.extra_bounds)return null;const t=new s_(e.bounds,e.minzoom,e.maxzoom);return t.addExtraBounds(e.extra_bounds),t}}const Du={loaded:!0,drawModels:function(i,e,t,n){if(i.renderPass==="opaque")return;const s=t.paint.get("model-opacity").constantOr(1),l=t.paint.get("model-elevation-reference"),c=l==="ground",h=l==="ground";if(s===0)return;const p=t.paint.get("model-cast-shadows");if(i.renderPass==="shadow"&&(!p||i.terrain&&s<.65&&t._transitionablePaint._values["model-opacity"].value.expression instanceof Fo))return;const _=i.shadowRenderer,y=t.paint.get("model-receive-shadows");_&&(_.useNormalOffset=!0,y||(_.enabled=!1));const v=()=>{_&&(_.useNormalOffset=!0,y||(_.enabled=!0))},b=e.getSource();if(i.renderPass==="light-beam"&&b.type!=="batched-model")return;if(b.type==="vector"||b.type==="geojson")return function(F,N,j,te,H){const W=F.transform,K=W.projection.name==="globe",ee=W.getFreeCameraOptions().position;if(!F.modelManager)return;const ae=F.modelManager;j.modelManager=ae;const he=F.shadowRenderer;if(!Object.hasOwn(j._unevaluatedLayout._values,"model-id"))return;const be=j._unevaluatedLayout._values["model-id"],xe={...j.layout.get("model-id").parameters},Te=F.style.order.indexOf(j.fqid),Fe=j.paint.get("model-opacity").constantOr(1);for(const se of te){const fe=N.getTile(se).getBucket(j);if(!fe||fe.projection.name!==W.projection.name)continue;const ge=fe.getModelUris();if(ge&&!fe.modelsRequested&&(ae.addModelsFromBucket(ge,H),fe.modelsRequested=!0),K)xe.zoom=se.overscaledZ;else{const Ve=jE(se,W);xe.zoom=Ve}const Ae=be.possiblyEvaluate(xe);if(UE(F,fe,se),ka.shadowUniformsInitialized=!1,ka.useSingleShadowCascade=!!he&&he.getMaxCascadeForTile(se.toUnwrapped())===0,F.renderPass==="shadow"&&he){if(F.currentShadowCascade===1&&fe.isInsideFirstShadowMapFrustum)continue;const Ve=W.calculatePosMatrix(se.toUnwrapped(),W.worldSize);if(ka.tileMatrix.set(Ve),ka.shadowTileMatrix.set(he.calculateShadowPassMatrixFromMatrix(Ve)),ka.aabb.min=[0,0,0],ka.aabb.max[0]=ka.aabb.max[1]=qe,ka.aabb.max[2]=0,HE(fe,ka,F,j.scope))continue}const Me=1<<se.canonical.z,ze=[((ee.x-se.wrap)*Me-se.canonical.x)*qe,(ee.y*Me-se.canonical.y)*qe,ee.z*Me*qe];F.conflationActive&&Object.keys(fe.instancesPerModel).length>0&&F.style.isLayerClipped(j,N.getSource())&&fe.updateReplacement(se,F.replacementSource,Te,j.scope)&&(fe.uploaded=!1,fe.upload(F.context));let Ce=0;const Be=new Array,ke=new Array,Ke=new Array;for(let Ve in fe.instancesPerModel){const $e=fe.instancesPerModel[Ve];$e.features.length>0&&!K&&(Ve=Ae.evaluate($e.features[0].feature,{}));const dt=ae.getModel(Ve,H);if(dt||ae.hasURLBeenRequested(Ve)||fe.modelUris.includes(Ve)||(fe.modelUris.push(Ve),fe.modelsRequested=!1),dt&&dt.uploaded)if(K){const pt=si([],[ee.x,ee.y,ee.z],F.transform.worldSize);ns(pt,pt);for(let yt=0;yt<$e.instancedDataArray.length;++yt){const ht=[0,0,0],wt=[1,1,1],bt=it(),ri=$e.tileCoordinatesForInstance(yt),jt=$e.transformForInstance(yt);Nl(wt,jt),zu(bt,jt),jl(ht,bt);const Qt=$e.translationForInstance(yt),ui=new f(0,0);yy(fe.canonical,ui,ri.x,ri.y);const Rr=Yn();Cm(Rr,dt,F.transform,ui,ht,wt,Qt,!0,!1,!1);const Uo=$e.colorForInstance(yt),ur=Bs([],pt),Xt=Ho([],[1,1,1/R(ui.lat,F.transform.zoom)]);Ke.push({zScaleMatrix:Xt,negCameraPosMatrix:ur});for(const Hi of dt.nodes)Ey(F,Hi,Rr,F.transform.expandedFarZProjMatrix,Ce,Be,ke,dt.materialOverrides,Fe,Uo);++Ce}}else for(const pt of dt.nodes)S1(F,j,pt,$e,ze,se,ka)}if(K)if(F.renderPass==="shadow"){for(const Ve of ke)Af(Ve.mesh,Ve.nodeModelMatrix,F,j);for(const Ve of Be)Af(Ve.mesh,Ve.nodeModelMatrix,F,j)}else E1(F,j,Be,ke,Ke)}}(i,e,t,n,w1(i,t)),void v();if(!b.loaded())return;if(b.type==="batched-model")return function(F,N,j,te){j.resetLayerRenderingStats(F);const H=F.context,W=F.transform,K=F.style.fog,ee=F.shadowRenderer;if(W.projection.name!=="mercator")return void _i(`Drawing 3D landmark models for ${W.projection.name} projection is not yet implemented`);const ae=F.transform.getFreeCameraOptions().position,he=si([],[ae.x,ae.y,ae.z],F.transform.worldSize),be=Bs([],ns([],he)),xe=R(W.center.lat,W.zoom),Te=Dt([],be,Ho([],[1,1,1/xe])),Fe=j.paint.get("model-opacity").constantOr(1),se=new pn(H.gl.LEQUAL,pn.ReadWrite,F.depthRangeFor3D),fe=new pn(H.gl.LEQUAL,pn.ReadOnly,F.depthRangeFor3D),ge=new Di([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),Ae=F.renderPass==="shadow",Me=F.renderPass==="light-beam",ze=j.paint.get("model-color-use-theme").constantOr("default")==="none",Ce=Ae&&ee?ee.getCurrentCascadeFrustum():W.getFrustum(W.scaleZoom(W.worldSize)),Be=j.paint.get("model-front-cutoff"),ke=Be[2]<1,Ke=Gh(F,j.paint.get("model-cutoff-fade-range")),Ve=j.getLayerRenderingStats();(function($e,dt,pt,yt){const ht=$e.terrain?$e.terrain.exaggeration():0,wt=$e.transform.zoom;for(const bt of yt){const ri=dt.getTile(bt).getBucket(pt);ri&&(ri.setFilter(pt.filter),$e.conflationActive&&ri.updateReplacement(bt,$e.replacementSource),ri.evaluateTransform($e,pt),$e.terrain&&ht>0&&ri.elevationUpdate($e.terrain,ht,bt,pt.source),ri.needsReEvaluation($e,wt,pt)&&ri.evaluate(pt))}})(F,N,j,te),function(){const $e=new Map;let dt,pt,yt;ke?(dt=te.length-1,pt=-1,yt=-1):(dt=0,pt=te.length,yt=1);const ht=Jt(),wt=new De(0,0);for(let bt=dt;bt!==pt;bt+=yt){const ri=te[bt],jt=N.getTile(ri).getBucket(j);if(!jt||!jt.uploaded)continue;let Qt=!1;ee&&(Qt=ee.getMaxCascadeForTile(ri.toUnwrapped())===0);const ui=W.calculatePosMatrix(ri.toUnwrapped(),W.worldSize),Rr=!!(4&jt.modelTraits);Dt(xy,Te,ui),Dt(vy,W.expandedFarZProjMatrix,ui),yn(Km,xy),kl(Km,Km);const Uo=!Ae&&ee&&ee.enabled?ee.computeCascadeTileMatrices(ui):null;!Ae&&ke&&(yn(Sc,ui),hi(ht,he,Sc),wt.x=ht[0],wt.y=ht[1]);const ur=[];jt.setFilter(j.filter);for(const Xt of jt.getNodesInfo()){if(Xt.hiddenByReplacement||!Xt.node.meshes)continue;const Hi=Xt.node;let mr=0;F.terrain&&Hi.elevation&&(mr=Hi.elevation*F.terrain.exaggeration());const Pr=()=>{const Zi=Xt.aabb,wo=ge.min,To=ge.max;return wo[0]=Zi.min[0],wo[1]=Zi.min[1],wo[2]=Zi.min[2]+mr,To[0]=Zi.max[0],To[1]=Zi.max[1],To[2]=Zi.max[2]+mr,hi(wo,wo,ui),hi(To,To,ui),ge},St=Pr(),Jr=Xt.evaluatedScale;if(Jr[0]<=1&&Jr[1]<=1&&Jr[2]<=1&&St.intersects(Ce)===0)continue;if(!Ae){const Zi=St.min,wo=St.max;Qm[0]=.5*(Zi[0]+wo[0]),Qm[1]=.5*(Zi[1]+wo[1]),Qm[2]=.5*(Zi[2]+wo[2]);const To=Za(he,Qm)*xe,an=F._debugParams.lodSwitchDistance,Na=an>=0;if(Na&&an>=9999)Xt.targetLod=0;else{let is;if(Na)is=an;else{const Nn=(wo[2]-Zi[2])*xe*Jr[2],Ol=Math.max(wo[0]-Zi[0],wo[1]-Zi[1])*xe*Math.max(Jr[0],Jr[1]);let Va;Va=Nn>=30?1:Ol>=80?.5:Math.max(Nn,Ol)>=20?.25:0,is=2e3+3e3*Va}GE(Xt,To,Math.min(F.frameTimeDelta,1e3/30),is,F._debugParams.lodSwitchFadeDuration)}}if(!Ae&&ke){const Zi=.16666666666666666;Xt.cameraCollisionOpacity=he[0]>St.min[0]&&he[0]<St.max[0]&&he[1]>St.min[1]&&he[1]<St.max[1]&&he[2]*xe<St.max[2]&&Hi.footprint&&gg(wt,Hi.footprint)?Math.max(Xt.cameraCollisionOpacity-Zi,0):Math.min(1,Xt.cameraCollisionOpacity+Zi)}const Qr=1/B(ri.canonical),Bn=Hi.anchor?Hi.anchor[0]:0,kn=Hi.anchor?Hi.anchor[1]:0,xo=[Bn*(Jr[0]-1)+Xt.evaluatedTranslation[0]*Qr,kn*(Jr[1]-1)+Xt.evaluatedTranslation[1]*Qr,mr+Xt.evaluatedTranslation[2]],vo=If(new Float64Array(16),ui,xo,Jr),_n=Dt([],vo,Hi.globalMatrix),sn=Dt([],W.expandedFarZProjMatrix,_n),gn=sn[2]*Bn+sn[6]*kn+sn[10]*mr+sn[14];Hi.hidden=!1;let bo=Fe;Ae||(ke&&(bo*=Xt.cameraCollisionOpacity,bo*=$E(vo,W,Xt.aabb,Be)),bo*=ZE(Ke,gn)),bo!==0?ur.push({nodeInfo:Xt,depth:gn,opacity:bo,wvpForNode:sn,nodeModelMatrix:_n,tileModelMatrix:vo,tileTranslation:xo}):Hi.hidden=!0}Ae||ur.sort((Xt,Hi)=>!ke||Xt.opacity===1&&Hi.opacity===1?Xt.depth<Hi.depth?-1:1:Xt.opacity===1?-1:Hi.opacity===1?1:Xt.depth>Hi.depth?-1:1);for(const Xt of ur){const Hi=Xt.nodeInfo,mr=Hi.node;let Pr=null;if(F._debugParams.show3DModelFootprints&&mr.footprint){const gn=mr.id||mr.name||"footprint";if(!$e.has(gn)){const bo=If(new Float64Array(16),vy,Xt.tileTranslation,Xt.nodeInfo.evaluatedScale);$e.set(gn,{node:mr,mvp:bo})}}const St=Xt.nodeInfo.evaluatedScale;If(Ba,xy,Xt.tileTranslation,St),Jm[0]=1/St[0],Jm[1]=-1/St[1],Jm[2]=1/St[2],hr(Sc,Km,Jm),Dt(Ba,Ba,mr.globalMatrix);const Jr=Rr?0:Hi.evaluatedRMEA[0][2],Qr=Hi.targetLod,Bn=mr.lodMeshes&&mr.lodMeshes.length>0,kn=Bn&&Qr>0&&Qr<1;if(Ae&&Bn&&Math.round(Qr)===1)continue;const xo=!Ae&&K?b1(v1,Xt.nodeModelMatrix,F.transform):null,vo=Ae&&ee?ee.calculateShadowPassMatrixFromMatrix(Xt.nodeModelMatrix):null,_n=kn?2:1,sn=Bn&&Math.round(Qr)===1;for(let gn=0;gn<_n;++gn){const bo=kn?gn===1:sn,Zi=bo?mr.lodMeshes:mr.meshes,wo=kn?bo?-Qr:1-Qr:1;for(let To=0;To<Zi.length;++To){const an=Zi[To],Na=!bo&&To===mr.lightMeshIndex;let is=Xt.wvpForNode;if(Na){if(!Me&&!F.terrain&&F.shadowRenderer){F.currentLayer<F.firstLightBeamLayer&&(F.firstLightBeamLayer=F.currentLayer);continue}is=If(OE,vy,Xt.tileTranslation,Xt.nodeInfo.evaluatedScale)}else if(Me)continue;const Nn={defines:[]},Ol=[],Va=!!an.normalBuffer;if(!Ae&&ee&&(ee.useNormalOffset=Va),wy(Nn.defines,Ol,an,F,ze?null:j.lut),Rr||Nn.defines.push("DIFFUSE_SHADED"),Qt&&Nn.defines.push("SHADOWS_SINGLE_CASCADE"),Ve&&(Ae?Ve.numRenderedVerticesInShadowPass+=an.vertexArray.length:Ve.numRenderedVerticesInTransparentPass+=an.vertexArray.length),Ae){Af(an,Xt.nodeModelMatrix,F,j,vo);continue}if(K&&W.projection.name!=="globe"){const Cn=an.aabb.min,jo=an.aabb.max,[ws,Ts]=K.getOpacityForBounds(xo,Cn[0],Cn[1],jo[0],jo[1]);Nn.overrideFog=ws>=Sf||Ts>=Sf}const Ua=an.material;let Lt;Ua.occlusionTexture&&Ua.occlusionTexture.offsetScale&&(Lt=Ua.occlusionTexture.offsetScale,Nn.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),kn&&Nn.defines.push("DITHERED_DISCARD");const _r=F.getOrCreateProgram("model",Nn);if(!Ae&&ee&&ee.enabled)if(Pr!==Va){for(let Cn=0;Cn<Uo.length;Cn++)If(by[Cn]=by[Cn]||new Float64Array(16),Uo[Cn],Xt.tileTranslation,Xt.nodeInfo.evaluatedScale);ee.setupShadowsFromCascadeMatrices(by,_r,Va),Pr=Va}else _r.setShadowUniformValues(H,ee.getShadowUniformValues());F.uploadCommonUniforms(H,_r,null,xo);const Xi=Ua.pbrMetallicRoughness;Xi.metallicFactor=.9,Xi.roughnessFactor=.5;const Dr=uy(is,Ba,Sc,mr.globalMatrix,F,Xt.opacity,Xi.baseColorFactor,Ua.emissiveFactor,Xi.metallicFactor,Xi.roughnessFactor,Ua,Jr,j,kE,Lt,void 0,void 0,wo,_r.fixedDefines.includes("LIGHTING_3D_MODE"));!Na&&(Hi.hasTranslucentParts||Xt.opacity<1)&&_r.draw(F,H.gl.TRIANGLES,se,vs.disabled,er.disabled,mn.backCCW,Dr,j.id,an.vertexBuffer,an.indexBuffer,an.segments,j.paint,F.transform.zoom,void 0,Ol),_r.draw(F,H.gl.TRIANGLES,Na?fe:se,vs.disabled,Na||Xt.opacity<1||Hi.hasTranslucentParts?er.alphaBlended:er.unblended,mn.backCCW,Dr,j.id,an.vertexBuffer,an.indexBuffer,an.segments,j.paint,F.transform.zoom,void 0,Ol)}}}}if(F._debugParams.show3DModelFootprints&&$e.size>0){const bt=Array.from($e.keys()).sort();for(const ri of bt){const{node:jt,mvp:Qt}=$e.get(ri);T1(F,0,jt,Qt)}}}()}(i,e,t,n),void v();if(b.type!=="model")return;const T=b.getModels(),S=[],A=i.transform.getFreeCameraOptions().position,C=si([],[A.x,A.y,A.z],i.transform.worldSize);ns(C,C);const D=[],z=[];let O=0;for(const F of T){const N=e.getFeatureState("",F.id),j={type:"Unknown",id:F.id,properties:F.featureProperties},te=t.paint.get("model-rotation").evaluate(j,N),H=t.paint.get("model-scale").evaluate(j,N),W=t.paint.get("model-translation").evaluate(j,N),K=t.paint.get("model-opacity").evaluate(j,N);NE(t,F.id,N,F.featureProperties,F.nodeOverrideNames,F.nodeOverrides),VE(t,F.id,N,F.featureProperties,F.materialOverrideNames,F.materialOverrides),F.nodeOverrides.size>0&&F.computeBoundsAndApplyParent(),F.computeModelMatrix(i,te,H,W,h,c,!1);const ee=Bs([],C),ae=Ho([],[1,1,1/R(F.position.lat,i.transform.zoom)]);S.push({zScaleMatrix:ae,negCameraPosMatrix:ee});for(const he of F.nodes)Ey(i,he,F.matrix,i.transform.expandedFarZProjMatrix,O,D,z,F.materialOverrides,K,void 0,F.lightOverrides);O++}if(D.sort((F,N)=>N.depth-F.depth),i.renderPass!=="shadow"){if(i._debugParams.show3DModelFootprints){const F=i.transform.projMatrix,N=new Map,j=(H,W)=>{if(H.footprint){const K=H.id||H.name||"footprint";if(!N.has(K)){const ee=Dt([],F,W);N.set(K,{node:H,mvp:ee})}}};for(const H of z)j(H.node,H.modelMatrix);for(const H of D)j(H.node,H.modelMatrix);const te=Array.from(N.keys()).sort();for(const H of te){const{node:W,mvp:K}=N.get(H);T1(i,0,W,K)}}E1(i,t,D,z,S),v()}else{for(const F of z)Af(F.mesh,F.nodeModelMatrix,i,t);for(const F of D)Af(F.mesh,F.nodeModelMatrix,i,t);v()}},prepare:function(i,e,t){const n=e.getSource();if(!n.loaded())return;if(n.type==="vector"||n.type==="geojson")return void(t.modelManager&&t.modelManager.upload(t,w1(t,i)));if(n.type==="batched-model"||n.type!=="model")return;const s=n.getModels();for(const l of s)l.upload(t.context)},shaders:JE,programUniforms:tS,ShadowRenderer:class{constructor(i){this.painter=i,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new nS,this._depthMode=new pn(i.context.gl.LEQUAL,pn.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(const i of this._cascades)i.texture.destroy(),i.framebuffer.destroy();this._cascades=[]}updateShadowParameters(i,e){const t=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!e||!e.properties)return;const n=e.properties.get("shadow-intensity"),s=e.properties.get("shadow-draw-before-layer");if(!e.shadowsEnabled()||n<=0)return;let l=-1,c=0;for(const C of t.style.order){const D=t.style._mergedLayers[C];D.hasShadowPass()&&!D.isHidden(i.zoom)&&(l=c),!s||s!==C&&s!==D.slot||(this._drawShadowAfterLayer=c>0?c-1:0),c+=1}if(this._enabled=l>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=l);const h=t.context,p=this._shadowParameters.shadowMapResolution,_=this._shadowParameters.shadowMapResolution;if(this._cascades.length===0||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let C=0;C<this._shadowParameters.cascadeCount;++C){const D=h.gl,z=h.createFramebuffer(p,_,0,"texture"),O=new am(h,{width:p,height:_,data:null},D.DEPTH_COMPONENT16);z.depthAttachment.set(O.texture),this._cascades.push({framebuffer:z,texture:O,matrix:[],far:0,boundingSphereRadius:0,frustum:new Cl,scale:0})}}this.shadowDirection=W1(e);let y=0;if(i.elevation){const C=i.elevation,D=[1e4,-1e4];C.visibleDemTiles.filter(z=>z.dem).forEach(z=>{const O=z.dem.tree;D[0]=Math.min(D[0],O.minimums[0]),D[1]=Math.max(D[1],O.maximums[0])}),D[0]!==1e4&&(y=(D[1]-D[0])*C.exaggeration())}const v=1.5*i.cameraToCenterDistance,b=3*v,T=new Float64Array(16);for(let C=0;C<this._cascades.length;++C){const D=this._cascades[C];let z=i.height/50,O=1;this._shadowParameters.cascadeCount===1?O=b:C===0?O=v:(z=v,O=b);const[F,N]=oS(i,this.shadowDirection,z,O,this._shadowParameters.shadowMapResolution,y);D.scale=i.scale,D.matrix=F,D.boundingSphereRadius=N,yn(T,D.matrix),D.frustum=Cl.fromInvProjectionMatrix(T,1,0,!0),D.far=O}const S=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[S].far,this._cascades[S].far],this._uniformValues.u_shadow_intensity=n,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=Wn.ShadowMap0,this._uniformValues.u_shadowmap_1=Wn.ShadowMap0+1,this._groundShadowTiles=t.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const A=t.transform.elevation;for(const C of this._groundShadowTiles){let D={min:0,max:0};if(A){const z=A.getMinMaxForTile(C);z&&(D=z)}this.addShadowReceiver(C.toUnwrapped(),D.min,D.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(i){this._enabled=i}drawShadowPass(i,e){if(!this.enabled)return;const t=this.painter,n=t.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(t.transform.getFrustum(0),t.transform.worldSize,this._cascades),n.viewport.set([0,0,this._shadowParameters.shadowMapResolution,this._shadowParameters.shadowMapResolution]);for(let s=0;s<this._numCascadesToRender;++s){t.currentShadowCascade=s,n.bindFramebuffer.set(this._cascades[s].framebuffer.framebuffer),n.clear({color:Pt.white,depth:1});for(const l of i.order){const c=i._mergedLayers[l];if(!c.hasShadowPass()||c.isHidden(t.transform.zoom))continue;const h=i.getLayerSourceCache(c),p=h?e[h.id]:void 0;(c.type==="model"||p&&p.length)&&t.renderLayer(t,h,c,p)}}t.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;const i=this.painter,e=i.style,t=i.context,n=t.gl,s=e.directionalLight,l=e.ambientLight;if(!s||!l)return;const c=[],h=Gh(i,i.longestCutoffRange);h.shouldRenderCutoff&&c.push("RENDER_CUTOFF"),c.push("RENDER_SHADOWS"),this.useNormalOffset&&c.push("NORMAL_OFFSET");const p=X1(e,s,l),_=new pn(n.LEQUAL,pn.ReadOnly,i.depthRangeFor3D),y=new vs({func:n.EQUAL,mask:255},0,255,n.KEEP,n.KEEP,n.KEEP);for(const v of this._groundShadowTiles){const b=v.toUnwrapped(),T=i.isTileAffectedByFog(v),S=i.getOrCreateProgram("groundShadow",{defines:c,overrideFog:T});this.setupShadows(b,S),i.uploadCommonUniforms(t,S,b,null,h);const A=QE(i.transform.calculateProjMatrix(b),p);S.draw(i,n.TRIANGLES,_,y,er.multiply,mn.disabled,A,"ground_shadow",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments,null,i.transform.zoom,null,null)}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(i){const e=this.painter.transform,t=e.calculatePosMatrix(i,e.worldSize);return Dt(t,this._cascades[this.painter.currentShadowCascade].matrix,t),Float32Array.from(t)}calculateShadowPassMatrixFromMatrix(i){return Dt(iS,this._cascades[this.painter.currentShadowCascade].matrix,i)}setupShadows(i,e,t){if(!this.enabled)return;const n=this.painter.transform,s=this.painter.context,l=s.gl,c=this._uniformValues,h=n.calculatePosMatrix(i,n.worldSize);for(let p=0;p<this._cascades.length;p++){const _=Y1(p);Dt(_,this._cascades[p].matrix,h),c[p===0?"u_light_matrix_0":"u_light_matrix_1"]=_,s.activeTexture.set(l.TEXTURE0+Wn.ShadowMap0+p),this._cascades[p].texture.bindExtraParam(l.LINEAR,l.LINEAR,l.CLAMP_TO_EDGE,l.CLAMP_TO_EDGE,l.GREATER)}if(this.useNormalOffset=!!t,this.useNormalOffset){const p=B(i.canonical),_=2/n.tileSize*qe/this._shadowParameters.shadowMapResolution,y=_*this._cascades[0].boundingSphereRadius,v=_*this._cascades.at(-1).boundingSphereRadius,b=(t==="vector-tile"?1:3)*function(T){const S=vt((T-22)/-22,0,1);return .125*(1-S)+4*S}(n.zoom);c.u_shadow_normal_offset=[p,y*b,v*b],c.u_shadow_bias=[1e-4,.0012,.012]}else c.u_shadow_bias=[36e-5,.0012,.012];e.setShadowUniformValues(s,c)}computeCascadeTileMatrices(i){const e=this._shadowParameters.cascadeCount;for(let t=0;t<e;t++)Dt(n_[t]=n_[t]||new Float64Array(16),this._cascades[t].matrix,i);return n_.length=e,n_}setupShadowsFromMatrix(i,e,t=!1){if(!this.enabled)return;const n=this._shadowParameters.cascadeCount;for(let s=0;s<n;s++)Dt(Y1(s),this._cascades[s].matrix,i);r_.length=n,this.setupShadowsFromCascadeMatrices(r_,e,t)}setupShadowsFromCascadeMatrices(i,e,t=!1){if(!this.enabled)return;const n=this.painter.context,s=n.gl,l=this._uniformValues;for(let c=0;c<this._shadowParameters.cascadeCount;c++)l[c===0?"u_light_matrix_0":"u_light_matrix_1"]=i[c],n.activeTexture.set(s.TEXTURE0+Wn.ShadowMap0+c),this._cascades[c].texture.bindExtraParam(s.LINEAR,s.LINEAR,s.CLAMP_TO_EDGE,s.CLAMP_TO_EDGE,s.GREATER);if(this.useNormalOffset=t,t){const c=this._shadowParameters.normalOffset;l.u_shadow_normal_offset=[1,c,c],l.u_shadow_bias=[6e-5,.0012,.012]}else l.u_shadow_bias=[36e-5,.0012,.012];e.setShadowUniformValues(n,l)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(i,e,t,n){if(n[2]>=0)return{};const s=function(h,p,_){const y=_/(1<<h.canonical.z);return new Di([h.canonical.x*y+h.wrap*_,h.canonical.y*y+h.wrap*_,0],[(h.canonical.x+1)*y+h.wrap*_,(h.canonical.y+1)*y+h.wrap*_,p])}(i,e,t).getCorners(),l=e/-n[2];n[0]<0?(Ji(s[0],s[0],[n[0]*l,0,0]),Ji(s[3],s[3],[n[0]*l,0,0])):n[0]>0&&(Ji(s[1],s[1],[n[0]*l,0,0]),Ji(s[2],s[2],[n[0]*l,0,0])),n[1]<0?(Ji(s[0],s[0],[0,n[1]*l,0]),Ji(s[1],s[1],[0,n[1]*l,0])):n[1]>0&&(Ji(s[2],s[2],[0,n[1]*l,0]),Ji(s[3],s[3],[0,n[1]*l,0]));const c={};return c.vertices=s,c.planes=[o_(s[1],s[0],s[4]),o_(s[2],s[1],s[5]),o_(s[3],s[2],s[6]),o_(s[0],s[3],s[7])],c}addShadowReceiver(i,e,t){this._receivers.add(i,Di.fromTileIdAndHeight(i,e,t))}getMaxCascadeForTile(i){const e=this._receivers.get(i);return e&&e.lastCascade?e.lastCascade:0}},drawGroundEffect:q1,queryModelLayerRendered:function(i,e,t,n){const s=t.getSource();if(!s||s.type!=="model")return{};const l=s,c={};c[i.id]=[];const h=c[i.id];let p=0;for(const _ of l.models){const y=t.getFeatureState(i.sourceLayer,_.id),v={type:"Unknown",id:_.id,properties:_.featureProperties},b=i.paint.get("model-rotation").evaluate(v,y),T=i.paint.get("model-scale").evaluate(v,y),S=i.paint.get("model-translation").evaluate(v,y),A=i.paint.get("model-elevation-reference");let C=[];Cm(C,_,n,_.position,b,T,S,A==="ground",A==="ground",!1),n.projection.name==="globe"&&(C=Am(C,n));const D=Dt([],n.projMatrix,C),z=Vg(e.isPointQuery()?e.screenBounds:e.screenGeometry,n,D,_.aabb);if(z!=null){const O=new Pu(void 0,0,0,0,_.id);O.layer=i.layer,O.properties=structuredClone(_.featureProperties),O.properties.layer=i.id,O.properties.uri=_.uri,O.properties.orientation=_.orientation,O.sourceLayer=i.sourceLayer,O.geometry={type:"Point",coordinates:[_.position.lng,_.position.lat]},O.state=y,O.source=i.source,h.push({featureIndex:p,feature:O,intersectionZ:z})}++p}return c},queryModelLayerIntersectsFeature:function(i,e,t,n,s,l){if(!i.modelManager)return!1;const c=i.modelManager,h=e.tile.getBucket(i);if(!(h&&h instanceof ay))return!1;for(const p in h.instancesPerModel){const _=h.instancesPerModel[p],y=t.id!==void 0?t.id:t.properties&&Object.hasOwn(t.properties,"id")?t.properties.id:void 0;if(Object.hasOwn(_.idToFeaturesIndex,y)){const v=_.features[_.idToFeaturesIndex[y]],b=c.getModel(p,l||i.scope);if(!b)return!1;let T=[];const S=new f(0,0),A=h.canonical;let C=Number.MAX_VALUE;for(let D=0;D<v.instancedDataCount;++D){const z=16*(v.instancedDataOffset+D),O=_.instancedDataArray.float32,F=[O[z+4],O[z+5],O[z+6]];yy(A,S,Math.floor(O[z]),Math.floor(O[z+1])),Cm(T,b,s,S,v.rotation,v.scale,F,!1,!1,!1),s.projection.name==="globe"&&(T=Am(T,s));const N=Dt([],s.projMatrix,T),j=e.queryGeometry,te=Vg(j.isPointQuery()?j.screenBounds:j.screenGeometry,s,N,b.aabb);te!=null&&(C=Math.min(te,C))}return C!==Number.MAX_VALUE&&C}}return!1},loadMatchingModelFeature:function(i,e,t,n){const s=i.getNodesInfo()[e];if(!s||s.hiddenByReplacement||!s.node.meshes)return;let l=Number.MAX_VALUE;const c=s.node,h=t.tile,p=n.calculatePosMatrix(h.tileID.toUnwrapped(),n.worldSize),_=s.evaluatedScale;let y=0;n.elevation&&c.elevation&&(y=c.elevation*n.elevation.exaggeration()),Yi(p,p,[(c.anchor?c.anchor[0]:0)*(_[0]-1),(c.anchor?c.anchor[1]:0)*(_[1]-1),y]),hr(p,p,_);const v=t.queryGeometry,b=v.isPointQuery()?v.screenBounds:v.screenGeometry,T=function(A){const C=Dt([],p,A.globalMatrix);Dt(C,n.expandedFarZProjMatrix,C);for(let D=0;D<A.meshes.length;++D){const z=A.meshes[D];if(D===A.lightMeshIndex)continue;const O=Vg(b,n,C,z.aabb);O!=null&&(l=Math.min(O,l))}if(A.children)for(const D of A.children)T(D)};if(T(c),l===Number.MAX_VALUE)return;const S=new f(0,0);return yy(h.tileID.canonical,S,s.node.anchor[0],s.node.anchor[1]),{intersectionZ:l,position:S,feature:s.feature}},ModelSource:Fl,Tiled3dModelSource:class extends Dn{constructor(i,e,t,n){super(),this.type="batched-model",this.id=i,this.tileSize=512,this._options=e,this.tiles=this._options.tiles,this.maxzoom=e.maxzoom||19,this.minzoom=e.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=t,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(n)}onAdd(i){this.map=i,this.load()}reload(){this.cancelTileJSONRequest();const i=yh(this.id,this.scope);this.load(()=>this.map.style.clearSource(i))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(i){this._loaded=!1,this.fire(new Mo("dataloading",{dataType:"source"}));const e=Array.isArray(this.map._language)?this.map._language.join():this.map._language,t=this.map.getWorldview();this._tileJSONRequest=J1(this._options,this.map._requestManager,e,t,(n,s)=>{this._tileJSONRequest=null,this._loaded=!0,n?(e&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${e}`),t&&t.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${t}`),this.fire(new wn(n))):s&&(Object.assign(this,s),s.bounds&&(this.tileBounds=new s_(s.bounds,this.minzoom,this.maxzoom)),Pn(s.tiles,this.map._requestManager._customAccessToken),this.fire(new Mo("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Mo("data",{dataType:"source",sourceDataType:"content"}))),i&&i(n)})}hasTransition(){return!1}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loaded(){return this._loaded}async loadTile(i,e){const t=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme)),n=!i.actor||i.state==="expired";if(n)i.actor=this.dispatcher.getActor();else{if(i.state==="loading")return void(i.reloadCallback=e);if(i.buckets){const h=Object.values(i.buckets);for(const p of h)p.dirty=!0;return void(i.state="loaded")}}const s=n?"loadTile":"reloadTile",l=new AbortController;i.request=l;const c=(h,p)=>(delete i.request,i.aborted?e(null):h&&!Ht(h)?e(h):(this.map._refreshExpiredTiles&&p&&i.setExpiryData(qo(p.headers)),i.loadModelData(p,this.map.painter),i.state="loaded",e(null),void(i.reloadCallback&&(this.loadTile(i,i.reloadCallback),i.reloadCallback=null))));try{const h=await this.map._requestManager.transformRequest(t,fi.Tile,l.signal);if(l.signal.aborted)return e(null);const p={request:h,data:void 0,uid:i.uid,tileID:i.tileID,tileZoom:i.tileZoom,zoom:i.tileID.overscaledZ,tileSize:this.tileSize*i.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:i.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:X.devicePixelRatio,promoteId:this.promoteId};i.request=i.actor.sendCancelable(s,p,{},c)}catch(h){if(l.signal.aborted)return e(null);e(h)}}abortTile(i){i.request&&(i.request.abort(),delete i.request),i.actor&&i.actor.notify("abortTile",{uid:i.uid,type:this.type,source:this.id,scope:this.scope})}serialize(){return{...this._options}}},loadModel:async function(i,e,t){const n=await Iv(i),s=new Pv(e,t,void 0,void 0,$g(n));return s.computeBoundsAndApplyParent(),s}};class eb{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ou(qe,qe,512),this.featureIndexArray=new Cr,this.promoteId=t,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,t,n,s,l,c=0,h=0){const p=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,s,l,c);const _=this.grid;for(let y=0;y<t.length;y++){const v=t[y],b=[1/0,1/0,-1/0,-1/0];for(let T=0;T<v.length;T++){const S=v[T];b[0]=Math.min(b[0],S.x),b[1]=Math.min(b[1],S.y),b[2]=Math.max(b[2],S.x),b[3]=Math.max(b[3],S.y)}h!==0&&(b[0]-=h,b[1]-=h,b[2]+=h,b[3]+=h),b[0]<qe&&b[1]<qe&&b[2]>=0&&b[3]>=0&&_.insert(p,b[0],b[1],b[2],b[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Z_(new nm(this.rawTileData)).layers,this.sourceLayerCoder=new n1(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t){const{tilespaceGeometry:n,transform:s,tileTransform:l,pixelPosMatrix:c,availableImages:h,worldview:p}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const _=t.queryRadius?t.queryRadius:0,y=n.bufferedTilespaceBounds,v=this.grid.queryKeys(y.min.x,y.min.y,y.max.x,y.max.y,(A,C,D,z)=>K_(n.bufferedTilespaceGeometry,A-_,C-_,D+_,z+_));v.sort(sS);let b=null;s.elevation&&v.length>0&&(b=Vh.create(s.elevation,this.tileID));const T={};let S;for(let A=0;A<v.length;A++){const C=v[A];if(C===S)continue;S=C;const D=this.featureIndexArray.get(C);let z=null;this.is3DTile?this.loadMatchingModelFeature(T,D,e,n,s,p):this.loadMatchingFeature(T,D,e,h,p,(O,F,N,j=0)=>(z||(z=ce(O,this.tileID.canonical,l)),F.queryIntersectsFeature(n,O,N,z,this.z,s,c,b,j,t.scope)))}return T}loadMatchingFeature(e,t,n,s,l,c){const{featureIndex:h,bucketIndex:p,sourceLayerIndex:_,layoutVertexArrayOffset:y}=t,v=this.bucketLayerIDs[p],b=n.layers,T=Object.keys(b);if(T.length&&!Bc(T,v))return;const S=n.sourceCache,A=this.sourceLayerCoder.decode(_),C=this.vtLayers[A].feature(h),D=this.getId(C,A);for(let z=0;z<v.length;z++){const O=v[z];if(!b[O])continue;const{styleLayer:F,targets:N}=b[O];let j={};D!==void 0&&(j=S.getFeatureState(F.sourceLayer,D));const te=!c||c(C,F,j,y);if(!te)continue;const H=new Pu(C,this.z,this.x,this.y,D);H.tile=this.tileID.canonical,H.state=j;let W=this.serializedLayersCache.get(O);W||(W=F.serialize(),W.id=O,this.serializedLayersCache.set(O,W)),H.source=W.source,H.sourceLayer=W["source-layer"],H.layer={...W},H.layer.paint=tb(W.paint,F.paint,C,j,s),H.layer.layout=tb(W.layout,F.layout,C,j,s);const K=new zi(this.tileID.overscaledZ,{worldview:l});let ee=!1;for(const ae of N){this.updateFeatureProperties(H,ae);const{filter:he}=ae;if(he){if(C.properties=H.properties,he.needGeometry){const be=_e(C,!0);if(!he.filter(K,be,this.tileID.canonical))continue}else if(!he.filter(K,C))continue}ee=!0,ae.targetId&&this.addFeatureVariant(H,ae)}ee&&this.appendToResult(e,O,h,H,te)}}loadMatchingModelFeature(e,t,n,s,l,c){const{featureIndex:h,bucketIndex:p}=t,_=this.bucketLayerIDs[p],y=n.layers,v=Object.keys(y);if(!v.length||Bc(v,_))for(let b=0;b<_.length;b++){const T=_[b],{styleLayer:S,targets:A}=y[T];if(S.type!=="model")continue;const C=s.tile,D=C.getBucket(S);if(!D||!D.isTiled3dModelBucket||!Du.loadMatchingModelFeature)continue;const z=Du.loadMatchingModelFeature(D,h,s,l);if(!z)continue;const{z:O,x:F,y:N}=C.tileID.canonical,{feature:j,intersectionZ:te,position:H}=z;let W={};j.id!==void 0&&(W=n.sourceCache.getFeatureState(S.sourceLayer,j.id));const K=new Pu({},O,F,N,j.id);K.tile=this.tileID.canonical,K.state=W,K.properties=j.properties,K.geometry={type:"Point",coordinates:[H.lng,H.lat]};let ee=this.serializedLayersCache.get(T);ee||(ee=S.serialize(),ee.id=T,this.serializedLayersCache.set(T,ee)),K.source=ee.source,K.sourceLayer=ee["source-layer"],K.layer={...ee};const ae=new zi(this.tileID.overscaledZ,{worldview:c});let he=!1;for(const be of A){this.updateFeatureProperties(K,be);const{filter:xe}=be;if(xe){if(j.properties=K.properties,xe.needGeometry){if(!xe.filter(ae,j,this.tileID.canonical))continue}else if(!xe.filter(ae,j))continue}he=!0,be.targetId&&this.addFeatureVariant(K,be)}he&&this.appendToResult(e,T,h,K,te)}}updateFeatureProperties(e,t,n){if(t.properties){const s={};for(const l in t.properties){const c=t.properties[l].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,n);c!=null&&(s[l]=c)}e.properties=s}}addFeatureVariant(e,t,n){const s={target:t.target,namespace:t.namespace,uniqueFeatureID:t.uniqueFeatureID};t.properties&&(s.properties=e.properties),e.variants=e.variants||{},e.variants[t.targetId]=e.variants[t.targetId]||[],e.variants[t.targetId].push(s)}appendToResult(e,t,n,s,l){let c=e[t];c===void 0&&(c=e[t]=[]),c.push({featureIndex:n,feature:s,intersectionZ:l})}lookupSymbolFeatures(e,t,n,s,l,c){const h={};this.loadVTLayers();for(const p of e)this.loadMatchingFeature(h,{bucketIndex:t,sourceLayerIndex:n,featureIndex:p,layoutVertexArrayOffset:0},s,l,c);return h}loadFeature(e){const{featureIndex:t,sourceLayerIndex:n}=e;this.loadVTLayers();const s=this.sourceLayerCoder.decode(n),l=this.vtFeatures[s];if(l[t])return l[t];const c=this.vtLayers[s].feature(t);return l[t]=c,c}hasLayer(e){for(const t of this.bucketLayerIDs)for(const n of t)if(e===n)return!0;return!1}getId(e,t){let n=e.id;if(this.promoteId){const s=Array.isArray(this.promoteId)||typeof this.promoteId!="object"?this.promoteId:this.promoteId[t];if(s!=null)if(Array.isArray(s)){if(!this.promoteIdExpression){const l=Ea(s);if(l.result!=="success"){const c=l.value.map(h=>`${h.key}: ${h.message}`).join(", ");return void _i(`Failed to create expression for promoteId: ${c}`)}this.promoteIdExpression=l.value}n=this.promoteIdExpression.evaluate({zoom:0},e)}else n=e.properties[s];typeof n=="boolean"&&(n=Number(n))}return n}}function tb(i,e,t,n,s){return to(i,(l,c)=>{const h=e instanceof Ia?e.get(c):null;return h&&h.evaluate?h.evaluate(t,n,void 0,s):h})}function sS(i,e){return e-i}async function ib(){return Promise.resolve()}et(eb,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const aS={circle:class extends Fn{constructor(i,e,t,n){super(i,{layout:Kv||(Kv=new ki({"circle-sort-key":new Ze(de.layout_circle["circle-sort-key"]),"circle-elevation-reference":new He(de.layout_circle["circle-elevation-reference"]),visibility:new He(de.layout_circle.visibility)})),paint:Jv||(Jv=new ki({"circle-radius":new Ze(de.paint_circle["circle-radius"]),"circle-color":new Ze(de.paint_circle["circle-color"]),"circle-blur":new Ze(de.paint_circle["circle-blur"]),"circle-opacity":new Ze(de.paint_circle["circle-opacity"]),"circle-translate":new He(de.paint_circle["circle-translate"]),"circle-translate-anchor":new He(de.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new He(de.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new He(de.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ze(de.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ze(de.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ze(de.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new He(de.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,t,n)}createBucket(i){return new jp(i)}queryRadius(i){const e=i;return Nh("circle-radius",this,e)+Nh("circle-stroke-width",this,e)+jm(this.paint.get("circle-translate"))}queryIntersectsFeature(i,e,t,n,s,l,c,h){const p=r0(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),l.angle,i.pixelToTileUnitsFactor),_=this.paint.get("circle-radius").evaluate(e,t)+this.paint.get("circle-stroke-width").evaluate(e,t);return o0(i,n,l,c,h,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",p,_)}getProgramIds(){return["circle"]}getDefaultProgramParams(i,e,t){const n=n0(this);return{config:new bu(this,{zoom:e,lut:t}),defines:n,overrideFog:!1}}is3D(i){return!i&&!!this.layout&&this.layout.get("circle-elevation-reference")!=="none"}hasElevation(){return this.layout&&this.layout.get("circle-elevation-reference")!=="none"}mayUse(i){return i==="HD"&&vh(this,"circle-elevation-reference",e=>e==="hd-road-markup")}prepare(){return this.mayUse("HD")?Um():Promise.resolve()}},heatmap:class extends Fn{createBucket(i){return new a0(i)}constructor(i,e,t,n){super(i,{layout:l0||(l0=new ki({visibility:new He(de.layout_heatmap.visibility)})),paint:c0||(c0=new ki({"heatmap-radius":new Ze(de.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ze(de.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new He(de.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Aa(de.paint_heatmap["heatmap-color"]),"heatmap-opacity":new He(de.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,t,n),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(i){i==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=xf({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(i){return Nh("heatmap-radius",this,i)}queryIntersectsFeature(i,e,t,n,s,l,c,h){const p=this.paint.get("heatmap-radius").evaluate(e,t);return o0(i,n,l,c,h,!0,!0,new De(0,0),p)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(i,e,t){return i==="heatmap"?{config:new bu(this,{zoom:e,lut:t}),overrideFog:!1}:{}}},hillshade:class extends Fn{constructor(i,e,t,n){super(i,{layout:u0||(u0=new ki({visibility:new He(de.layout_hillshade.visibility)})),paint:h0||(h0=new ki({"hillshade-illumination-direction":new He(de.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new He(de.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new He(de.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new He(de.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new He(de.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new He(de.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new He(de.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,t,n)}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(i,e,t){return{overrideFog:!1}}},fill:class extends Fn{constructor(i,e,t,n){super(i,{layout:d0||(d0=new ki({"fill-sort-key":new Ze(de.layout_fill["fill-sort-key"]),visibility:new He(de.layout_fill.visibility),"fill-elevation-reference":new He(de.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new Ze(de.layout_fill["fill-construct-bridge-guard-rail"])})),paint:f0||(f0=new ki({"fill-antialias":new He(de.paint_fill["fill-antialias"]),"fill-opacity":new Ze(de.paint_fill["fill-opacity"]),"fill-color":new Ze(de.paint_fill["fill-color"]),"fill-outline-color":new Ze(de.paint_fill["fill-outline-color"]),"fill-translate":new He(de.paint_fill["fill-translate"]),"fill-translate-anchor":new He(de.paint_fill["fill-translate-anchor"]),"fill-pattern":new Ze(de.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new He(de.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new He(de.paint_fill["fill-emissive-strength"]),"fill-z-offset":new Ze(de.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new Ze(de.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new Ze(de.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,t,n)}getProgramIds(){const i=this.paint.get("fill-pattern"),e=i&&i.constantOr(1),t=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&t.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),t}getDefaultProgramParams(i,e,t){return{config:new bu(this,{zoom:e,lut:t}),overrideFog:!1}}recalculate(i,e){super.recalculate(i,e);const t=this.paint._values["fill-outline-color"];t.value.kind==="constant"&&t.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(i){return new H_(i)}queryRadius(){return jm(this.paint.get("fill-translate"))}queryIntersectsFeature(i,e,t,n,s,l){return!i.queryGeometry.isAboveHorizon&&q_(i0(i.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),l.angle,i.pixelToTileUnitsFactor),n)}isTileClipped(){return this.paint.get("fill-z-offset").constantOr(1)===0}is3D(i){if(this.paint.get("fill-z-offset").constantOr(1)!==0)return!0;const e=this.layout&&this.layout.get("fill-elevation-reference")!=="none";return i!=null?e&&!i:e}hasElevation(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}mayUse(i){return i==="HD"&&vh(this,"fill-elevation-reference",e=>e!=="none")}prepare(){return this.mayUse("HD")?Um():Promise.resolve()}hasShadowPass(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}},"fill-extrusion":class extends Fn{constructor(i,e,t,n){super(i,{layout:_0||(_0=new ki({visibility:new He(de["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new He(de["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new He(de["layout_fill-extrusion"]["source-max-zoom"])})),paint:g0||(g0=new ki({"fill-extrusion-opacity":new He(de["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ze(de["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new He(de["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new He(de["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ze(de["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new He(de["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new Ze(de["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ze(de["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new He(de["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new He(de["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new He(de["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new He(de["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new He(de["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new He(de["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new He(de["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new He(de["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new He(de["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new He(de["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new Ze(de["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new Ze(de["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new He(de["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new He(de["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new He(de["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new He(de["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new He(de["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new Ze(de["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new Ze(de["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new He(de["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,t,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(i){return new km(i)}queryRadius(){return jm(this.paint.get("fill-extrusion-translate"))}is3D(i){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(i,e,t,n,s,l,c,h,p){const _=r0(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),l.angle,i.pixelToTileUnitsFactor),y=this.paint.get("fill-extrusion-height").evaluate(e,t),v=this.paint.get("fill-extrusion-base").evaluate(e,t),b=[0,0],T=h&&l.elevation,S=l.elevation?l.elevation.exaggeration():1,A=i.tile.getBucket(this);if(A instanceof km){const F=A.centroidData.find(N=>p>=N.vertexArrayOffset&&p<N.vertexArrayOffset+N.vertexCount);if(F&&F.flags&Lm)return!1;if(T){const N=A.centroidVertexArray,j=p+1;j<N.length&&(b[0]=N.geta_centroid_pos0(j),b[1]=N.geta_centroid_pos1(j))}}if(b[0]===0&&b[1]===1)return!1;l.projection.name==="globe"&&(n=Xv([n],[new De(0,0),new De(qe,qe)],i.tileID.canonical).map(F=>F.polygon).flat());const C=T?h:null,[D,z]=S0(l,n,v,y,_,c,C,b,S,l.center.lat,i.tileID.canonical),O=i.queryGeometry;return E0(D,z,O.isPointQuery()?O.screenBounds:O.screenGeometry)}},building:class extends Fn{constructor(i,e,t,n){super(i,{layout:y0||(y0=new ki({visibility:new He(de.layout_building.visibility),"building-facade":new Ze(de.layout_building["building-facade"]),"building-facade-floors":new Ze(de.layout_building["building-facade-floors"]),"building-facade-unit-width":new Ze(de.layout_building["building-facade-unit-width"]),"building-facade-window":new Ze(de.layout_building["building-facade-window"]),"building-roof-shape":new Ze(de.layout_building["building-roof-shape"]),"building-height":new Ze(de.layout_building["building-height"]),"building-base":new Ze(de.layout_building["building-base"]),"building-flood-light-wall-radius":new Ze(de.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Ze(de.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Ze(de.layout_building["building-flip-roof-orientation"])})),paint:x0||(x0=new ki({"building-opacity":new He(de.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new He(de.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new He(de.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new He(de.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new He(de.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new He(de.paint_building["building-vertical-scale"]),"building-cast-shadows":new He(de.paint_building["building-cast-shadows"]),"building-color":new Ze(de.paint_building["building-color"]),"building-emissive-strength":new Ze(de.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new He(de.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new He(de.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new He(de.paint_building["building-front-cutoff"]),"building-flood-light-color":new He(de.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new He(de.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new He(de.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,t,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}mayUse(i){return i==="HD"}prepare(){return async function(){return function(){if(!hs(self)||xs!=null||Qv!=null)return null;if(kh!=null)return kh;const i=fetch(ye());return kh=function(e){let t,n,s,l,c;function h(){t=new Uint8Array(c.buffer),n=new Int16Array(c.buffer),s=new Int32Array(c.buffer),l=new Float32Array(c.buffer)}function p(){throw new Error("Unexpected BuildingGen error.")}const _=()=>{},y={a:{a:p,f:function(v){const b=t.length,T=Math.max(v>>>0,Math.ceil(1.2*b)),S=Math.ceil((T-b)/65536);try{return c.grow(S),h(),!0}catch{return!1}},g:p,b:_,c:_,d:_,e:_}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,y):e.then(v=>v.arrayBuffer()).then(v=>WebAssembly.instantiate(v,y))).then(v=>{const b=v.instance.exports;return(0,b.g)(),c=b.f,h(),new yE({setStyle:b.h,setAOOptions:b.i,setMetricOptions:b.j,setStructuralOptions:b.k,setFacadeOptions:b.l,setFauxFacadeOptions:b.m,setFacadeClassifierOptions:b.n,addFeature:b.o,addFacade:b.p,generateMesh:b.q,getLastError:b.r,getOuterRingLength:b.s,getMeshCount:b.t,getPositionsPtr:b.u,getPositionsLength:b.v,getNormalsPtr:b.w,getNormalsLength:b.x,getAOPtr:b.y,getAOLength:b.z,getUVPtr:b.A,getUVLength:b.B,getFauxFacadePtr:b.C,getFauxFacadeLength:b.D,getIndicesPtr:b.E,getIndicesLength:b.F,getBuildingPart:b.G,getRingCount:b.H,getRingPtr:b.I,getRingLength:b.J,malloc:b.K,free:b.L,heapU8:t,heap16:n,heap32:s,heapF32:l})})}(i).then(e=>{kh=null,xs=e}).catch(e=>{_i("Could not load building-gen"),kh=null,Qv=e}),kh}()}()}createBucket(i){return new e0(i)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(i){return!0}queryRadius(i){return 0}queryIntersectsFeature(i,e,t,n,s,l,c,h,p,_){let y=this.layout.get("building-height").evaluate(e,t);const v=this.layout.get("building-base").evaluate(e,t),b=i.tile.getBucket(this).getFootprint(e);if(b){if(b.hiddenFlags!==0)return!1;y=b.height}const[T,S]=S0(l,n,v,y,new De(0,0),c,null,[0,0],1,l.center.lat,i.tileID.canonical),A=i.queryGeometry;return E0(T,S,A.isPointQuery()?A.screenBounds:A.screenGeometry)}},line:class extends Fn{constructor(i,e,t,n){const s=P0();super(i,s,e,t,n),s.layout&&(this.layout=new Ia(s.layout)),this.gradientVersion=0,this.borderGradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null}_handleSpecialPaintPropertyUpdate(i){if(i==="line-gradient"){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof pl,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}else if(i==="line-gradient-use-theme")this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;else if(i==="line-border-gradient"){const e=this._transitionablePaint._values["line-border-gradient"].value.expression;this.borderStepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof pl,this.borderGradientVersion=(this.borderGradientVersion+1)%Number.MAX_SAFE_INTEGER}else i==="line-border-gradient-use-theme"&&(this.borderGradientVersion=(this.borderGradientVersion+1)%Number.MAX_SAFE_INTEGER)}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}borderGradientExpression(){return this._transitionablePaint._values["line-border-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(i,e){super.recalculate(i,e),this.paint._values["line-floorwidth"]=(()=>{if(wf)return wf;const t=P0();return wf=new CE(t.paint.properties["line-width"].specification),wf.useIntegerZoom=!0,wf})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,i)}createBucket(i){return new tg(i)}getProgramIds(){const i=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&i.push("lineBlendComposite"),i}getDefaultProgramParams(i,e,t){if(i==="lineBlendComposite")return{};const n=M0(this);return{config:new bu(this,{zoom:e,lut:t}),defines:n,overrideFog:!1}}queryRadius(i){const e=i,t=z0(Nh("line-width",this,e),Nh("line-gap-width",this,e)),n=Nh("line-offset",this,e);return t/2+Math.abs(n)+jm(this.paint.get("line-translate"))}queryIntersectsFeature(i,e,t,n,s,l){if(i.queryGeometry.isAboveHorizon)return!1;const c=i0(i.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),l.angle,i.pixelToTileUnitsFactor),h=i.pixelToTileUnitsFactor/2*z0(this.paint.get("line-width").evaluate(e,t),this.paint.get("line-gap-width").evaluate(e,t)),p=this.paint.get("line-offset").evaluate(e,t);return p&&(n=function(_,y){const v=[],b=new De(0,0);for(let T=0;T<_.length;T++){const S=_[T],A=[];for(let C=0;C<S.length;C++){const D=S[C],z=S[C+1],O=C===0?b:D.sub(S[C-1])._unit()._perp(),F=C===S.length-1?b:z.sub(D)._unit()._perp(),N=O._add(F)._unit();N._mult(1/(N.x*F.x+N.y*F.y)),A.push(N._mult(y)._add(D))}v.push(A)}return v}(n,p*i.pixelToTileUnitsFactor)),function(_,y,v){for(let b=0;b<y.length;b++){const T=y[b];if(_.length>=3){for(let S=0;S<T.length;S++)if(mc(_,T[S]))return!0}if(Kb(_,T,v))return!0}return!1}(c,n,h)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(i){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"}mayUse(i){return i==="HD"&&vh(this,"line-elevation-reference",e=>e==="hd-road-markup")}prepare(){return this.mayUse("HD")?Um():Promise.resolve()}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(i){this._destroyLineBlendFbo(i.painter&&i.painter.context&&i.painter.context.gl||void 0)}_clear(){this._destroyLineBlendFbo()}_destroyLineBlendFbo(i){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),i&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(i),this.lineBlendDensityReadback=null}},symbol:Gm,background:class extends Fn{constructor(i,e,t,n){super(i,{layout:B0||(B0=new ki({visibility:new He(de.layout_background.visibility)})),paint:k0||(k0=new ki({"background-pitch-alignment":new He(de.paint_background["background-pitch-alignment"]),"background-color":new He(de.paint_background["background-color"]),"background-pattern":new He(de.paint_background["background-pattern"]),"background-opacity":new He(de.paint_background["background-opacity"]),"background-emissive-strength":new He(de.paint_background["background-emissive-strength"]),"background-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,t,n)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(i,e,t){return{overrideFog:!1}}is3D(i){return this.paint.get("background-pitch-alignment")==="viewport"}},raster:U0,"raster-particle":X0,sky:class extends Fn{constructor(i,e,t,n){super(i,{layout:H0||(H0=new ki({visibility:new He(de.layout_sky.visibility)})),paint:Z0||(Z0=new ki({"sky-type":new He(de.paint_sky["sky-type"]),"sky-atmosphere-sun":new He(de.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new He(de.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new He(de.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new He(de.paint_sky["sky-gradient-radius"]),"sky-gradient":new Aa(de.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new He(de.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new He(de.paint_sky["sky-atmosphere-color"]),"sky-opacity":new He(de.paint_sky["sky-opacity"]),"sky-gradient-use
3102-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,t,n),this._updateColorRamp()}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0}_handleSpecialPaintPropertyUpdate(i){i==="sky-gradient"?this._updateColorRamp():i!=="sky-atmosphere-sun"&&i!=="sky-atmosphere-halo-color"&&i!=="sky-atmosphere-color"&&i!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=xf({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(i){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=i.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(i,e){if(this.paint.get("sky-type")==="atmosphere"){const n=this.paint.get("sky-atmosphere-sun"),s=!n,l=i.style.light,c=l.properties.get("position");return s&&l.properties.get("anchor")==="viewport"&&_i("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),s?sy(c.azimuthal,90-c.polar,e):sy(n[0],90-n[1],e)}const t=this.paint.get("sky-gradient-center");return sy(t[0],90-t[1],e)}isSky(){return!0}markSkyboxValid(i){this._skyboxInvalidated=!1,this._lightPosition=i.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const i=this.paint.get("sky-type");return i==="atmosphere"?["skyboxCapture","skybox"]:i==="gradient"?["skyboxGradient"]:null}},slot:class extends Fn{constructor(i,e,t,n){super(i,{paint:$0||($0=new ki({}))},e,null)}},model:class extends Fn{constructor(i,e,t,n){super(i,{layout:q0||(q0=new ki({visibility:new He(de.layout_model.visibility),"model-id":new Ze(de.layout_model["model-id"]),"model-allow-density-reduction":new He(de.layout_model["model-allow-density-reduction"])})),paint:W0||(W0=new ki({"model-opacity":new Ze(de.paint_model["model-opacity"]),"model-rotation":new Ze(de.paint_model["model-rotation"]),"model-scale":new Ze(de.paint_model["model-scale"]),"model-translation":new Ze(de.paint_model["model-translation"]),"model-color":new Ze(de.paint_model["model-color"]),"model-color-mix-intensity":new Ze(de.paint_model["model-color-mix-intensity"]),"model-type":new He(de.paint_model["model-type"]),"model-cast-shadows":new He(de.paint_model["model-cast-shadows"]),"model-receive-shadows":new He(de.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new He(de.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Ze(de.paint_model["model-emissive-strength"]),"model-roughness":new Ze(de.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Ze(de.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new He(de.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new He(de.paint_model["model-front-cutoff"]),"model-elevation-reference":new He(de.paint_model["model-elevation-reference"]),"model-line-cutout-mode":new He(de.paint_model["model-line-cutout-mode"]),"model-color-use-theme":new Ze({type:"string",default:"default","property-type":"data-driven"})}))},e,t,n),this.layer=i,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}mayUse(i){return i==="Standard"}prepare(){return ib()}createBucket(i){return new ay(i)}getProgramIds(){return["model"]}is3D(i){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(i){return i.isTiled3dModelBucket?8191:0}queryRenderedFeatures(i,e,t){return Du.queryModelLayerRendered?Du.queryModelLayerRendered(this,i,e,t):{}}queryIntersectsFeature(i,e,t,n,s,l,c,h,p,_){return!!Du.queryModelLayerIntersectsFeature&&Du.queryModelLayerIntersectsFeature(this,i,e,t,l,_)}_handleOverridablePaintPropertyUpdate(i,e,t){return!(!this.layout||e.isDataDriven()||t.isDataDriven()||i!=="model-color"&&i!=="model-color-mix-intensity"&&i!=="model-rotation"&&i!=="model-scale"&&i!=="model-translation"&&i!=="model-emissive-strength")}_isPropertyZoomDependent(i){const e=this._transitionablePaint._values[i];return e!=null&&e.value!=null&&e.value.expression!=null&&e.value.expression instanceof Fo}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends Fn{constructor(i,e,t,n){super(i,{layout:p0||(p0=new ki({"clip-layer-types":ne
vendor: 46,503 bytes, line 3102
3102w He(de.layout_clip["clip-layer-types"]),"clip-layer-scope":new He(de.layout_clip["clip-layer-scope"]),visibility:new He(de.layout_clip.visibility)})),paint:m0||(m0=new ki({}))},e,t,n)}recalculate(i,e){super.recalculate(i,e)}createBucket(i){return new w0(i)}is3D(i){return!0}}};class Ay{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){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,t)}delete(e){this.cache.delete(e)}}et(Ay,"LRUCache");class lS{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&&(this._channel.port1.close(),this._channel.port2.close()),this._callback=()=>{}}}const rb={Other:0,Symbol:1,FillExtrusion:2,HdRoadCoverage:3,HdRoadElevation:4};class cS{constructor(){this.tasks=new Map,us(["process"],this),this.invoker=new lS(this.process),this.nextId=0}add(e,t){const n=this.nextId++,s=function({type:l,renderSourceType:c,zoom:h}){h=h||0;const p=c===rb.Symbol;return l==="message"?0:l!=="maybePrepare"||p?l!=="parseTile"||p?l==="parseTile"&&p?300-h:l==="maybePrepare"&&p?400-h:500:200-h:100-h}(t);if(s===0){try{e()}finally{}return null}return this.tasks.set(n,{fn:e,metadata:t,priority:s,id:n}),this.invoker.trigger(),{cancel:()=>{this.tasks.delete(n)}}}process(){try{const e=this.pick();if(!e)return;this.tasks.delete(e.id),this.tasks.size>0&&this.invoker.trigger(),e.fn()}finally{}}pick(){let e=null,t=1/0;for(const n of this.tasks.values())n.priority<t&&(t=n.priority,e=n);return e}remove(){this.tasks.clear(),this.invoker.remove()}}const nb={type:"message"},Cy=new Map,ob=new Map;class sb{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const n=this.toIdx(e,t);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function ab(i,e,t,n){let s=0,l=Number.MAX_VALUE;for(let c=0;c<3;c++)if(Math.abs(n[c])<1e-15){if(t[c]<i[c]||t[c]>e[c])return null}else{const h=1/n[c];let p=(i[c]-t[c])*h,_=(e[c]-t[c])*h;if(p>_){const y=p;p=_,_=y}if(p>s&&(s=p),_<l&&(l=_),s>l)return null}return s}function lb(i,e,t,n,s,l,c,h,p,_,y){const v=n-i,b=s-e,T=l-t,S=c-i,A=h-e,C=p-t,D=y[1]*C-y[2]*A,z=y[2]*S-y[0]*C,O=y[0]*A-y[1]*S,F=v*D+b*z+T*O;if(Math.abs(F)<1e-15)return null;const N=1/F,j=_[0]-i,te=_[1]-e,H=_[2]-t,W=(j*D+te*z+H*O)*N;if(W<0||W>1)return null;const K=te*T-H*b,ee=H*v-j*T,ae=j*b-te*v,he=(y[0]*K+y[1]*ee+y[2]*ae)*N;return he<0||W+he>1?null:(S*K+A*ee+C*ae)*N}function cb(i,e,t,n,s,l,c,h,p){const _=1<<t,y=l-n,v=c-s,b=(i+1)/_*y+n,T=(e+0)/_*v+s,S=(e+1)/_*v+s;h[0]=(i+0)/_*y+n,h[1]=T,p[0]=b,p[1]=S}class ub{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;const t=function(l){const c=l.dim,h=Math.ceil(Math.log2(c/8)),p=[];let _=Math.ceil(Math.pow(2,h));const y=(C,D,z,O,F)=>{const N=O?1:0,j=(C+1)*z-N,te=D*z,H=(D+1)*z-N;F[0]=C*z,F[1]=te,F[2]=j,F[3]=H};let v=new sb(_);const b=1/_,{floatView:T,stride:S}=l,A=[];for(let C=0;C<_*_;C++){const D=Math.floor(C/_),z=C%_;y(z,D,b,!1,A);const O=Ic(A[0],A[1],l),F=Ic(A[2],A[1],l),N=Ic(A[2],A[3],l),j=Ic(A[0],A[3],l),te=Math.min(O,F,N,j),H=Math.max(0,8*z-1),W=Math.min(c-1,8*(z+1)),K=Math.max(0,8*D-1),ee=Math.min(c-1,8*(D+1));let ae=-1/0;for(let he=K;he<=ee;he++){const be=(he+1)*S;for(let xe=H;xe<=W;xe++){const Te=T[be+xe+1];Te>ae&&(ae=Te)}}v.minimums.push(te),v.maximums.push(ae),v.leaves.push(1)}for(p.push(v),_/=2;_>=1;_/=2){const C=p.at(-1);v=new sb(_);for(let D=0;D<_*_;D++){y(D%_,Math.floor(D/_),2,!0,A);const z=C.getElevation(A[0],A[1]),O=C.getElevation(A[2],A[1]),F=C.getElevation(A[2],A[3]),N=C.getElevation(A[0],A[3]),j=C.isLeaf(A[0],A[1]),te=C.isLeaf(A[2],A[1]),H=C.isLeaf(A[2],A[3]),W=C.isLeaf(A[0],A[3]),K=Math.min(z.min,O.min,F.min,N.min),ee=Math.max(z.max,O.max,F.max,N.max),ae=j&&te&&H&&W;v.maximums.push(ee),v.minimums.push(K),v.leaves.push(ee-K<=5&&ae?1:0)}p.push(v)}return p}(this.dem),n=t.length-1,s=t[n];this._addNode(s.minimums[0],s.maximums[0],s.leaves[0]),this._construct(t,0,0,n,0)}raycastRoot(e,t,n,s,l,c,h=1){return ab([e,t,-100],[n,s,this.maximums[0]*h],l,c)}raycast(e,t,n,s,l,c,h=1){if(!this.nodeCount)return null;const p=this.raycastRoot(e,t,n,s,l,c,h);if(p==null)return null;const _=[],y=[],v=[],b=[],T=[{idx:0,t:p,nodex:0,nodey:0,depth:0}];for(;T.length>0;){const{idx:S,t:A,nodex:C,nodey:D,depth:z}=T.pop();if(this.leaves[S]){cb(C,D,z,e,t,n,s,v,b);const F=1<<z,N=C/F,j=(C+1)/F,te=D/F,H=(D+1)/F,{dim:W,floatView:K,stride:ee}=this.dem,ae=Math.floor(N*W),he=Math.ceil(j*W),be=Math.floor(te*W),xe=he-ae,Te=Math.ceil(H*W)-be;if(xe<=0||Te<=0)continue;const Fe=v[0],se=v[1],fe=(b[0]-Fe)/xe,ge=(b[1]-se)/Te,Ae=Math.max(0,A),Me=l[0]+c[0]*Ae,ze=l[1]+c[1]*Ae,Ce=Math.abs(c[0])>1e-10,Be=Math.abs(c[1])>1e-10,ke=c[0]>=0?1:-1,Ke=c[1]>=0?1:-1;let Ve=Math.max(0,Math.min(xe-1,Math.floor((Me-Fe)/fe))),$e=Math.max(0,Math.min(Te-1,Math.floor((ze-se)/ge)));const dt=Ce?Math.abs(fe/c[0]):Number.MAX_VALUE,pt=Be?Math.abs(ge/c[1]):Number.MAX_VALUE;let yt=Ce?Ae+(Fe+(c[0]>=0?Ve+1:Ve)*fe-Me)/c[0]:Number.MAX_VALUE,ht=Be?Ae+(se+(c[1]>=0?$e+1:$e)*ge-ze)/c[1]:Number.MAX_VALUE;const wt=(Pr,St)=>K[(St+1)*ee+Pr+1]*h;let bt=wt(ae+Ve,be+$e),ri=wt(ae+Ve+1,be+$e),jt=wt(ae+Ve,be+$e+1),Qt=wt(ae+Ve+1,be+$e+1),ui=null;for(let Pr=0;Pr<xe+Te;Pr++){const St=Math.min(yt,ht);if(c[2]>=0||l[2]+c[2]*St<=Math.max(bt,ri,jt,Qt)){const Qr=Fe+Ve*fe,Bn=Qr+fe,kn=se+$e*ge,xo=kn+ge,vo=lb(Bn,kn,ri,Qr,kn,bt,Qr,xo,jt,l,c),_n=lb(Qr,xo,jt,Bn,xo,Qt,Bn,kn,ri,l,c);vo!=null&&vo>=0&&(ui===null||vo<ui)&&(ui=vo),_n!=null&&_n>=0&&(ui===null||_n<ui)&&(ui=_n)}const Jr=yt<ht;if(Jr?(Ve+=ke,yt+=dt):($e+=Ke,ht+=pt),Ve<0||Ve>=xe||$e<0||$e>=Te||ui!==null&&St>ui)break;Jr?ke>0?(bt=ri,jt=Qt,ri=wt(ae+Ve+1,be+$e),Qt=wt(ae+Ve+1,be+$e+1)):(ri=bt,Qt=jt,bt=wt(ae+Ve,be+$e),jt=wt(ae+Ve,be+$e+1)):Ke>0?(bt=jt,ri=Qt,jt=wt(ae+Ve,be+$e+1),Qt=wt(ae+Ve+1,be+$e+1)):(jt=bt,Qt=ri,bt=wt(ae+Ve,be+$e),ri=wt(ae+Ve+1,be+$e))}if(ui!==null)return ui||0;const Rr=cn([],l,c,A),Uo=(Rr[0]-v[0])/(b[0]-v[0]),ur=(Rr[1]-v[1])/(b[1]-v[1]),Xt=Ic(N,te,this.dem)*h,Hi=Ic(j,te,this.dem)*h,mr=Ic(j,H,this.dem)*h;if(hb(Xt,Hi,Ic(N,H,this.dem)*h,mr,Uo,ur)>=Rr[2])return A;continue}let O=0;for(let F=0;F<this._siblingOffset.length;F++){cb((C<<1)+this._siblingOffset[F][0],(D<<1)+this._siblingOffset[F][1],z+1,e,t,n,s,v,b),v[2]=-100,b[2]=this.maximums[this.childOffsets[S]+F]*h;const N=ab(v,b,l,c);if(N!=null){const j=N;_[F]=j;let te=!1;for(let H=0;H<O&&!te;H++)j>=_[y[H]]&&(y.splice(H,0,F),te=!0);te||(y[O]=F),O++}}for(let F=0;F<O;F++){const N=y[F];T.push({idx:this.childOffsets[S]+N,t:_[N],nodex:(C<<1)+this._siblingOffset[N][0],nodey:(D<<1)+this._siblingOffset[N][1],depth:z+1})}}return null}_addNode(e,t,n){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(n),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,n,s,l){if(e[s].isLeaf(t,n)===1)return;this.childOffsets[l]||(this.childOffsets[l]=this.nodeCount);const c=s-1,h=e[c];let p=0,_=0;for(let y=0;y<this._siblingOffset.length;y++){const v=2*t+this._siblingOffset[y][0],b=2*n+this._siblingOffset[y][1],T=h.getElevation(v,b),S=h.isLeaf(v,b),A=this._addNode(T.min,T.max,S);S&&(p|=1<<y),_||(_=A)}for(let y=0;y<this._siblingOffset.length;y++)p&1<<y||this._construct(e,2*t+this._siblingOffset[y][0],2*n+this._siblingOffset[y][1],c,_+y)}}function hb(i,e,t,n,s,l){return lt(lt(i,t,l),lt(e,n,l),s)}function Ic(i,e,t){const n=t.dim,s=vt(i*n-.5,0,n-1),l=vt(e*n-.5,0,n-1),c=Math.floor(s),h=Math.floor(l),p=Math.min(c+1,n-1),_=Math.min(h+1,n-1);return hb(t.get(c,h),t.get(p,h),t.get(c,_),t.get(p,_),s-c,l-h)}const uS={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function hS(i,e,t){return(256*i*256+256*e+t)/10-1e4}function dS(i,e,t){return 256*i+e+t/256-32768}class a_{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,n,s=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(n&&n!=="mapbox"&&n!=="terrarium")return void _i(`"${n}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const l=this.dim=t.height-2,c=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=s,this._modifiedForSources={},!s){for(let p=0;p<l;p++)c[this._idx(-1,p)]=c[this._idx(0,p)],c[this._idx(l,p)]=c[this._idx(l-1,p)],c[this._idx(p,-1)]=c[this._idx(p,0)],c[this._idx(p,l)]=c[this._idx(p,l-1)];c[this._idx(-1,-1)]=c[this._idx(0,0)],c[this._idx(l,-1)]=c[this._idx(l-1,0)],c[this._idx(-1,l)]=c[this._idx(0,l-1)],c[this._idx(l,l)]=c[this._idx(l-1,l-1)]}const h=n==="terrarium"?dS:hS;for(let p=0;p<c.length;++p){const _=4*p;this.floatView[p]=h(this.pixels[_],this.pixels[_+1],this.pixels[_+2])}this._timestamp=X.now()}_buildQuadTree(){this._tree=new ub(this)}get(e,t,n=!1){n&&(e=vt(e,-1,this.dim),t=vt(t,-1,this.dim));const s=this._idx(e,t);return this.floatView[s]}set(e,t,n){const s=this._idx(e,t),l=this.floatView[s];return this.floatView[s]=n,n-l}static getUnpackVector(e){return uS[e]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}static pack(e,t){const n=[0,0,0,0],s=a_.getUnpackVector(t);let l=Math.floor((e+s[3])/s[2]);return n[2]=l%256,l=Math.floor(l/256),n[1]=l%256,l=Math.floor(l/256),n[0]=l,n}getPixels(){return new Xy({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let s=t*this.dim,l=t*this.dim+this.dim,c=n*this.dim,h=n*this.dim+this.dim;switch(t){case-1:s=l-1;break;case 1:l=s+1}switch(n){case-1:c=h-1;break;case 1:h=c+1}const p=-t*this.dim,_=-n*this.dim;for(let y=c;y<h;y++)for(let v=s;v<l;v++){const b=4*this._idx(v,y),T=4*this._idx(v+p,y+_);this.pixels[b+0]=e.pixels[T+0],this.pixels[b+1]=e.pixels[T+1],this.pixels[b+2]=e.pixels[T+2],this.pixels[b+3]=e.pixels[T+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function fS(i,e){const t={};let n;for(;n=i.nextField(e);)n===1?(t.delta_filter=pS(i,i.readVarint()+i.pos),t.filter="delta_filter"):n===2?(i.readVarint(),t.filter="zigzag_filter"):n===3?(i.readVarint(),t.filter="bitshuffle_filter"):n===4&&(i.readVarint(),t.filter="byteshuffle_filter");return t}function pS(i,e){const t={blockSize:0};let n;for(;n=i.nextField(e);)n===1&&(t.blockSize=i.readVarint());return t}function mS(i,e){const t={};let n;for(;n=i.nextField(e);)n===1?(i.readVarint(),t.codec="gzip_data"):n===2?(i.readVarint(),t.codec="jpeg_image"):n===3?(i.readVarint(),t.codec="webp_image"):n===4&&(i.readVarint(),t.codec="png_image");return t}function _S(i,e){const t={firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]};let n,s=0,l=0;for(;n=i.nextField(e);)n===1?t.firstByte=i.readFixed64():n===2?t.lastByte=i.readFixed64():n===3?t.filters.push(fS(i,i.readVarint()+i.pos)):n===4?t.codec=mS(i,i.readVarint()+i.pos):n===5?l=i.readFloat():n===6?s=i.readFloat():n===7?t.bands.push(i.readString()):n===8?t.offset=i.readDouble():n===9&&(t.scale=i.readDouble());return t.offset===0&&(t.offset=l),t.scale===0&&(t.scale=s),t}function gS(i,e){const t={version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]};let n;for(;n=i.nextField(e);)n===1?t.version=i.readVarint():n===2?t.name=i.readString():n===3?t.units=i.readString():n===4?t.tileSize=i.readVarint():n===5?t.buffer=i.readVarint():n===6?t.pixelFormat=i.readVarint():n===7&&t.dataIndex.push(_S(i,i.readVarint()+i.pos));return t}function yS(i,e,t){let n;for(;n=i.nextField(e);)if(n===1){let s=0;const l=i.readVarint()+i.pos;for(;i.pos<l;)t[s++]=i.readVarint()}return t}function xS(i,e){if(e.length!==4)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let t=e[3];for(let n=2;n>=1;n--){const s=n===1?1:0,l=n===2?1:0;for(let c=0;c<e[0];c++){const h=e[1]*c;for(let p=s;p<e[1];p++){const _=e[2]*(p+h);for(let y=l;y<e[2];y++){const v=e[3]*(y+_);for(let b=0;b<e[3];b++){const T=v+b;i[T]+=i[T-t]}}}}t*=e[n]}return i}function vS(i){for(let e=0,t=i.length;e<t;e++)i[e]=i[e]>>>1^-(1&i[e]);return i}function bS(i,e){switch(e){case"uint32":return i;case"uint16":for(let t=0;t<i.length;t+=2){const n=i[t],s=i[t+1];i[t]=(240&n)>>4|(61440&n)>>8|(240&s)<<4|61440&s,i[t+1]=15&n|(3840&n)>>4|(15&s)<<8|(3840&s)<<4}return i;case"uint8":for(let t=0;t<i.length;t+=4){const n=i[t],s=i[t+1],l=i[t+2],c=i[t+3];i[t+0]=(192&n)>>6|(192&s)>>4|(192&l)>>2|192&c,i[t+1]=(48&n)>>4|(48&s)>>2|48&l|(48&c)<<2,i[t+2]=(12&n)>>2|12&s|(12&l)<<2|(12&c)<<4,i[t+3]=3&n|(3&s)<<2|(3&l)<<4|(3&c)<<6}return i;default:throw new Error(`Invalid pixel format, "${e}"`)}}et(a_,"DEMData"),et(ub,"DemMinMaxQuadTree",{omit:["dem"]});var bs=Uint8Array,Cf=Uint16Array,wS=Int32Array,db=new bs([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]),fb=new bs([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]),TS=new bs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pb=function(i,e){for(var t=new Cf(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];var s=new wS(t[30]);for(n=1;n<30;++n)for(var l=t[n];l<t[n+1];++l)s[l]=l-t[n]<<5|n;return{b:t,r:s}},mb=pb(db,2),_b=mb.b,ES=mb.r;_b[28]=258,ES[258]=28;for(var SS=pb(fb,0).b,gb=new Cf(32768),Mr=0;Mr<32768;++Mr){var Zh=(43690&Mr)>>1|(21845&Mr)<<1;gb[Mr]=((65280&(Zh=(61680&(Zh=(52428&Zh)>>2|(13107&Zh)<<2))>>4|(3855&Zh)<<4))>>8|(255&Zh)<<8)>>1}var Mf=function(i,e,t){for(var n=i.length,s=0,l=new Cf(e);s<n;++s)i[s]&&++l[i[s]-1];var c,h=new Cf(e);for(s=1;s<e;++s)h[s]=h[s-1]+l[s-1]<<1;c=new Cf(1<<e);var p=15-e;for(s=0;s<n;++s)if(i[s])for(var _=s<<4|i[s],y=e-i[s],v=h[i[s]-1]++<<y,b=v|(1<<y)-1;v<=b;++v)c[gb[v]>>p]=_;return c},Rf=new bs(288);for(Mr=0;Mr<144;++Mr)Rf[Mr]=8;for(Mr=144;Mr<256;++Mr)Rf[Mr]=9;for(Mr=256;Mr<280;++Mr)Rf[Mr]=7;for(Mr=280;Mr<288;++Mr)Rf[Mr]=8;var yb=new bs(32);for(Mr=0;Mr<32;++Mr)yb[Mr]=5;var IS=Mf(Rf,9),AS=Mf(yb,5),My=function(i){for(var e=i[0],t=1;t<i.length;++t)i[t]>e&&(e=i[t]);return e},ra=function(i,e,t){var n=e/8|0;return(i[n]|i[n+1]<<8)>>(7&e)&t},Ry=function(i,e){var t=e/8|0;return(i[t]|i[t+1]<<8|i[t+2]<<16)>>(7&e)},CS=function(i){return(i+7)/8|0},MS=["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"],na=function(i,e,t){var n=new Error(e||MS[i]);if(n.code=i,Error.captureStackTrace&&Error.captureStackTrace(n,na),!t)throw n;return n},RS=new bs(0),PS=typeof TextDecoder<"u"&&new TextDecoder;try{PS.decode(RS,{stream:!0})}catch{}const DS={gzip_data:"gzip"};class zs extends Error{constructor(e){super(e),this.name="MRTError"}}const LS={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},xb={uint32:1,uint16:2,uint8:4},zS={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Py;class l_{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){const t=this.layers[e];if(!t)throw new zs(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),n=new DataView(e);if(t[0]!==13)throw new zs("File is not a valid MRT.");return n.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),n=this.getHeaderLength(e);if(t.length<n)throw new zs(`Expected header with length >= ${n} but got buffer of length ${t.length}`);const s=function(l){const c={headerLength:0,x:0,y:0,z:0,layers:[]};let h;for(;h=l.nextField(void 0);)h===1?c.headerLength=l.readFixed32():h===2?c.x=l.readVarint():h===3?c.y=l.readVarint():h===4?c.z=l.readVarint():h===5&&c.layers.push(gS(l,l.readVarint()+l.pos));return c}(new Py(t.subarray(0,n)));if(!isNaN(this.x)&&(this.x!==s.x||this.y!==s.y||this.z!==s.z))throw new zs(`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(const l of s.layers)this.layers[l.name]=new vb(l,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],n=this.getLayer(e.layerName);for(let s of e.blockIndices){const l=n.dataIndex[s],c=l.firstByte-e.firstByte,h=l.lastByte-e.firstByte;if(n._blocksInProgress.has(s))continue;const p={layerName:n.name,firstByte:c,lastByte:h,pixelFormat:n.pixelFormat,blockIndex:s,blockShape:[l.bands.length].concat(n.bandShape),buffer:n.buffer,codec:l.codec.codec,filters:l.filters.map(_=>_.filter)};n._blocksInProgress.add(s),t.push(p)}return new bb(t,()=>{t.forEach(s=>n._blocksInProgress.delete(s.blockIndex))},(s,l)=>{if(t.forEach(c=>n._blocksInProgress.delete(c.blockIndex)),s)throw s;l.forEach(c=>{this.getLayer(c.layerName).processDecodedData(c)})})}}class vb{constructor({version:e,name:t,units:n,tileSize:s,pixelFormat:l,buffer:c,dataIndex:h},p){if(this.version=e,this.version!==1)throw new zs(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=n,this.tileSize=s,this.buffer=c,this.pixelFormat=LS[l],this.dataIndex=h,this.bandShape=[s+2*c,s+2*c,xb[this.pixelFormat]],this._decodedBlocks=new Ay(p?p.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return xb[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[n,s]of this.dataIndex.entries()){for(const[l,c]of s.bands.entries())if(c===e)return{bandIndex:t+l,blockIndex:n,blockBandIndex:l};t+=s.bands.length}break;case"number":for(const[n,s]of this.dataIndex.entries()){if(e>=t&&e<t+s.bands.length)return{bandIndex:e,blockIndex:n,blockBandIndex:e-t};t+=s.bands.length}break;default:throw new zs(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let t=1/0,n=-1/0;const s=[],l=new Set;for(const c of e){const{blockIndex:h}=this.getBlockForBand(c);if(h<0)throw new zs(`Invalid band: ${JSON.stringify(c)}`);const p=this.dataIndex[h];s.includes(h)||s.push(h),l.add(h),t=Math.min(t,p.firstByte),n=Math.max(n,p.lastByte)}if(l.size>this.cacheSize)throw new zs(`Number of blocks to decode (${l.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:n,blockIndices:s}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:n}=this.getBlockForBand(e);if(t<0)throw new zs(`Band not found: ${JSON.stringify(e)}`);const s=this._decodedBlocks.get(t.toString());if(!s)throw new zs(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const l=this.dataIndex[t],c=this.bandShape.reduce((_,y)=>_*y,1),h=n*c,p=s.subarray(h,h+c);return{data:p,bytes:new Uint8Array(p.buffer).subarray(p.byteOffset,p.byteOffset+p.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:l.offset,scale:l.scale}}}l_.setPbf=function(i){Py=i};class bb{constructor(e,t,n){this.tasks=e,this._onCancel=t,this._onComplete=n,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}l_.performDecoding=function(i,e){const t=new Uint8Array(i);return Promise.all(e.tasks.map(n=>{const{layerName:s,firstByte:l,lastByte:c,pixelFormat:h,blockShape:p,blockIndex:_,filters:y,codec:v}=n,b=t.subarray(l,c+1),T=new Uint32Array(p[0]*p[1]*p[2]);let S;if(v!=="gzip_data")throw new zs(`Unhandled codec: ${v}`);return S=function(A,C){if(!globalThis.DecompressionStream&&C==="gzip_data")return Promise.resolve((N=function(H){H[0]==31&&H[1]==139&&H[2]==8||na(6,"invalid gzip data");var W=H[3],K=10;4&W&&(K+=2+(H[10]|H[11]<<8));for(var ee=(W>>3&1)+(W>>4&1);ee>0;ee-=!H[K++]);return K+(2&W)}(D=A),N+8>D.length&&na(6,"invalid gzip data"),function(H,W,K,ee){var ae=H.length;if(!ae||W.f&&!W.l)return K||new bs(0);var he=!K,be=he||W.i!=2,xe=W.i;he&&(K=new bs(3*ae));var Te=function(_n){var sn=K.length;if(_n>sn){var gn=new bs(Math.max(2*sn,_n));gn.set(K),K=gn}},Fe=W.f||0,se=W.p||0,fe=W.b||0,ge=W.l,Ae=W.d,Me=W.m,ze=W.n,Ce=8*ae;do{if(!ge){Fe=ra(H,se,1);var Be=ra(H,se+1,3);if(se+=3,!Be){var ke=H[(jt=CS(se)+4)-4]|H[jt-3]<<8,Ke=jt+ke;if(Ke>ae){xe&&na(0);break}be&&Te(fe+ke),K.set(H.subarray(jt,Ke),fe),W.b=fe+=ke,W.p=se=8*Ke,W.f=Fe;continue}if(Be==1)ge=IS,Ae=AS,Me=9,ze=5;else if(Be==2){var Ve=ra(H,se,31)+257,$e=ra(H,se+10,15)+4,dt=Ve+ra(H,se+5,31)+1;se+=14;for(var pt=new bs(dt),yt=new bs(19),ht=0;ht<$e;++ht)yt[TS[ht]]=ra(H,se+3*ht,7);se+=3*$e;var wt=My(yt),bt=(1<<wt)-1,ri=Mf(yt,wt);for(ht=0;ht<dt;){var jt,Qt=ri[ra(H,se,bt)];if(se+=15&Qt,(jt=Qt>>4)<16)pt[ht++]=jt;else{var ui=0,Rr=0;for(jt==16?(Rr=3+ra(H,se,3),se+=2,ui=pt[ht-1]):jt==17?(Rr=3+ra(H,se,7),se+=3):jt==18&&(Rr=11+ra(H,se,127),se+=7);Rr--;)pt[ht++]=ui}}var Uo=pt.subarray(0,Ve),ur=pt.subarray(Ve);Me=My(Uo),ze=My(ur),ge=Mf(Uo,Me),Ae=Mf(ur,ze)}else na(1);if(se>Ce){xe&&na(0);break}}be&&Te(fe+131072);for(var Xt=(1<<Me)-1,Hi=(1<<ze)-1,mr=se;;mr=se){var Pr=(ui=ge[Ry(H,se)&Xt])>>4;if((se+=15&ui)>Ce){xe&&na(0);break}if(ui||na(2),Pr<256)K[fe++]=Pr;else{if(Pr==256){mr=se,ge=null;break}var St=Pr-254;Pr>264&&(St=ra(H,se,(1<<(Bn=db[ht=Pr-257]))-1)+_b[ht],se+=Bn);var Jr=Ae[Ry(H,se)&Hi],Qr=Jr>>4;if(Jr||na(3),se+=15&Jr,ur=SS[Qr],Qr>3){var Bn=fb[Qr];ur+=Ry(H,se)&(1<<Bn)-1,se+=Bn}if(se>Ce){xe&&na(0);break}be&&Te(fe+131072);var kn=fe+St;if(fe<ur){var xo=0-ur,vo=Math.min(ur,kn);for(xo+fe<0&&na(3);fe<vo;++fe)K[fe]=ee[xo+fe]}for(;fe<kn;++fe)K[fe]=K[fe-ur]}}W.l=ge,W.p=mr,W.b=fe,W.f=Fe,ge&&(Fe=1,W.m=Me,W.d=Ae,W.n=ze)}while(!Fe);return fe!=K.length&&he?function(_n,sn,gn){return(gn==null||gn>_n.length)&&(gn=_n.length),new bs(_n.subarray(0,gn))}(K,0,fe):K.subarray(0,fe)}(D.subarray(N,-8),{i:2},new bs(((O=D)[(F=O.length)-4]|O[F-3]<<8|O[F-2]<<16|O[F-1]<<24)>>>0),z)));var D,z,O,F,N;const j=DS[C];if(!j)throw new Error(`Unhandled codec: ${C}`);const te=new globalThis.DecompressionStream(j);return new Response(new Blob([A]).stream().pipeThrough(te)).arrayBuffer().then(H=>new Uint8Array(H))}(b,v).then(A=>(function(C,D){let z;for(;z=C.nextField();)if(z===2)yS(C,C.readVarint()+C.pos,D);else if(z===3)throw new Error("Not implemented")}(new Py(A),T),new zS[h](T.buffer))),S.then(A=>{for(let C=y.length-1;C>=0;C--)switch(y[C]){case"delta_filter":xS(A,p);break;case"zigzag_filter":vS(A);break;case"bitshuffle_filter":bS(A,h);break;default:throw new zs(`Unhandled filter "${y[C]}"`)}return{layerName:s,blockIndex:_,data:A}}).catch(A=>{throw A})}))},et(bb,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),et(l_,"MapboxRasterTile"),et(vb,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const wb=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],jr=new Uint32Array(96);class Dy{static from(e){if(!e||e.byteLength===void 0||e.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[t,n]=new Uint8Array(e,0,2);if(t!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=n>>4;if(s!==1)throw new Error(`Got v${s} data when expected v1.`);const l=wb[15&n];if(!l)throw new Error("Unrecognized array type.");const[c]=new Uint16Array(e,2,1),[h]=new Uint32Array(e,4,1);return new Dy(h,c,l,void 0,e)}constructor(e,t=64,n=Float64Array,s=ArrayBuffer,l){if(isNaN(e)||e<0)throw new Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const c=wb.indexOf(this.ArrayType),h=2*e*this.ArrayType.BYTES_PER_ELEMENT,p=e*this.IndexArrayType.BYTES_PER_ELEMENT,_=(8-p%8)%8;if(c<0)throw new Error(`Unexpected typed array class: ${n}.`);if(l)this.data=l,this.ids=new this.IndexArrayType(l,8,e),this.coords=new n(l,8+p+_,2*e),this._pos=2*e,this._finished=!0;else{const y=this.data=new s(8+h+p+_);this.ids=new this.IndexArrayType(y,8,e),this.coords=new n(y,8+p+_,2*e),this._pos=0,this._finished=!1,new Uint8Array(y,0,2).set([219,16+c]),new Uint16Array(y,2,1)[0]=t,new Uint32Array(y,4,1)[0]=e}}add(e,t){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Ly(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:c,nodeSize:h}=this;jr[0]=0,jr[1]=l.length-1,jr[2]=0;let p=3;const _=[];for(;p>0;){const y=jr[--p],v=jr[--p],b=jr[--p];if(v-b<=h){for(let C=b;C<=v;C++){const D=c[2*C],z=c[2*C+1];D>=e&&D<=n&&z>=t&&z<=s&&_.push(l[C])}continue}const T=b+v>>1,S=c[2*T],A=c[2*T+1];S>=e&&S<=n&&A>=t&&A<=s&&_.push(l[T]),(y===0?e<=S:t<=A)&&(jr[p++]=b,jr[p++]=T-1,jr[p++]=1-y),(y===0?n>=S:s>=A)&&(jr[p++]=T+1,jr[p++]=v,jr[p++]=1-y)}return _}within(e,t,n){const s=[];return this.withinInto(e,t,n,s),s}withinInto(e,t,n,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:c,nodeSize:h}=this;jr[0]=0,jr[1]=l.length-1,jr[2]=0;let p=3,_=0;const y=n*n;for(;p>0;){const v=jr[--p],b=jr[--p],T=jr[--p];if(b-T<=h){for(let D=T;D<=b;D++)Eb(c[2*D],c[2*D+1],e,t)<=y&&(s[_++]=l[D]);continue}const S=T+b>>1,A=c[2*S],C=c[2*S+1];Eb(A,C,e,t)<=y&&(s[_++]=l[S]),(v===0?e-n<=A:t-n<=C)&&(jr[p++]=T,jr[p++]=S-1,jr[p++]=1-v),(v===0?e+n>=A:t+n>=C)&&(jr[p++]=S+1,jr[p++]=b,jr[p++]=1-v)}return _}}function Ly(i,e,t,n,s,l){if(s-n<=t)return;const c=n+s>>1;Tb(i,e,c,n,s,l),Ly(i,e,t,n,c-1,1-l),Ly(i,e,t,c+1,s,1-l)}function Tb(i,e,t,n,s,l){for(;s>n;){if(s-n>600){const _=s-n+1,y=t-n+1,v=Math.log(_),b=.5*Math.exp(2*v/3),T=.5*Math.sqrt(v*b*(_-b)/_)*(y-_/2<0?-1:1);Tb(i,e,t,Math.max(n,Math.floor(t-y*b/_+T)),Math.min(s,Math.floor(t+(_-y)*b/_+T)),l)}const c=e[2*t+l];let h=n,p=s;for(Pf(i,e,n,t),e[2*s+l]>c&&Pf(i,e,n,s);h<p;){for(Pf(i,e,h,p),h++,p--;e[2*h+l]<c;)h++;for(;e[2*p+l]>c;)p--}e[2*n+l]===c?Pf(i,e,n,p):(p++,Pf(i,e,p,s)),p<=t&&(n=p+1),t<=p&&(s=p-1)}}function Pf(i,e,t,n){zy(i,t,n),zy(e,2*t,2*n),zy(e,2*t+1,2*n+1)}function zy(i,e,t){const n=i[e];i[e]=i[t],i[t]=n}function Eb(i,e,t,n){const s=i-t,l=e-n;return s*s+l*l}L.$=mn,L.A=va,L.B=Jo,L.C=Pt,L.D=al,L.E=Dn,L.F=En,L.G=jc,L.H=tc,L.I=Er,L.J=Nd,L.K=/^(.*)-transition$/,L.L=Ay,L.M=Ed,L.N=bd,L.O=ls,L.P=De,L.Q=Fs,L.R=fi,L.S=Rl,L.T=am,L.U=/^(.*)-use-theme$/,L.V=function(i,e){const t=Rl(e.zoom);if(t===0)return za(i);const n=Wp(i),s=ug(n),l=fo(n.getWest())*e.worldSize,c=fo(n.getEast())*e.worldSize,h=$n(n.getNorth())*e.worldSize,p=$n(n.getSouth())*e.worldSize,_=[l,h,0],y=[c,h,0],v=[l,p,0],b=[c,p,0],T=yn([],e.globeMatrix);return hi(_,_,T),hi(y,y,T),hi(v,v,T),hi(b,b,T),s[0]=Ml(s[0],v,t),s[1]=Ml(s[1],b,t),s[2]=Ml(s[2],y,t),s[3]=Ml(s[3],_,t),Di.fromPoints(s)},L.W=hg,L.X=Dt,L.Y=Yn,L.Z=pn,L._=vs,L.a=async function(i,e){i.headers||(i.headers={}),i.headers.accept="image/webp,*/*";const t=await function(n){return new Promise((s,l)=>{if(n&&n.aborted)return void l(n.reason);const c=()=>{const _=Qi.shift();_?_():Si--};if(Si<ie.MAX_PARALLEL_IMAGE_REQUESTS)return Si++,void s(c);const h=()=>{n&&n.removeEventListener("abort",p),s(c)},p=()=>{const _=Qi.indexOf(h);_!==-1&&Qi.splice(_,1),l(n.reason)};n&&n.addEventListener("abort",p),Qi.push(h)})}(e);try{const{data:n,headers:s}=await vi(i,e);let l;try{l=await createImageBitmap(new Blob([new Uint8Array(n)],{type:"image/png"}))}catch(c){throw new Error(`Could not load image because of ${c.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`,{cause:c})}return e&&e.throwIfAborted(),{data:l,headers:s}}finally{t()}},L.a$=Ar,L.a0=x1,L.a1=er,L.a2=qe,L.a3=on,L.a4=Et,L.a5=Kr,L.a6=Ur,L.a7=fo,L.a8=$n,L.a9=Ha,L.aA=R,L.aB=bx,L.aC=km,L.aD=Wv,L.aE=Gh,L.aF=X1,L.aG=fn,L.aH=(i,e,t,n,s,l,c,h,p,_,y,v,b,T,S,A,C,D,z=!1)=>{const O=Z1(i,e,t,n,s,l,c,h,_,y,v,b,T,S,A,C,1,[0,0,0],[0,0,1],z),F={u_height_factor:-Math.pow(2,h.overscaledZ)/p.tileSize/8};return Object.assign(O,G1(e,p,D),F)},L.aI=Z1,L.aJ=zl,L.aK=450,L.aL=7,L.aM=(i,e,t,n,s,l)=>({u_matrix:i,u_edge_radius:e,u_width_scale:t,u_vertical_scale:n,u_height_type:i_[s],u_base_type:i_[l]}),L.aN=hr,L.aO=yn,L.aP=kl,L.aQ=q1,L.aR=4,L.aS=2,L.aT=$_,L.aU=q_,L.aV=us,L.aW=class{static calculate(i,e,t){const n=new Set,s=new Map,l=new Set,c=new Set;for(const p of Object.values(i))for(const[_,y]of Object.entries(p.floors)){l.add(_),y.isDefault&&c.add(_),y.conflicts&&s.set(_,y.conflicts);const v=_===e,b=y.connections&&e&&y.connections.has(e);(v||b)&&n.add(_)}const h=p=>{const _=s.get(p)||new Set;for(const y of n)if((s.get(y)||new Set).has(p)||_.has(y))return!0;return!1};if(t)for(const p of t)l.has(p)&&(h(p)||n.add(p));for(const p of c)n.has(p)||h(p)||n.add(p);return n}},L.aX=pr,L.aY=El,L.aZ=class extends ts{constructor(i){super(i),this.current=new Float32Array(9)}set(i,e,t){if(!this.fetchUniformLocation(i,e))return;const n=this.current;for(let s=0;s<9;s++)if(t[s]!==n[s]){n.set(t),this.gl.uniformMatrix3fv(this.location,!1,n);break}}},L.a_=ve,L.aa=yi,L.ab=_w,L.ac=li,L.ad=_t,L.ae=bp,L.af=ki,L.ag=He,L.ah=class{constructor(i){this.specification=i}possiblyEvaluate(i,e){return kc(i.expression.evaluate(e))}interpolate(i,e,t){return{x:lt(i.x,e.x,t),y:lt(i.y,e.y,t),z:lt(i.z,e.z,t),azimuthal:lt(i.azimuthal,e.azimuthal,t),polar:lt(i.polar,e.polar,t)}}},L.ai=zi,L.aj=Fo,L.ak=Ia,L.al=lt,L.am=cs,L.an=65,L.ao=45,L.ap=function(i,e,t){const n=V.fromLngLat(e),s=t.elevation?t.elevation.getAtPointOrZero(n):0;return y1(i,n.x,n.y,s,t)},L.aq=function(i,e,t,n,s,l,c){const h=[[t,n,0],[s,n,0],[s,l,0],[t,l,0]];let p=Number.MAX_VALUE,_=-Number.MAX_VALUE;for(const y of h){const v=Ki(hi([],y,e));p=Math.min(p,v),_=Math.max(_,v)}return[Ym(i,p,c.pitch),Ym(i,_,c.pitch)]},L.ar=Tn,L.as=y1,L.at=Sf,L.au=Ot,L.av=function(){return Uu++},L.aw=class{constructor(i,e,t){this.target=i,this.parent=e,this.mapId=t,this.pendingResponses=new Map,us(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new cS}send(i,e,t){const{signal:n,targetMapId:s,metadata:l}=t||{},c=Math.round(1e18*Math.random()).toString(36).substring(0,10),h=new Set;return n&&n.aborted?Promise.reject(n.reason):(this.target.postMessage({id:c,type:i,targetMapId:s,sourceMapId:this.mapId,data:po(e,h)},[...h]),new Promise((p,_)=>{const y={resolve:p,reject:_,metadata:l||nb};if(n){const v=()=>{this.pendingResponses.delete(c),_(n.reason)};n.addEventListener("abort",v,{once:!0}),y.detach=()=>n.removeEventListener("abort",v)}this.pendingResponses.set(c,y)}))}notify(i,e,t){const{targetMapId:n}=t||{},s=new Set;this.target.postMessage({type:i,targetMapId:n,sourceMapId:this.mapId,data:po(e,s)},[...s])}sendCancelable(i,e,t,n){const s=new AbortController;return this.send(i,e,{...t,signal:s.signal}).then(l=>n(null,l)).catch(l=>{l.name!=="AbortError"&&n(l)}),s}getWorkerSourceActor(i){return{scheduler:this.scheduler,send:(e,t,n)=>this.send(e,t,{...n,targetMapId:i}),notify:(e,t)=>{this.notify(e,t,{targetMapId:i})},sendCancelable:(e,t,n,s)=>this.sendCancelable(e,t,{...n,targetMapId:i},s)}}receive(i){const e=i.data;if(!e)return;const t=e.id;if(!e.targetMapId||this.mapId===e.targetMapId)if(hs(self)){const n=this.pendingResponses.get(t);this.scheduler.add(()=>{this.processTask(t,e)},n&&n.metadata||nb)}else this.processTask(t,e)}async processTask(i,e){if(e.type==="<response>"){const s=this.pendingResponses.get(i);if(this.pendingResponses.delete(i),s){s.detach&&s.detach();try{e.error?s.reject(Oo(e.error)):s.resolve(Oo(e.data))}catch(l){s.reject(l)}}return}const t=new Set,n=Oo(e.data);try{let s;if(this.parent[e.type])s=await this.parent[e.type](e.sourceMapId,n);else{if(!this.parent.getWorkerSource)throw new Error(`Could not find function ${e.type}`);{const l=e.type.split("."),{source:c,scope:h}=n;s=await this.parent.getWorkerSource(e.sourceMapId,{type:l[0],source:c,scope:h})[l[1]](n)}}if(!i)return;this.target.postMessage({id:i,type:"<response>",sourceMapId:this.mapId,error:null,data:po(s,t)},[...t])}catch(s){this.target.postMessage({id:i,type:"<response>",sourceMapId:this.mapId,error:po(s),data:null},[])}}remove(){for(const i of this.pendingResponses.values())i.detach&&i.detach(),i.reject(new DOMException("Actor removed","AbortError"));this.pendingResponses.clear(),this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},L.ax=class{constructor(i){this.specification=i}possiblyEvaluate(i,e){return function([t,n]){const s=kc([1,t,n]);return{x:s.x,y:s.y,z:s.z}}(i.expression.evaluate(e))}interpolate(i,e,t){return{x:lt(i.x,e.x,t),y:lt(i.y,e.y,t),z:lt(i.z,e.z,t)}}},L.ay=Du,L.az=Cl,L.b=An,L.b$=function(i,{x:e,y:t},n=0){return new De(((e-n)*i.scale-i.x)*qe,(t*i.scale-i.y)*qe)},L.b0=vt,L.b1=6,L.b2=Wp,L.b3=function(i){const e=80.051129;i=vt(i,-80.051129,e)/e*90;const t=Math.pow(Math.abs(Math.sin(Ot(i))),3);return Math.round(t*(Th.length-1))},L.b4=Kp,L.b5=za,L.b6=function(i){const e=i.pixelsPerMeter,t=e/x(1,i.center.lat),n=rr(new Float64Array(16));return Yi(n,n,[i.point.x,i.point.y,0]),hr(n,n,[t,t,e]),Float32Array.from(n)},L.b7=function(i,e,t,n){const s=e.getNorth(),l=e.getSouth(),c=e.getWest(),h=e.getEast(),p=1<<i.z,_=h-c,y=s-l,v=_/wl,b=-y/Th[t],T=[0,v,0,b,0,0,s,c,0];if(i.z>0){const S=180/n;ai(T,T,[S/_+1,0,0,0,S/y+1,0,-.5*S/v,.5*S/b,1])}return T[2]=p,T[5]=i.x,T[8]=i.y,T},L.b8=Kl,L.b9=256,L.bA=H_,L.bB=ce,L.bC=Re,L.bD=ni,L.bE=og,L.bF=ea,L.bG=Kd,L.bH=hi,L.bI=Ml,L.bJ=Ue,L.bK=Sw,L.bL=Ho,L.bM=Yi,L.bN=function(){ps.isLoading()||ps.isLoaded()||hc()!=="deferred"||mo()},L.bO=Ht,L.bP=Wr,L.bQ=function(i,e){const t=[];for(const n in i)n in e||t.push(n);return t},L.bR=rb,L.bS=V,L.bT=Is,L.bU="hd_road_coverage",L.bV=function(i){const e=i.indexOf(mu);return e>=0?i.slice(0,e):i},L.bW=Ip,L.bX=yc,L.bY=Jp,L.bZ=function(i,e,t=0,n=!0){const s=new De(t,t),l=i.sub(s),c=e.add(s),h=[l,new De(c.x,l.y),c,new De(l.x,c.y)];return n&&h.push(l.clone()),h},L.b_=function(i,e){const t=[];for(let n=0;n<i.length;n++){const s=xn(n-1,-1,i.length-1),l=xn(n+1,-1,i.length-1),c=i[n],h=i[l],p=i[s].sub(c).unit(),_=h.sub(c).unit(),y=_.angleWithSep(p.x,p.y),v=p.add(_).unit().mult(-1*e/Math.sin(y/2));t.push(c.add(v))}return t},L.ba=B1,L.bb=ci,L.bc=Ti,L.bd=Mn,L.be=Gs,L.bf=Co,L.bg=Ga,L.bh=br,L.bi=sh,L.bj=o,L.bk=Wt,L.bl=Mi,L.bm=w,L.bn=jh,L.bo=Nc,L.bp=pg,L.bq=qn,L.br=vr,L.bs=Pe,L.bt=_s,L.bu=fm,L.bv=du,L.bw=_e,L.bx=Pu,L.by=Gn,L.bz=tg,L.c=Ea,L.c$=g1,L.c0=K_,L.c1=function(i,e,t=0){return br(((e.x-t)*i.scale-i.x)*qe,(e.y*i.scale-i.y)*qe,w(e.z,e.y))},L.c2=Pi,L.c3=ei,L.c4=$p,L.c5=bf,L.c6=function(i){let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const l of i)e=Math.min(e,l.x),t=Math.min(t,l.y),n=Math.max(n,l.x),s=Math.max(s,l.y);return{min:new De(e,t),max:new De(n,s)}},L.c7=lr,L.c8=On,L.c9=mc,L.cA=l_,L.cB=nm,L.cC=vi,L.cD=["type","source","source-layer","minzoom","maxzoom","filter","layout"],L.cE=function(i,e,t,n,s,l,c){const h=_y(i,e,t,n,s,l,c);return l.name==="globe"&&t||(h[2]=h[6]=h[10]=h[14]=0),h},L.cF=function(i,e,t,n,s,l,c){if(t){if(l.name==="globe"){const h=_y(i,e,t,n,s,l,c);return yn(h,h),Dt(h,i,h),h}{const h=Fs(i),[p,_,y,v]=c,[b,T,S,A,C,D,z,O]=h;return h[0]=p*b+_*C,h[1]=p*T+_*D,h[2]=p*S+_*z,h[3]=p*A+_*O,h[4]=y*b+v*C,h[5]=y*T+v*D,h[6]=y*S+v*z,h[7]=y*A+v*O,n||Os(h,h,-s.angle),h}}return s.glCoordMatrix},L.cG=Tu,L.cH=Ax,L.cI=Pm,L.cJ=Px,L.cK=gg,L.cL=Al,L.cM=rx,L.cN=function(i,[e,t]){let n=0,s=0;if(t===ww){e<0&&(e=0);const l=e/Tw;switch(i){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(i){case"top-right":case"bottom-right":n=-l;break;case"top-left":case"bottom-left":n=l;break;case"left":n=e;break;case"right":n=-e}}else{switch(e=Math.abs(e),t=Math.abs(t),i){case"top-right":case"top-left":case"top":s=t-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-t}switch(i){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}}return[n,s]},L.cO=function(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"},L.cP=ou,L.cQ=Zs,L.cR=qa,L.cS=ss,L.cT=as,L.cU=xn,L.cV=Pc,L.cW=class{isDataAvailableAtPoint(i){const e=this._source();if(this.isUsingMockSource()||!e||i.y<0||i.y>1)return!1;const t=e.getSource().maxzoom,n=1<<t,s=Math.floor(i.x),l=Math.floor((i.x-s)*n),c=Math.floor(i.y*n),h=this.findDEMTileFor(new Wr(t,s,t,l,c));return!(!h||!h.dem)}getAtPointOrZero(i,e=0){return this.getAtPoint(i,e)||0}getAtPoint(i,e,t=!0){if(this.isUsingMockSource())return null;e??(e=null);const n=this._source();if(!n||i.y<0||i.y>1)return e;const s=n.getSource().maxzoom,l=1<<s,c=Math.floor(i.x),h=i.x-c,p=new Wr(s,c,s,Math.floor(h*l),Math.floor(i.y*l)),_=this.findDEMTileFor(p);if(!_||!_.dem)return e;const y=_.dem,v=1<<_.tileID.canonical.z,b=(h*v-_.tileID.canonical.x)*y.dim,T=(i.y*v-_.tileID.canonical.y)*y.dim,S=Math.floor(b),A=Math.floor(T);return(t?this.exaggeration():1)*lt(lt(y.get(S,A),y.get(S,A+1),T-A),lt(y.get(S+1,A),y.get(S+1,A+1),T-A),b-S)}static getAtTileOffset(i,e,t,n){const s=1<<i.canonical.z;return n?n.pointElevation(e):t?t.getAtPointOrZero(new V(i.wrap+(i.canonical.x+e.x/qe)/s,(i.canonical.y+e.y/qe)/s)):0}static getAtTileOffsetFunc(i,e,t,n){return(s,l,c)=>{const h=this.getAtTileOffset(i,s,l,c),p=n.upVector(i.canonical,s.x,s.y);return si(p,p,h*n.upVectorScale(i.canonical,e,t).metersToTile),p}}getForTilePoints(i,e,t,n){if(this.isUsingMockSource())return!1;const s=Vh.create(this,i,n);return!!s&&(e.forEach(l=>{l[2]=this.exaggeration()*s.getElevationAt(l[0],l[1],t,!0)}),!0)}getMinMaxForTile(i){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(i);if(!e||!e.dem)return null;const t=e.dem.tree,n=e.tileID,s=1<<i.canonical.z-n.canonical.z;let l=i.canonical.x/s-n.canonical.x,c=i.canonical.y/s-n.canonical.y,h=0;for(let p=0;p<i.canonical.z-n.canonical.z&&!t.leaves[h];p++){l*=2,c*=2;const _=2*Math.floor(c)+Math.floor(l);h=t.childOffsets[h]+_,l%=1,c%=1}return{min:this.exaggeration()*t.minimums[h],max:this.exaggeration()*t.maximums[h]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(i,e,t){throw new Error("Pure virtual method called.")}pointCoordinate(i){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(i){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const i=this.visibleDemTiles;if(i.length===0)return null;let e=!1,t=Number.MAX_VALUE,n=Number.MIN_VALUE;for(const s of i){const l=this.getMinMaxForTile(s.tileID);l&&(t=Math.min(t,l.min),n=Math.max(n,l.max),e=!0)}return e?{min:t,max:n}:null}},L.cX=Ec,L.cY=h1,L.cZ=Q_,L.c_=function(i,e,t,n,s,l){const c=[e,t,n];return hi(c,c,l.calculateFogTileMatrix(s)),Ym(i,Ki(c),l.pitch)},L.ca=G,L.cb=Qa,L.cc=class{constructor(i){this.entries={},this.scheduler=i}request(i,e,t,n){const s=this.entries[i]=this.entries[i]||{callbacks:[]};if(s.result){const[l,c]=s.result;return this.scheduler?this.scheduler.add(()=>{n(l,c)},e):n(l,c),()=>{}}return s.callbacks.push(n),s.cancel||(s.cancel=t((l,c)=>{s.result=[l,c];for(const h of s.callbacks)this.scheduler?this.scheduler.add(()=>{h(l,c)},e):h(l,c);setTimeout(()=>delete this.entries[i],3e3)})),()=>{s.result||(s.callbacks=s.callbacks.filter(l=>l!==n),s.callbacks.length||(s.cancel(),delete this.entries[i]))}}},L.cd=function(i){if("provider"in i&&!i.provider)return null;let e=i.provider;if(!e&&"url"in i&&i.url&&(e=function(s){try{const l=new URL(s).pathname.split("/").pop()||"",c=l.lastIndexOf(".");return c>=0?l.slice(c+1):""}catch{return""}}(i.url)),!e)return null;const t=ie.TILE_PROVIDER_URLS[e];if(!t)return null;let n;try{n=new URL(t,ie.API_URL).href}catch{return new Error(`TileProvider "${e}" has an invalid URL: "${t}"`)}return{name:e,url:n}},L.ce=J1,L.cf=s_,L.cg=Ut,L.ch=function(i,e,t){const n=JSON.stringify(i.request);return i.data&&(this.deduped.entries[n]={result:[null,i.data]}),this.deduped.request(n,{type:"parseTile",renderSourceType:i.renderSourceType,zoom:i.tileZoom},s=>{const l=new AbortController;return vi(i.request,l.signal).then(({data:c,headers:h})=>{s(null,{rawData:c,vectorTile:t?void 0:new Z_(new nm(c)),headers:h})}).catch(c=>{l.signal.aborted||(Ht(c)?s(null,null):s(c))}),()=>{l.abort(),s(null,null)}},e)},L.ci=qo,L.cj=function(i){It++,It>ut&&(i.getActor().notify("enforceCacheSizeLimit",Ge),It=0)},L.ck=Pn,L.cl=async function(i,e,t){const n=i.url&&!i.tiles?await e.transformRequest(i.url,fi.Source,t):void 0;return{request:n,options:n?{...i,url:n.url}:i}},L.cm=function(i,e,t){return e?K1(i,e,t):i.tiles&&i.tiles.length>0?{tiles:i.tiles}:new Error('TileJSON is missing required "tiles" property')},L.cn=async function(i,e){const t=ob.get(i);if(t)return t;const n=Cy.get(i);if(n!==void 0)return n;const s=self.__mapboxImport(e).catch(l=>{throw new Error(`TileProvider "${i}" failed to load: ${l instanceof Error?l.message:String(l)}`)}).then(l=>{const c=l.default;if(typeof c!="function")throw new Error(`TileProvider "${i}" module must default-export a class`);if(typeof c.prototype.loadTile!="function")throw new Error(`TileProvider "${i}" class must have a loadTile method`);return ob.set(i,c),c}).finally(()=>{Cy.delete(i)});return Cy.set(i,s),s},L.co=class{constructor(i,e){this.context=i,this.texture=e}bind(i,e){const{context:t}=this,{gl:n}=t;n.bindTexture(n.TEXTURE_2D,this.texture),i!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,i),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i),this.minFilter=i),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}},L.cp=E,L.cq=function(i,e,t,n){for(;e<t;){const s=e+t>>1;i[s]<=n?e=s+1:t=s}return e},L.cr=function(i,e,t,n){for(;e<t;){const s=e+t>>1;i[s]<n?e=s+1:t=s}return e},L.cs=wl,L.ct=Ao,L.cu=function(i,e){var t=e[0],n=e[1],s=e[2],l=e[3],c=e[4],h=e[5],p=e[6],_=e[7],y=e[8];return i[0]=c*y-h*_,i[1]=s*_-n*y,i[2]=n*h-s*c,i[3]=h*p-l*y,i[4]=t*y-s*p,i[5]=s*l-t*h,i[6]=l*_-c*p,i[7]=n*p-t*_,i[8]=t*c-n*l,i},L.cv=ai,L.cw=async function(i){const e=document.createElement("video");e.muted=!0;for(const t of i){const n=document.createElement("source");dr(t)||(e.crossOrigin="Anonymous"),n.src=t,e.appendChild(n)}return await new Promise((t,n)=>{e.onloadstart=()=>t(),e.onerror=()=>n(new Error(`Could not load video: ${i.join(", ")}`))}),e},L.cx=U0,L.cy=X0,L.cz=f,L.d=class{constructor(i){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(i&&i.maxTextureMemoryMB?i.maxTextureMemoryMB:256)*1024,this.currentFrameAtlases=new Set,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures()})}beginFrame(){this.currentFrameAtlases.clear()}calculateTextureMemory(i){return i.image?Math.ceil(i.image.width*i.image.height*4*(i.patternPositions.size>0?1.33:1)):0}evictTexture(i){const e=this.textures.get(i);if(e){const t=this.calculateTextureMemory(i);e.destroy(),this.textures.delete(i),this.textureAccessTimes.delete(i),this.textureMemoryUsed-=t,i.uploaded=!1}}evictTexturesIfNeeded(i){for(;this.textureMemoryUsed+i>this.maxTextureMemory&&this.textures.size>0;){let e=null,t=1/0;for(const[n]of this.textures.entries()){if(this.currentFrameAtlases.has(n))continue;const s=this.textureAccessTimes.get(n)||0;s<t&&(t=s,e=n)}if(!e)break;this.evictTexture(e)}}findCachedAtlas(i){const e=this.cache.get(i.hash);if(e){const t=e.deref();if(t&&t.contentDescriptor&&this.isMipmapCompatible(i,t.contentDescriptor))return t}for(const[,t]of this.cache.entries()){const n=t.deref();if(n&&n.contentDescriptor){const s=i.subsetOf(n.contentDescriptor),l=this.isMipmapCompatible(i,n.contentDescriptor);if(s&&l)return n}}}getTextureForAtlas(i,e,t){this.textureAccessTimes.set(i,performance.now()),this.currentFrameAtlases.add(i);let n=this.textures.get(i);if(n)return n;if(i.image){const s=this.calculateTextureMemory(i);return this.evictTexturesIfNeeded(s),n=new am(e,i.image,t,{useMipmap:!!i.patternPositions.size}),this.textures.set(i,n),this.textureMemoryUsed+=s,n}return null}clearExpiredTextures(){for(const[i]of this.textures.entries())if(!this.isAtlasCached(i)){const e=this.textures.get(i);if(e){const t=this.calculateTextureMemory(i);e.destroy(),this.textureMemoryUsed-=t}this.textures.delete(i),this.textureAccessTimes.delete(i)}}isAtlasCached(i){if(!i.contentDescriptor)return!1;const e=this.cache.get(i.contentDescriptor.hash);return!!e&&e.deref()===i}getOrCache(i){if(!("image"in i)){const s=this.cache.get(i.sourceAtlasHash);if(s){const l=s.deref();if(l)return l}return _i("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!i.contentDescriptor)return i;const e=i.contentDescriptor,t=e.hash,n=this.cache.get(t);if(n){const s=n.deref();if(s&&s.contentDescriptor&&this.isMipmapCompatible(e,s.contentDescriptor))return s}return this.cache.set(t,new WeakRef(i)),this.finalizationRegistry.register(i,t,i),i}isMipmapCompatible(i,e){return!i.requiresMipMaps||e.requiresMipMaps}destroyTextures(){for(const i of this.textures.values())i&&i.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}clear(){for(const i of this.textures.values())i&&i.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}},L.d$=Su,L.d0=rr,L.d1=Mh,L.d2=.9,L.d3=Qn,L.d4=Hp,L.d5=Dy,L.d6=function(i){return i({pluginStatus:zn,pluginURL:Sa}),uc.on("pluginStateChange",i),i},L.d7=Ct,L.d8=lm,L.d9=Eg,L.dA=cn,L.dB=function(i,e){return[Math.pow(i[0],2.2)*e,Math.pow(i[1],2.2)*e,Math.pow(i[2],2.2)*e]},L.dC=si,L.dD=Ji,L.dE=ju,L.dF=Ri,L.dG=XE,L.dH=YE,L.dI=i=>({u_cutoff_params:new El(i)}),L.dJ=i=>({u_light_matrix_0:new Kr(i),u_light_matrix_1:new Kr(i),u_fade_range:new on(i),u_shadow_normal_offset:new 
vendor: 1,124 bytes, line 3102
3102Ur(i),u_shadow_intensity:new Et(i),u_shadow_texel_size:new Et(i),u_shadow_map_resolution:new Et(i),u_shadow_direction:new Ur(i),u_shadow_bias:new Ur(i),u_shadowmap_0:new pr(i),u_shadowmap_1:new pr(i)}),L.dK=G1,L.dL=_x,L.dM=oy,L.dN=Gu,L.dO=Yl,L.dP=function(i,e){const t=[0,0,0];return hi(t,t,Kp(za(e.canonical))),hi(t,t,i),t},L.dQ=Wn,L.dR=function(i,e,t,n,s,l){const{width:c,height:h}=n.imageManager.getPixelSize(e),p=Math.pow(2,l.tileID.overscaledZ),_=l.tileSize*Math.pow(2,n.transform.tileZoom)/p,y=_*(l.tileID.canonical.x+l.tileID.wrap*p),v=_*l.tileID.canonical.y;return{u_image:0,u_pattern_tl:t.tl,u_pattern_br:t.br,u_texsize:[c,h],u_pattern_size:t.displaySize,u_pattern_units_to_pixels:s?[n.transform.width,-1*n.transform.height]:[1/bf(l,1,n.transform.tileZoom),1/bf(l,1,n.transform.tileZoom)],u_pixel_coord_upper:[y>>16,v>>16],u_pixel_coord_lower:[65535&y,65535&v]}},L.dS=i=>({u_matrix:new Kr(i),u_texsize:new on(i),u_pixels_to_tile_units:new U_(i),u_device_pixel_ratio:new Et(i),u_width_scale:new Et(i),u_floor_width_scale:new Et(i),u_image:new pr(i),u_units_to_pixels:new on(i),u_tile_units_to_pixels:new Et(i),u_alph
vendor: 83,580 bytes, line 3102
3102a_discard_threshold:new Et(i),u_trim_offset:new on(i),u_trim_fade_range:new on(i),u_trim_gradient_mix_range:new on(i),u_trim_color:new El(i),u_zbias_factor:new Et(i),u_tile_to_meter:new Et(i),u_ground_shadow_factor:new Ur(i),u_pattern_transition:new Et(i),u_opacity_multiplier:new Et(i)}),L.dT=i=>({u_matrix:new Kr(i),u_pixels_to_tile_units:new U_(i),u_device_pixel_ratio:new Et(i),u_width_scale:new Et(i),u_floor_width_scale:new Et(i),u_units_to_pixels:new on(i),u_dash_image:new pr(i),u_gradient_image:new pr(i),u_border_gradient_image:new pr(i),u_image_height:new Et(i),u_texsize:new on(i),u_tile_units_to_pixels:new Et(i),u_alpha_discard_threshold:new Et(i),u_trim_offset:new on(i),u_trim_fade_range:new on(i),u_trim_gradient_mix_range:new on(i),u_trim_color:new El(i),u_zbias_factor:new Et(i),u_road_view_depth_bias:new Et(i),u_road_clip_to_view:new El(i),u_tile_to_meter:new Et(i),u_ground_shadow_factor:new Ur(i),u_opacity_multiplier:new Et(i)}),L.dU=i=>({u_color:new V_(i),u_matrix:new Kr(i),u_overlay:new pr(i),u_overlay_scale:new Et(i)}),L.dV=i=>({u_camera_to_center_distance:new Et(i),u_extrude_scale:new U_(i),u_device_pixel_ratio:new Et(i),u_matrix:new Kr(i),u_inv_rot_matrix:new Kr(i),u_merc_center:new on(i),u_tile_id:new Ur(i),u_zoom_transition:new Et(i),u_up_dir:new Ur(i),u_emissive_strength:new Et(i)}),L.dW=i=>({u_matrix:new Kr(i),u_lightpos:new Ur(i),u_lightintensity:new Et(i),u_lightcolor:new Ur(i),u_vertical_gradient:new Et(i),u_height_factor:new Et(i),u_edge_radius:new Et(i),u_width_scale:new Et(i),u_ao:new on(i),u_height_type:new pr(i),u_base_type:new pr(i),u_tile_id:new Ur(i),u_zoom_transition:new Et(i),u_inv_rot_matrix:new Kr(i),u_merc_center:new on(i),u_up_dir:new Ur(i),u_height_lift:new Et(i),u_image:new pr(i),u_texsize:new on(i),u_pixel_coord_upper:new on(i),u_pixel_coord_lower:new on(i),u_tile_units_to_pixels:new Et(i),u_opacity:new Et(i),u_pattern_transition:new Et(i)}),L.dX=i=>({u_matrix:new Kr(i),u_lightpos:new Ur(i),u_lightintensity:new Et(i),u_lightcolor:new Ur(i),u_vertical_gradient:new Et(i),u_opacity:new Et(i),u_edge_radius:new Et(i),u_width_scale:new Et(i),u_ao:new on(i),u_height_type:new pr(i),u_base_type:new pr(i),u_tile_id:new Ur(i),u_zoom_transition:new Et(i),u_inv_rot_matrix:new Kr(i),u_merc_center:new on(i),u_up_dir:new Ur(i),u_height_lift:new Et(i),u_flood_light_color:new Ur(i),u_vertical_scale:new Et(i),u_flood_light_intensity:new Et(i),u_ground_shadow_factor:new Ur(i),u_front_cutoff_params:new Ur(i)}),L.dY=_y,L.dZ=Ef,L.d_=u1,L.da=vp,L.db=Le,L.dc=il,L.dd=jn,L.de=el,L.df=function(i){return i.includes(mu)},L.dg=function(i){const e=i.lastIndexOf(mu);return e>=0?i.slice(e+1):""},L.dh=function(i,e={}){const t=e.type&&!e.array&&Array.isArray(i)?{type:e.type,"property-type":"data-constant"}:void 0;return Ea(i===null||typeof i!="object"||Array.isArray(i)?i:["literal",i],t)},L.di=function(i){const e=[],t=i.id;return t===void 0&&e.push({message:`layers.${t}: missing required property "id"`}),i.render===void 0&&e.push({message:`layers.${t}: missing required method "render"`}),i.renderingMode&&i.renderingMode!=="2d"&&i.renderingMode!=="3d"&&e.push({message:`layers.${t}: property "renderingMode" must be either "2d" or "3d"`}),e},L.dj=function(i,e,t,n){return i.type==="custom"?new RE(i,e):new aS[i.type](i,e,t,n)},L.dk=Oc,L.dl=class extends Pu{constructor(i,e){super(i._vectorTileFeature,i._z,i._x,i._y,i.id),i.state&&(this.state={...i.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=i.source,this.sourceLayer=i.sourceLayer,this.layer=i.layer)}toJSON(){const i=super.toJSON();return i.target=this.target,i.namespace=this.namespace,i}},L.dm=uc,L.dn=W1,L.dp=function(){return{API_URL:ie.API_URL,DRACO_URL:ie.DRACO_URL,MESHOPT_URL:ie.MESHOPT_URL,MESHOPT_SIMD_URL:ie.MESHOPT_SIMD_URL,BUILDING_GEN_URL:ie.BUILDING_GEN_URL}},L.dq=V_,L.dr=Fu,L.ds=ua,L.dt=function(i,e,t){const n=Rl(t.zoom),s=i.style.map._antialias,l=i.terrain&&i.terrain.exaggeration()>0;return n===0&&!s&&!l},L.du=function(i,e,t){const n=rr(new Float64Array(16)),s=(e/(1<<i)-.5)*Math.PI*2;return Io(n,t.globeMatrix,s),Float32Array.from(n)},L.dv=Xy,L.dw=x,L.dx=qp,L.dy=Zo,L.dz=Jn,L.e=X,L.e$=ao,L.e0=function(i,e,t,n,s,l,c,h,p,_,y=1){const v=t.transform,b=n?i.textSizeData:i.iconSizeData,T=Tu(b,t.transform.zoom,y),S=v.projection.name==="globe",A=(()=>{if(!S)return null;const H=Rl(v.zoom);return H===0?null:{t:H,invMatrix:v.projection.createInversionMatrix(v,_.canonical),mercCenter:[fo(v.center.lng),$n(v.center.lat)]}})(),C=[256/t.width*2+1,256/t.height*2+1],D=n?i.text.dynamicLayoutVertexArray:i.icon.dynamicLayoutVertexArray;D.clear();let z=null;S&&(z=n?i.text.globeExtVertexArray:i.icon.globeExtVertexArray);const O=i.lineVertexArray,F=n?i.text.placedSymbolArray:i.icon.placedSymbolArray,N=t.transform.width/t.transform.height;let j,te=!1;for(let H=0;H<F.length;H++){const W=F.get(H),{numGlyphs:K,writingMode:ee}=W;if(ee!==Al.vertical||te||j===Al.horizontal||(te=!0),j=ee,(W.hidden||ee===Al.vertical)&&!te){Ef(K,D);continue}te=!1;const ae=new De(W.tileAnchorX,W.tileAnchorY),he=i.elevationType==="road",be=!!v.elevation||he;let{x:xe,y:Te,z:Fe}=v.projection.projectTilePoint(ae.x,ae.y,_.canonical);if(A){const[dt,pt,yt]=p1(ae,_.canonical,A);xe+=(dt-xe)*A.t,Te+=(pt-Te)*A.t,Fe+=(yt-Fe)*A.t}let se=null;if(be){se=he&&i.hdExt?i.hdExt.makeRoadSymbolElevationParams(i,n?i.text:i.icon,H,_,p,v.elevation,v.projection,v.center.lat,v.worldSize):{getElevation:p,elevation:v.elevation,elevationFeature:null};const[dt,pt,yt]=se.getElevation(ae,v.elevation,se.elevationFeature);xe+=dt,Te+=pt,Fe+=yt}const fe=[xe,Te,Fe,1];if(lr(fe,fe,e),!FE(fe,C)){Ef(K,D);continue}const ge=fe[3],Ae=u1(t.transform.getCameraToCenterDistance(v.projection),ge),Me=Hp(b,T,W),ze=c?Me/Ae:Me*Ae,Ce=Ec(xe,Te,Fe,s);if(Ce[3]<=0){Ef(K,D);continue}let Be={};const ke=Ot(i.layers[0].layout.get("text-max-angle")),Ke=Math.cos(ke),Ve=c?null:se,$e=f1(W,ze,!1,h,e,s,l,i.glyphOffsetArray,O,D,z,Ce,ae,Be,N,Ve,v.projection,_,c,Ke,A);te=$e.useVertical,Ve&&$e.needsFlipping&&(Be={}),($e.notEnoughRoom||te||$e.needsFlipping&&f1(W,ze,!0,h,e,s,l,i.glyphOffsetArray,O,D,z,Ce,ae,Be,N,Ve,v.projection,_,c,Ke,A).notEnoughRoom)&&Ef(K,D)}n?(i.text.dynamicLayoutVertexBuffer.updateData(D),z&&i.text.globeExtVertexBuffer&&i.text.globeExtVertexBuffer.updateData(z)):(i.icon.dynamicLayoutVertexBuffer.updateData(D),z&&i.icon.globeExtVertexBuffer&&i.icon.globeExtVertexBuffer.updateData(z))},L.e1=Bx,L.e2=n0,L.e3=(i,e,t,n,s,l)=>{const c=i.transform,h=c.projection.name==="globe";let p;if(l.paint.get("circle-pitch-alignment")==="map")if(h){const y=_x(c.zoom,e.canonical)*c._pixelsPerMercatorPixel;p=Float32Array.from([y,0,0,y])}else p=c.calculatePixelsToTileUnitsMatrix(t);else p=new Float32Array([c.pixelsToGLUnits[0],0,0,c.pixelsToGLUnits[1]]);const _={u_camera_to_center_distance:i.transform.getCameraToCenterDistance(c.projection),u_matrix:i.translatePosMatrix(e.projMatrix,t,l.paint.get("circle-translate"),l.paint.get("circle-translate-anchor")),u_device_pixel_ratio:X.devicePixelRatio,u_extrude_scale:p,u_inv_rot_matrix:TE,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(h){_.u_inv_rot_matrix=n,_.u_merc_center=s,_.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],_.u_zoom_transition=Rl(c.zoom);const y=s[0]*qe,v=s[1]*qe;_.u_up_dir=c.projection.upVector(new yc(0,0,0),y,v)}return _},L.e4=M0,L.e5=(i,e,t,n,s,l,c,h,p,_)=>{const y=i.transform,v=y.pitch<15?lt(.07,.7,vt((14-y.zoom)/5,0,1)):.07,b=t.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:C0(i,e,t,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:y.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:s,u_width_scale:l,u_floor_width_scale:c,u_image:0,u_tile_units_to_pixels:A0(e,y),u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:h,u_trim_fade_range:t.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:t.paint.get("line-trim-color").toPremultipliedRenderColor(b?null:t.lut).toArray01(),u_zbias_factor:v,u_tile_to_meter:B(e.tileID.canonical,0),u_ground_shadow_factor:p,u_pattern_transition:_,u_opacity_multiplier:1}},L.e6=(i,e,t,n,s,l,c,h,p,_)=>{const y=i.transform,v=y.calculatePixelsToTileUnitsMatrix(e),b=t.paint.get("line-trim-color-use-theme").constantOr("default")==="none",T=y.pitch<15?lt(.07,.7,vt((14-y.zoom)/5,0,1)):.07;return{u_matrix:C0(i,e,t,n),u_pixels_to_tile_units:v,u_device_pixel_ratio:l,u_width_scale:c,u_floor_width_scale:h,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_border_gradient_image:2,u_image_height:s,u_texsize:R0(t)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:A0(e,i.transform),u_alpha_discard_threshold:0,u_trim_offset:p,u_trim_fade_range:t.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:t.paint.get("line-trim-color").toPremultipliedRenderColor(b?null:t.lut).toArray01(),u_zbias_factor:T,u_road_view_depth_bias:0,u_road_clip_to_view:[0,0,0,0],u_tile_to_meter:B(e.tileID.canonical,0),u_ground_shadow_factor:_,u_opacity_multiplier:1}},L.e7=ql,L.e8=xf,L.e9=5,L.eA=function(i,e,t){return i[0]=e[0]/t[0],i[1]=e[1]/t[1],i[2]=e[2]/t[2],i},L.eB=Ou,L.eC=m,L.eD=r,L.eE=gr,L.eF=Di,L.eG=rs,L.eH=Ui,L.eI=function([i,e,t]){const n=Math.hypot(i,e,t),s=Math.atan2(i,t),l=.5*Math.PI-Math.acos(-e/n);return new f(Gr(s),Gr(l))},L.eJ=Za,L.eK=Ul,L.eL=Ng,L.eM=ie,L.eN=nr,L.eO=Ii,L.eP=gy,L.eQ=class{constructor(i,e,t){this._transformRequestFn=i,this._customAccessToken=e,this._silenceAuthErrors=!!t,this._createSkuToken()}_createSkuToken(){const i=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Li,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}async transformRequest(i,e,t){if(!this._transformRequestFn)return{url:i};const n=t?{signal:t}:{};return await this._transformRequestFn(i,e,n)||{url:i}}normalizeStyleURL(i,e){if(!Ut(i))return i;const t=Vt(i);return t.params.push(`sdk=js-${Eo}`),t.path=`/styles/v1${t.path}`,this._makeAPIURL(t,this._customAccessToken||e)}normalizeGlyphsURL(i,e){if(!Ut(i))return i;const t=Vt(i);return t.path=`/fonts/v1${t.path}`,this._makeAPIURL(t,this._customAccessToken||e)}normalizeModelURL(i,e){if(!Ut(i))return i;const t=Vt(i);return t.path=`/models/v1${t.path}`,this._makeAPIURL(t,this._customAccessToken||e)}normalizeSourceURL(i,e,t,n){if(!Ut(i))return i;const s=Vt(i);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),t&&s.params.push(`language=${t}`),n&&s.params.push(`worldview=${n}`),this._makeAPIURL(s,this._customAccessToken||e)}normalizeIconsetURL(i,e){const t=Vt(i);return Ut(i)?(t.path=`/styles/v1${t.path}/iconset.pbf`,this._makeAPIURL(t,this._customAccessToken||e)):$i(t)}normalizeSpriteURL(i,e,t,n){const s=Vt(i);return Ut(i)?(s.path=`/styles/v1${s.path}/sprite${e}${t}`,this._makeAPIURL(s,this._customAccessToken||n)):(s.path+=`${e}${t}`,$i(s))}normalizeTileURL(i,e,t){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!Ut(i))return i;const n=Vt(i);n.path=n.path.replace(Zr,(e||t&&n.authority!=="raster"&&t===512?"@2x":"")+".webp"),n.authority==="raster"?n.path=`/${ie.RASTER_URL_PREFIX}${n.path}`:n.authority==="rasterarrays"?n.path=`/${ie.RASTERARRAYS_URL_PREFIX}${n.path}`:n.authority==="3dtiles"?n.path=`/${ie.TILES3D_URL_PREFIX}${n.path}`:(n.path=n.path.replace(fr,"/"),n.path=`/${ie.TILE_URL_VERSION}${n.path}`);const s=this._customAccessToken||function(l){for(const c of l){const h=c.match(gi);if(h)return h[1]}return null}(n.params)||ie.ACCESS_TOKEN;return ie.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(i,e){const t=Vt(i);if(!Ai.test(t.path)||!ro.test(t.path))return i;let n="mapbox://";t.path.startsWith("/raster/v1/")?n+=`raster/${t.path.replace(`/${ie.RASTER_URL_PREFIX}/`,"")}`:t.path.startsWith("/rasterarrays/v1/")?n+=`rasterarrays/${t.path.replace(`/${ie.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${t.path.replace(`/${ie.TILE_URL_VERSION}/`,"")}`;let s=t.params;return e&&(s=s.filter(l=>!l.match(gi))),s.length&&(n+=`?${s.join("&")}`),n}canonicalizeTileset(i,e){const t=!!e&&Ut(e),n=[];for(const s of i.tiles||[])Nt(s)?n.push(this.canonicalizeTileURL(s,t)):n.push(s);return n}_makeAPIURL(i,e){const t="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=Vt(ie.API_URL);if(i.protocol=n.protocol,i.authority=n.authority,i.protocol==="http"){const s=i.params.indexOf("secure");s>=0&&i.params.splice(s,1)}if(n.path!=="/"&&(i.path=`${n.path}${i.path}`),!ie.REQUIRE_ACCESS_TOKEN)return $i(i);if(e=e||ie.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${t}`);if(e[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${t}`)}return i.params=i.params.filter(s=>!s.includes("access_token")),i.params.push(`access_token=${e||""}`),$i(i)}},L.eR=Rn,L.eS=function(i,e){e?hn.add(i):hn.delete(i)},L.eT=Tr,L.eU=As,L.eV=Yr,L.eW=rn,L.eX=so,L.eY=Hn,L.eZ=bn,L.e_=function(i){hn.delete(i)},L.ea=ME,L.eb=We,L.ec=function(i,e){var t=Math.sin(e),n=Math.cos(e);return i[0]=n,i[1]=0,i[2]=-t,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=t,i[9]=0,i[10]=n,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},L.ed=function(i,e){var t=Math.sin(e),n=Math.cos(e);return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=n,i[6]=t,i[7]=0,i[8]=0,i[9]=-t,i[10]=n,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},L.ee=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],i},L.ef=Bl,L.eg=Yt,L.eh=1,L.ei=Uh,L.ej=0,L.ek=Wi,L.el=function(i,e,t,n,s){return vt((i-e)/(t-e)*(s-n)+n,n,s)},L.em=Ki,L.en=sa,L.eo=function(i,e){var t=e[0],n=e[1],s=e[2],l=e[3],c=e[4],h=e[5],p=e[6],_=e[7],y=e[8],v=y*c-h*_,b=-y*l+h*p,T=_*l-c*p,S=t*v+n*b+s*T;return S?(i[0]=v*(S=1/S),i[1]=(-y*n+s*_)*S,i[2]=(h*n-s*c)*S,i[3]=b*S,i[4]=(y*t-s*p)*S,i[5]=(-h*t+s*l)*S,i[6]=T*S,i[7]=(-_*t+n*p)*S,i[8]=(c*t-n*l)*S,i):null},L.ep=Mt,L.eq=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new De(1/0,1/0),max:new De(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(i,e=!1){const t=Mx(new De(0,0),new De(qe,qe),i),n=[];if(e&&!mg(t,this._globalClipBounds))return n;for(const s of this._activeRegions){if(s.hiddenByOverlap||!mg(t,s))continue;const l=Uw(s.min,s.max,i);n.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 n}setSources(i){this._setSources(i.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const n of e.cache.getVisibleCoordinates()){const s=e.cache.getTile(n).buckets[e.layer];s&&s.updateFootprints(n.toUnwrapped(),t)}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(i){const e=i.getFootprints();if(e.length===0)return;const t=i.getOrder(),n=i.getClipMask(),s=i.getClipScope();for(const l of e){if(!l.footprint)continue;const c=Mx(l.footprint.min,l.footprint.max,l.id);this._activeRegions.push({min:c.min,max:c.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:l.id,footprint:l.footprint,order:t,clipMask:n,clipScope:s})}this._sourceIds.push(i.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||im(e.min,t.min)||im(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(n,s){const l=(c,h)=>c+h;return n.length-s.length||n.reduce(l,"").localeCompare(s.reduce(l,""))}(e.clipScope,t.clipScope));let i=this._activeRegions.length!==this._prevRegions.length;if(!i){let e=0;for(;!i&&e!==this._activeRegions.length;){const t=this._activeRegions[e],n=this._prevRegions[e];i=t.priority!==n.priority||!Cx(t,n)||t.order!==n.order||t.clipMask!==n.clipMask||!ls(t.clipScope,n.clipScope),this._activeRegions[e].hiddenByOverlap=n.hiddenByOverlap,++e}}if(i){++this._updateTime;for(const t of this._activeRegions)t.order!==rf&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const e=t=>{const n=this._activeRegions;if(t>=n.length)return t;const s=n[t].priority;for(;t<n.length&&n[t].priority===s;)++t;return t};if(this._sourceIds.length>1){let t=0,n=e(t);for(;t!==n;){let s=t;const l=t;for(;s!==n;){const c=this._activeRegions[s];c.hiddenByOverlap=!1;for(let h=0;h<l;h++){const p=this._activeRegions[h];if(!p.hiddenByOverlap&&c.order===rf&&mg(c,p)&&(c.hiddenByOverlap=Rx(c.footprint,c.tileId,p.footprint,p.tileId),c.hiddenByOverlap))break}++s}t=n,n=e(t)}}}}_setSources(i){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let e=i.length-1;e>=0;e--)this._addSource(i[e]);this._computeReplacement()}},L.er=rf,L.es=class{constructor(i){this._createGrid(i),this._createPoles(i)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const i of this._poleSegments)i.destroy();for(const i of this._gridSegments)i.withSkirts.destroy(),i.withoutSkirts.destroy()}_fillGridMeshWithLods(i,e){const t=new Re,n=new _t,s=[],l=i+1+2,c=e[0]+1,h=e[0]+1+(1+e.length),p=(_,y,v)=>{let b=_===l-1?_-2:_===0?_:_-1;return b+=v?24575:0,[b,y]};for(let _=0;_<l;++_)t.emplaceBack(...p(_,0,!0));for(let _=0;_<c;++_)for(let y=0;y<l;++y)t.emplaceBack(...p(y,_,(y===0||y===l-1)&&!0));for(let _=0;_<e.length;++_){const y=e[_];for(let v=0;v<l;++v)t.emplaceBack(...p(v,y,!0))}for(let _=0;_<e.length;++_){const y=n.length,v=e[_]+1+2,b=new _t;for(let A=0;A<v-1;A++){const C=A===v-2,D=C?l*(h-e.length+_-A):l;for(let z=0;z<l-1;z++){const O=A*l+z;A===0||C||z===0||z===l-2?(b.emplaceBack(O+1,O,O+D),b.emplaceBack(O+D,O+D+1,O+1)):(n.emplaceBack(O+1,O,O+D),n.emplaceBack(O+D,O+D+1,O+1))}}const T=li.simpleSegment(0,y,t.length,n.length-y);for(let A=0;A<b.uint16.length;A+=3)n.emplaceBack(b.uint16[A],b.uint16[A+1],b.uint16[A+2]);const S=li.simpleSegment(0,y,t.length,n.length-y);s.push({withoutSkirts:T,withSkirts:S})}return{vertices:t,indices:n,segments:s}}_createGrid(i){const e=this._fillGridMeshWithLods(wl,Th);this._gridSegments=e.segments,this._gridBuffer=i.createVertexBuffer(e.vertices,og.members),this._gridIndexBuffer=i.createIndexBuffer(e.indices,!0)}_createPoles(i){const e=new _t;for(let c=0;c<=wl;c++)e.emplaceBack(0,c+1,c+2);this._poleIndexBuffer=i.createIndexBuffer(e,!0);const t=new Yt,n=new Yt,s=new Yt,l=new Yt;this._poleSegments=[];for(let c=0,h=0;c<6;c++){const p=360/(1<<c);t.emplaceBack(0,-On,0,.5,0),n.emplaceBack(0,-On,0,.5,1),s.emplaceBack(0,-On,0,.5,.5),l.emplaceBack(0,-On,0,.5,.5);for(let _=0;_<=wl;_++){let y=_/wl,v=0;const b=lt(0,p,y),[T,S,A]=a(Rw,Pw,b,On);t.emplaceBack(T,S,A,y,v),n.emplaceBack(T,S,A,y,1-v);const C=Ot(b);y=.5+.5*Math.sin(C),v=.5+.5*Math.cos(C),s.emplaceBack(T,S,A,y,v),l.emplaceBack(T,S,A,y,1-v)}this._poleSegments.push(li.simpleSegment(h,0,66,64)),h+=66}this._poleNorthVertexBuffer=i.createVertexBuffer(t,Zp,!1),this._poleSouthVertexBuffer=i.createVertexBuffer(n,Zp,!1),this._texturedPoleNorthVertexBuffer=i.createVertexBuffer(s,Zp,!1),this._texturedPoleSouthVertexBuffer=i.createVertexBuffer(l,Zp,!1)}getGridBuffers(i,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[i].withSkirts:this._gridSegments[i].withoutSkirts]}getPoleBuffers(i,e){return[e?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,e?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[i]]}},L.et=function(i){return hn.has(i)},L.eu=KE,L.ev=Vw,L.ew=Lc,L.ex=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},L.ey=Yh,L.ez=P,L.f=wn,L.f$=Rh,L.f0=vn,L.f1=function(i,e){Ge=i,ut=e},L.f2=Eo,L.f3=fg,L.f4=Gr,L.f5=yx,L.f6=function(i){const e=[0,0,0],t=rr(new Float64Array(16));return Dt(t,i.pixelMatrix,i.globeMatrix),hi(e,e,t),new De(e[0],e[1])},L.f7=function(i){oo=i},L.f8=Gt,L.f9=c1,L.fA=eb,L.fB=function(i){let e=0;if(new Uint32Array(i,0,1)[0]!==bv){const t=new Uint32Array(i,0,7),[,,n,s,l,c]=t;e=t.byteLength+s+l+c+l,(n!==i.byteLength||e>=i.byteLength)&&_i("Invalid b3dm header information.")}return Sv(i,e)},L.fC=function(i,e){const t=i.json.extensionsUsed&&i.json.extensionsUsed.includes("mbx_bvh"),n=$g(i);for(const s of n){if(!t)for(const l of s.meshes)ZT(l);s.lights&&(s.lightMeshIndex=s.meshes.length,s.meshes.push($T(s.lights,e)))}return n},L.fD=B,L.fE=t1,L.fF=et,L.fG=function(i,e){let t="";for(let n=0;n<i.length;n++){const s=i.charCodeAt(n+1)||null,l=i.charCodeAt(n-1)||null;t+=!e&&(s&&zd(s)&&!Yd[i[n+1]]||l&&zd(l)&&!Yd[i[n-1]])||!Yd[i[n]]?i[n]:Yd[i[n]]}return t},L.fH=ps,L.fI=function(i){return!(i<11904||!(fh(i)||Ad(i)||Pd(i)||pp(i)||dp(i)||au(i)||cp(i)||lu(i)||Cd(i)||Ds(i)||hp(i)||xl(i)||dh(i)||Id(i)||hh(i)||up(i)||cc(i)||mp(i)||yl(i)||Md(i)))},L.fJ=Ld,L.fK=function(i){return Sd(i)||lp(i)||su(i)||Rd(i)||Dd(i)},L.fL=function(i){return i===12307||i===12312||i===12313||i===12316||i===12448||i===12540||i>=8592&&i<=8595||i===8208||i===8229||i===8741||i>=9472&&i<=9547||i===65294||i===65309||i===65374||i===65507},L.fM=3,L.fN=Gc,L.fO=Uy,L.fP=Il,L.fQ=function(i){for(const e of i)if(!gp(e.charCodeAt(0)))return!1;return!0},L.fR=cu,L.fS=ng,L.fT=nx,L.fU=cx,L.fV=ox,L.fW=kx,L.fX=1,L.fY=sx,L.fZ=ax,L.f_=Ei,L.fa=function(i,e){if(!i||!e)throw new Error("TileProvider name and URL are required");ie.TILE_PROVIDER_URLS[i]=X.resolveURL(e)},L.fb=function(i){typeof i!="string"||i.length>64||!no.test(i)?_i(`Invalid SDK info "${i}"; expected a "Name/version" string. Ignoring.`):Br=i},L.fc=hc,L.fd=function(i,e,t=!1){if(zn===Sn.deferred||zn===Sn.loading||zn===Sn.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Sa=X.resolveURL(i),zn=Sn.deferred,Fd=e,Od(),t||mo()},L.fe=function(i){ie.BUILDING_GEN_URL=X.resolveURL(i)},L.ff=ye,L.fg=function(i){const e=X.resolveURL(i);ie.MESHOPT_URL=e,ie.MESHOPT_SIMD_URL=e},L.fh=le,L.fi=function(i){ie.DRACO_URL=X.resolveURL(i)},L.fj=ne,L.fk=function(i){const e=gt();if(!e)return;const t=e.delete(Ne);i&&t.then(()=>i()).catch(i)},L.fl=function(i){ie.MAX_PARALLEL_IMAGE_REQUESTS=i},L.fm=function(i){ie.API_URL=i},L.fn=function(i){ie.ACCESS_TOKEN=i},L.fo="hd_road_elevation",L.fp=class{static parseFrom(i,e){const t=Dl.parse(i);if(!t)return[];let{vertices:n,features:s}=t;const l=1/B(e);s.sort((_,y)=>_.id-y.id),n.sort((_,y)=>_.id-y.id||_.idx-y.idx),n=n.filter((_,y,v)=>y===v.findIndex(b=>b.id===_.id&&b.idx===_.idx));const c=new Array;let h=0;const p=n.length;for(const _ of s){if(_.constantHeight){c.push(new Ll(_.id,_.bounds,_.constantHeight));continue}for(;h!==p&&n[h].id<_.id;)h++;if(h===p||n[h].id!==_.id)continue;const y=new Array,v=new Array,b=h;for(;h!==p&&n[h].id===_.id;){const T=n[h];if(y.push({position:T.position,height:T.height,extent:T.extent,index:T.idx}),h!==b&&n[h-1].idx===T.idx-1){const S=h-b;v.push({a:S-1,b:S})}h++}c.push(new Ll(_.id,_.bounds,void 0,y,v,l))}return c}},L.fq=Pl,L.fr=t0,L.fs=xm,L.ft=Un,L.fu=Ku,L.fv=function(i,e){const t=i.layers[0].layout.get("fill-elevation-reference"),n=t==="hd-road-base"||t==="hd-road-markup"?t:null,s=!!e&&e.length>0&&Og(e,i.layers[0].source,i.sourceLayerName);(n||s)&&(i.hdExt=new uv(i,n,s))},L.fw=function(i,e){const t=i.layers[0].layout.get("line-elevation-reference")==="hd-road-markup",n=!!e&&e.length>0&&Og(e,i.layers[0].source,i.sourceLayerName);(t||n)&&(i.hdExt=new hv(t,n))},L.fx=jp,L.fy=function(i){const e=i.layers[0];e.type==="circle"&&e.layout.get("circle-elevation-reference")==="hd-road-markup"&&(i.hdExt=new dv)},L.fz=function(i){i.layers[0].layout.get("symbol-elevation-reference")==="hd-road-markup"&&(i.hdExt=new fv)},L.g=yr,L.g0=Hx,L.g1=ux,L.g2=function(i,e){const t=i.stretchY||[[0,i.paddedRect.h-2]];return i.stretchX||i.stretchY?$x(i.stretchX||[[0,i.paddedRect.w-2]])*$x(t):1},L.g3=qx,L.g4=_c,L.g5=2,L.g6=n1,L.g7=Yy,L.g8=Og,L.g9=function(i,e){const t=xm(i);return t!==null&&!!(e&1<<t)},L.ga=to,L.gb=wg,L.gc=xg,L.gd=Nx,L.ge=Vx,L.gf=Z_,L.gg=function(i){return i<=1?1:Math.pow(2,Math.floor(Math.log2(i)))},L.gh=a_,L.gi=pc,L.gj=class{constructor(i=new Uint8Array(16)){this.buf=ArrayBuffer.isView(i)?i:new Uint8Array(i),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.length=this.buf.length}writeTag(i,e){this.writeVarint(i<<3|e)}realloc(i){let e=this.length||16;for(;e<this.pos+i;)e*=2;if(e!==this.length){const t=new Uint8Array(e);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(i){this.realloc(4),this.dataView.setInt32(this.pos,i,!0),this.pos+=4}writeSFixed32(i){this.realloc(4),this.dataView.setInt32(this.pos,i,!0),this.pos+=4}writeFixed64(i){this.realloc(8),this.dataView.setInt32(this.pos,-1&i,!0),this.dataView.setInt32(this.pos+4,Math.floor(i*Dx),!0),this.pos+=8}writeSFixed64(i){this.realloc(8),this.dataView.setInt32(this.pos,-1&i,!0),this.dataView.setInt32(this.pos+4,Math.floor(i*Dx),!0),this.pos+=8}writeVarint(i){if((i=+i||0)>=0&&i<128)return this.pos>=this.length&&this.realloc(1),void(this.buf[this.pos++]=i);i>268435455||i<0?function(e,t){let n,s;if(e>=0?(n=e%4294967296|0,s=e/4294967296|0):(n=~(-e%4294967296),s=~(-e/4294967296),4294967295^n?n=n+1|0:(n=0,s=s+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(l,c,h){h.buf[h.pos++]=127&l|128,l>>>=7,h.buf[h.pos++]=127&l|128,l>>>=7,h.buf[h.pos++]=127&l|128,l>>>=7,h.buf[h.pos++]=127&l|128,h.buf[h.pos]=127&(l>>>=7)}(n,0,t),function(l,c){const h=(7&l)<<4;c.buf[c.pos++]|=h|((l>>>=3)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l|((l>>>=7)?128:0),l&&(c.buf[c.pos++]=127&l)))))}(s,t)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))}writeSVarint(i){this.writeVarint(i<0?2*-i-1:2*i)}writeBoolean(i){this.writeVarint(+i)}writeString(i){i=String(i),this.realloc(4*i.length),this.pos++;const e=this.pos;this.pos=function(n,s,l){for(let c,h,p=0;p<s.length;p++){if(c=s.charCodeAt(p),c>55295&&c<57344){if(!h){c>56319||p+1===s.length?(n[l++]=239,n[l++]=191,n[l++]=189):h=c;continue}if(c<56320){n[l++]=239,n[l++]=191,n[l++]=189,h=c;continue}c=h-55296<<10|c-56320|65536,h=null}else h&&(n[l++]=239,n[l++]=191,n[l++]=189,h=null);c<128?n[l++]=c:(c<2048?n[l++]=c>>6|192:(c<65536?n[l++]=c>>12|224:(n[l++]=c>>18|240,n[l++]=c>>12&63|128),n[l++]=c>>6&63|128),n[l++]=63&c|128)}return l}(this.buf,i,this.pos);const t=this.pos-e;t>=128&&zx(e,t,this),this.pos=e-1,this.writeVarint(t),this.pos+=t}writeFloat(i){this.realloc(4),this.dataView.setFloat32(this.pos,i,!0),this.pos+=4}writeDouble(i){this.realloc(8),this.dataView.setFloat64(this.pos,i,!0),this.pos+=8}writeBytes(i){const e=i.length;this.writeVarint(e),this.realloc(e),this.buf.set(i,this.pos),this.pos+=e}writeRawMessage(i,e){this.pos++;const t=this.pos;i(e,this);const n=this.pos-t;n>=128&&zx(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n}writeMessage(i,e,t){this.writeTag(i,2),this.writeRawMessage(e,t)}writePackedVarint(i,e){e.length&&this.writeMessage(i,jw,e)}writePackedSVarint(i,e){e.length&&this.writeMessage(i,Gw,e)}writePackedBoolean(i,e){e.length&&this.writeMessage(i,$w,e)}writePackedFloat(i,e){e.length&&this.writeMessage(i,Hw,e)}writePackedDouble(i,e){e.length&&this.writeMessage(i,Zw,e)}writePackedFixed32(i,e){e.length&&this.writeMessage(i,qw,e)}writePackedSFixed32(i,e){e.length&&this.writeMessage(i,Ww,e)}writePackedFixed64(i,e){e.length&&this.writeMessage(i,Xw,e)}writePackedSFixed64(i,e){e.length&&this.writeMessage(i,Yw,e)}writeBytesField(i,e){this.writeTag(i,2),this.writeBytes(e)}writeFixed32Field(i,e){this.writeTag(i,5),this.writeFixed32(e)}writeSFixed32Field(i,e){this.writeTag(i,5),this.writeSFixed32(e)}writeFixed64Field(i,e){this.writeTag(i,1),this.writeFixed64(e)}writeSFixed64Field(i,e){this.writeTag(i,1),this.writeSFixed64(e)}writeVarintField(i,e){this.writeTag(i,0),this.writeVarint(e)}writeSVarintField(i,e){this.writeTag(i,0),this.writeSVarint(e)}writeStringField(i,e){this.writeTag(i,2),this.writeString(e)}writeFloatField(i,e){this.writeTag(i,5),this.writeFloat(e)}writeDoubleField(i,e){this.writeTag(i,1),this.writeDouble(e)}writeBooleanField(i,e){this.writeVarintField(i,+e)}},L.gk=hs,L.gl=tm,L.gm=Sn,L.gn=ib,L.go=function(i){at(),Qe!=null&&Qe.then(e=>{e.keys().then(t=>{for(let n=0;n<t.length-i;n++)e.delete(t[n]).catch(s=>_i(s.message))}).catch(t=>_i(t.message))}).catch(e=>_i(e.message))},L.h=Mo,L.i=uo,L.j=2,L.k=nf,L.l=ga,L.m=yh,L.n=ol,L.o=J,L.p=Fx,L.q=ya,L.r=Td,L.s=de,L.t=iu,L.u=kd,L.v=wd,L.w=_i,L.x=nu,L.y=hu,L.z=op}),h_(["require","./shared"],function(d,L){function Eo(Z){const M=Z?Z.url.toString():void 0;return M?performance.getEntriesByName(M):[]}function Xn(Z,M){if(Object.hasOwn(Z.layers,L.fo))return L.fp.parseFrom(Z.layers[L.fo],M)}function Lr({buckets:Z,data:M,sourceLayerCoder:k,canonical:q,options:J}){if(!J.elevationFeatures||J.elevationFeatures.length===0)return;const X=[];for(const ie of Object.values(Z))if(ie instanceof L.bA&&ie.hdExt){const ne=ie.hdExt.getUnevaluatedPortalGraph();ne&&X.push(ne)}const Q=L.fq.evaluate(X);for(const ie of Object.values(Z))if(ie instanceof L.bA&&ie.hdExt){const ne=M.layers[k.decode(ie.sourceLayerIndex)];ie.hdExt.setEvaluatedPortalGraph(Q,ne,q,J.availableImages,J.brightness,ie.worldview)}}function Ac(Z){const M=[];for(let k=0;k<Z.length;k++){const q=Z.feature(k),J=q.properties.frc_mask;if(J==null)continue;const X=Number(J);if(!X)continue;const Q=q.loadGeometry();if(Q.length>0){let ne=!1;for(const le of Q[0])if(le.x<0||le.x>L.a2||le.y<0||le.y>L.a2){ne=!0;break}if(ne)continue}const ie=Q.length===1&&Q[0].length===5&&Q[0].some(ne=>ne.x<=0&&ne.y<=0)&&Q[0].some(ne=>ne.x>=L.a2&&ne.y<=0)&&Q[0].some(ne=>ne.x>=L.a2&&ne.y>=L.a2)&&Q[0].some(ne=>ne.x<=0&&ne.y>=L.a2);M.push(new L.fr(X,ie?[]:Q))}return M}function Bl(Z,M,k,q,J){const X=L.fs(M);if(X===null)return!1;let Q=k.x,ie=k.y;const ne=J??q.z;if(q.z!==ne){const le=1<<q.z-ne,ye=L.a2/le;Q=q.x%le*ye+k.x/le,ie=q.y%le*ye+k.y/le}for(const le of Z){if(!(le.hasGeometry()&&le.frcMask&1<<X))continue;const ye=le.rings.map(Ee=>Ee.map(Le=>[Le.x,Le.y]));if(L.ft([Q,ie],ye))return!0}return!1}function ai(Z,M,k,q){const J=M.indoorState.activeFloorsVisible;if(!M.sourceLayers)return J?M.indoorState.activeFloors:void 0;const X=function(ne,le){if(!ne)return L.w("No source layers defined in indoor specification"),le;if(ne.size===0)return le;const ye=ne.difference(le);for(const Ee of ye)L.w(`Missing source layer required in indoor specification: ${Ee}`);return le.intersection(le)}(M.sourceLayers,new Set(Object.keys(Z.layers))),Q=M.indoorState,ie=function(ne,le,ye,Ee,Le){const Ne={};for(const Ge of le){const ut=ne.layers[Ge];if(ut)for(let nt=0;nt<ut.length;nt++){const Qe=ut.feature(nt);if(kl(Qe)){const{id:gt,center:at}=Fs(Qe);So(Ne,gt,at);continue}if(yn(Qe)){const gt=Cc(Qe,Le);Yn(Ne,gt.buildings,gt.id,gt)}}else L.w(`indoor source layer not found: ${Ge}`)}return{buildings:Ne,activeFloors:L.aW.calculate(Ne,Ee,ye)}}(Z,X,Q.activeFloors,Q.selectedFloorId,q);return k.notify("setIndoorData",ie),J?ie.activeFloors:void 0}function So(Z,M,k){Z[M]?k&&(Z[M].center=k):Z[M]={floorIds:new Set,center:k||[0,0],floors:{}}}function Yn(Z,M,k,q){for(const J of M)So(Z,J),Z[J].floors[k]=q,Z[J].floorIds.add(k)}function Fs(Z){return{id:Z.properties.id.toString(),center:[Z.properties.center_lon||0,Z.properties.center_lat||0]}}function Cc(Z,M){const k=Z.properties.id.toString(),q=!!Z.properties.is_default&&Z.properties.is_default,J=Z.properties.connected_floor_ids?new Set(Z.properties.connected_floor_ids.toString().split(";")):new Set,X=Z.properties.conflicted_floor_ids?new Set(Z.properties.conflicted_floor_ids.toString().split(";")):new Set,Q=Z.properties.structure_ids?new Set(Z.properties.structure_ids.toString().split(";")):new Set,ie=Z.properties.name.toString(),ne=Z.properties.z_index,le=function(ye,Ee){const Le=ye.loadGeometry();if(!Le||Le.length===0)return;const Ne=Le.map(Ge=>Ge.map(ut=>L.fu(ut,Ee,ye.extent)));return Ne.length===0?void 0:{type:"Polygon",coordinates:[Ne[0]]}}(Z,M);return{id:k,isDefault:q,connections:J,conflicts:X,buildings:Q,name:ie,zIndex:ne,geometry:le}}function rr(Z,M){return M.every(k=>Z.properties&&Z.properties[k]!=null)}function kl(Z){return rr(Z,["type","id","name"])&&Z.properties.type==="structure"}function yn(Z){return rr(Z,["type","id","name","z_index"])&&Z.properties.type==="floor"}function Dt(Z,M){Z instanceof L.bA?L.fv(Z,M):Z instanceof L.bz?L.fw(Z,M):Z instanceof L.fx?L.fy(Z):Z instanceof L.bu&&L.fz(Z)}function Yi(Z){for(const M in Z){const k=Z[M];if(k instanceof L.bz&&k.hdExt&&k.hdExt.hasDeferredElevationFeatures||k instanceof L.bu&&k.hdExt&&k.hdExt.hasDeferredElevationFeatures)return!0}return!1}class hr{constructor(M,k,q){this.tileID=new L.bP(M.tileID.overscaledZ,M.tileID.wrap,M.tileID.canonical.z,M.tileID.canonical.x,M.tileID.canonical.y),this.tileZoom=M.tileZoom,this.uid=M.uid,this.zoom=M.zoom,this.canonical=M.tileID.canonical,this.pixelRatio=M.pixelRatio,this.tileSize=M.tileSize,this.source=M.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=M.projection,this.brightness=k,this.worldview=q}async parse(M,k,q){this.status="parsing";const J=new L.bP(q.tileID.overscaledZ,q.tileID.wrap,q.tileID.canonical.z,q.tileID.canonical.x,q.tileID.canonical.y),X=[],Q=k.familiesBySource[q.source],ie=new L.fA(J,q.promoteId);ie.bucketLayerIDs=[],ie.is3DTile=!0;const ne=await L.fB(M),le=ne.json.extensionsUsed&&ne.json.extensionsUsed.includes("MAPBOX_mesh_features")||ne.json.asset.extras&&ne.json.asset.extras.MAPBOX_mesh_features,ye=ne.json.extensionsUsed&&ne.json.extensionsUsed.includes("EXT_meshopt_compression"),Ee=new L.ai(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Le in Q)for(const Ne of Q[Le]){const Ge=Ne[0];ie.bucketLayerIDs.push(Ne.map(Qe=>L.m(Qe.id,Qe.scope))),Ge.recalculate(Ee,[]);const ut=L.fC(ne,1/L.fD(q.tileID.canonical)),nt=new L.fE(Ne,ut,J,le,ye,this.brightness,ie,this.worldview);le||(nt.needsUpload=!0),X.push(nt),nt.evaluate(Ge)}return this.status="done",{buckets:X,featureIndex:ie,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null}}}class Es{constructor({actor:M,layerIndex:k,availableImages:q,availableModels:J,brightness:X,worldview:Q}){this.actor=M,this.layerIndex=k,this.availableImages=q,this.availableModels=J,this.brightness=X,this.loading={},this.loaded={},this.worldview=Q}async loadTile(M){const k=M.uid,q=new AbortController,J=this.loading[k]=new hr(M,this.brightness,this.worldview);J.abort=()=>q.abort();const X=(ie,ne)=>{const le=J.reloadCallback;le&&(delete J.reloadCallback,le(ie,ne))};let Q;try{Q=(await L.cC(M.request,q.signal)).data}catch(ie){if(delete this.loading[k],J.status="done",this.loaded[k]=J,q.signal.aborted)return null;throw ie}if(delete this.loading[k],!Q||Q.byteLength===0)return J.status="done",this.loaded[k]=J,null;try{const ie=await J.parse(Q,this.layerIndex,M);return this.loaded[k]=J,X(null,ie),ie}catch(ie){throw this.loaded[k]=J,X(ie),ie}}async reloadTile(M){const k=this.loaded&&this.loaded[M.uid];if(k)return k.projection=M.projection,k.brightness=M.brightness,k.status==="parsing"&&await new Promise((q,J)=>{k.reloadCallback=X=>{X?J(X):q()}}),this.loadTile(M)}abortTile(M){const k=M.uid,q=this.loading[k];q&&(q.abort&&q.abort(),delete this.loading[k])}removeTile(M){const k=this.loaded,q=M.uid;k&&k[q]&&delete k[q]}}function Io(Z){if(typeof Z=="number"||typeof Z=="boolean"||typeof Z=="string"||Z==null)return JSON.stringify(Z);if(Array.isArray(Z)){let k="[";for(const q of Z)k+=`${Io(q)},`;return`${k}]`}let M="{";for(const k of Object.keys(Z).sort())M+=`${k}:${Io(Z[k])},`;return`${M}}`}function Os(Z){let M="";for(const k of L.cD)M+=`/${Io(Z[k])}`;return M}function Bs(Z,M){return function k(q){return typeof q=="string"&&q===M||(Array.isArray(q)?q.some(k):!(!q||typeof q!="object")&&Object.values(q).some(k))}(Z)}class Ho{constructor(M){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),M&&this.replace(M)}replace(M,k){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(M,[],k)}update(M,k,q){this._options=q;for(const X of M)this._layerConfigs[X.id]=X,(this._layers[X.id]=L.dj(X,this.scope,null,this._options)).compileFilter(q),this.keyCache[X.id]&&delete this.keyCache[X.id];for(const X of k)delete this.keyCache[X],delete this._layerConfigs[X],delete this._layers[X];this.familiesBySource=Object.create(null);const J=function(X,Q){const ie=Object.create(null);for(let le=0;le<X.length;le++){const ye=X[le];let Ee=Q&&Q[ye.id];Ee||(ye.type==="symbol"?Ee=ye.id:(Ee=Os(ye),ye.type==="line"&&ye.paint&&(Bs(ye.paint["line-width"],"line-progress")&&(Ee+=`/${Io(ye.paint["line-width"])}`),Bs(ye.paint["line-emissive-strength"],"line-progress")&&(Ee+=`/${Io(ye.paint["line-emissive-strength"])}`)))),Q&&(Q[ye.id]=Ee);let Le=ie[Ee];Le||(Le=ie[Ee]=[]),Le.push(ye)}const ne=[];for(const le in ie)ne.push(ie[le]);return ne}(Object.values(this._layerConfigs),this.keyCache);for(const X of J){const Q=X.map(Le=>this._layers[Le.id]),ie=Q[0];if(ie.visibility==="none")continue;const ne=ie.source||"";let le=this.familiesBySource[ne];le||(le=this.familiesBySource[ne]=Object.create(null));const ye=ie.sourceLayer||"_geojsonTileLayer";let Ee=le[ye];Ee||(Ee=le[ye]=[]),Ee.push(Q)}}}class Kn extends L.P{constructor(M,k,q,J,X){super(M,k),this.angle=J,this.z=q,X!==void 0&&(this.segment=X)}clone(){return new Kn(this.x,this.y,this.z,this.angle,this.segment)}}function Nl(Z,M,k,q,J){if(M.segment===void 0)return!0;let X=M,Q=M.segment+1,ie=0;for(;ie>-k/2;){if(Q--,Q<0)return!1;ie-=Z[Q].dist(X),X=Z[Q]}ie+=Z[Q].dist(Z[Q+1]),Q++;const ne=[];let le=0;for(;ie<k/2;){const ye=Z[Q],Ee=Z[Q+1];if(!Ee)return!1;let Le=Z[Q-1].angleTo(ye)-ye.angleTo(Ee);for(Le=Math.abs((Le+3*Math.PI)%(2*Math.PI)-Math.PI),ne.push({distance:ie,angleDelta:Le}),le+=Le;ie-ne[0].distance>q;)le-=ne.shift().angleDelta;if(le>J)return!1;Q++,ie+=ye.dist(Ee)}return!0}function zu(Z){let M=0;for(let k=0;k<Z.length-1;k++)M+=Z[k].dist(Z[k+1]);return M}function Ga(Z,M,k){return Z?.6*M*k:0}function Vl(Z,M){return Math.max(Z?Z.right-Z.left:0,M?M.right-M.left:0)}function Fu(Z,M,k,q,J,X){const Q=Ga(k,J,X),ie=Vl(k,q)*X;let ne=0;const le=zu(Z)/2;for(let ye=0;ye<Z.length-1;ye++){const Ee=Z[ye],Le=Z[ye+1],Ne=Ee.dist(Le);if(ne+Ne>le){const Ge=(le-ne)/Ne,ut=L.al(Ee.x,Le.x,Ge),nt=L.al(Ee.y,Le.y,Ge),Qe=new Kn(ut,nt,0,Le.angleTo(Ee),ye);return!Q||Nl(Z,Qe,ie,Q,M)?Qe:void 0}ne+=Ne}}function Ha(Z,M,k,q,J,X,Q,ie,ne){const le=Ga(q,X,Q),ye=Vl(q,J),Ee=ye*Q,Le=Z[0].x===0||Z[0].x===ne||Z[0].y===0||Z[0].y===ne;return M-Ee<M/4&&(M=Ee+M/4),Jt(Z,Le?M/2*ie%M:(ye/2+2*X)*Q*ie%M,M,le,k,Ee,Le,!1,ne)}function Jt(Z,M,k,q,J,X,Q,ie,ne){const le=X/2,ye=zu(Z);let Ee=0,Le=M-k,Ne=[];for(let Ge=0;Ge<Z.length-1;Ge++){const ut=Z[Ge],nt=Z[Ge+1],Qe=ut.dist(nt),gt=nt.angleTo(ut);for(;Le+k<Ee+Qe;){Le+=k;const at=(Le-Ee)/Qe,It=L.al(ut.x,nt.x,at),Nt=L.al(ut.y,nt.y,at);if(It>=0&&It<ne&&Nt>=0&&Nt<ne&&Le-le>=0&&Le+le<=ye){const Ut=new Kn(It,Nt,0,gt,Ge);q&&!Nl(Z,Ut,X,q,J)||Ne.push(Ut)}}Ee+=Qe}return ie||Ne.length||Q||(Ne=Jt(Z,Ee/2,k,q,J,X,Q,!0,ne)),Ne}L.fF(Kn,"Anchor");class ks{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(M,k){const q=new ks;return q.scale=M||1,q.fontStack=k,q}static forImage(M){const k=new ks;return k.image=M,k}}class Ki{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(M,k,q,J=1){const X=new Ki;for(let Q=0;Q<M.sections.length;Q++){const ie=M.sections[Q];ie.image?X.addImageSection(ie,q,J):X.addTextSection(ie,k)}return X}length(){return this.text.length}getSection(M){return this.sections[this.sectionIndex[M]]}getSections(){return this.sections}getSectionIndex(M){return this.sectionIndex[M]}getCodePoint(M){return this.text.codePointAt(M)}verticalizePunctuation(M){this.text=L.fG(this.text,M)}trim(){let M=0;for(let q=0;q<this.text.length&&Ui[this.text.charCodeAt(q)];q++)M++;let k=this.text.length;for(let q=this.text.length-1;q>=0&&q>=M&&Ui[this.text.charCodeAt(q)];q--)k--;this.text=this.text.substring(M,k),this.sectionIndex=this.sectionIndex.slice(M,k)}substring(M,k){const q=new Ki;return q.text=this.text.substring(M,k),q.sectionIndex=this.sectionIndex.slice(M,k),q.sections=this.sections,q}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((M,k)=>Math.max(M,this.sections[k].scale),0)}addTextSection(M,k){this.text+=M.text,this.sections.push(ks.forText(M.scale,M.fontStack||k));const q=this.sections.length-1;for(let J=0;J<M.text.length;++J)this.sectionIndex.push(q)}addImageSection(M,k,q=1){const J=M.image?M.image.getPrimary():null;if(!J)return void L.w("Can't add FormattedSection with an empty image.");J.scaleSelf(k*q);const X=this.getNextImageSectionCharCode();X?(this.text+=String.fromCodePoint(X),this.sections.push(ks.forImage(J)),this.sectionIndex.push(this.sections.length-1)):L.w("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function br(Z,M,k,q,J,X,Q,ie,ne,le,ye,Ee,Le,Ne,Ge,ut=1,nt=1){const Qe=Ki.fromFeature(Z,J,ut,nt);Ee===L.cL.vertical&&Qe.verticalizePunctuation(Le);let gt=[];const at=function(At,xi,fi,Bt,Ht,Ct,Zt){if(!At)return[];const pi=[],zt=function(vi,dr,Qi,Si,Li,Ii,nr){let Hr=0;for(let Zr=0;Zr<vi.length();Zr++){const fr=vi.getSection(Zr);Hr+=Jn(vi.getCodePoint(Zr),fr,Si,Li,dr,Ii,nr)}return Hr/Math.max(1,Math.ceil(Hr/Qi))}(At,xi,fi,Bt,Ht,Ct,Zt),di=At.text.includes("​");let yr=0;for(let vi=0;vi<At.length();vi++){const dr=At.getSection(vi),Qi=At.getCodePoint(vi);if(Ui[Qi]||(yr+=Jn(Qi,dr,Bt,Ht,xi,Ct,Zt)),vi<At.length()-1){const Si=L.fI(Qi);(Ji[Qi]||Si||dr.image)&&pi.push(Vs(vi+1,yr,zt,pi,Ns(Qi,At.getCodePoint(vi+1),Si&&di),!1))}}return si(Vs(At.length(),yr,zt,pi,0,!0))}(Qe,le,X,M,q,Ne,nt),{processBidirectionalText:It,processStyledBidirectionalText:Nt}=L.fH;if(It&&Qe.sections.length===1){const At=It(Qe.toString(),at);for(const xi of At){const fi=new Ki;fi.text=xi,fi.sections=Qe.sections;for(let Bt=0;Bt<xi.length;Bt++)fi.sectionIndex.push(0);gt.push(fi)}}else if(Nt){const At=Nt(Qe.text,Qe.sectionIndex,at);for(const xi of At){const fi=new Ki;fi.text=xi[0],fi.sectionIndex=xi[1],fi.sections=Qe.sections,gt.push(fi)}}else gt=function(At,xi){const fi=[],Bt=At.text;let Ht=0;for(const Ct of xi)fi.push(At.substring(Ht,Ct)),Ht=Ct;return Ht<Bt.length&&fi.push(At.substring(Ht,Bt.length)),fi}(Qe,at);const Ut=[],Gt={positionedLines:Ut,text:Qe.toString(),top:ye[1],bottom:ye[1],left:ye[0],right:ye[0],writingMode:Ee,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(At,xi,fi,Bt,Ht,Ct,Zt,pi,zt,di,yr,vi,dr){let Qi=0,Si=0,Li=0;const Ii=pi==="right"?1:pi==="left"?0:.5;let nr=!1;for(const Ai of Ht){const gi=Ai.getSections();for(const Yr of gi){if(Yr.image)continue;const wr=xi[Yr.fontStack];if(wr&&(nr=wr.ascender!==void 0&&wr.descender!==void 0,!nr))break}if(!nr)break}let Hr=0;for(const Ai of Ht){Ai.trim();const gi=Ai.getMaxScale(),Yr=(gi-1)*L.d1,wr={positionedGlyphs:[],lineOffset:0};At.positionedLines[Hr]=wr;const Vt=wr.positionedGlyphs;let $i=0;if(!Ai.length()){Si+=Ct,++Hr;continue}let Or=0,Rn=0;for(let Br=0;Br<Ai.length();Br++){const no=Ai.getSection(Br),oo=Ai.getSectionIndex(Br),Ci=Ai.getCodePoint(Br);let ar=no.scale,kr=null,Pn=null,vn=null,rn=L.d1,$r=0,so=zt;so===L.cL.vertical&&L.fL(Ci)&&(so=L.cL.horizontal);const Wo=!(so===L.cL.horizontal||!yr&&!L.fJ(Ci)||yr&&(Ui[Ci]||L.fK(Ci)));if(no.image){const Hn=Bt.get(no.image.toString());if(!Hn)continue;vn=no.image,At.iconsInText=!0,Pn=Hn.paddedRect;const or=Hn.displaySize,bn=or[0]*dr,Oi=or[1]*dr;ar=ar*L.d1/vi,kr={width:bn,height:Oi,left:0,top:-L.fM,advance:Wo?Oi:bn,localGlyph:!1},$r=nr?-kr.height*ar:gi*L.d1-17-Oi*ar,rn=kr.advance;const Tr=(Wo?bn:Oi)*ar-L.d1*gi;Tr>0&&Tr>$i&&($i=Tr)}else{const Hn=fi[no.fontStack];if(!Hn)continue;Hn[Ci]&&(Pn=Hn[Ci]);const or=xi[no.fontStack];if(!or)continue;const bn=or.glyphs[Ci];if(!bn)continue;if(kr=bn.metrics,rn=Ci!==8203?L.d1:0,nr){const Oi=or.ascender!==void 0?Math.abs(or.ascender):0,Tr=or.descender!==void 0?Math.abs(or.descender):0,ao=(Oi+Tr)*ar;Or<ao&&(Or=ao,Rn=(Oi-Tr)/2*ar),$r=-Oi*ar}else $r=(gi-ar)*L.d1-17}Vt.push({glyph:Ci,image:vn,x:Qi,y:Si+$r,vertical:Wo,scale:ar,localGlyph:kr.localGlyph,fontStack:no.fontStack,sectionIndex:oo,metrics:kr,rect:Pn}),Wo?(At.verticalizable=!0,Qi+=rn*ar+di):Qi+=kr.advance*ar+di}Vt.length!==0&&(Li=Math.max(Qi-di,Li),nr?cn(Vt,Ii,$i,Rn,Ct*gi/2):cn(Vt,Ii,$i,0,Ct/2)),Qi=0;const tn=Ct*gi+$i;wr.lineOffset=Math.max($i,Yr),Si+=tn,++Hr}const Zr=Si,{horizontalAlign:fr,verticalAlign:ro}=L.cM(Zt);(function(Ai,gi,Yr,wr,Vt,$i){const Or=(gi-Yr)*Vt,Rn=-$i*wr;for(const tn of Ai)for(const Br of tn.positionedGlyphs)Br.x+=Or,Br.y+=Rn})(At.positionedLines,Ii,fr,ro,Li,Zr),At.top+=-ro*Zr,At.bottom=At.top+Zr,At.left+=-fr*Li,At.right=At.left+Li,At.hasBaseline=nr}(Gt,M,k,q,gt,Q,ie,ne,Ee,le,Le,Ge,nt),!function(At){for(const xi of At)if(xi.positionedGlyphs.length!==0)return!1;return!0}(Ut))return Gt}const Ui={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Ji={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 Jn(Z,M,k,q,J,X,Q){if(M.image){const ie=q.get(M.image.toString());return ie?ie.displaySize[0]*Q*M.scale*L.d1/X+J:0}{const ie=k[M.fontStack],ne=ie&&ie.glyphs[Z];return ne?ne.metrics.advance*M.scale+J:0}}function Mc(Z,M,k,q){const J=Math.pow(Z-M,2);return q?Z<M?J/2:2*J:J+Math.abs(k)*k}function Ns(Z,M,k){let q=0;return Z===10&&(q-=1e4),k&&(q+=150),Z!==40&&Z!==65288||(q+=50),M!==41&&M!==65289||(q+=50),q}function Vs(Z,M,k,q,J,X){let Q=null,ie=Mc(M,k,J,X);for(const ne of q){const le=Mc(M-ne.x,k,J,X)+ne.badness;le<=ie&&(Q=ne,ie=le)}return{index:Z,x:M,priorBreak:Q,badness:ie}}function si(Z){return Z?si(Z.priorBreak).concat(Z.index):[]}function cn(Z,M,k,q,J){if(!(M||k||q||J))return;const X=Z.length-1,Q=Z[X],ie=(Q.x+Q.metrics.advance*Q.scale)*M;for(let ne=0;ne<=X;ne++)Z[ne].x-=ie,Z[ne].y+=k+q+J}function Za(Z,M=1,k=!1){let q=1/0,J=1/0,X=-1/0,Q=-1/0;const ie=Z[0];for(let Ne=0;Ne<ie.length;Ne++){const Ge=ie[Ne];(!Ne||Ge.x<q)&&(q=Ge.x),(!Ne||Ge.y<J)&&(J=Ge.y),(!Ne||Ge.x>X)&&(X=Ge.x),(!Ne||Ge.y>Q)&&(Q=Ge.y)}const ne=Math.min(X-q,Q-J);let le=ne/2;const ye=new L.fN([],Us);if(ne===0)return new L.P(q,J);for(let Ne=q;Ne<X;Ne+=ne)for(let Ge=J;Ge<Q;Ge+=ne)ye.push(new rs(Ne+le,Ge+le,le,Z));let Ee=function(Ne){let Ge=0,ut=0,nt=0;const Qe=Ne[0];for(let gt=0,at=Qe.length,It=at-1;gt<at;It=gt++){const Nt=Qe[gt],Ut=Qe[It],Gt=Nt.x*Ut.y-Ut.x*Nt.y;ut+=(Nt.x+Ut.x)*Gt,nt+=(Nt.y+Ut.y)*Gt,Ge+=3*Gt}return new rs(ut/Ge,nt/Ge,0,Ne)}(Z),Le=ye.length;for(;ye.length;){const Ne=ye.pop();(Ne.d>Ee.d||!Ee.d)&&(Ee=Ne,k&&console.log("found best %d after %d probes",Math.round(1e4*Ne.d)/1e4,Le)),Ne.max-Ee.d<=M||(le=Ne.h/2,ye.push(new rs(Ne.p.x-le,Ne.p.y-le,le,Z)),ye.push(new rs(Ne.p.x+le,Ne.p.y-le,le,Z)),ye.push(new rs(Ne.p.x-le,Ne.p.y+le,le,Z)),ye.push(new rs(Ne.p.x+le,Ne.p.y+le,le,Z)),Le+=4)}return k&&(console.log(`num probes: ${Le}`),console.log(`best distance: ${Ee.d}`)),Ee.p}function Us(Z,M){return M.max-Z.max}class rs{constructor(M,k,q,J){this.p=new L.P(M,k),this.h=q,this.d=function(X,Q){let ie=!1,ne=1/0;for(let le=0;le<Q.length;le++){const ye=Q[le];for(let Ee=0,Le=ye.length,Ne=Le-1;Ee<Le;Ne=Ee++){const Ge=ye[Ee],ut=ye[Ne];Ge.y>X.y!=ut.y>X.y&&X.x<(ut.x-Ge.x)*(X.y-Ge.y)/(ut.y-Ge.y)+Ge.x&&(ie=!ie),ne=Math.min(ne,L.fO(X,Ge,ut))}}return(ie?1:-1)*Math.sqrt(ne)}(this.p,J),this.max=this.d+this.h*Math.SQRT2}}const ns=Object.keys;function ei(Z){return Z.imagePrimary!==void 0&&Z.top!==void 0&&Z.bottom!==void 0&&Z.left!==void 0&&Z.right!==void 0}function Ri(Z){return!Z.imagePrimary.stretchX}function gr(Z){return!Z.imagePrimary.stretchY}function js(Z){return{width:Z.right-Z.left,height:Z.bottom-Z.top}}const hi=Number.POSITIVE_INFINITY;function Ao(Z,M,k,q,J,X){const Q=ei(Z)&&Z.collisionPadding?Z.collisionPadding:[0,0,0,0],ie={top:Z.top-Q[1],bottom:Z.bottom+Q[3],left:Z.left-Q[0],right:Z.right+Q[2],scaled:!1};return q!==void 0&&function(ne,le){ne.top*=le,ne.bottom*=le,ne.left*=le,ne.right*=le,ne.scaled=!0}(ie,q),X&&(ie.left+=X[0],ie.right+=X[0],ie.top+=X[1],ie.bottom+=X[1]),k&&function(ne,le,ye){if(!le)return;const Ee=L.au(le),Le=new L.P(ye?ye[0]:0,ye?ye[1]:0),Ne=new L.P(ne.left,ne.top),Ge=new L.P(ne.right,ne.top),ut=new L.P(ne.left,ne.bottom),nt=new L.P(ne.right,ne.bottom);Ne._rotateAround(Ee,Le),Ge._rotateAround(Ee,Le),ut._rotateAround(Ee,Le),nt._rotateAround(Ee,Le),ne.left=Math.min(Ne.x,Ge.x,ut.x,nt.x),ne.right=Math.max(Ne.x,Ge.x,ut.x,nt.x),ne.top=Math.min(Ne.y,Ge.y,ut.y,nt.y),ne.bottom=Math.max(Ne.y,Ge.y,ut.y,nt.y)}(ie,k,J),M?{top:Math.min(M.top,ie.top),bottom:Math.max(M.bottom,ie.bottom),left:Math.min(M.left,ie.left),right:Math.max(M.right,ie.right),scaled:M.scaled||ie.scaled}:ie}function oa(Z,M,k,q,J,X,Q,ie=1,ne,le,ye,Ee,Le,Ne,Ge,ut,nt){Z.createArrays(),Z.tilePixelRatio=L.a2/(512*Z.overscaling),Z.compareText={},Z.iconsNeedLinear=!1;const Qe=Z.layers[0].layout,gt=Z.layers[0]._unevaluatedLayout._values,at={};at.scaleFactor=ie,at.textSizeScaleRange=Qe.get("text-size-scale-range"),at.iconSizeScaleRange=Qe.get("icon-size-scale-range");const[It,Nt]=at.textSizeScaleRange,[Ut,Gt]=at.iconSizeScaleRange;at.textScaleFactor=L.b0(at.scaleFactor,It,Nt),at.iconScaleFactor=L.b0(at.scaleFactor,Ut,Gt);const At=gt["text-size"],xi=gt["icon-size"];if(Z.textSizeData.kind==="composite"){const{minZoom:zt,maxZoom:di}=Z.textSizeData;at.compositeTextSizes=[At.possiblyEvaluate(new L.ai(zt,{worldview:ye}),X),At.possiblyEvaluate(new L.ai(di,{worldview:ye}),X)]}if(Z.iconSizeData.kind==="composite"){const{minZoom:zt,maxZoom:di}=Z.iconSizeData;at.compositeIconSizes=[xi.possiblyEvaluate(new L.ai(zt,{worldview:ye}),X,Ee),xi.possiblyEvaluate(new L.ai(di,{worldview:ye}),X,Ee)]}at.layoutTextSize=At.possiblyEvaluate(new L.ai(Q+1,{worldview:ye}),X),at.layoutIconSize=xi.possiblyEvaluate(new L.ai(Q+1,{worldview:ye}),X,Ee),at.textMaxSize=At.possiblyEvaluate(new L.ai(18,{worldview:ye}),X);const fi=Qe.get("symbol-placement"),Bt=Qe.get("text-rotation-alignment")==="map"&&fi!=="point",Ht=Qe.get("text-size");let Ct=!1;const Zt=[],pi=Le!=null&&Le!==0;for(const zt of Z.features){if(pi&&zt.properties&&ut&&ut(zt.properties,Le))continue;let di=65535;if(Z.hdExt&&zt.properties&&Object.hasOwn(zt.properties,L.fP)){const Ci=+zt.properties[L.fP];if(!Number.isNaN(Ci)){const ar=Z.hdExt.resolveRoadElevation(zt,Ci);if(ar==="defer")continue;di=ar}}const yr=Qe.get("text-font").evaluate(zt,{},X).join(","),vi=Ht.evaluate(zt,{},X)*at.textScaleFactor,dr=at.layoutTextSize.evaluate(zt,{},X)*at.textScaleFactor,Qi=at.layoutIconSize.evaluate(zt,{},X,Ee)*at.iconScaleFactor,Si={horizontal:{},vertical:void 0},Li=zt.text;let Ii,nr=[0,0];if(Li){const Ci=Li.toString(),ar=Qe.get("text-letter-spacing").evaluate(zt,{},X)*L.d1,kr=Qe.get("text-line-height").evaluate(zt,{},X)*L.d1,Pn=L.fQ(Ci)?ar:0,vn=Qe.get("text-anchor").evaluate(zt,{},X),rn=Qe.get("text-variable-anchor");if(!rn){const or=Qe.get("text-radial-offset").evaluate(zt,{},X);if(or)nr=L.cN(vn,[or*L.d1,hi]);else{const bn=Qe.get("text-offset").evaluate(zt,{},X);nr=[bn[0]*L.d1,bn[1]*L.d1]}}let $r=Bt?"center":Qe.get("text-justify").evaluate(zt,{},X);const so=fi==="point",Wo=so?Qe.get("text-max-width").evaluate(zt,{},X)*L.d1:1/0,Hn=or=>{Z.allowVerticalPlacement&&L.fR(Ci)&&(Si.vertical=br(Li,M,k,J,yr,Wo,kr,vn,or,Pn,nr,L.cL.vertical,!0,dr,vi,ne,at.textScaleFactor))};if(!Bt&&rn){const or=$r==="auto"?rn.map(Oi=>L.cO(Oi)):[$r];let bn=!1;for(let Oi=0;Oi<or.length;Oi++){const Tr=or[Oi];if(!Si.horizontal[Tr])if(bn)Si.horizontal[Tr]=Si.horizontal[0];else{const ao=br(Li,M,k,J,yr,Wo,kr,"center",Tr,Pn,nr,L.cL.horizontal,!1,dr,vi,ne,at.textScaleFactor);ao&&(Si.horizontal[Tr]=ao,bn=ao.positionedLines.length===1)}}Hn("left")}else{if($r==="auto"&&($r=L.cO(vn)),so||Qe.get("text-writing-mode").includes("horizontal")||!L.fR(Ci)){const or=br(Li,M,k,J,yr,Wo,kr,vn,$r,Pn,nr,L.cL.horizontal,!1,dr,vi,ne,at.textScaleFactor);or&&(Si.horizontal[$r]=or)}Hn(so?"left":$r)}}let Hr,Zr,fr,ro,Ai,gi,Yr=!1;const wr=Qe.get("icon-text-fit").evaluate(zt,{},X);if(zt.icon&&zt.icon.hasPrimary()){const Ci=L.fS(zt.icon,Z.iconSizeData,gt["icon-size"],X,Z.zoom,zt,ne,at.iconScaleFactor,ye,Ee);Hr=Ci.iconPrimary,fr=Ci.iconSecondary;const ar=Hr.toString();if(Zr=q.get(ar),Zr&&(Ai=Qe.get("icon-offset").evaluate(zt,{},X),gi=Qe.get("icon-anchor").evaluate(zt,{},X),Ii=L.fT(J.get(ar),fr?J.get(fr.toString()):void 0,Ai,gi),Yr=Zr.sdf,Z.sdfIcons===void 0?Z.sdfIcons=Zr.sdf:Z.sdfIcons!==Zr.sdf&&L.w("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Zr.pixelRatio!==Z.pixelRatio||Qe.get("icon-rotate").constantOr(1)!==0)&&(Z.iconsNeedLinear=!0)),fr){const kr=fr.toString();ro=q.get(kr)}}Ct=Ct||!(!zt.icon||!zt.icon.hasSecondary());const Vt=Gs(Si.horizontal)||Si.vertical;Z.iconsInText||(Z.iconsInText=!!Vt&&Vt.iconsInText);const $i=L.fU(dr,at.textScaleFactor),{defaultShapedIcon:Or,verticallyShapedIcon:Rn}=it(Z,Ii,Qe,zt,X,Si,$i,Ai,wr);wr!=="none"&&Ii&&(Ri(Ii)||gr(Ii))&&(Ss(Zr,Hr,Ii,Or,wr,le,q,J),Ss(ro,fr,Ii,Or,wr,le,q,J),Rn&&(Ss(Zr,Hr,Ii,Rn,wr,le,q,J),Ss(ro,fr,Ii,Rn,wr,le,q,J))),Ii=Or;const{iconBBox:tn,iconVerticalBBox:Br,textBBox:no,textVerticalBBox:oo}=Rc(Z,Ii,Rn,Qe,zt,X,Qi,Ai,at,J,gi,Si,dr,nr,Ee);Zt.push({feature:zt,shapedTextOrientations:Si,shapedText:Vt,shapedIcon:Ii,iconPrimary:Hr,iconSecondary:fr,iconOffset:Ai,iconAnchor:gi,verticallyShapedIcon:Rn,layoutTextSize:dr,layoutIconSize:Qi,textOffset:nr,isSDFIcon:Yr,iconTextFit:wr,iconCollisionBounds:tn,iconVerticalCollisionBounds:Br,textCollisionBounds:no,textVerticalCollisionBounds:oo,elevationFeatureIndex:di})}return Z.hdExt&&Z.hdExt.clearWorkerState(),{featureData:Zt,sizes:at,hasAnySecondaryIcon:Ct,textAlongLine:Bt,symbolPlacement:fi,coverageFrcMask:Le,coveragePolygons:Ne,coverageTileZoom:Ge,isFeatureCoveredByFrcMask:ut,symbolAnchorInFrcCoverage:nt}}function Rc(Z,M,k,q,J,X,Q,ie,ne,le,ye,Ee,Le,Ne,Ge){const ut=Z.layers[0],nt=ut.appearances;if(nt.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Qe={iconBBox:null,iconVerticalBBox:null},gt={textBBox:null,textVerticalBBox:null},{baseIconRotate:at,baseTextRotate:It,iconScaleFactor:Nt}=function(Gt,At,xi){const fi=Gt.get("icon-rotate").evaluate(At,{},xi),Bt=Gt.get("text-rotate").evaluate(At,{},xi),[Ht,Ct]=Gt.get("icon-size-scale-range");return{baseIconRotate:fi,baseTextRotate:Bt,iconScaleFactor:L.b0(1,Ht,Ct)}}(q,J,X);M&&(Qe.iconBBox=Ao(M,Qe.iconBBox,at),k)&&(Qe.iconVerticalBBox=Ao(k,Qe.iconVerticalBBox,at+90));const Ut=Gs(Ee.horizontal);Ut&&(gt.textBBox=Ao(Ut,gt.textBBox,It,1,Ne)),Ee.vertical&&(gt.textVerticalBBox=Ao(Ee.vertical,gt.textVerticalBBox,It+90,1,Ne));for(const Gt of nt)Gt.hasIconLayoutProperties()&&os(Qe,Z,ut,Gt,J,X,ie,at,Q,ne,M,le,Nt,ye,Ge),Gt.hasTextLayoutProperties()&&Ou(gt,ut,Gt,J,X,Ne,It,Le,Ut,Ee.vertical);return{iconBBox:Qe.iconBBox,iconVerticalBBox:Qe.iconVerticalBBox,textBBox:gt.textBBox,textVerticalBBox:gt.textVerticalBBox}}function os(Z,M,k,q,J,X,Q,ie,ne,le,ye,Ee,Le,Ne,Ge){const{appearanceIconOffset:ut,appearanceIconRotate:nt,appearanceIconSize:Qe}=L.fY(q,k,J,X,Q,ie,ne,le.iconScaleFactor);let gt=null,at=null,It=null;q.hasLayoutProperty("icon-image")?It=Pi(M,k,q,J,X,Ee,Le,Ge):ye&&(It=ye.imagePrimary),It&&(gt=L.fT(It,null,ut,Ne),M.allowVerticalPlacement&&(at=gt));const Nt=ne>0?Qe/ne:1;gt&&(Z.iconBBox=Ao(gt,Z.iconBBox,nt,Nt!==1?Nt:void 0)),at&&(Z.iconVerticalBBox=Ao(at,Z.iconVerticalBBox,nt+90,Nt!==1?Nt:void 0))}function Pi(Z,M,k,q,J,X,Q,ie){let ne=null;const le=M.getAppearanceValueAndResolveTokens(k,"icon-image",q,J,ie);if(le){const ye=Z.getResolvedImageFromTokens(le),Ee=k.hasLayoutProperty("icon-size")?k.getUnevaluatedLayoutProperty("icon-size"):M._unevaluatedLayout._values["icon-size"],Le=L.f$(Z.zoom,Ee,Z.worldview,ie),Ne=L.fS(ye,Le,Ee,J,Z.zoom,q,Z.pixelRatio,Q,Z.worldview,ie);ne=X.get(Ne.iconPrimary.toString())}return ne}function Ou(Z,M,k,q,J,X,Q,ie,ne,le){const{appearanceTextOffset:ye,appearanceTextRotate:Ee,appearanceTextSize:Le}=L.fZ(k,M,q,J,X,Q,ie),Ne=Le/ie,Ge=[(ye[0]-X[0])*Ne,(ye[1]-X[1])*Ne],ut=Ge[0]!==0||Ge[1]!==0;ne&&(Z.textBBox=Ao(ne,Z.textBBox,Ee,Ne,ye,ut?Ge:void 0)),le&&(Z.textVerticalBBox=Ao(le,Z.textVerticalBBox,Ee+90,Ne,ye,ut?Ge:void 0))}function Ss(Z,M,k,q,J,X,Q,ie){if(!Z||!Z.usvg)return;const ne=js(k),le=js(q),ye=J!=="both"&&J!=="width"||!Ri(k)?1:le.width/ne.width,Ee=J!=="both"&&J!=="height"||!gr(k)?1:le.height/ne.height;M.scaleSelf(ye,Ee);const Le=M.toString();X.set(Le,M),Q.set(Le,Z);const{imagePosition:Ne}=L.fW(Le,Z,L.fX);ie.set(Le,Ne)}function Qn(Z,M,k){if(!M)return;const q=k.get(Z.toString()),J=k.get(M.toString());q&&J&&(q.paddedRect.w===J.paddedRect.w&&q.paddedRect.h===J.paddedRect.h||L.w(`Mismatch in icon variant sizes: ${Z.toString()} and ${M.toString()}`),q.usvg!==J.usvg&&L.w(`Mismatch in icon variant image types: ${Z.id} and ${M.id}`))}function Pc(Z,M,k,q,J,X,Q,ie,ne,le){Z.iconAtlasPositions=le.iconPositions;const{featureData:ye,sizes:Ee,textAlongLine:Le,symbolPlacement:Ne,coveragePolygons:Ge,coverageTileZoom:ut,symbolAnchorInFrcCoverage:nt}=M,Qe=M.hasAnySecondaryIcon||Z.hasAnySecondaryIcon;for(const gt of ye){const{shapedIcon:at,verticallyShapedIcon:It,feature:Nt,shapedTextOrientations:Ut,shapedText:Gt,layoutTextSize:At,textOffset:xi,isSDFIcon:fi,iconPrimary:Bt,iconSecondary:Ht,iconTextFit:Ct,iconOffset:Zt,iconCollisionBounds:pi,iconVerticalCollisionBounds:zt,textCollisionBounds:di,elevationFeatureIndex:yr}=gt;Zo(at,le.iconPositions,Bt,Ht),Zo(It,le.iconPositions,Bt,Ht),Ul(Ut,le.iconPositions),Qn(Bt,Ht,le.iconPositions),(Gt||at)&&Mn(Z,Nt,Ut,at,It,ne,Ee,At,0,xi,fi,q,J,Q,ie,Qe,Ct,Zt,Le,Ne,pi,zt,di,0,0,Ge,ut,nt,yr)}k&&Z.generateCollisionDebugBuffers(X,Z.collisionBoxArray,Ee.textScaleFactor),Z.text.uboBinder&&Z.text.uboBinder.finalize(),Z.icon.uboBinder&&Z.icon.uboBinder.finalize()}function Zo(Z,M,k,q){if(!Z)return;const J=M.get(k.toString());if(J&&(Z.imagePrimary=J),q){const X=M.get(q.toString());Z.imageSecondary=X}}function Ul(Z,M){for(const k in Z.horizontal)lr(Z.horizontal[k],M);lr(Z.vertical,M)}function lr(Z,M){if(Z){for(const k of Z.positionedLines)for(const q of k.positionedGlyphs)if(q.image!==null){const J=q.image.toString();q.rect=M.get(J).paddedRect}}}function it(Z,M,k,q,J,X,Q,ie,ne){const le=Gs(X.horizontal)||X.vertical,ye=k.get("icon-text-fit-padding").evaluate(q,{},J);let Ee,Le=M;return M&&ne!=="none"&&(Z.allowVerticalPlacement&&X.vertical&&(Ee=L.fV(M,X.vertical,ne,ye,ie,Q)),le&&(Le=L.fV(M,le,ne,ye,ie,Q))),{defaultShapedIcon:Le,verticallyShapedIcon:Ee}}function Mn(Z,M,k,q,J,X,Q,ie,ne,le,ye,Ee,Le,Ne,Ge,ut,nt,Qe,gt,at,It,Nt,Ut,Gt,At,xi,fi,Bt,Ht=65535){let Ct=Q.textMaxSize.evaluate(M,{},Le);Ct===void 0?Ct=ie*Q.textScaleFactor:Ct*=Q.textScaleFactor;const Zt=Z.layers[0].layout,pi=L.d1,zt=L.fU(ie,Q.textScaleFactor),di=Gs(k.horizontal)||k.vertical,yr=Z.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),vi=Z.getAppearanceFeatureData(M.index);(nt!=="none"||yr)&&vi&&(vi.textShaping=di,vi.iconTextFitPadding=Zt.get("icon-text-fit-padding").evaluate(M,{},Le),vi.fontScale=zt,vi.textScaleFactor=Q.textScaleFactor);const dr=Ne.name==="globe",Qi=Z.tilePixelRatio*Ct/pi,Si=(fr=Z.overscaling,Z.zoom>18&&fr>2&&(fr>>=1),Math.max(L.a2/(512*fr),1)*Zt.get("symbol-spacing")),Li=Zt.get("text-padding")*Z.tilePixelRatio,Ii=Zt.get("icon-padding")*Z.tilePixelRatio,nr=L.au(Zt.get("text-max-angle")),Hr=Zt.get("icon-rotation-alignment")==="map"&&at!=="point",Zr=Si/2;var fr;Z.hasAnyIconTextFit===!1&&nt!=="none"&&(Z.hasAnyIconTextFit=!0);const ro=(Ai,gi,Yr)=>{if(gi.x<0||gi.x>=L.a2||gi.y<0||gi.y>=L.a2||xi&&xi.length>0&&M.properties&&Bt&&Bt(xi,M.properties,gi,Le,fi))return;let wr=null;if(dr){const{x:Vt,y:$i,z:Or}=Ne.projectTilePoint(gi.x,gi.y,Yr);wr={anchor:new Kn(Vt,$i,Or,0,void 0),up:Ne.upVector(Yr,gi.x,gi.y)}}(function(Vt,$i,Or,Rn,tn,Br,no,oo,Ci,ar,kr,Pn,vn,rn,$r,so,Wo,Hn,or,bn,Oi,Tr,ao,As,hn,il,Mo,wn,Ro,Xo,Dn,Er){const Yo=Vt.addToLineVertexArray($i,Rn);let ds,Cs,lt,Xs,Pt,Ms,Zu,$u=0,Tn=0,da=0,dn=0,rl=-1,fa=-1;const st={};let ti=L.dc("");const $t=Or?Or.anchor:$i,nn=wn!=="none";let lo=0,qt=0;if(Ci._unevaluatedLayout.getValue("text-radial-offset")===void 0){const ji=Ci.layout.get("text-offset").evaluate(Oi,{},hn);lo=ji[0]*L.d1,qt=ji[1]*L.d1}else lo=Ci.layout.get("text-radial-offset").evaluate(Oi,{},hn)*L.d1,qt=hi;if(Vt.allowVerticalPlacement&&tn.vertical){const ji=tn.vertical;if($r)Ms=Co(ji),oo&&(Zu=Co(oo));else{const Bi=Ci.layout.get("text-rotate").evaluate(Oi,{},hn)+90;lt=sa(ar,$t,$i,kr,Pn,vn,ji,rn,Bi,so,Er),oo&&(Xs=sa(ar,$t,$i,kr,Pn,vn,oo,Hn,Bi,null,Dn))}}if(Br){const ji=Ci.layout.get("icon-rotate").evaluate(Oi,{},hn),Bi=L.g0(Br,ji,ao,nn,Tr.iconScaleFactor),Po=oo?L.g0(oo,ji,ao,nn,Tr.iconScaleFactor):void 0;Cs=sa(ar,$t,$i,kr,Pn,vn,Br,Hn,ji,null,Xo);const Ln=function(Sr,uo,fn,Uc,Ys,Nr,Do,Ko,xr){const ec=Sr.layers[0],Tt=ec.appearances;let Zn=uo.length;if(fn&&(Zn=Math.max(Zn,fn.length)),Tt.length===0)return Zn;const[_a,ol]=Uc.get("icon-size-scale-range"),ga=L.b0(1,_a,ol);for(const tc of Tt)if(tc.hasLayoutProperty("icon-image")){const ya=Pi(Sr,ec,tc,Ys,Nr,Do,ga,xr);ya&&(Zn=Math.max(Zn,L.g2(ya)))}return Zn}(Vt,Bi,Po,Ci.layout,Oi,hn,Vt.iconAtlasPositions,0,As);$u=4*Ln;const Jl=Ci.layout.get("icon-size").evaluate(Oi,{},hn,As),nl=Tr.compositeIconSizes?Tr.compositeIconSizes[0].evaluate(Oi,{},hn,As):0,Ql=Tr.compositeIconSizes?Tr.compositeIconSizes[1].evaluate(Oi,{},hn,As):0,ma=L.g1(Vt.layerIds[0],Vt.iconSizeData,Jl,Br.imagePrimary.usvg?1:Tr.iconScaleFactor,nl,Ql);Vt.addSymbols(Vt.icon,Bi,ma,bn,or,Oi,void 0,Or,$i,Yo.lineStartIndex,Yo.lineLength,-1,As,hn,il,Mo,Vt.symbolInstances.length,Ln),rl=Vt.icon.placedSymbolArray.length-1,Po&&(Tn=4*Ln,Vt.addSymbols(Vt.icon,Po,ma,bn,or,Oi,L.cL.vertical,Or,$i,Yo.lineStartIndex,Yo.lineLength,-1,As,hn,il,Mo,Vt.symbolInstances.length,Ln),fa=Vt.icon.placedSymbolArray.length-1)}for(const ji in tn.horizontal){const Bi=ji,Po=tn.horizontal[Bi];ds||(ti=L.dc(Po.text),$r?Pt=Co(Po):ds=sa(ar,$t,$i,kr,Pn,vn,Po,rn,Ci.layout.get("text-rotate").evaluate(Oi,{},hn),so,Er));const Ln=Po.positionedLines.length===1;if(da+=jl(Vt,Or,$i,Po,no,Ci,$r,Oi,so,Yo,tn.vertical?L.cL.horizontal:L.cL.horizontalOnly,Ln?ns(tn.horizontal):[Bi],st,rl,Tr,As,hn,Vt.symbolInstances.length,il),Ln)break}tn.vertical&&(dn+=jl(Vt,Or,$i,tn.vertical,no,Ci,$r,Oi,so,Yo,L.cL.vertical,["vertical"],st,fa,Tr,As,hn,Vt.symbolInstances.length,il));let co=-1;const fs=(ji,Bi)=>ji?Math.max(ji,Bi):Bi;co=fs(Pt,co),co=fs(Ms,co),co=fs(Zu,co);const pa=co>-1?1:0;Vt.glyphOffsetArray.length>=65535&&L.w("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Oi.sortKey!==void 0&&Vt.addToSortKeyRanges(Vt.symbolInstances.length,Oi.sortKey),Vt.symbolInstances.emplaceBack($i.x,$i.y,$t.x,$t.y,$t.z,st.right>=0?st.right:-1,st.center>=0?st.center:-1,st.left>=0?st.left:-1,st.vertical>=0?st.vertical:-1,rl,fa,ti,ds!==void 0?ds:Vt.collisionBoxArray.length,ds!==void 0?ds+1:Vt.collisionBoxArray.length,lt!==void 0?lt:Vt.collisionBoxArray.length,lt!==void 0?lt+1:Vt.collisionBoxArray.length,Cs!==void 0?Cs:Vt.collisionBoxArray.length,Cs!==void 0?Cs+1:Vt.collisionBoxArray.length,Xs||Vt.collisionBoxArray.length,Xs?Xs+1:Vt.collisionBoxArray.length,kr,da,dn,$u,Tn,pa,0,lo,qt,co,0,nn?1:0,Ro)})(Z,gi,wr,Ai,k,q,X,J,Z.layers[0],Z.collisionBoxArray,M.index,M.sourceLayerIndex,Z.index,Li,gt,le,0,Ii,Hr,Qe,M,Q,ye,Ee,Le,Ge,ut,nt,Ht,It,Nt,Ut)};if(at==="line")for(const Ai of L.cZ(M.geometry,0,0,L.a2,L.a2)){const gi=Ha(Ai,Si,nr,k.vertical||di,q,pi,Qi,Z.overscaling,L.a2);for(const Yr of gi)di&&eo(Z,di.text,Zr,Yr)||ro(Ai,Yr,Le)}else if(at==="line-center"){for(const Ai of M.geometry)if(Ai.length>1){const gi=Fu(Ai,nr,k.vertical||di,q,pi,Qi);gi&&ro(Ai,gi,Le)}}else if(M.type==="Polygon")for(const Ai of L.f_(M.geometry,0)){const gi=Za(Ai,16);ro(Ai[0],new Kn(gi.x,gi.y,0,0,void 0),Le)}else if(M.type==="LineString")for(const Ai of M.geometry)ro(Ai,new Kn(Ai[0].x,Ai[0].y,0,0,void 0),Le);else if(M.type==="Point")for(const Ai of M.geometry)for(const gi of Ai)ro([gi],new Kn(gi.x,gi.y,0,0,void 0),Le)}function jl(Z,M,k,q,J,X,Q,ie,ne,le,ye,Ee,Le,Ne,Ge,ut,nt,Qe,gt){const at=L.g3(k,q,ne,X,Q,ie,J,Z.allowVerticalPlacement,void 0,Ge.textScaleFactor),It=X.layout.get("text-size").evaluate(ie,{},nt),Nt=Ge.compositeTextSizes?Ge.compositeTextSizes[0].evaluate(ie,{},nt):0,Ut=Ge.compositeTextSizes?Ge.compositeTextSizes[1].evaluate(ie,{},nt):0,Gt=L.g1(Z.layerIds[0],Z.textSizeData,It,Ge.textScaleFactor,Nt,Ut);Z.addSymbols(Z.text,at,Gt,ne,Q,ie,ye,M,k,le.lineStartIndex,le.lineLength,Ne,ut,nt,gt,!1,Qe,at.length);for(const At of Ee)Le[At]=Z.text.placedSymbolArray.length-1;return 4*at.length}function Gs(Z){for(const M in Z)return Z[M];return null}function sa(Z,M,k,q,J,X,Q,ie,ne,le,ye){let Ee,Le,Ne,Ge;if(Ee=ye?ye.top:Q.top,Le=ye?ye.bottom:Q.bottom,Ne=ye?ye.left:Q.left,Ge=ye?ye.right:Q.right,ei(Q)&&Q.collisionPadding){const ut=Q.collisionPadding;Ne-=ut[0],Ee-=ut[1],Ge+=ut[2],Le+=ut[3]}if(ne){const ut=new L.P(Ne,Ee),nt=new L.P(Ge,Ee),Qe=new L.P(Ne,Le),gt=new L.P(Ge,Le),at=L.au(ne);let It=new L.P(0,0);le&&(It=new L.P(le[0],le[1])),ut._rotateAround(at,It),nt._rotateAround(at,It),Qe._rotateAround(at,It),gt._rotateAround(at,It),Ne=Math.min(ut.x,nt.x,Qe.x,gt.x),Ge=Math.max(ut.x,nt.x,Qe.x,gt.x),Ee=Math.min(ut.y,nt.y,Qe.y,gt.y),Le=Math.max(ut.y,nt.y,Qe.y,gt.y)}return Z.emplaceBack(M.x,M.y,M.z,k.x,k.y,Ne,Ee,Ge,Le,ie,q,J,X),Z.length-1}function Co(Z){ei(Z)&&Z.collisionPadding&&(Z.top-=Z.collisionPadding[1],Z.bottom+=Z.collisionPadding[3]);const M=Z.bottom-Z.top;return M>0?Math.max(10,M):null}function eo(Z,M,k,q){const J=Z.compareText;if(M in J){const X=J[M];for(let Q=X.length-1;Q>=0;Q--)if(q.dist(X[Q])<k)return!0}else J[M]=[];return J[M].push(q),!1}const Dc=1*L.g5;class aa{constructor(M){const k={},q=[];for(const ie in M){const ne=M[ie],le=k[ie]={};for(const ye in ne.glyphs){const Ee=ne.glyphs[+ye];if(!Ee||Ee.bitmap.width===0||Ee.bitmap.height===0)continue;const Le=Ee.metrics.localGlyph?Dc:1,Ne={x:0,y:0,w:Ee.bitmap.width+2*Le,h:Ee.bitmap.height+2*Le};q.push(Ne),le[ye]=Ne}}const{w:J,h:X}=L.p(q),Q=new L.g4({width:J||1,height:X||1});for(const ie in M){const ne=M[ie];for(const le in ne.glyphs){const ye=ne.glyphs[+le];if(!ye||ye.bitmap.width===0||ye.bitmap.height===0)continue;const Ee=k[ie][le],Le=ye.metrics.localGlyph?Dc:1;L.g4.copy(ye.bitmap,Q,{x:0,y:0},{x:Ee.x+Le,y:Ee.y+Le},ye.bitmap)}}this.image=Q,this.positions=k}}function $a(Z){for(const M of Z)if(M.hdExt!=null||M.requiresHDRuntime)return!0;return!1}function Hs(Z){for(const M of Z)if(M.requiresStandardRuntime)return!0;return!1}function Xr(Z,M,k){const q=Z!=null&&!!L.g8&&L.g8(Z.sourceLayers,M,k);return{applies:q,frcMask:q&&Z?Z.frcMask:null,polygons:q&&Z?Z.polygons:null,tileZoom:q&&Z?Z.tileZoom:null}}L.fF(aa,"GlyphAtlas");class Zs{constructor(M){this.tileID=new L.bP(M.tileID.overscaledZ,M.tileID.wrap,M.tileID.canonical.z,M.tileID.canonical.x,M.tileID.canonical.y),this.tileZoom=M.tileZoom,this.uid=M.uid,this.zoom=M.zoom,this.lut=M.lut,this.canonical=M.tileID.canonical,this.pixelRatio=M.pixelRatio,this.tileSize=M.tileSize,this.source=M.source,this.scope=M.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=M.showCollisionBoxes,this.showElevationIdDebug=M.showElevationIdDebug,this.collectResourceTiming=!!M.request&&M.request.collectResourceTiming,this.promoteId=M.promoteId,this.renderSourceType=M.renderSourceType,this.frcCoverage=M.frcCoverage||null,this.elevation=M.elevation||null,this.crossSourceElevationEnabled=!!M.crossSourceElevationEnabled,this.terrainEnabled=!!M.terrainEnabled,this.deferRoadStructure=!1,this.tileTransform=L.bp(M.tileID.canonical,M.projection),this.projection=M.projection,this.worldview=M.worldview,this.localizableLayerIds=M.localizableLayerIds,this.brightness=M.brightness,this.extraShadowCaster=!!M.extraShadowCaster,this.tessellationStep=M.tessellationStep,this.scaleFactor=M.scaleFactor,this.worldview=M.worldview,this.indoor=M.indoor}isLayerActiveForTile(M){return!(this.renderSourceType===L.bR.Symbol&&M.type!=="symbol"||this.renderSourceType===L.bR.FillExtrusion&&M.type!=="fill-extrusion"||this.renderSourceType===L.bR.Other&&(M.type==="symbol"||M.type==="fill-extrusion")||this.renderSourceType===L.bR.HdRoadElevation||M.minzoom&&this.zoom<Math.floor(M.minzoom)||M.maxzoom&&this.zoom>=M.maxzoom||M.visibility==="none")}parse(M,k,q,J,X,Q){this._parseAfterHD(M,k,q,J,X,Q)}_parseAfterHD(M,k,q,J,X,Q){let ie;if(this.status="parsing",this.data=M,this.renderSourceType===L.bR.HdRoadCoverage){const nt=M.layers[L.bU];ie=nt&&Ac?Ac(nt):[]}this.collisionBoxArray=new L.bt;const ne=new L.g6(Object.keys(M.layers).sort()),le=new L.fA(this.tileID,this.promoteId);le.bucketLayerIDs=[];const ye={},Ee=new L.g7(256,256),Le={featureIndex:le,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Ee,availableImages:q,brightness:this.brightness,scaleFactor:this.scaleFactor,showElevationIdDebug:this.showElevationIdDebug,elevationFeatures:void 0,elevationParams:this.elevation,crossSourceElevationEnabled:this.crossSourceElevationEnabled,terrainEnabled:this.terrainEnabled,activeFloors:void 0};this.indoor&&ai&&(Le.activeFloors=ai(M,this.indoor,X,this.canonical));const Ne=[],Ge=k.familiesBySource[this.source];if(this.renderSourceType===L.bR.HdRoadElevation){const nt=Xn&&Xn(M,this.canonical)||[],Qe=new aa({});return this.status="done",void Q(null,{buckets:[],containsHdExt:!1,containsStandardExt:!1,featureIndex:le,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Qe.image,lineAtlas:Ee,imageAtlas:null,brightness:this.brightness,parsedElevationFeatures:nt})}if(this.deferRoadStructure=!1,this.renderSourceType!==L.bR.HdRoadCoverage&&this.frcCoverage!=null&&!this.frcCoverage.resolved&&this.frcCoverage.frcMask===null){for(const nt in Ge)if(L.g8&&L.g8(this.frcCoverage.sourceLayers,this.source,nt)){this.deferRoadStructure=!0;break}}for(const nt in Ge){const Qe=M.layers[nt];if(!Qe)continue;let gt=!1,at=!1,It=!1,Nt=!1;for(const Bt of Ge[nt])Bt[0].type==="symbol"?gt=!0:Bt[0].type==="fill-extrusion"?at=!0:It=!0,Bt[0].is3D()&&Bt[0].type!=="model"&&(Nt=!0);if(this.extraShadowCaster&&!Nt||this.renderSourceType===L.bR.Symbol&&!gt||this.renderSourceType===L.bR.FillExtrusion&&!at||(this.renderSourceType===L.bR.Other||this.renderSourceType===L.bR.HdRoadCoverage)&&!It)continue;const Ut=this.frcCoverage!=null&&!!L.g8&&L.g8(this.frcCoverage.sourceLayers,this.source,nt);if(this.deferRoadStructure&&Ut)continue;Qe.version===1&&L.w(`Vector tile source "${this.source}" layer "${nt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Gt=ne.encode(nt),At=[],xi=this.localizableLayerIds&&this.localizableLayerIds.has(nt);let fi=!1;for(let Bt=0,Ht=0;Bt<Qe.length;Bt++){const Ct=Qe.feature(Bt),Zt=le.getId(Ct,nt),pi=Ct.properties?Ct.properties.worldview:null;if(xi&&this.worldview&&typeof pi=="string")if(pi==="all")Ct.properties.$localized=!0;else{if(!pi.split(",").includes(this.worldview))continue;Ct.properties.$localized=!0,Ct.properties.worldview=this.worldview}!fi&&Ct.properties&&Object.hasOwn(Ct.properties,L.fP)&&(fi=!0),Ut&&this.frcCoverage&&this.frcCoverage.frcMask&&Ct.properties&&L.g9&&L.g9(Ct.properties,this.frcCoverage.frcMask)||(At.push({feature:Ct,id:Zt,index:Ht,sourceLayerIndex:Gt}),Ht++)}fi&&!Le.elevationFeatures&&Xn&&(Le.elevationFeatures=Xn(M,this.canonical));for(const Bt of Ge[nt]){const Ht=Bt[0];if(this.extraShadowCaster&&(!Ht.is3D()||Ht.type==="model")||this.renderSourceType===L.bR.Symbol&&Ht.type!=="symbol"||this.renderSourceType===L.bR.FillExtrusion&&Ht.type!=="fill-extrusion"||!(this.renderSourceType!==L.bR.Other&&this.renderSourceType!==L.bR.HdRoadCoverage||Ht.type!=="symbol"&&Ht.type!=="fill-extrusion")||!this.isLayerActiveForTile(Ht))continue;const Ct=le.bucketLayerIDs.length;le.bucketLayerIDs.push(Bt.map(pi=>L.m(pi.id,pi.scope)));const Zt=()=>{Gl(Bt,this.zoom,Le.brightness,q,this.worldview,Le.activeFloors);const pi=ye[Ht.id]=Ht.createBucket({index:Ct,layers:Bt,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Gt,sourceLayerName:nt,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:J,worldview:this.worldview,localizable:xi,availableImages:q,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords});Dt&&Dt(pi,this.frcCoverage?this.frcCoverage.sourceLayers:null),pi.populate(At,Le,this.tileID.canonical,this.tileTransform)};Ht.mayUse("HD")||Ht.mayUse("Standard")?Ne.push(Ht.prepare().then(()=>Zt())):Zt()}}const ut=()=>{Ee.trim();const nt=!(!Le.elevationFeatures||!Le.elevationFeatures.some(Bt=>Bt.heightRange.min<0));let Qe,gt,at,It,Nt,Ut,Gt;const At={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},xi=()=>{if(Qe)return this.status="done",Q(Qe);if(this.extraShadowCaster){this.status="done";const Bt=Object.values(ye).filter(Ct=>!Ct.isEmpty()),Ht=Le.elevationFeatures;Q(null,{buckets:Bt,containsHdExt:$a(Bt),containsStandardExt:Hs(Bt),featureIndex:le,collisionBoxArray:null,hasTunnelGeometry:nt,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Le.brightness,hasDeferredElevationFeatures:!!Yi&&Yi(ye),parsedElevationFeatures:Ht,glyphMap:null,iconMap:null,glyphPositions:null})}else if(gt&&at&&It&&Gt){const Ht=new aa(gt),Ct=new Map;for(const[pi,zt]of at.entries()){const{imagePosition:di}=L.fW(pi,zt,L.fX);Ct.set(pi,di)}const Zt={};for(const pi in ye){const zt=ye[pi];if(zt instanceof L.bu){Gl(zt.layers,this.zoom,Le.brightness,q,this.worldview,Le.activeFloors);const di=Xr(this.frcCoverage,this.source,zt.layers[0].sourceLayer);Zt[pi]=oa(zt,gt,Ht.positions,at,Ct,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,Nt,this.worldview,q,di.frcMask,di.polygons,di.tileZoom,L.g9||null,Bl||null)}}Nt.size||Ut.size?this.rasterizeTask=X.sendCancelable("rasterizeImages",{scope:this.scope,iconTasks:Nt,patternTasks:Ut},{},(pi,zt)=>{if(!pi)for(const[di,yr]of zt.entries())at.has(di)&&at.set(di,Object.assign(at.get(di),{data:yr})),It.has(di)&&It.set(di,Object.assign(It.get(di),{data:yr}));fi(Zt,Ht,void 0,Gt)}):fi(Zt,Ht,void 0,Gt)}},fi=(Bt,Ht,Ct,Zt)=>{const pi=at.size>0||It.size>0,zt=Object.keys(Bt).length>0,di=Le.elevationFeatures;if(!pi&&!zt){this.status="done";const vi=Object.values(ye).filter(dr=>!dr.isEmpty());return void Q(null,{buckets:vi,containsHdExt:$a(vi),containsStandardExt:Hs(vi),featureIndex:le,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:nt,glyphAtlasImage:Ht.image,lineAtlas:Ee,imageAtlas:null,brightness:Le.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:ie,hasDeferredElevationFeatures:!!Yi&&Yi(ye),parsedElevationFeatures:di})}const yr=(vi,dr)=>{for(const Si in ye){const Li=ye[Si];if(Si in Bt)Pc(Li,Bt[Si],this.showCollisionBoxes,q,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,at,dr);else if(Li.hasPattern&&(Li instanceof L.bz||Li instanceof L.bA||Li instanceof L.aC)){Gl(Li.layers,this.zoom,Le.brightness,q,this.worldview,Le.activeFloors);const Ii=Object.fromEntries(dr.patternPositions);Li.addFeatures(Le,this.tileID.canonical,Ii,q,this.tileTransform,this.brightness)}}this.status="done";const Qi=Object.values(ye).filter(Si=>!Si.isEmpty());Q(null,{buckets:Qi,containsHdExt:$a(Qi),containsStandardExt:Hs(Qi),featureIndex:le,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:nt,glyphAtlasImage:Ht.image,lineAtlas:Ee,imageAtlas:vi,brightness:Le.brightness,hasDeferredRoadStructure:this.deferRoadStructure,frcCoveragePolygons:ie,hasDeferredElevationFeatures:!!Yi&&Yi(ye),parsedElevationFeatures:di})};if(pi){const vi=new Map,dr=L.gb(at,vi),Qi=L.gb(It,vi),Si=new L.gc(dr,Qi,Zt,this.lut,this.scope,vi);X.send("checkAtlasCache",{descriptor:Si,scope:this.scope}).then(Li=>{let Ii,nr;if(Li)Ii=new L.gd(Li.sourceHash),nr=Li;else{const Hr=new L.ge(at,It,this.lut,Zt,this.scope);Ii=Hr,nr=Hr}yr(Ii,nr)}).catch(Li=>{Li.name!=="AbortError"&&L.w(`[Worker] Error checking atlas cache: ${Li.message}`);const Ii=new L.ge(at,It,this.lut,Zt,this.scope);yr(Ii,Ii)})}else yr(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const Bt=L.ga(Le.glyphDependencies,Zt=>Object.keys(Zt).map(Number));Object.keys(Bt).length?X.send("getGlyphs",{uid:this.uid,stacks:Bt},{metadata:At}).then(Zt=>{Qe||(gt=Zt,xi())}).catch(Zt=>{Qe||(Qe=Zt,xi())}):gt={},Gt=new Map;const Ht=Array.from(Le.iconDependencies.keys()).map(Zt=>L.I.parse(Zt)),Ct=Array.from(Le.patternDependencies.keys()).map(Zt=>L.I.parse(Zt));Ht.length||Ct.length?X.send("getImages",{icons:Ht,patterns:Ct,source:this.source,scope:this.scope,tileID:this.tileID},{metadata:At}).then(Zt=>{if(!Qe){at=new Map,It=new Map,Nt=this.updateImageMapAndGetImageTaskQueue(at,Zt.images,Le.iconDependencies),Ut=this.updateImageMapAndGetImageTaskQueue(It,Zt.images,Le.patternDependencies);for(const[pi,zt]of Zt.versions.entries())Gt.set(pi,zt);xi()}}).catch(Zt=>{Qe||(Qe=Zt,xi())}):(at=new Map,It=new Map,Nt=new Map,Ut=new Map)}Lr&&Lr({buckets:ye,data:M,sourceLayerCoder:ne,canonical:this.tileID.canonical,options:Le}),xi()};Ne.length>0?Promise.allSettled(Ne).then(ut).catch(Q):ut()}updateParameters(M){this.scaleFactor=M.scaleFactor,this.showCollisionBoxes=M.showCollisionBoxes,this.showElevationIdDebug=M.showElevationIdDebug,this.projection=M.projection,this.brightness=M.brightness,this.tileTransform=L.bp(M.tileID.canonical,M.projection),this.extraShadowCaster=M.extraShadowCaster,this.lut=M.lut,this.worldview=M.worldview,this.indoor=M.indoor,this.frcCoverage=M.frcCoverage||null,this.elevation=M.elevation||null,this.terrainEnabled=!!M.terrainEnabled}updateImageMapAndGetImageTaskQueue(M,k,q){const J=new Map;for(const X of k.keys()){const Q=q.get(X)||[];for(const ie of Q){const ne=ie.toString(),le=k.get(ie.id.toString());le.usvg?J.has(ne)||(J.set(ne,ie),M.set(ne,{...le})):M.set(ne,le)}}return J}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.abort()}}function Gl(Z,M,k,q,J,X){const Q=new L.ai(M,{brightness:k,worldview:J,activeFloors:X});for(const ie of Z)ie.recalculate(Q,q)}class ss extends L.E{constructor({actor:M,layerIndex:k,availableImages:q,availableModels:J,isSpriteLoaded:X,tileProvider:Q,brightness:ie,maxUniformBufferBindings:ne,maxUniformBlockSizeDwords:le}){super(),this.actor=M,this.layerIndex=k,this.availableImages=q,this.availableModels=J,this.loadVectorData=L.ch,this.tileProvider=Q,this.loading={},this.loaded={},this.deduped=new L.cc(M.scheduler),this.isSpriteLoaded=X,this.scheduler=M.scheduler,this.brightness=ie,this.maxUniformBufferBindings=ne,this.maxUniformBlockSizeDwords=le}loadTileData(M,k){if(!this.tileProvider)return this.loadVectorData(M,k);const q=new AbortController;return this.loadTileWithProvider(this.tileProvider,M,q,k),()=>q.abort()}async loadTileWithProvider(M,k,q,J){const{z:X,x:Q,y:ie}=k.tileID.canonical;try{const ne=await M.loadTile({z:X,x:Q,y:ie},{request:k.request,signal:q.signal});if(q.signal.aborted)return;if(ne==null){const ye=new Error("Tile not found");return ye.status=404,J(ye)}if(ne.data==null)return J(null,null);if(ne.data instanceof ImageBitmap)return J(new Error("Vector tiles require ArrayBuffer data"));const le=new Headers;ne.expires&&le.set("expires",ne.expires),ne.cacheControl&&le.set("cache-control",ne.cacheControl),J(null,{rawData:ne.data,headers:le})}catch(ne){if(q.signal.aborted)return;J(ne instanceof Error?ne:new Error(String(ne)))}}_fetchTileData(M,k){return new Promise((q,J)=>{M.abort=this.loadTileData(k,(X,Q)=>{X?J(X):q(Q)})})}async _parse(M,k){const q=!this.isSpriteLoaded;return q&&await this.once("isSpriteLoaded"),new Promise((J,X)=>{const Q=()=>M.parse(M.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(ie,ne)=>{ie?X(ie):J(ne)});q&&this.scheduler?this.scheduler.add(Q,{type:"parseTile",renderSourceType:k.renderSourceType,zoom:k.tileZoom}):Q()})}async loadTile(M){const k=M.uid,q=M&&M.request,J=q&&q.collectResourceTiming,X=this.loading[k]=new Zs(M);X.maxUniformBufferBindings=this.maxUniformBufferBindings,X.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords;const Q=(Ge,ut)=>{const nt=X.reloadCallback;nt&&(delete X.reloadCallback,Ge||!ut?nt(Ge,null):X.parse(X.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,nt))};let ie,ne;try{ie=await this._fetchTileData(X,M)}catch(Ge){ne=Ge}const le=!this.loading[k];if(delete this.loading[k],X.cancelRasterize(),ne||le||!ie){if(X.status="done",le||(this.loaded[k]=X),ne)throw ne;return null}const ye=ie.rawData;let Ee;X.vectorTile=ie.vectorTile||new L.gf(new L.cB(ye)),this.loaded=this.loaded||{},this.loaded[k]=X;try{Ee=await this._parse(X,M)}catch(Ge){throw Q(Ge),Ge}if(!Ee)return Q(null,null),null;const Le={};if(J){const Ge=Eo(q);Ge.length>0&&(Le.resourceTiming=JSON.parse(JSON.stringify(Ge)))}const Ne={rawTileData:ye.slice(0),headers:ie.headers,...Ee,...Le};return Q(null,Ee),Ne}async reloadTile(M){const k=this.loaded,q=M.uid;if(k&&k[q])return new Promise((J,X)=>{const Q=k[q];Q.updateParameters(M);const ie=(ne,le)=>{const ye=Q.reloadCallback;ye&&(delete Q.reloadCallback,Q.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ye)),ne?X(ne):J(le)};Q.status==="parsing"?Q.reloadCallback=ie:Q.status==="done"?Q.vectorTile?Q.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,ie):ie():J(void 0)})}abortTile(M){const k=M.uid,q=this.loading[k];q&&(q.abort&&q.abort(),delete this.loading[k])}removeTile(M){const k=this.loaded,q=M.uid;k&&k[q]&&delete k[q]}}class $s{constructor(M){this.tileProvider=M.tileProvider,this.loading={}}async loadTile(M){const k=M.uid,q=new AbortController;if(this.loading[k]={cancel:()=>q.abort()},this.tileProvider)return this.loadTileWithProvider(this.tileProvider,k,M,q);try{const{data:J,headers:X}=await L.cC(M.request,q.signal);if(!J)return null;const Q=await this.decodeTile(k,J,M.encoding);return Q.headers=X,Q}catch(J){if(q.signal.aborted)return null;throw J}finally{delete this.loading[k]}}async decodeTile(M,k,q){const J=k instanceof ImageBitmap?k:await createImageBitmap(new Blob([new Uint8Array(k)],{type:"image/png"})),X=1-(J.width-L.gg(J.width))/2,Q=X<1,ie=this.getImageData(J,X);return J.close(),{dem:new L.gh(M,ie,q,Q),borderReady:Q}}async loadTileWithProvider(M,k,q,J){const{z:X,x:Q,y:ie}=q.tileID.canonical;try{const ne=await M.loadTile({z:X,x:Q,y:ie},{request:q.request,signal:J.signal});if(J.signal.aborted)return null;if(ne==null){const Ee=new Error("Tile not found");throw Ee.status=404,Ee}if(ne.data==null)return null;const le=await this.decodeTile(k,ne.data,q.encoding);
3102if(J.signal.aborted)return null;const ye=new Headers;return ne.expires&&ye.set("expires",ne.expires),ne.cacheControl&&ye.set("cache-control",ne.cacheControl),le.headers=ye,le}catch(ne){if(J.signal.aborted)return null;throw ne}finally{delete this.loading[k]}}async reloadTile(M){}abortTile(M){const k=M.uid,q=this.loading[k];q&&(q.cancel(),delete this.loading[k])}removeTile(M){}getImageData(M,k){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(M.width,M.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=M.width,this.offscreenCanvas.height=M.height,this.offscreenCanvasContext.drawImage(M,0,0,M.width,M.height);const q=this.offscreenCanvasContext.getImageData(-k,-k,M.width+2*k,M.height+2*k);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),q}}const qa=L.gi.prototype.toGeoJSON;class Hl{constructor(M){this._feature=M,this.extent=L.a2,this.type=M.type,this.properties=M.tags,"id"in M&&!isNaN(M.id)&&(this.id=parseInt(M.id,10))}loadGeometry(){if(this._feature.type===1){const M=[];for(const k of this._feature.geometry)M.push([new L.P(k[0],k[1])]);return M}{const M=[];for(const k of this._feature.geometry){const q=[];for(const J of k)q.push(new L.P(J[0],J[1]));M.push(q)}return M}}toGeoJSON(M,k,q){return qa.call(this,M,k,q)}}class la{constructor(M,k){this.name=M,this.extent=L.a2,this.length=k.length,this._jsonFeatures=k}feature(M){return new Hl(this._jsonFeatures[M])}}class Wa{constructor(M){this.layers={},this.extent=L.a2;for(const k of Object.keys(M))this.layers[k]=new la(k,M[k])}}const as=64/4096;class Lc{constructor(){this.features=new Map}clear(){this.features.clear()}load(M=[],k){for(const q of M){const J=q.id;if(J==null)continue;let X=this.features.get(J);X&&this.updateCache(X,k),q.geometry?(X=ls(q),this.updateCache(X,k),this.features.set(J,X)):this.features.delete(J),this.updateCache(X,k)}}updateCache(M,k){for(const{canonical:q,uid:J}of Object.values(k)){const{z:X,x:Q,y:ie}=q;De(M,Math.pow(2,X),Q,ie)&&delete k[J]}}getTile(M,k,q){const J=Math.pow(2,M),X=[];for(const Q of this.features.values())De(Q,J,k,q)&&X.push(Bu(Q,J,k,q));return{features:X}}getFeatures(){return[...this.features.values()]}}function De({minX:Z,minY:M,maxX:k,maxY:q},J,X,Q){return Z<(X+1+as)/J&&M<(Q+1+as)/J&&k>(X-as)/J&&q>(Q-as)/J}function ls(Z){const{id:M,geometry:k,properties:q}=Z;if(!k)return;if(k.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:J,coordinates:X}=k,Q={id:M,type:1,geometry:[],tags:q,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},ie=Q.geometry;if(J==="Point")Xa(X,ie,Q);else if(J==="MultiPoint")for(const ne of X)Xa(ne,ie,Q);else if(J==="LineString")Q.type=2,qs(X,ie,Q);else if(J==="MultiLineString")Q.type=2,Zl(X,ie,Q);else if(J==="Polygon")Q.type=3,Zl(X,ie,Q,!0);else{if(J!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Q.type=3;for(const ne of X)Zl(ne,ie,Q,!0)}return Q}function Xa([Z,M],k,q){const J=L.a7(Z);let X=L.a8(M);X=X<0?0:X>1?1:X,k.push(J,X),q.minX=Math.min(q.minX,J),q.minY=Math.min(q.minY,X),q.maxX=Math.max(q.maxX,J),q.maxY=Math.max(q.maxY,X)}function qs(Z,M,k,q=!1,J=!1){const X=[];for(const Q of Z)Xa(Q,X,k);M.push(X),q&&function(Q,ie){let ne=0;for(let le=0,ye=Q.length,Ee=ye-2;le<ye;Ee=le,le+=2)ne+=(Q[le]-Q[Ee])*(Q[le+1]+Q[Ee+1]);if(ne>0===ie)for(let le=0,ye=Q.length;le<ye/2;le+=2){const Ee=Q[le],Le=Q[le+1];Q[le]=Q[ye-2-le],Q[le+1]=Q[ye-1-le],Q[ye-2-le]=Ee,Q[ye-1-le]=Le}}(X,J)}function Zl(Z,M,k,q=!1){for(let J=0;J<Z.length;J++)qs(Z[J],M,k,q,J===0)}function Bu(Z,M,k,q){const{id:J,type:X,geometry:Q,tags:ie}=Z,ne=[];if(X===1)(function(le,ye,Ee,Le,Ne){for(let Ge=0;Ge<le.length;Ge+=2){const ut=Math.round(L.a2*(le[Ge+0]*ye-Ee)),nt=Math.round(L.a2*(le[Ge+1]*ye-Le));Ne.push([ut,nt])}})(Q,M,k,q,ne);else if(X===2)for(const le of Q)ku(le,M,k,q,ne);else if(X===3)for(const le of Q)Ei(le,M,k,q,ne);return{id:J,type:X,geometry:ne,tags:ie}}function ku(Z,M,k,q,J){const Q=L.a2+128;let ie;for(let ne=0;ne<Z.length-2;ne+=2){let le=Math.round(L.a2*(Z[ne+0]*M-k)),ye=Math.round(L.a2*(Z[ne+1]*M-q)),Ee=Math.round(L.a2*(Z[ne+2]*M-k)),Le=Math.round(L.a2*(Z[ne+3]*M-q));const Ne=Ee-le,Ge=Le-ye;le<-128&&Ee<-128||(le<-128?(ye+=Math.round(Ge*((-128-le)/Ne)),le=-128):Ee<-128&&(Le=ye+Math.round(Ge*((-128-le)/Ne)),Ee=-128),ye<-128&&Le<-128||(ye<-128?(le+=Math.round(Ne*((-128-ye)/Ge)),ye=-128):Le<-128&&(Ee=le+Math.round(Ne*((-128-ye)/Ge)),Le=-128),le>=Q&&Ee>=Q||(le>=Q?(ye+=Math.round(Ge*((Q-le)/Ne)),le=Q):Ee>=Q&&(Le=ye+Math.round(Ge*((Q-le)/Ne)),Ee=Q),ye>=Q&&Le>=Q||(ye>=Q?(le+=Math.round(Ne*((Q-ye)/Ge)),ye=Q):Le>=Q&&(Ee=le+Math.round(Ne*((Q-ye)/Ge)),Le=Q),ie&&le===ie.at(-1)[0]&&ye===ie.at(-1)[1]||(ie=[[le,ye]],J.push(ie)),ie.push([Ee,Le])))))}}function Ei(Z,M,k,q,J){const X=(k-as)/M,Q=(q-as)/M,ie=(k+1+as)/M,ne=(q+1+as)/M;function le(Le,Ne){let Ge=0;return Le<X?Ge|=1:Le>ie&&(Ge|=2),Ne<Q?Ge|=4:Ne>ne&&(Ge|=8),Ge}let ye=[];for(let Le=1;Le<=8;Le*=2){let Ne=Z[Z.length-2],Ge=Z.at(-1),ut=!(le(Ne,Ge)&Le);for(let nt=0;nt<Z.length;nt+=2){const Qe=Z[nt],gt=Z[nt+1],at=!(le(Qe,gt)&Le);at!==ut&&(8&Le?ye.push(Ne+(Qe-Ne)*(ne-Ge)/(gt-Ge),ne):4&Le?ye.push(Ne+(Qe-Ne)*(Q-Ge)/(gt-Ge),Q):2&Le?ye.push(ie,Ge+(gt-Ge)*(ie-Ne)/(Qe-Ne)):1&Le&&ye.pu
3102sh(X,Ge+(gt-Ge)*(X-Ne)/(Qe-Ne))),at&&ye.push(Qe,gt),Ne=Qe,Ge=gt,ut=at}if(!(Z=ye).length||Le===8)break;ye=[]}const Ee=[];for(let Le=0;Le<ye.length;Le+=2)Ee.push([Math.round(L.a2*(ye[Le]*M-k)),Math.round(L.a2*(ye[Le+1]*M-q))]);Ee.length&&J.push(Ee)}function zr({name:Z,features:M},k){k.writeStringField(1,Z),k.writeVarintField(5,L.a2);const q=new Map,J=new Map,X={keys:q,values:J,feature:null};for(const Q of M)X.feature=Q,k.writeMessage(2,Ya,X);for(const Q of q.keys())k.writeStringField(3,Q);for(const Q of J.keys())k.writeMessage(4,Ws,Q)}function Ya(Z,M){const k=Z.feature;k.id!==void 0&&Number.isSafeInteger(+k.id)&&M.writeVarintField(1,+k.id),k.tags&&M.writeMessage(2,Nu,Z),M.writeVarintField(3,k.type),M.writeMessage(4,zc,k)}function Nu({keys:Z,values:M,feature:k},q){for(const J of Object.keys(k.tags)){let X=k.tags[J];if(X===null)continue;let Q=Z.get(J);Q===void 0&&(Q=Z.size,Z.set(J,Q)),q.writeVarint(Q);const ie=typeof X;ie!=="string"&&ie!=="boolean"&&ie!=="number"&&(X=JSON.stringify(X));let ne=M.get(X);ne===void 0&&(ne=M.size,M.set(X,ne)),q.writeVarint(ne)}}function un(Z,M){return(M<<3)+(7&Z)}function Un(Z){return Z<<1^Z>>31}function zc(Z,M){const{geometry:k,type:q}=Z;let J=0,X=0;if(q===1){M.writeVarint(un(1,k.length));for(const Q of k){const ie=Q[0]-J,ne=Q[1]-X;M.writeVarint(Un(ie)),M.writeVarint(Un(ne)),J+=ie,X+=ne}}else for(const Q of k){if(Q.length===0)continue;M.writeVarint(un(1,1));const ie=Q.length-(q===3?1:0);for(let ne=0;ne<ie;ne++){ne===1&&M.writeVarint(un(2,ie-1));const le=Q[ne][0]-J,ye=Q[ne][1]-X;M.writeVarint(Un(le)),M.writeVarint(Un(ye)),J+=le,X+=ye}q===3&&M.writeVarint(un(7,1))}}function Ws(Z,M){const k=typeof Z;k==="string"?M.writeStringField(1,Z):k==="boolean"?M.writeBooleanField(7,Z):k==="number"&&(Z%1!=0?M.writeDoubleField(3,Z):Z<0?M.writeSVarintField(6,Z):M.writeVarintField(5,Z))}const Ka={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:Z=>Z},Fc=Math.fround||(ca=new Float32Array(1),Z=>(ca[0]=+Z,ca[0]));var ca;class Vu{constructor(M){this.options=Object.assign(Object.create(Ka),M),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(M){const{log:k,minZoom:q,maxZoom:J}=this.options;k&&console.time("total time");const X=`prepare ${M.length} points`;k&&console.time(X),this.points=M;const Q=[];for(let ne=0;ne<M.length;ne++){const le=M[ne];if(!le.geometry)continue;const[ye,Ee]=le.geometry.coordinates,Le=Fc(Ja(ye)),Ne=Fc(ua(Ee));Q.push(Le,Ne,1/0,ne,-1,1),this.options.reduce&&Q.push(0)}let ie=this.trees[J+1]=this._createTree(Q);k&&console.timeEnd(X);for(let ne=J;ne>=q;ne--){const le=+Date.now();ie=this.trees[ne]=this._createTree(this._cluster(ie,ne)),k&&console.log("z%d: %d clusters in %dms",ne,ie.numItems,+Date.now()-le)}return k&&console.timeEnd("total time"),this}getClusters(M,k){let q=((M[0]+180)%360+360)%360-180;const J=Math.max(-90,Math.min(90,M[1]));let X=M[2]===180?180:((M[2]+180)%360+360)%360-180;const Q=Math.max(-90,Math.min(90,M[3]));if(M[2]-M[0]>=360)q=-180,X=180;else if(q>X){const Ee=this.getClusters([q,J,180,Q],k),Le=this.getClusters([-180,J,X,Q],k);return Ee.concat(Le)}const ie=this.trees[this._limitZoom(k)],ne=ie.range(Ja(q),ua(Q),Ja(X),ua(J)),le=ie.data,ye=[];for(const Ee of ne){const Le=this.stride*Ee;ye.push(le[Le+5]>1?Ot(le,Le,this.clusterProps):this.points[le[Le+3]])}return ye}getChildren(M){const k=this._getOriginId(M),q=this._getOriginZoom(M),J="No cluster with the specified id.",X=this.trees[q];if(!X)throw new Error(J);const Q=X.data;if(k*this.stride>=Q.length)throw new Error(J);const ie=this.options.radius/(this.options.extent*Math.pow(2,q-1)),ne=X.within(Q[k*this.stride],Q[k*this.stride+1],ie),le=[];for(const ye of ne){const Ee=ye*this.stride;Q[Ee+4]===M&&le.push(Q[Ee+5]>1?Ot(Q,Ee,this.clusterProps):this.points[Q[Ee+3]])}if(le.length===0)throw new Error(J);return le}getLeaves(M,k,q){const J=[];return this._appendLeaves(J,M,k=k||10,q=q||0,0),J}getTile(M,k,q){const J=this.trees[this._limitZoom(M)],X=Math.pow(2,M),{extent:Q,radius:ie}=this.options,ne=ie/Q,le=(q-ne)/X,ye=(q+1+ne)/X,Ee={features:[]};return this._addTileFeatures(J.range((k-ne)/X,le,(k+1+ne)/X,ye),J.data,k,q,X,Ee),k===0&&this._addTileFeatures(J.range(1-ne/X,le,1,ye),J.data,X,q,X,Ee),k===X-1&&this._addTileFeatures(J.range(0,le,ne/X,ye),J.data,-1,q,X,Ee),Ee.features.length?Ee:null}getClusterExpansionZoom(M){let k=this._getOriginZoom(M)-1;for(;k<=this.options.maxZoom;){const q=this.getChildren(M);if(k++,q.length!==1)break;M=q[0].properties.cluster_id}return k}_appendLeaves(M,k,q,J,X){const Q=this.getChildren(k);for(const ie of Q){const ne=ie.properties;if(ne&&ne.cluster?X+ne.point_count<=J?X+=ne.point_count:X=this._appendLeaves(M,ne.cluster_id,q,J,X):X<J?X++:M.push(ie),M.length===q)break}return X}_createTree(M){const k=new L.d5(M.length/this.stride|0,this.options.nodeSize,Float32Array);for(let q=0;q<M.length;q+=this.stride)k.add(M[q],M[q+1]);
vendor: 12,221 bytes, line 3102
3102return k.finish(),k.data=M,k}_addTileFeatures(M,k,q,J,X,Q){for(const ie of M){const ne=ie*this.stride,le=k[ne+5]>1;let ye,Ee,Le;if(le)ye=Gr(k,ne,this.clusterProps),Ee=k[ne],Le=k[ne+1];else{const ut=this.points[k[ne+3]];ye=ut.properties;const[nt,Qe]=ut.geometry.coordinates;Ee=Ja(nt),Le=ua(Qe)}const Ne={type:1,geometry:[[Math.round(this.options.extent*(Ee*X-q)),Math.round(this.options.extent*(Le*X-J))]],tags:ye};let Ge;Ge=le||this.options.generateId?k[ne+3]:this.points[k[ne+3]].id,Ge!==void 0&&(Ne.id=Ge),Q.features.push(Ne)}}_limitZoom(M){return Math.max(this.options.minZoom,Math.min(Math.floor(+M),this.options.maxZoom+1))}_cluster(M,k){const{radius:q,extent:J,reduce:X,minPoints:Q}=this.options,ie=q/(J*Math.pow(2,k)),ne=M.data,le=[],ye=this.stride;for(let Ee=0;Ee<ne.length;Ee+=ye){if(ne[Ee+2]<=k)continue;ne[Ee+2]=k;const Le=ne[Ee],Ne=ne[Ee+1],Ge=M.within(ne[Ee],ne[Ee+1],ie),ut=ne[Ee+5];let nt=ut;for(const Qe of Ge){const gt=Qe*ye;ne[gt+2]>k&&(nt+=ne[gt+5])}if(nt>ut&&nt>=Q){let Qe,gt=Le*ut,at=Ne*ut,It=-1;const Nt=(Ee/ye<<5)+(k+1)+this.points.length;for(const Ut of Ge){const Gt=Ut*ye;if(ne[Gt+2]<=k)continue;ne[Gt+2]=k;const At=ne[Gt+5];gt+=ne[Gt]*At,at+=ne[Gt+1]*At,ne[Gt+4]=Nt,X&&(Qe||(Qe=this._map(ne,Ee,!0),It=this.clusterProps.length,this.clusterProps.push(Qe)),X(Qe,this._map(ne,Gt)))}ne[Ee+4]=Nt,le.push(gt/nt,at/nt,1/0,Nt,-1,nt),X&&le.push(It)}else{for(let Qe=0;Qe<ye;Qe++)le.push(ne[Ee+Qe]);if(nt>1)for(const Qe of Ge){const gt=Qe*ye;if(!(ne[gt+2]<=k)){ne[gt+2]=k;for(let at=0;at<ye;at++)le.push(ne[gt+at])}}}}return le}_getOriginId(M){return M-this.points.length>>5}_getOriginZoom(M){return(M-this.points.length)%32}_map(M,k,q){if(M[k+5]>1){const Q=this.clusterProps[M[k+6]];return q?Object.assign({},Q):Q}const J=this.points[M[k+3]].properties,X=this.options.map(J);return q&&X===J?Object.assign({},X):X}}function Ot(Z,M,k){return{type:"Feature",id:Z[M+3],properties:Gr(Z,M,k),geometry:{type:"Point",coordinates:[(q=Z[M],360*(q-.5)),Yh(Z[M+1])]}};var q}function Gr(Z,M,k){const q=Z[M+5],J=q>=1e4?`${Math.round(q/1e3)}k`:q>=1e3?Math.round(q/100)/10+"k":q,X=Z[M+6],Q=X===-1?{}:Object.assign({},k[X]);return Object.assign(Q,{cluster:!0,cluster_id:Z[M+3],point_count:q,point_count_abbreviated:J})}function Ja(Z){return Z/360+.5}function ua(Z){const M=Math.sin(Z*Math.PI/180),k=.5-.25*Math.log((1+M)/(1-M))/Math.PI;return k<0?0:k>1?1:k}function Yh(Z){const M=(180-360*Z)*Math.PI/180;return 360*Math.atan(Math.exp(M))/Math.PI-90}function vt(Z,M,k,q){let J=q;const X=M+(k-M>>1);let Q,ie=k-M;const ne=Z[M],le=Z[M+1],ye=Z[k],Ee=Z[k+1];for(let Le=M+3;Le<k;Le+=3){const Ne=cs(Z[Le],Z[Le+1],ne,le,ye,Ee);if(Ne>J)Q=Le,J=Ne;else if(Ne===J){const Ge=Math.abs(Le-X);Ge<ie&&(Q=Le,ie=Ge)}}J>q&&(Q-M>3&&vt(Z,M,Q,q),Z[Q+2]=J,k-Q>3&&vt(Z,Q,k,q))}function cs(Z,M,k,q,J,X){let Q=J-k,ie=X-q;if(Q!==0||ie!==0){const ne=((Z-k)*Q+(M-q)*ie)/(Q*Q+ie*ie);ne>1?(k=J,q=X):ne>0&&(k+=Q*ne,q+=ie*ne)}return Q=Z-k,ie=M-q,Q*Q+ie*ie}function xn(Z,M,k,q){const J={id:Z??null,type:M,geometry:k,tags:q,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(M==="Point"||M==="MultiPoint"||M==="LineString")Is(J,k);else if(M==="Polygon")Is(J,k[0]);else if(M==="MultiLineString")for(const X of k)Is(J,X);else if(M==="MultiPolygon")for(const X of k)Is(J,X[0]);return J}function Is(Z,M){for(let k=0;k<M.length;k+=3)Z.minX=Math.min(Z.minX,M[k]),Z.minY=Math.min(Z.minY,M[k+1]),Z.maxX=Math.max(Z.maxX,M[k]),Z.maxY=Math.max(Z.maxY,M[k+1])}function Qa(Z,M,k,q){if(!M.geometry)return;const J=M.geometry.coordinates;if(J&&J.length===0)return;const X=M.geometry.type,Q=Math.pow(k.tolerance/((1<<k.maxZoom)*k.extent),2);let ie=[],ne=M.id;if(k.promoteId?ne=M.properties[k.promoteId]:k.generateId&&(ne=q||0),X==="Point")Uu(J,ie);else if(X==="MultiPoint")for(const le of J)Uu(le,ie);else if(X==="LineString")$l(J,ie,Q,!1);else if(X==="MultiLineString"){if(k.lineMetrics){for(const le of J)ie=[],$l(le,ie,Q,!1),Z.push(xn(ne,"LineString",ie,M.properties));return}ql(J,ie,Q,!1)}else if(X==="Polygon")ql(J,ie,Q,!0);else{if(X!=="MultiPolygon"){if(X==="GeometryCollection"){for(const le of M.geometry.geometries)Qa(Z,{id:ne,geometry:le,properties:M.properties},k,q);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const le of J){const ye=[];ql(le,ye,Q,!0),ie.push(ye)}}Z.push(xn(ne,X,ie,M.properties))}function Uu(Z,M){M.push(Wl(Z[0]),us(Z[1]),0)}function $l(Z,M,k,q){let J,X,Q=0;for(let ne=0;ne<Z.length;ne++){const le=Wl(Z[ne][0]),ye=us(Z[ne][1]);M.push(le,ye,0),ne>0&&(Q+=q?(J*ye-le*X)/2:Math.sqrt(Math.pow(le-J,2)+Math.pow(ye-X,2))),J=le,X=ye}const ie=M.length-3;M[2]=1,vt(M,0,ie,k),M[ie+2]=1,M.size=Math.abs(Q),M.start=0,M.end=M.size}function ql(Z,M,k,q){for(let J=0;J<Z.length;J++){const X=[];$l(Z[J],X,k,q),M.push(X)}}function Wl(Z){return Z/360+.5}function us(Z){const M=Math.sin(Z*Math.PI/180),k=.5-.25*Math.log((1+M)/(1-M))/Math.PI;return k<0?0:k>1?1:k}function to(Z,M,k,q,J,X,Q,ie){if(q/=M,X>=(k/=M)&&Q<q)return Z;if(Q<k||X>=q)return null;const ne=[];for(const le of Z){const ye=le.geometry;let Ee=le.type;const Le=J===0?le.minX:le.minY,Ne=J===0?le.maxX:le.maxY;if(Le>=k&&Ne<q){ne.push(le);continue}if(Ne<k||Le>=q)continue;let Ge=[];if(Ee==="Point"||Ee==="MultiPoint")Oc(ye,Ge,k,q,J);else if(Ee==="LineString")jn(ye,Ge,k,q,J,!1,ie.lineMetrics);else if(Ee==="MultiLineString")Xl(ye,Ge,k,q,J,!1);else if(Ee==="Polygon")Xl(ye,Ge,k,q,J,!0);else if(Ee==="MultiPolygon")for(const ut of ye){const nt=[];Xl(ut,nt,k,q,J,!0),nt.length&&Ge.push(nt)}if(Ge.length){if(ie.lineMetrics&&Ee==="LineString"){for(const ut of Ge)ne.push(xn(le.id,Ee,ut,le.tags));continue}Ee!=="LineString"&&Ee!=="MultiLineString"||(Ge.length===1?(Ee="LineString",Ge=Ge[0]):Ee="MultiLineString"),Ee!=="Point"&&Ee!=="MultiPoint"||(Ee=Ge.length===3?"Point":"MultiPoint"),ne.push(xn(le.id,Ee,Ge,le.tags))}}return ne.length?ne:null}function Oc(Z,M,k,q,J){for(let X=0;X<Z.length;X+=3){const Q=Z[X+J];Q>=k&&Q<=q&&_i(M,Z[X],Z[X+1],Z[X+2])}}function jn(Z,M,k,q,J,X,Q){let ie=Bc(Z);const ne=J===0?$o:kc;let le,ye,Ee=Z.start;for(let nt=0;nt<Z.length-3;nt+=3){const Qe=Z[nt],gt=Z[nt+1],at=Z[nt+2],It=Z[nt+3],Nt=Z[nt+4],Ut=J===0?Qe:gt,Gt=J===0?It:Nt;let At=!1;Q&&(le=Math.sqrt(Math.pow(Qe-It,2)+Math.pow(gt-Nt,2))),Ut<k?Gt>=k&&(ye=ne(ie,Qe,gt,It,Nt,k),Q&&(ie.start=Ee+le*ye)):Ut>q?Gt<=q&&(ye=ne(ie,Qe,gt,It,Nt,q),Q&&(ie.start=Ee+le*ye)):_i(ie,Qe,gt,at),Gt<k&&Ut>=k&&(ye=ne(ie,Qe,gt,It,Nt,k),At=!0),Gt>q&&Ut<=q&&(ye=ne(ie,Qe,gt,It,Nt,q),At=!0),!X&&At&&(Q&&(ie.end=Ee+le*ye),M.push(ie),ie=Bc(Z)),Q&&(Ee+=le)}let Le=Z.length-3;const Ne=Z[Le],Ge=Z[Le+1],ut=J===0?Ne:Ge;ut>=k&&ut<=q&&_i(ie,Ne,Ge,Z[Le+2]),Le=ie.length-3,X&&Le>=3&&(ie[Le]!==ie[0]||ie[Le+1]!==ie[1])&&_i(ie,ie[0],ie[1],ie[2]),ie.length&&M.push(ie)}function Bc(Z){const M=[];return M.size=Z.size,M.start=Z.start,M.end=Z.end,M}function Xl(Z,M,k,q,J,X){for(const Q of Z)jn(Q,M,k,q,J,X,!1)}function _i(Z,M,k,q){Z.push(M,k,q)}function $o(Z,M,k,q,J,X){const Q=(X-M)/(q-M);return _i(Z,X,k+(J-k)*Q,1),Q}function kc(Z,M,k,q,J,X){const Q=(X-k)/(J-k);return _i(Z,M+(q-M)*Q,X,1),Q}function el(Z,M){const k=[];for(let q=0;q<Z.length;q++){const J=Z[q],X=J.type;let Q;if(X==="Point"||X==="MultiPoint"||X==="LineString")Q=hs(J.geometry,M);else if(X==="MultiLineString"||X==="Polygon"){Q=[];for(const ie of J.geometry)Q.push(hs(ie,M))}else if(X==="MultiPolygon"){Q=[];for(const ie of J.geometry){const ne=[];for(const le of ie)ne.push(hs(le,M));Q.push(ne)}}k.push(xn(J.id,X,Q,J.tags))}return k}function hs(Z,M){const k=[];k.size=Z.size,Z.start!==void 0&&(k.start=Z.start,k.end=Z.end);for(let q=0;q<Z.length;q+=3)k.push(Z[q]+M,Z[q+1],Z[q+2]);return k}function Gn(Z,M){if(Z.transformed)return Z;const k=1<<Z.z,q=Z.x,J=Z.y;for(const X of Z.features){const Q=X.geometry,ie=X.type;if(X.geometry=[],ie===1)for(let ne=0;ne<Q.length;ne+=2)X.geometry.push(qo(Q[ne],Q[ne+1],M,k,q,J));else for(let ne=0;ne<Q.length;ne++){const le=[];for(let ye=0;ye<Q[ne].length;ye+=2)le.push(qo(Q[ne][ye],Q[ne][ye+1],M,k,q,J));X.geometry.push(le)}}return Z.transformed=!0,Z}function qo(Z,M,k,q,J,X){return[Math.round(k*(Z*q-J)),Math.round(k*(M*q-X))]}function ha(Z,M,k,q,J){const X=M===J.maxZoom?0:J.tolerance/((1<<M)*J.extent),Q={features:[],numPoints:0,numSimplified:0,numFeatures:Z.length,source:null,x:k,y:q,z:M,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const ie of Z)Fr(Q,ie,X,J);return Q}function Fr(Z,M,k,q){const J=M.geometry,X=M.type,Q=[];if(Z.minX=Math.min(Z.minX,M.minX),Z.minY=Math.min(Z.minY,M.minY),Z.maxX=Math.max(Z.maxX,M.maxX),Z.maxY=Math.max(Z.maxY,M.maxY),X==="Point"||X==="MultiPoint")for(let ie=0;ie<J.length;ie+=3)Q.push(J[ie],J[ie+1]),Z.numPoints++,Z.numSimplified++;else if(X==="LineString")io(Q,J,Z,k,!1,!1);else if(X==="MultiLineString"||X==="Polygon")for(let ie=0;ie<J.length;ie++)io(Q,J[ie],Z,k,X==="Polygon",ie===0);else if(X==="MultiPolygon")for(let ie=0;ie<J.length;ie++){const ne=J[ie];for(let le=0;le<ne.length;le++)io(Q,ne[le],Z,k,!0,le===0)}if(Q.length){let ie=M.tags||null;if(X==="LineString"&&q.lineMetrics){ie={};for(const le in M.tags)ie[le]=M.tags[le];ie.mapbox_clip_start=J.start/J.size,ie.mapbox_clip_end=J.end/J.size}const ne={geometry:Q,type:X==="Polygon"||X==="MultiPolygon"?3:X==="LineString"||X==="MultiLineString"?2:1,tags:ie};M.id!==null&&(ne.id=M.id),Z.features.push(ne)}}function io(Z,M,k,q,J,X){const Q=q*q;if(q>0&&M.size<(J?Q:q))return void(k.numPoints+=M.length/3);const ie=[];for(let ne=0;ne<M.length;ne+=3)(q===0||M[ne+2]>Q)&&(k.numSimplified++,ie.push(M[ne],M[ne+1])),k.numPoints++;J&&function(ne,le){let ye=0;for(let Ee=0,Le=ne.length,Ne=Le-2;Ee<Le;Ne=Ee,Ee+=2)ye+=(ne[Ee]-ne[Ne])*(ne[Ee+1]+ne[Ne+1]);if(ye>0===le)for(let Ee=0,Le=ne.length;Ee<Le/2;Ee+=2){const Ne=ne[Ee],Ge=ne[Ee+1];ne[Ee]=ne[Le-2-Ee],ne[Ee+1]=ne[Le-1-Ee],ne[Le-2-Ee]=Ne,ne[Le-1-Ee]=Ge}}(ie,X),Z.push(ie)}const ju={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Gu{constructor(M,k){const q=(k=this.options=function(X,Q){for(const ie in Q)X[ie]=Q[ie];return X}(Object.create(ju),k)).debug;if(q&&console.time("preprocess data"),k.maxZoom<0||k.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(k.promoteId&&k.generateId)throw new Error("promoteId and generateId cannot be used together.");let J=function(X,Q){const ie=[];if(X.type==="FeatureCollection")for(let ne=0;ne<X.features.length;ne++)Qa(ie,X.features[ne],Q,ne);else Qa(ie,X.type==="Feature"?X:{geometry:X},Q);return ie}(M,k);this.tiles={},this.tileCoords=[],q&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",k.indexMaxZoom,k.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),J=function(X,Q){const ie=Q.buffer/Q.extent;let ne=X;const le=to(X,1,-1-ie,ie,0,-1,2,Q),ye=to(X,1,1-ie,2+ie,0,-1,2,Q);return(le||ye)&&(ne=to(X,1,-ie,1+ie,0,-1,2,Q)||[],le&&(ne=el(le,1).concat(ne)),ye&&(ne=ne.concat(el(ye,-1)))),ne}(J,k),J.length&&this.splitTile(J,0,0,0),q&&(J.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(M,k,q,J,X,Q,ie){const ne=[M,k,q,J],le=this.options,ye=le.debug;for(;ne.length;){J=ne.pop(),q=ne.pop(),k=ne.pop(),M=ne.pop();const Ee=1<<k,Le=Yl(k,q,J);let Ne=this.tiles[Le];if(!Ne&&(ye>1&&console.time("creation"),Ne=this.tiles[Le]=ha(M,k,q,J,le),this.tileCoords.push({z:k,x:q,y:J}),ye)){ye>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",k,q,J,Ne.numFeatures,Ne.numPoints,Ne.numSimplified),console.timeEnd("creation"));const At=`z${k}`;this.stats[At]=(this.stats[At]||0)+1,this.total++}if(Ne.source=M,X==null){if(k===le.indexMaxZoom||Ne.numPoints<=le.indexMaxPoints)continue}else{if(k===le.maxZoom||k===X)continue;if(X!=null){const At=X-k;if(q!==Q>>At||J!==ie>>At)continue}}if(Ne.source=null,M.length===0)continue;ye>1&&console.time("clipping");const Ge=.5*le.buffer/le.extent,ut=.5-Ge,nt=.5+Ge,Qe=1+Ge;let gt=null,at=null,It=null,Nt=null;const Ut=to(M,Ee,q-Ge,q+nt,0,Ne.minX,Ne.maxX,le),Gt=to(M,Ee,q+ut,q+Qe,0,Ne.minX,Ne.maxX,le);Ut&&(gt=to(Ut,Ee,J-Ge,J+nt,1,Ne.minY,Ne.maxY,le),at=to(Ut,Ee,J+ut,J+Qe,1,Ne.minY,Ne.maxY,le)),Gt&&(It=to(Gt,Ee,J-Ge,J+nt,1,Ne.minY,Ne.maxY,le),Nt=to(Gt,Ee,J+ut,J+Qe,1,Ne.minY,Ne.maxY,le)),ye>
vendor: 58,477 bytes, lines 3102-3103
31021&&console.timeEnd("clipping"),ne.push(gt||[],k+1,2*q,2*J),ne.push(at||[],k+1,2*q,2*J+1),ne.push(It||[],k+1,2*q+1,2*J),ne.push(Nt||[],k+1,2*q+1,2*J+1)}}getTile(M,k,q){M=+M,k=+k,q=+q;const J=this.options,{extent:X,debug:Q}=J;if(M<0||M>24)return null;const ie=1<<M,ne=Yl(M,k=k+ie&ie-1,q);if(this.tiles[ne])return Gn(this.tiles[ne],X);Q>1&&console.log("drilling down to z%d-%d-%d",M,k,q);let le,ye=M,Ee=k,Le=q;for(;!le&&ye>0;)ye--,Ee>>=1,Le>>=1,le=this.tiles[Yl(ye,Ee,Le)];return le&&le.source?(Q>1&&(console.log("found parent tile z%d-%d-%d",ye,Ee,Le),console.time("drilling down")),this.splitTile(le.source,ye,Ee,Le,M,k,q),Q>1&&console.timeEnd("drilling down"),this.tiles[ne]?Gn(this.tiles[ne],X):null):null}}function Yl(Z,M,k){return 32*((1<<Z)*k+M)+Z}function Hu(Z,M){const k=Z.tileID.canonical;if(!this._geoJSONIndex)return void M(null,null);const q=this._geoJSONIndex.getTile(k.z,k.x,k.y);if(!q)return void M(null,null);const J=le=>le.tags&&"3d_elevation_id"in le.tags&&"source"in le.tags&&le.tags.source==="elevation",X=q.features.filter(le=>J(le));let Q={_geojsonTileLayer:q.features};X.length>0&&(Q={_geojsonTileLayer:q.features.filter(le=>!J(le)),hd_road_elevation:X});const ie=new Wa(Q),ne=function(le){const ye=new L.gj;for(const Ee of Object.keys(le))ye.writeMessage(3,zr,{name:Ee,features:le[Ee]});return ye.finish()}(Q).buffer;M(null,{vectorTile:ie,rawData:ne,headers:new Headers})}class Nc extends ss{constructor(M){super(M),this.loadVectorData=Hu,this._dynamicIndex=new Lc}async loadData(M){const k=M&&M.request,q=k&&k.collectResourceTiming;this._geoJSONIndex=null;let J=await new Promise((Q,ie)=>{this.loadGeoJSON(M,(ne,le)=>{ne?ie(ne):Q(le)})});if(!J)return{};if(typeof J!="object")throw new Error(`Input data given to '${M.source}' is not a valid GeoJSON object.`);if(M.filter){const Q=L.c(M.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Q.result==="error")throw new Error(Q.value.map(ie=>`${ie.key}: ${ie.message}`).join(", "));J.features=J.features.filter(ie=>Q.value.evaluate({zoom:0},ie))}M.dynamic?(J.type==="Feature"&&(J={type:"FeatureCollection",features:[J]}),M.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(J.features,this.loaded),M.cluster&&(J.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=M.cluster?new Vu(function({superclusterOptions:Q,clusterProperties:ie}){if(!ie||!Q)return Q;const ne={},le={},ye={accumulated:null,zoom:0},Ee={properties:null},Le=Object.keys(ie);for(const Ne of Le){const[Ge,ut]=ie[Ne],nt=L.c(ut),Qe=L.c(typeof Ge=="string"?[Ge,["accumulated"],["get",Ne]]:Ge);ne[Ne]=nt.value,le[Ne]=Qe.value}return Q.map=Ne=>{Ee.properties=Ne;const Ge={};for(const ut of Le)Ge[ut]=ne[ut].evaluate(ye,Ee);return Ge},Q.reduce=(Ne,Ge)=>{Ee.properties=Ge;for(const ut of Le)ye.accumulated=Ne[ut],Ne[ut]=le[ut].evaluate(ye,Ee)},Q}(M)).load(J.features):M.dynamic?this._dynamicIndex:function(Q,ie){return new Gu(Q,ie)}(J,M.geojsonVtOptions);const X={};if(q){const Q=Eo(k);Q&&(X.resourceTiming={},X.resourceTiming[M.source]=JSON.parse(JSON.stringify(Q)))}return X}async reloadTile(M){const k=this.loaded;return k&&k[M.uid]?M.partial?void 0:super.reloadTile(M):this.loadTile(M)}loadGeoJSON(M,k){if(M.request)L.g(M.request).then(({data:q})=>k(null,q)).catch(q=>k(q));else{if(typeof M.data!="string")return k(new Error(`Input data given to '${M.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return k(null,JSON.parse(M.data))}catch{return k(new Error(`Input data given to '${M.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(M){return this._geoJSONIndex.getClusterExpansionZoom(M.clusterId)}getClusterChildren(M){return this._geoJSONIndex.getChildren(M.clusterId)}getClusterLeaves(M){return this._geoJSONIndex.getLeaves(M.clusterId,M.limit,M.offset)}}L.cA.setPbf(L.cB);class Kl{constructor(M){this._mrt=new L.cA(M.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=M.uid,this.tileID=M.tileID,this.source=M.source}async parse(M){const k=this._mrt;this.status="parsing",this._entireBuffer=M,k.parseHeader(M),this._isHeaderLoaded=!0;const q=[];for(const J in k.layers){const X=k.getLayer(J),Q=X.getDataRange(X.getBandList()),ie=k.createDecodingTask(Q),ne=M.slice(Q.firstByte,Q.lastByte+1);q.push(L.cA.performDecoding(ne,ie).then(le=>ie.complete(null,le)).catch(le=>ie.complete(le,null)))}return await Promise.allSettled(q),k}}class Vc{constructor({actor:M}){this.actor=M,this.loading={},this.loaded={}}async loadTile(M){const k=M.uid,q=new AbortController,J=this.loading[k]=new Kl(M);J.abort=()=>q.abort();try{const{data:X,headers:Q}=await L.cC(M.request,q.signal);return X?(this.loaded[k]=J,{mrt:await J.parse(X),headers:Q}):(J.status="done",this.loaded[k]=J,null)}catch(X){if(q.signal.aborted)return null;throw J.status="done",this.loaded[k]=J,X}finally{delete this.loading[k]}}async reloadTile(M){}abortTile(M){const k=M.uid,q=this.loading[k];q&&(q.abort&&q.abort(),delete this.loading[k])}removeTile(M){const k=M.uid;this.loaded[k]&&delete this.loaded[k]}async decodeRasterArray(M){return L.cA.performDecoding(M.buffer,M.task)}}class tl{constructor(M){this.self=M,this.actor=new L.aw(M,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=L.gl({name:"mercator"}),this.workerSourceTypes={vector:ss,geojson:Nc,"raster-dem":$s},this.workerSources={},this.self.registerRTLTextPlugin=k=>{if(L.fH.isParsed())throw new Error("RTL text plugin already registered.");L.fH.setState({pluginStatus:L.gm.parsed,pluginURL:L.fH.getPluginURL()}),L.fH.applyArabicShaping=k.applyArabicShaping,L.fH.processBidirectionalText=k.processBidirectionalText,L.fH.processStyledBidirectionalText=k.processStyledBidirectionalText;for(const{resolve:q}of this.rtlPluginParsingListeners)q(!0);this.rtlPluginParsingListeners=[]}}clearCaches(M,k){delete this.layerIndexes[M],delete this.availableImages[M],delete this.availableModels[M],delete this.workerSources[M],delete this.isSpriteLoaded[M]}checkIfReady(M,k){}spriteLoaded(M,k){const{scope:q}=k;if(this.isSpriteLoaded[M]||(this.isSpriteLoaded[M]={}),this.isSpriteLoaded[M][q]=!0,this.workerSources[M]&&this.workerSources[M][q])for(const J in this.workerSources[M][q]){const X=this.workerSources[M][q][J];for(const Q in X){const ie=X[Q];ie instanceof ss&&(ie.isSpriteLoaded=!0,ie.fire(new L.h("isSpriteLoaded")))}}}setImages(M,k){this.availableImages[M]||(this.availableImages[M]={});const{scope:q,images:J}=k;if(this.availableImages[M][q]=J,k.isSpriteLoaded&&this.spriteLoaded(M,{scope:q}),this.workerSources[M]&&this.workerSources[M][q])for(const X in this.workerSources[M][q]){const Q=this.workerSources[M][q][X];for(const ie in Q)Q[ie].availableImages=J}}setModels(M,{scope:k,models:q}){if(this.availableModels[M]||(this.availableModels[M]={}),this.availableModels[M][k]=q,this.workerSources[M]&&this.workerSources[M][k])for(const J in this.workerSources[M][k]){const X=this.workerSources[M][k][J];for(const Q in X)X[Q].availableModels=q}}setProjection(M,k){this.projections[M]=L.gl(k)}setGlobalParams(M,k){if(this.referrer=k.referrer,Object.assign(L.eM,k.config),k.contextOptions){const{maxBindingPoints:q,maxUniformBlockSizeDwords:J}=k.contextOptions;this.maxUniformBufferBindings=q,this.maxUniformBlockSizeDwords=J}}upsertRenderParams(M,k){k.brightness!==void 0&&(this.brightness=k.brightness),k.worldview!==void 0&&(this.worldview=k.worldview)}setLayers(M,k){this.getLayerIndex(M,k.scope).replace(k.layers,k.options)}updateLayers(M,k){this.getLayerIndex(M,k.scope).update(k.layers,k.removedIds,k.options)}async loadTile(M,k){if(k.projection=this.projections[M]||this.defaultProjection,k.type==="batched-model"&&!this.workerSourceTypes["batched-model"]){if(await L.gn(),!Es)throw new Error('Could not load Standard module for "batched-model" source.');this.workerSourceTypes["batched-model"]=Es}return k.type==="raster-array"&&await this.ensureRasterArrayWorkerSource(),this.getWorkerSource(M,k).loadTile(k)}async ensureRasterArraySource(M,k){await this.ensureRasterArrayWorkerSource()}async ensureRasterArrayWorkerSource(){if(!this.workerSourceTypes["raster-array"]){if(await async function(){return Promise.resolve()}(),!Vc)throw new Error('Could not load raster-array module for "raster-array" source.');this.workerSourceTypes["raster-array"]=Vc}}async decodeRasterArray(M,k){return await this.ensureRasterArrayWorkerSource(),this.getWorkerSource(M,k).decodeRasterArray(k)}reloadTile(M,k){return k.projection=this.projections[M]||this.defaultProjection,this.getWorkerSource(M,k).reloadTile(k)}abortTile(M,k){const q=this.getExistingWorkerSource(M,k);return q?q.abortTile(k):void 0}removeTile(M,k){const q=this.getExistingWorkerSource(M,k);return q?q.removeTile(k):void 0}getExistingWorkerSource(M,k){const{type:q,source:J,scope:X}=k,Q=this.workerSources[M];if(Q&&Q[X]&&Q[X][q])return Q[X][q][J]}async removeSource(M,k){const{type:q,source:J,scope:X}=k,Q=this.workerSources[M]&&this.workerSources[M][X]&&this.workerSources[M][X][q],ie=Q&&Q[J];ie&&(delete Q[J],ie.removeSource&&await ie.removeSource({source:J}))}async loadTileProvider(M,k){const q=new(await L.cn(k.name,k.url))(k.options);return this.getWorkerSource(M,{type:k.type,source:k.source,scope:k.scope},q),q.load&&k.request?q.load({request:k.request}):null}async syncRTLPluginState(M,k){if(L.fH.isParsed())return!0;if(L.fH.isParsing())return new Promise((J,X)=>{this.rtlPluginParsingListeners.push({resolve:J,reject:X})});L.fH.setState(k);const q=L.fH.getPluginURL();if(!L.fH.isLoaded()||L.fH.isParsed()||L.fH.isParsing())return!1;L.fH.setState({pluginStatus:L.gm.parsing,pluginURL:q});try{return await self.__mapboxImport(q),!!L.fH.isParsed()||new Promise((J,X)=>{this.rtlPluginParsingListeners.push({resolve:J,reject:X})})}catch(J){L.fH.setState({pluginStatus:L.gm.error,pluginURL:q});for(const{reject:X}of this.rtlPluginParsingListeners)X(J);throw this.rtlPluginParsingListeners=[],J}}getAvailableImages(M,k){this.availableImages[M]||(this.availableImages[M]={});let q=this.availableImages[M][k];return q||(q=[]),q}getAvailableModels(M,k){this.availableModels[M]||(this.availableModels[M]={});let q=this.availableModels[M][k];return q||(q={}),q}getLayerIndex(M,k){this.layerIndexes[M]||(this.layerIndexes[M]={});let q=this.layerIndexes[M][k];return q||(q=this.layerIndexes[M][k]=new Ho,q.scope=k),q}getWorkerSource(M,k,q){const{type:J,source:X,scope:Q}=k,ie=this.workerSources;if(ie[M]||(ie[M]={}),ie[M][Q]||(ie[M][Q]={}),ie[M][Q][J]||(ie[M][Q][J]={}),this.isSpriteLoaded[M]||(this.isSpriteLoaded[M]={}),this.getExistingWorkerSource(M,k))q&&(ie[M][Q][J][X].tileProvider=q);else{const ne=this.actor.getWorkerSourceActor(M),le=this.workerSourceTypes[J];if(!le)throw new Error(`Unknown worker source type "${J}".`);ie[M][Q][J][X]=new le({actor:ne,layerIndex:this.getLayerIndex(M,Q),availableImages:this.getAvailableImages(M,Q),availableModels:this.getAvailableModels(M,Q),isSpriteLoaded:this.isSpriteLoaded[M][Q],tileProvider:q,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords})}return ie[M][Q][J][X]}enforceCacheSizeLimit(M,k){L.go(k)}}return L.gk(self)&&(self.worker=new tl(self)),tl}),h_(["./shared"],function(d){const L={antialias:!1,alpha:!0,stencil:!0,depth:!0};let Eo,Xn;function Lr(a){const r=document.createElement("canvas"),o=Object.create(L);o.failIfMajorPerformanceCaveat=a;const u=r.getContext("webgl2",o);if(!u)return!1;let f;try{f=u.createShader(u.VERTEX_SHADER)}catch{return!1}return!(!f||u.isContextLost())&&(u.shaderSource(f,"void main() {}"),u.compileShader(f),u.getShaderParameter(f,u.COMPILE_STATUS)===!0)}const Ac=/firefox/i,Bl=/macintosh/i;function ai(a,r,o){const u=document.createElement(a);return r!=null&&(u.className=r),o&&o.appendChild(u),u}function So(a,r,o){const u=document.createElementNS("http://www.w3.org/2000/svg",a);for(const f of Object.keys(r))u.setAttributeNS(null,f,String(r[f]));return o&&o.appendChild(u),u}const Yn=typeof document<"u"?document.documentElement&&document.documentElement.style:null,Fs=Yn&&Yn.userSelect!==void 0?"userSelect":"WebkitUserSelect";let Cc;function rr(){Yn&&Fs&&(Cc=Yn[Fs],Yn[Fs]="none")}function kl(){Yn&&Fs&&(Yn[Fs]=Cc)}function yn(a){a.preventDefault(),a.stopPropagation(),window.removeEventListener("click",yn,!0)}function Dt(){window.addEventListener("click",yn,!0),window.setTimeout(()=>{window.removeEventListener("click",yn,!0)},0)}function Yi(a,r){const o=a.getBoundingClientRect();return Io(a,o,r)}function hr(a,r){const o=a.getBoundingClientRect(),u=[];for(let f=0;f<r.length;f++)u.push(Io(a,o,r[f]));return u}function Es(a){return Ac.test(navigator.userAgent)&&Bl.test(navigator.userAgent)&&a.button===2&&a.ctrlKey?0:a.button}function Io(a,r,o){const u=a.offsetWidth===r.width?1:a.offsetWidth/r.width;return new d.P((o.clientX-r.left)*u,(o.clientY-r.top)*u)}class Os{constructor(){this._changed=!1,this._updatedLayers=Object.create(null),this._removedLayers=Object.create(null),this._updatedSourceCaches=Object.create(null),this._updatedPaintProps=new Set,this._updatedImages=Object.create(null)}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(r,o){this._updatedSourceCaches[r]=o,this.setDirty()}discardSourceCacheUpdate(r){delete this._updatedSourceCaches[r]}updateLayer(r){const o=r.scope;this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._updatedLayers[o].add(r.id),this.setDirty()}removeLayer(r){const o=r.scope;this._removedLayers[o]=this._removedLayers[o]||{},this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._removedLayers[o][r.id]=r,this._updatedLayers[o].delete(r.id),this._updatedPaintProps.delete(r.fqid),this.setDirty()}getRemovedLayer(r){return this._removedLayers[r.scope]?this._removedLayers[r.scope][r.id]:null}discardLayerRemoval(r){this._removedLayers[r.scope]&&delete this._removedLayers[r.scope][r.id]}getLayerUpdatesByScope(){const r={};for(const o in this._updatedLayers)r[o]=r[o]||{},r[o].updatedIds=Array.from(this._updatedLayers[o].values());for(const o in this._removedLayers)r[o]=r[o]||{},r[o].removedIds=Object.keys(this._removedLayers[o]);return r}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(r){this._updatedPaintProps.add(r.fqid),this.setDirty()}getUpdatedImages(r){return this._updatedImages[r]?Array.from(this._updatedImages[r].values()):[]}updateImage(r,o){this._updatedImages[o]=this._updatedImages[o]||new Set,this._updatedImages[o].add(d.I.toString(r)),this.setDirty()}resetUpdatedImages(r){this._updatedImages[r]&&this._updatedImages[r].clear()}reset(){this._changed=!1,this._updatedLayers=Object.create(null),this._removedLayers=Object.create(null),this._updatedSourceCaches=Object.create(null),this._updatedPaintProps.clear(),this._updatedImages=Object.create(null)}}class Bs{constructor(r){this._layer=r,this._filterDependencies=void 0}invalidateFilter(){this._filterDependencies=void 0}get _filterDeps(){return this._filterDependencies===void 0&&(this._filterDependencies=this._computeFilterDependencies()),this._filterDependencies}_computeFilterDependencies(){const r=this._layer;if(!r.type||r.type==="custom"||r.type==="background"||r.type==="sky"||r.type==="slot")return null;const o=d.c(r.filter,d.s[`filter_${r.type}`]);return o.result==="error"?null:{configDependencies:o.value.configDependencies,isIndoorDependent:o.value.isIndoorDependent}}hasConfigDependency(r){const{_unevaluatedLayout:o,_transitionablePaint:u}=this._layer;if(o&&o.configDependencies.has(r)||u&&u.configDependencies.has(r))return!0;const f=this._filterDeps;return!!f&&f.configDependencies.has(r)}get isConfigDependent(){const{_unevaluatedLayout:r,_transitionablePaint:o}=this._layer;if(r&&r.configDependencies.size!==0||o&&o.configDependencies.size!==0)return!0;const u=this._filterDeps;return!!u&&u.configDependencies.size!==0}get isIndoorDependent(){const{_unevaluatedLayout:r,_transitionablePaint:o}=this._layer;if(r&&r.isIndoorDependent()||o&&o.isIndoorDependent())return!0;const u=this._filterDeps;return!!u&&u.isIndoorDependent}}function Ho(a){const{userImage:r}=a;return!!(r&&r.render&&r.render())&&(a.data.replace(new Uint8Array(r.data.buffer)),!0)}const Kn=new d.C(0,0,0);function Nl(a,r){const o=[],u=a[`stretch_${r}`];let f=null;for(let m=0;m<u.length;m++)f===null?f=o.length===0?u[0]:o.at(-1)[1]+u[m]:(o.push([f,f+u[m]]),f=null);a[`stretch_${r}_areas`]=o}function zu(a,r){const o={name:void 0};let u;for(;u=a.nextField(r);)u===1?o.name=a.readString():u===2?o.metadata=Ga(a,a.readVarint()+a.pos):u===3&&(o.usvg_tree=Ha(a,a.readVarint()+a.pos),o.data="usvg_tree");return function(f){if(f.usvg_tree.height||(f.usvg_tree.height=f.usvg_tree.width),!f.metadata)return f;const{metadata:m}=f;if(m.content_area){const{content_area:g}=m;g.left??(g.left=0),g.top??(g.top=g.left),g.width??(g.width=f.usvg_tree.width),g.height??(g.height=g.width)}if(m.text_placeholder){const{text_placeholder:g}=m;g.top??(g.top=g.left),g.height??(g.height=g.width)}return m.stretch_x&&m.stretch_x.length&&Nl(m,"x"),m.stretch_y&&m.stretch_y.length&&Nl(m,"y"),f}(o)}function Ga(a,r){const o={stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]};let u;for(;u=a.nextField(r);)u===1?o.stretch_x=a.readPackedVarint():u===2?o.stretch_y=a.readPackedVarint():u===3?o.content_area=Vl(a,a.readVarint()+a.pos):u===4?o.variables.push(Fu(a,a.readVarint()+a.pos)):u===5&&(o.text_placeholder=Vl(a,a.readVarint()+a.pos));return o}function Vl(a,r){const o={};let u;for(;u=a.nextField(r);)u===1?o.left=a.readVarint():u===2?o.width=a.readVarint():u===3?o.top=a.readVarint():u===4&&(o.height=a.readVarint());return o}function Fu(a,r){const o={name:void 0};let u;for(;u=a.nextField(r);)u===1?o.name=a.readString():u===2&&(o.rgb_color=Jn(a.readVarint()),o.value="rgb_color");return o}function Ha(a,r){const o={width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[],height:20};let u;for(;u=a.nextField(r);)u===1?o.width=o.height=a.readVarint():u===2?o.height=a.readVarint():u===3?o.children.push(Jt(a,a.readVarint()+a.pos)):u===4?o.linear_gradients.push(Mc(a,a.readVarint()+a.pos)):u===5?o.radial_gradients.push(Vs(a,a.readVarint()+a.pos)):u===7?o.clip_paths.push(si(a,a.readVarint()+a.pos)):u===8&&o.masks.push(cn(a,a.readVarint()+a.pos));return o}function Jt(a,r){const o={};let u;for(;u=a.nextField(r);)u===1?(o.group=ks(a,a.readVarint()+a.pos),o.node="group"):u===2&&(o.path=br(a,a.readVarint()+a.pos),o.node="path");return o}function ks(a,r){const o={opacity:255,children:[]};let u;for(;u=a.nextField(r);)u===1?o.transform=Ki(a,a.readVarint()+a.pos):u===2?o.opacity=a.readVarint():u===5?o.clip_path_idx=a.readVarint():u===6?o.mask_idx=a.readVarint():u===7&&o.children.push(Jt(a,a.readVarint()+a.pos));return o}function Ki(a,r){const o={sx:1,ky:0,kx:0,sy:1,tx:0,ty:0};let u;for(;u=a.nextField(r);)u===1?o.sx=a.readFloat():u===2?o.ky=a.readFloat():u===3?o.kx=a.readFloat():u===4?o.sy=a.readFloat():u===5?o.tx=a.readFloat():u===6&&(o.ty=a.readFloat());return o}function br(a,r){const o={paint_order:1,commands:[],step:1,diffs:[],rule:1};let u;for(;u=a.nextField(r);)u===1?o.fill=Ui(a,a.readVarint()+a.pos):u===2?o.stroke=Ji(a,a.readVarint()+a.pos):u===3?o.paint_order=a.readVarint():u===5?a.readPackedVarint(o.commands):u===6?o.step=a.readFloat():u===7?a.readPackedSVarint(o.diffs):u===8&&(o.rule=a.readVarint());return o}function Ui(a,r){const o={rgb_color:Kn,paint:"rgb_color",opacity:255};let u;for(;u=a.nextField(r);)u===1?(o.rgb_color=Jn(a.readVarint()),o.paint="rgb_color"):u===2?(o.linear_gradient_idx=a.readVarint(),o.paint="linear_gradient_idx"):u===3?(o.radial_gradient_idx=a.readVarint(),o.paint="radial_gradient_idx"):u===5&&(o.opacity=a.readVarint());return o}function Ji(a,r){const o={rgb_color:Kn,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1};let u;for(;u=a.nextField(r);)u===1?(o.rgb_color=Jn(a.readVarint()),o.paint="rgb_color"):u===2?(o.linear_gradient_idx=a.readVarint(),o.paint="linear_gradient_idx"):u===3?(o.radial_gradient_idx=a.readVarint(),o.paint="radial_gradient_idx"):u===5?a.readPackedFloat(o.dasharray):u===6?o.dashoffset=a.readFloat():u===7?o.miterlimit=a.readFloat():u===8?o.opacity=a.readVarint():u===9?o.width=a.readFloat():u===10?o.linecap=a.readVarint():u===11&&(o.linejoin=a.readVarint());return o}function Jn(a){return new d.C((a>>16&255)/255,(a>>8&255)/255,(255&a)/255,1)}function Mc(a,r){const o={spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0};let u;for(;u=a.nextField(r);)u===1?o.transform=Ki(a,a.readVarint()+a.pos):u===2?o.spread_method=a.readVarint():u===3?o.stops.push(Ns(a,a.readVarint()+a.pos)):u===4?o.x1=a.readFloat():u===5?o.y1=a.readFloat():u===6?o.x2=a.readFloat():u===7&&(o.y2=a.readFloat());return o}function Ns(a,r){const o={offset:0,opacity:255,rgb_color:Kn};let u;for(;u=a.nextField(r);)u===1?o.offset=a.readFloat():u===2?o.opacity=a.readVarint():u===3&&(o.rgb_color=Jn(a.readVarint()));return o}function Vs(a,r){const o={spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0};let u;for(;u=a.nextField(r);)u===1?o.transform=Ki(a,a.readVarint()+a.pos):u===2?o.spread_method=a.readVarint():u===3?o.stops.push(Ns(a,a.readVarint()+a.pos)):u===4?o.cx=a.readFloat():u===5?o.cy=a.readFloat():u===6?o.r=a.readFloat():u===7?o.fx=a.readFloat():u===8?o.fy=a.readFloat():u===9&&(o.fr=a.readFloat());return o}function si(a,r){const o={children:[]};let u;for(;u=a.nextField(r);)u===1?o.transform=Ki(a,a.readVarint()+a.pos):u===2?o.clip_path_idx=a.readVarint():u===3&&o.children.push(Jt(a,a.readVarint()+a.pos));return o}function cn(a,r){const o={left:0,width:20,mask_type:1,children:[]};let u;for(;u=a.nextField(r);)u===1?o.left=o.top=a.readFloat():u===2?o.width=o.height=a.readFloat():u===3?o.top=a.readFloat():u===4?o.height=a.readFloat():u===5?o.mask_type=a.readVarint():u===6?o.mask_idx=a.readVarint():u===7&&o.children.push(Jt(a,a.readVarint()+a.pos));return o.height??(o.height=o.width),o.top??(o.top=o.left),o}class Za{static calculate(r={},o=[]){const u=new Map,f=new Map;if(Object.keys(r).length===0)return u;o.forEach(m=>{f.set(m.name,m.rgb_color||new d.C(0,0,0))});for(const[m,g]of Object.entries(r))f.has(m)?u.set(f.get(m).toString(),g):console.warn(`Ignoring unknown image variable "${m}"`);return u}}function Us(a,r=255,o){const u=o.get(a.toString())||a;return r===255?u.toString():new d.C(u.r,u.g,u.b,u.a*r/255).toString()}const rs=[];let ns=0;function ei(a,r){if(ns>=rs.length){const u=d.o()?new OffscreenCanvas(a,r).getContext("2d",{willReadFrequently:!0}):document.createElement("canvas").getContext("2d",{willReadFrequently:!0});rs.push(u)}const o=rs[ns++];return o.canvas.width=a,o.canvas.height=r,o}function Ri(){ns--}function gr(a,r,o,u,f){for(const m of u.children)js(a,r,o,m,f)}function js(a,r,o,u,f){u.group?(a.save(),function(m,g,x,w,E){const I=w.mask_idx!=null?x.masks[w.mask_idx]:null,R=w.clip_path_idx!=null?x.clip_paths[w.clip_path_idx]:null;if(w.transform&&(g=Qn(w.transform).preMultiplySelf(g)),!function(B,V,U){return B.opacity!==255||V||U}(w,R!=null,I!=null))return void gr(m,g,x,w,E);const P=ei(m.canvas.width,m.canvas.height);gr(P,g,x,w,E),R&&Ou(P,g,x,R),I&&Ss(P,g,x,I,E),m.globalAlpha=w.opacity/255,m.drawImage(P.canvas,0,0),Ri()}(a,r,o,u.group,f),a.restore()):u.path&&(a.save(),function(m,g,x,w,E){m.setTransform(g),w.paint_order===1?(hi(m,x,w,E),oa(m,x,w,E)):(oa(m,x,w,E),hi(m,x,w,E))}(a,r,o,u.path,f),a.restore())}function hi(a,r,o,u){const f=o.fill;if(!f)return;const m=f.opacity/255;switch(a.save(),a.beginPath(),Pc(o,a),f.paint){case"rgb_color":a.fillStyle=Us(f.rgb_color,f.opacity,u);break;case"linear_gradient_idx":{const g=r.linear_gradients[f.linear_gradient_idx];g.transform&&a.setTransform(Qn(g.transform).preMultiplySelf(a.getTransform())),a.fillStyle=Rc(a,g,m,u);break}case"radial_gradient_idx":{const g=r.radial_gradients[f.radial_gradient_idx];g.transform&&a.setTransform(Qn(g.transform).preMultiplySelf(a.getTransform())),a.fillStyle=os(a,g,m,u)}}a.fill(Ao(o)),a.restore()}function Ao(a){return a.rule===1?"nonzero":a.rule===2?"evenodd":void 0}function oa(a,r,o,u){const f=o.stroke;if(!f)return;const m=Zo(o);a.lineWidth=f.width,a.miterLimit=f.miterlimit,a.setLineDash(f.dasharray),a.lineDashOffset=f.dashoffset;const g=f.opacity/255;switch(f.paint){case"rgb_color":a.strokeStyle=Us(f.rgb_color,f.opacity,u);break;case"linear_gradient_idx":a.strokeStyle=Rc(a,r.linear_gradients[f.linear_gradient_idx],g,u,!0);break;case"radial_gradient_idx":a.strokeStyle=os(a,r.radial_gradients[f.radial_gradient_idx],g,u,!0)}switch(f.linejoin){case 2:case 1:a.lineJoin="miter";break;case 3:a.lineJoin="round";break;case 4:a.lineJoin="bevel"}switch(f.linecap){case 1:a.lineCap="butt";break;case 2:a.lineCap="round";break;case 3:a.lineCap="square"}a.stroke(m)}function Rc(a,r,o,u,f=!1){if(r.stops.length===1){const P=r.stops[0];return Us(P.rgb_color,P.opacity*o,u)}const{x1:m,y1:g,x2:x,y2:w}=r;let E=new DOMPoint(m,g),I=new DOMPoint(x,w);if(f){const P=Qn(r.transform);E=P.transformPoint(E),I=P.transformPoint(I)}const R=a.createLinearGradient(E.x,E.y,I.x,I.y);for(const P of r.stops)R.addColorStop(P.offset,Us(P.rgb_color,P.opacity*o,u));return R}function os(a,r,o,u,f=!1){if(r.stops.length===1){const $=r.stops[0];return Us($.rgb_color,$.opacity*o,u)}const m=Qn(r.transform),{fx:g,fy:x,fr:w,cx:E,cy:I,r:R}=r;let P=new DOMPoint(g,x),B=new DOMPoint(E,I),V=w,U=R;if(f){P=m.transformPoint(P),B=m.transformPoint(B);const $=(m.a+m.d)/2;V=w*$,U=r.r*$}const G=a.createRadialGradient(P.x,P.y,V,B.x,B.y,U);for(const $ of r.stops)G.addColorStop($.offset,Us($.rgb_color,$.opacity*o,u));return G}function Pi(a,r,o,u){const f=u.transform?Qn(u.transform).preMultiplySelf(r):r,m=ei(a.canvas.width,a.canvas.height);for(const x of u.children)if(x.group)Pi(m,f,o,x.group);else if(x.path){const w=x.path,E=new Path2D;E.addPath(Zo(w),f),m.fill(E,Ao(w))}const g=u.clip_path_idx!=null?o.clip_paths[u.clip_path_idx]:null;g&&Ou(m,f,o,g),a.globalCompositeOperation="source-over",a.drawImage(m.canvas,0,0),Ri()}function Ou(a,r,o,u){const f=ei(a.canvas.width,a.canvas.height);Pi(f,r,o,u),a.globalCompositeOperation="destination-in",a.drawImage(f.canvas,0,0),Ri()}function Ss(a,r,o,u,f){if(u.children.length===0)return;const m=u.mask_idx!=null?o.masks[u.mask_idx]:null;m&&Ss(a,r,o,m,f);const g=a.canvas.width,x=a.canvas.height,w=ei(g,x),E=u.width,I=u.height,R=u.left,P=u.top,B=new Path2D,V=new Path2D;V.rect(R,P,E,I),B.addPath(V,r),w.clip(B);for(const $ of u.children)js(w,r,o,$,f);const U=w.getImageData(0,0,g,x),G=U.data;if(u.mask_type===1)for(let $=0;$<G.length;$+=4)G[$+3]=G[$+3]/255*(.2126*G[$]+.7152*G[$+1]+.0722*G[$+2]);w.putImageData(U,0,0),a.globalCompositeOperation="destination-in",a.drawImage(w.canvas,0,0),Ri()}function Qn(a){return a?new DOMMatrix([a.sx,a.ky,a.kx,a.sy,a.tx,a.ty]):new DOMMatrix}function Pc(a,r){const o=a.step;let u=a.diffs[0]*o,f=a.diffs[1]*o;r.moveTo(u,f);for(let m=0,g=2;m<a.commands.length;m++)switch(a.commands[m]){case 1:u+=a.diffs[g++]*o,f+=a.diffs[g++]*o,r.moveTo(u,f);break;case 2:u+=a.diffs[g++]*o,f+=a.diffs[g++]*o,r.lineTo(u,f);break;case 3:{const x=u+a.diffs[g++]*o,w=f+a.diffs[g++]*o;u=x+a.diffs[g++]*o,f=w+a.diffs[g++]*o,r.quadraticCurveTo(x,w,u,f);break}case 4:{const x=u+a.diffs[g++]*o,w=f+a.diffs[g++]*o,E=x+a.diffs[g++]*o,I=w+a.diffs[g++]*o;u=E+a.diffs[g++]*o,f=I+a.diffs[g++]*o,r.bezierCurveTo(x,w,E,I,u,f);break}case 5:r.closePath()}return r}function Zo(a){return Pc(a,new Path2D)}class Ul{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(r){return new d.b(r,r.data)}getFromCache(r,o,u){return this.cacheMap.has(u)||this.cacheMap.set(u,new d.L(150)),this.cacheMap.get(u).get(d.m(r.toString(),o))}setInCache(r,o,u,f){this.cacheDependenciesMap.has(f)||this.cacheDependenciesMap.set(f,new Map),this.cacheMap.has(f)||this.cacheMap.set(f,new d.L(150));const m=this.cacheDependenciesMap.get(f),g=d.m(r.id.toString(),u);m.get(g)||m.set(g,new Set);const x=this.cacheMap.get(f),w=r.toString();m.get(g).add(w),x.put(d.m(r.toString(),u),o)}removeImagesFromCacheByIds(r,o,u=0){if(!this.cacheMap.has(u)||!this.cacheDependenciesMap.has(u))return;const f=this.cacheMap.get(u),m=this.cacheDependenciesMap.get(u);for(const g of r){const x=d.m(g.toString(),o);if(m.has(x)){for(const w of m.get(x))f.delete(w);m.delete(x)}}}rasterize(r,o,u,f){const m=this.getFromCache(r,u,f);if(m)return m.clone();const g=function(w,E){const I=Za.calculate(E.params,w.metadata?w.metadata.variables:[]),R=w.usvg_tree,P=R.width,B=R.height,V=Math.max(1,Math.round(P*E.sx)),U=Math.max(1,Math.round(B*E.sy)),G=new DOMMatrix([V/P,0,0,U/B,0,0]),$=ei(V,U);gr($,G,R,R,I);const Y=$.getImageData(0,0,V,U);return Ri(),Y}(o.icon,r),x=Ul._getImage(g);return this.setInCache(r,x,u,f),x.clone()}}class lr extends d.E{constructor(r){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 d.d,this.dirty=!0,this.spriteFormat=r,this.imageRasterizer=new Ul}addScope(r){this.loaded.set(r,!1),this.imageProviders.set(r,new Map),this.images.set(r,new Map),this.updatedImages.set(r,new Set),this.callbackDispatchedThisFrame.set(r,new Set),this.imageVersions.set(r,new Map),this.patterns.set(r,new Map),this.atlasImage.set(r,new d.b({width:1,height:1}))}removeScope(r){this.loaded.delete(r),this.imageProviders.delete(r),this.images.delete(r),this.updatedImages.delete(r),this.callbackDispatchedThisFrame.delete(r),this.imageVersions.delete(r),this.patterns.delete(r),this.atlasImage.delete(r);const o=this.atlasTexture.get(r);o&&(o.destroy(),this.atlasTexture.delete(r))}addImageProvider(r,o){this.imageProviders.has(o)||this.imageProviders.set(o,new Map),this.imageProviders.get(o).set(r.id,r)}removeImageProvider(r,o){this.imageProviders.has(o)&&this.imageProviders.get(o).delete(r)}getPendingImageProviders(){const r=[];for(const o of this.imageProviders.values())for(const u of o.values())u.hasPendingRequests()&&r.push(u);return r}isLoaded(){for(const r of this.loaded.keys())if(!this.loaded.get(r))return!1;return!0}setLoaded(r,o){if(this.loaded.get(o)!==r&&(this.loaded.set(o,r),r)){for(const{ids:u,callback:f}of this.requestors)this._notify(u,o,f);this.requestors=[]}}hasImage(r,o){return!!this.getImage(r,o)}getImage(r,o){return this.images.get(o).get(r.toString())}addImage(r,o,u){if(this._validate(r,u)){this.images.get(o).set(r.toString(),u);const f=this.imageVersions.get(o),m=f.get(r.toString())||0;f.set(r.toString(),m+1)}}_validate(r,o){let u=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new d.f(new Error(`Image "${r.name}" has invalid "stretchX" value`))),u=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new d.f(new Error(`Image "${r.name}" has invalid "stretchY" value`))),u=!1),this._validateContent(o.content,o)||(this.fire(new d.f(new Error(`Image "${r.name}" has invalid "content" value`))),u=!1),u}_validateStretch(r,o){if(!r)return!0;let u=0;for(const f of r){if(f[0]<u||f[1]<f[0]||o<f[1])return!1;u=f[1]}return!0}_validateContent(r,o){return r?r.length!==4||!o.usvg&&(r[0]<0||o.data.width<r[0]||r[1]<0||o.data.height<r[1]||r[2]<0||o.data.width<r[2]||r[3]<0||o.data.height<r[3])?!1:!(r[2]<r[0]||r[3]<r[1]):!0}updateImage(r,o,u){const f=this.images.get(o).get(r.toString());u.version=f.version+1,this.images.get(o).set(r.toString(),u),this.updatedImages.get(o).add(r);const m=this.imageVersions.get(o),g=m.get(r.toString())||0;m.set(r.toString(),g+1),this.removeFromImageRasterizerCache(r,o)}clearUpdatedImages(r){this.updatedImages.get(r).clear()}removeFromImageRasterizerCache(r,o){this.spriteFormat!=="raster"&&this.imageRasterizer.removeImagesFromCacheByIds([r],o)}removeImage(r,o){const u=this.images.get(o),f=u.get(r.toString());u.delete(r.toString());const m=this.imageVersions.get(o),g=m.get(r.toString())||0;m.set(r.toString(),g+1),this.patterns.get(o).delete(r.toString()),this.removeFromImageRasterizerCache(r,o),f.userImage&&f.userImage.onRemove&&f.userImage.onRemove()}listImages(r){return Array.from(this.images.get(r).keys()).map(o=>d.I.from(o))}getImageVersions(r){return this.imageVersions.get(r)||new Map}hasImageProviderForSource(r,o){const u=this.imageProviders.get(o);if(!u)return!1;for(const f of u.values())if(f.sourceCache.getSource().id===r)return!0;return!1}getImages(r,o,u){const f=[],m=[],g=this.imageProviders.get(o);for(const I of r){if(!I.iconsetId){f.push(I);continue}const R=g.get(I.iconsetId);R&&(this.getImage(I,o)?m.push(I):R.addPendingRequest(I))}if(f.length===0)return void this._notify(m,o,u);let x=!0;const w=!!this.loaded.get(o),E=this.images.get(o);if(!w)for(const I of f)E.has(I.toString())||(x=!1);w||x?this._notify(f,o,u):this.requestors.push({ids:f,scope:o,callback:u})}rasterizeImages(r,o){const u=new Map,{iconTasks:f,patternTasks:m,scope:g}=r;for(const x of[f,m])for(const[w,E]of x.entries()){const I=this.getImage(E.id,g);I&&u.set(w,{image:I,imageVariant:E})}o(null,this._rasterizeImages(g,u))}_rasterizeImages(r,o){const u=new Map;for(const[f,{image:m,imageVariant:g}]of o.entries())u.set(f,this.imageRasterizer.rasterize(g,m,r,0));return u}getUpdatedImages(r){return this.updatedImages.get(r)||new Set}_notify(r,o,u){const f=this.images.get(o),m=new Map;for(const g of r){if(!f.get(g.toString())){if(g.iconsetId)continue;this.fire(new d.h("styleimagemissing",{id:g.name}))}const x=f.get(g.toString());if(!x){d.w(`Image "${g.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}const w={data:x.usvg?null:x.data.clone(),pixelRatio:x.pixelRatio,sdf:x.sdf,usvg:x.usvg,stretchX:x.stretchX,stretchY:x.stretchY,content:x.content,hasRenderCallback:!!(x.userImage&&x.userImage.render)};x.usvg&&Object.assign(w,{width:x.icon.usvg_tree.width,height:x.icon.usvg_tree.height}),m.set(d.I.toString(g),w)}u(null,{images:m,versions:this.getImageVersions(o)})}getPixelSize(r){const{width:o,height:u}=this.atlasImage.get(r);return{width:o,height:u}}getPattern(r,o,u){const f=r.toString(),m=this.patterns.get(o),g=m.get(f),x=this.getImage(r,o);if(!x)return null;if(g){if(g.position.version===x.version)return g.position;g.position.version=x.version}else{if(x.usvg&&!x.data){const w=this.getPatternInFlightId(f,o);if(this.patternsInFlight.has(w))return null;this.patternsInFlight.add(w);const E=new d.i(r).scaleSelf(d.e.devicePixelRatio),I=new Map([[E.toString(),{image:x,imageVariant:E}]]),R=this._rasterizeImages(o,I);return this.storePatternImage(E,o,x,u,R),null}this.storePattern(r,o,x)}return this._updatePatternAtlas(o,u),m.get(f).position}getPatternInFlightId(r,o){return d.m(r,o)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(r,o,u,f,m){const g=r.toString(),x=m?m.get(g):void 0;x&&(u.data=x,this.storePattern(r.id,o,u),this._updatePatternAtlas(o,f),this.patternsInFlight.delete(this.getPatternInFlightId(r.id.toString(),o)))}storePattern(r,o,u){const f={w:u.data.width+2*d.j,h:u.data.height+2*d.j,x:0,y:0},m=new d.k(f,u,d.j);this.patterns.get(o).set(r.toString(),{bin:f,position:m})}destroyAtlasTextures(){for(const r of this.atlasTexture.values())r&&r.destroy();this.atlasTexture.clear()}bind(r,o){const u=r.gl;let f=this.atlasTexture.get(o);f?this.dirty&&(f.update(this.atlasImage.get(o)),this.dirty=!1):(f=new d.T(r,this.atlasImage.get(o),u.RGBA8),this.atlasTexture.set(o,f)),f.bind(u.LINEAR,u.CLAMP_TO_EDGE)}_updatePatternAtlas(r,o){const u=this.patterns.get(r),f=Array.from(u.values()).map(({bin:E})=>E),{w:m,h:g}=d.p(f),x=this.atlasImage.get(r);x.resize({width:m||1,height:g||1});const w=this.images.get(r);for(const[E,{bin:I,position:R}]of u.entries()){let P=R.padding;const B=I.x+P,V=I.y+P,U=w.get(E).data,G=U.width,$=U.height;P=P>1?P-1:P,d.b.copy(U,x,{x:0,y:0},{x:B,y:V},{width:G,height:$},o),d.b.copy(U,x,{x:0,y:$-P},{x:B,y:V-P},{width:G,height:P},o),d.b.copy(U,x,{x:0,y:0},{x:B,y:V+$},{width:G,height:P},o),d.b.copy(U,x,{x:G-P,y:0},{x:B-P,y:V},{width:P,height:$},o),d.b.copy(U,x,{x:0,y:0},{x:B+G,y:V},{width:P,height:$},o),d.b.copy(U,x,{x:G-P,y:$-P},{x:B-P,y:V-P},{width:P,height:P},o),d.b.copy(U,x,{x:0,y:$-P},{x:B+G,y:V-P},{width:P,height:P},o),d.b.copy(U,x,{x:0,y:0},{x:B+G,y:V+$},{width:P,height:P},o),d.b.copy(U,x,{x:G-P,y:0},{x:B-P,y:V+$},{width:P,height:P},o)}this.dirty=!0}beginFrame(){for(const r of this.images.keys())this.callbackDispatchedThisFrame.set(r,new Set);this.imageAtlasCache.beginFrame()}dispatchRenderCallbacks(r,o){const u=this.images.get(o);for(const f of r){if(this.callbackDispatchedThisFrame.get(o).has(f.toString()))continue;this.callbackDispatchedThisFrame.get(o).add(f.toString());const m=u.get(f.toString());Ho(m)&&this.updateImage(f,o,m)}}}class it{constructor(r,o,u,f){this.message=(r?`${r}: `:"")+u,f&&(this.identifier=f),o!=null&&o.__line__&&(this.line=o.__line__)}}class Mn extends it{}function jl(a){const r=a.value,o=a.valueSpec,u=a.style,f=a.styleSpec,m=a.key,g=a.arrayElementValidator||Ei;if(!Array.isArray(r))return[new it(m,r,`array expected, ${d.n(r)} found`)];if(o.length&&r.length!==o.length)return[new it(m,r,`array length ${o.length} expected, length ${r.length} found`)];if(o["min-length"]&&r.length<o["min-length"])return[new it(m,r,`array length at least ${o["min-length"]} expected, length ${r.length} found`)];let x={type:o.value,values:o.values,minimum:o.minimum,maximum:o.maximum,function:void 0};f.$version<7&&(x.function=o.function),d.l(o.value)&&(x=o.value);let w=[];for(let E=0;E<r.length;E++)w=w.concat(g({array:r,arrayIndex:E,value:r[E],valueSpec:x,style:u,styleSpec:f,key:`${m}[${E}]`},!0));return w}function Gs(a){const r=a.key,o=a.value,u=a.valueSpec;if(!d.q(o))return[new it(r,o,`number expected, ${d.n(o)} found`)];if(o!=o)return[new it(r,o,"number expected, NaN found")];if("minimum"in u){let f=u.minimum;if(Array.isArray(u.minimum)&&(f=u.minimum[a.arrayIndex]),o<f)return[new it(r,o,`${o} is less than the minimum value ${f}`)]}if("maximum"in u){let f=u.maximum;if(Array.isArray(u.maximum)&&(f=u.maximum[a.arrayIndex]),o>f)return[new it(r,o,`${o} is greater than the maximum value ${f}`)]}return[]}function sa(a){const r=a.key,o=a.value;if(!d.l(o))return[new it(r,o,`object expected, ${d.n(o)} found`)];const u=a.valueSpec,f=d.u(o.type);let m,g,x,w={};const E=f!=="categorical"&&o.property===void 0,I=!E,R=function(U){const G=U.stops;return Array.isArray(G)&&Array.isArray(G[0])&&d.l(G[0][0])}(o),P=zr({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(U){if(f==="identity")return[new it(U.key,U.value,'identity function may not have a "stops" property')];let G=[];const $=U.value;return G=G.concat(jl({key:U.key,value:$,valueSpec:U.valueSpec,style:U.style,styleSpec:U.styleSpec,arrayElementValidator:B})),Array.isArray($)&&$.length===0&&G.push(new it(U.key,$,"array must have at least one stop")),G},default:function(U){return Ei({key:U.key,value:U.value,valueSpec:u,style:U.style,styleSpec:U.styleSpec})}}});return f==="identity"&&E&&P.push(new it(a.key,a.value,'missing required property "property"')),f==="identity"||o.stops||P.push(new it(a.key,a.value,'missing required property "stops"')),f==="exponential"&&u.expression&&!d.r(u)&&P.push(new it(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(I&&!d.t(u)?P.push(new it(a.key,a.value,"property functions not supported")):E&&!d.v(u)&&P.push(new it(a.key,a.value,"zoom functions not supported"))),f!=="categorical"&&!R||o.property!==void 0||P.push(new it(a.key,a.value,'"property" property is required')),P;function B(U){let G=[];const $=U.value,Y=U.key;if(!Array.isArray($))return[new it(Y,$,`array expected, ${d.n($)} found`)];if($.length!==2)return[new it(Y,$,`array length 2 expected, length ${$.length} found`)];if(R){if(!d.l($[0]))return[new it(Y,$,`object expected, ${d.n($[0])} found`)];const re=$[0];if(re.zoom===void 0)return[new it(Y,$,"object stop key must have zoom")];if(re.value===void 0)return[new it(Y,$,"object stop key must have value")];const oe=d.u(re.zoom);if(typeof oe!="number")return[new it(Y,re.zoom,"stop zoom values must be numbers")];if(x&&x>oe)return[new it(Y,re.zoom,"stop zoom values must appear in ascending order")];oe!==x&&(x=oe,g=void 0,w={}),G=G.concat(zr({key:`${Y}[0]`,value:$[0],valueSpec:{zoom:{}},style:U.style,styleSpec:U.styleSpec,objectElementValidators:{zoom:Gs,value:V}}))}else G=G.concat(V({key:`${Y}[0]`,value:$[0],style:U.style,styleSpec:U.styleSpec},$));return d.x(d.y($[1]))?G.concat([new it(`${Y}[1]`,$[1],"expressions are not allowed in function stops.")]):G.concat(Ei({key:`${Y}[1]`,value:$[1],valueSpec:u,style:U.style,styleSpec:U.styleSpec}))}function V(U,G){const $=d.n(U.value),Y=d.u(U.value),re=U.value!==null?U.value:G;if(m){if($!==m)return[new it(U.key,re,`${$} stop domain type must match previous stop domain type ${m}`)]}else m=$;if($!=="number"&&$!=="string"&&$!=="boolean"&&typeof Y!="number"&&typeof Y!="string"&&typeof Y!="boolean")return[new it(U.key,re,"stop domain value must be a number, string, or boolean")];if($!=="number"&&f!=="categorical"){let oe=`number expected, ${$} found`;return d.t(u)&&f===void 0&&(oe+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new it(U.key,re,oe)]}return f!=="categorical"||$!=="number"||typeof Y=="number"&&isFinite(Y)&&Math.floor(Y)===Y?f!=="categorical"&&$==="number"&&typeof Y=="number"&&typeof g=="number"&&g!==void 0&&Y<g?[new it(U.key,re,"stop domain values must appear in ascending order")]:(g=Y,f==="categorical"&&Y in w?[new it(U.key,re,"stop domain values must be unique")]:(w[Y]=!0,[])):[new it(U.key,re,`integer expected, found ${String(Y)}`)]}}function Co(a){const r=(a.expressionContext==="property"?d.z:d.c)(d.y(a.value),a.valueSpec);if(r.result==="error")return r.value.map(u=>new it(`${a.key}${u.key}`,a.value,u.message));const o=r.value.expression||r.value._styleExpression.expression;if(a.expressionContext==="property"&&a.propertyKey==="text-font"&&!o.outputDefined())return[new it(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"&&!d.A(o))return[new it(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.')];if(a.expressionContext==="filter")return eo(o,a);if(a.expressionContext==="appearance")return $a(o,a);if(a.expressionContext&&a.expressionContext.indexOf("cluster")===0){if(!d.B(o,["zoom","feature-state"]))return[new it(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(a.expressionContext==="cluster-initial"&&!d.D(o))return[new it(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function eo(a,r){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(r.valueSpec&&r.valueSpec.expression)for(const f of r.valueSpec.expression.parameters)o.delete(f);if(o.size===0)return[];const u=[];return a instanceof d.F&&o.has(a.name)?[new it(r.key,r.value,`["${a.name}"] expression is not supported in a filter for a ${r.object.type} layer with id: ${r.object.id}`)]:(a.eachChild(f=>{u.push(...eo(f,r))}),u)}const Dc=new Set(["get","has","properties","geometry-type","id"]),aa=new Set(["zoom","pitch","distance-from-center","feature","feature-state","measure-light","heatmap-density","line-progress","raster-value","raster-particle-speed","sky-radial-progress"]);function $a(a,r){if(r.valueSpec&&r.valueSpec.expression)for(const u of r.valueSpec.expression.parameters)aa.delete(u);if(aa.size===0)return[];const o=[];if(a instanceof d.F){const u=Dc.has(a.name)?"feature":a.name;if(aa.has(u))return[new it(r.key,r.value,`["${a.name}"] is not an allowed parameter`)]}return a.eachChild(u=>{o.push(...$a(u,r))}),o}function Hs(a){const r=a.key,o=a.value,u=a.valueSpec,f=[];return Array.isArray(u.values)?u.values.includes(d.u(o))||f.push(new it(r,o,`expected one of [${u.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(u.values).includes(d.u(o))||f.push(new it(r,o,`expected one of [${Object.keys(u.values).join(", ")}], ${JSON.stringify(o)} found`)),f}function Xr(a){if(d.J(d.y(a.value))){const r=a.layerType||"fill";return Co({...a,expressionContext:"filter",valueSpec:a.styleSpec[`filter_${r}`]})}return Zs(a)}function Zs(a){const r=a.value,o=a.key;if(!Array.isArray(r))return[new it(o,r,`array expected, ${d.n(r)} found`)];if(r.length<1)return[new it(o,r,"filter array must have at least 1 element")];const u=a.styleSpec;let f=Hs({key:`${o}[0]`,value:r[0],valueSpec:u.filter_operator});const m=()=>{r.length>=2&&(d.H(r[1])||f.push(new it(`${o}[1]`,r[1],`string expected, ${d.n(r[1])} found`)));for(let g=2;g<r.length;g++)d.u(r[1])==="$type"?f=f.concat(Hs({key:`${o}[${g}]`,value:r[g],valueSpec:u.geometry_type})):d.H(r[g])||d.q(r[g])||d.G(r[g])||f.push(new it(`${o}[${g}]`,r[g],`string, number, or boolean expected, ${d.n(r[g])} found.`))};switch(d.u(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&d.u(r[1])==="$type"&&f.push(new it(o,r,`"$type" cannot be use with operator "${r[0]}"`)),r.length!==3&&f.push(new it(o,r,`filter array for operator "${r[0]}" must have 3 elements`)),m();break;case"==":case"!=":r.length!==3&&f.push(new it(o,r,`filter array for operator "${r[0]}" must have 3 elements`)),m();break;case"in":case"!in":m();break;case"any":case"all":case"none":for(let g=1;g<r.length;g++)f=f.concat(Zs({key:`${o}[${g}]`,value:r[g],style:a.style,styleSpec:a.styleSpec}));break;case"has":case"!has":r.length!==2?f.push(new it(o,r,`filter array for "${r[0]}" operator must have 2 elements`)):d.H(r[1])||f.push(new it(`${o}[1]`,r[1],`string expected, ${d.n(r[1])} found`))}return f}const Gl=/^{([^}]+)}$/;function ss(a,r){const o=a.key,u=a.style,f=a.layer,m=a.styleSpec,g=a.value,x=a.objectKey,w=m[`${r}_${a.layerType}`];if(!w)return[];const E=x.match(d.U);if(E&&w[E[1]])return d.x(d.y(g))?[].concat(Ei({key:o,value:g,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:u,styleSpec:m,expressionContext:"property",propertyType:r,propertyKey:x})):Ei({key:o,value:g,valueSpec:{type:"string"},style:u,styleSpec:m});const I=x.match(d.K);if(r==="paint"&&I&&w[I[1]]&&w[I[1]].transition)return Ei({key:o,value:g,valueSpec:m.transition,style:u,styleSpec:m});const R=a.valueSpec||w[x];if(!R)return[new Mn(o,g,`unknown property "${x}"`)];let P;if(d.H(g)&&d.t(R)&&!R.tokens&&(P=Gl.exec(g))){const V=`\`{ "type": "identity", "property": ${P?JSON.stringify(P[1]):'"_"'} }\``;return[new it(o,g,`"${x}" does not support interpolation syntax
3103Use an identity property function instead: ${V}.`)]}const B=[];if(a.layerType==="symbol")x!=="text-field"||!u||u.glyphs||u.imports||B.push(new it(o,g,'use of "text-field" requires a style "glyphs" property')),x==="text-font"&&d.M(d.y(g))&&d.u(g.type)==="identity"&&B.push(new it(o,g,'"text-font" does not support identity functions'));else if(a.layerType==="model"&&r==="paint"&&f&&f.layout&&Object.hasOwn(f.layout,"model-id")&&d.t(R)&&(d.N(R)||d.v(R))){const V=d.z(d.y(g),R).value,U="expression"in V&&V.expression||"_styleExpression"in V&&V._styleExpression&&V._styleExpression.expression;U&&!d.B(U,["measure-light"])&&(x==="model-emissive-strength"&&d.D(U)&&d.A(U)||B.push(new it(o,g,`${x} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return B.concat(Ei({key:a.key,value:g,valueSpec:R,style:u,styleSpec:m,expressionContext:"property",propertyType:r,propertyKey:x}))}function $s(a){return ss(a,"paint")}function qa(a){return ss(a,"layout")}function Hl(a){let r=[];const o=a.value,u=a.key,f=a.style,m=a.styleSpec;if(!d.l(o))return[new it(u,o,"object expected")];o.type||o.ref||r.push(new it(u,o,'either "type" or "ref" is required'));let g=d.u(o.type);const x=d.u(o.ref);if(o.id){const w=d.u(o.id);for(let E=0;E<a.arrayIndex;E++){const I=f.layers[E];d.u(I.id)===w&&r.push(new it(u,o.id,`duplicate layer id "${w}", previously used at line ${I.id.__line__}`))}}if("ref"in o){let w;["type","source","source-layer","filter","layout"].forEach(E=>{E in o&&r.push(new it(u,o[E],`"${E}" is prohibited for ref layers`))}),f.layers.forEach(E=>{d.u(E.id)===x&&(w=E)}),w?w.ref?r.push(new it(u,o.ref,"ref cannot reference another ref layer")):g=d.u(w.type):typeof x=="string"&&r.push(new it(u,o.ref,`ref layer "${x}" not found`))}else if(g!=="background"&&g!=="sky"&&g!=="slot")if(o.source)if(d.H(o.source)){const w=f.sources&&Object.hasOwn(f.sources,o.source)?f.sources[o.source]:void 0,E=w&&d.u(w.type);w?E==="vector"&&g==="raster"?r.push(new it(u,o.source,`layer "${o.id}" requires a raster source`)):E==="raster"&&g!=="raster"?r.push(new it(u,o.source,`layer "${o.id}" requires a vector source`)):E!=="vector"||o["source-layer"]?E==="raster-dem"&&g!=="hillshade"?r.push(new it(u,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):E!=="raster-array"||["raster","raster-particle"].includes(g)?g==="line"&&o.paint&&o.paint["line-gradient"]&&E==="geojson"&&!w.lineMetrics?r.push(new it(u,o,`layer "${o.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):g==="line"&&o.paint&&o.paint["line-trim-offset"]&&E==="geojson"&&!w.lineMetrics?r.push(new it(u,o,`layer "${o.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):g==="raster-particle"&&E!=="raster-array"&&r.push(new it(u,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):r.push(new it(u,o.source,"raster-array source can only be used with layer type 'raster'.")):r.push(new it(u,o,`layer "${o.id}" must specify a "source-layer"`)):r.push(new it(u,o.source,`source "${o.source}" not found`))}else r.push(new it(`${u}.source`,o.source,'"source" must be a string'));else r.push(new it(u,o,'missing required property "source"'));return r=r.concat(zr({key:u,value:o,valueSpec:m.layer,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Ei({key:`${u}.type`,value:o.type,valueSpec:m.layer.type,style:a.style,styleSpec:a.styleSpec,object:o,objectKey:"type"}),filter:w=>Xr({layerType:g,...w}),layout:w=>zr({layer:o,key:w.key,value:w.value,valueSpec:{},style:w.style,styleSpec:w.styleSpec,objectElementValidators:{"*":E=>qa({layerType:g,...E})}}),paint:w=>zr({layer:o,key:w.key,value:w.value,valueSpec:{},style:w.style,styleSpec:w.styleSpec,objectElementValidators:{"*":E=>$s({layerType:g,layer:o,...E})}}),appearances(w){const E=jl({key:w.key,value:w.value,valueSpec:w.valueSpec,style:w.style,styleSpec:w.styleSpec,arrayElementValidator:P=>function(B){const{key:V,layer:U,layerType:G}=B,$=d.u(B.value),Y=d.u($.name),re=d.u($.condition),oe=zr({key:V,value:$,valueSpec:B.styleSpec.appearance,style:B.style,styleSpec:B.styleSpec,objectElementValidators:{condition:pe=>function(ce){const _e=[];return _e.push(...Co({key:ce.key,value:ce.object.condition,valueSpec:d.s.appearance.condition,expressionContext:"appearance"})),_e}({...pe}),properties:pe=>function(ce){const _e=[],{styleSpec:ue,layer:me,layerType:Ie}=ce,we=ue[`paint_${Ie}`],ve=ue[`layout_${Ie}`],Se=ce.object[ce.objectKey];for(const Re in Se){const Ue=Re in we?"paint":Re in ve?"layout":void 0;if(!Ue){_e.push(new it(ce.key,Re,`unknown property "${Re}" for layer type "${Ie}"`));continue}const Pe={...ce,key:`${ce.key}.${Re}`,objectKey:Re,layer:me,layerType:Ie,value:Se[Re],valueSpec:Ue==="paint"?we[Re]:ve[Re]};_e.push(...ss(Pe,Ue))}return _e}({layer:U,layerType:G,...pe})}});return Y!=="hidden"&&re===void 0&&oe.push(new it(B.key,"name",'Appearance with name different than "hidden" must have a condition')),oe}({layerType:g,layer:o,...P})}),I=Array.isArray(w.value)?w.value:[],R=new Set;return I.forEach((P,B)=>{const V=d.u(P.name);if(V)if(R.has(V)){const U=d.u(o.id);E.push(new it(w.key,V,`Duplicated appearance name "${V}" for layer "${U}"`))}else R.add(V)}),E}}})),r}function la({key:a,value:r}){return d.H(r)?[]:[new it(a,r,`string expected, ${d.n(r)} found`)]}const Wa={promoteId:function a({key:r,value:o}){if(d.H(o))return la({key:r,value:o});if(Array.isArray(o)){const f=[],m=d.y(o),g=d.c(m);return g.result==="error"?(g.value.forEach(x=>{f.push(new it(`${r}${x.key}`,null,`${x.message}`))}),f):(d.B(g.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"])||f.push(new it(`${r}`,null,"promoteId expression should be only feature dependent")),f)}if(!d.l(o))return[new it(r,o,`string, expression or object expected, "${d.n(o)}" found`)];const u=[];for(const f in o)u.push(...a({key:`${r}.${f}`,value:o[f]}));return u}};function as(a){const r=a.value,o=a.key,u=a.styleSpec,f=a.style;if(!d.l(r))return[new it(o,r,`object expected, ${d.n(r)} found`)];if(!("type"in r))return[new it(o,r,'"type" is required')];const m=d.u(r.type);let g=[];switch(["vector","raster","raster-dem","raster-array"].includes(m)&&("url"in r||"tiles"in r||g.push(new Mn(o,r,'Either "url" or "tiles" is required.'))),m){case"vector":case"raster":case"raster-dem":case"raster-array":return g=g.concat(zr({key:o,value:r,valueSpec:u[`source_${m.replace("-","_")}`],style:a.style,styleSpec:u,objectElementValidators:Wa})),g;case"geojson":if(g=zr({key:o,value:r,valueSpec:u.source_geojson,style:f,styleSpec:u,objectElementValidators:Wa}),"cluster"in r&&"clusterProperties"in r){if(!d.l(r.clusterProperties))return[new it(`${o}.clusterProperties`,r,`object expected, ${d.n(r)} found`)];for(const x in r.clusterProperties){const w=r.clusterProperties[x];if(!Array.isArray(w))return[new it(`${o}.clusterProperties.${x}`,w,"array expected")];const[E,I]=w,R=typeof E=="string"?[E,["accumulated"],["get",x]]:E;g.push(...Co({key:`${o}.${x}.map`,value:I,expressionContext:"cluster-map"})),g.push(...Co({key:`${o}.${x}.reduce`,value:R,expressionContext:"cluster-reduce"}))}}return g;case"video":return zr({key:o,value:r,valueSpec:u.source_video,style:f,styleSpec:u});case"image":return zr({key:o,value:r,valueSpec:u.source_image,style:f,styleSpec:u});case"canvas":return[new it(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Hs({key:`${o}.type`,value:r.type,valueSpec:{values:Lc(u)}})}}function Lc(a){return a.source.reduce((r,o)=>{const u=a[o];return u.type.type==="enum"&&(r=r.concat(Object.keys(u.type.values||{}))),r},[])}function De(a,r){const o=!a.includes("://");try{return new URL(a,o&&r?"http://example.com":void 0),!0}catch{return!1}}function ls(a){const r=a.value;return r?d.H(r)?De(r,!0)?[]:[new it(a.key,r,`invalid url "${r}"`)]:[new it(a.key,r,`string expected, "${d.n(r)}" found`)]:[]}function Xa(a){const r=a.value,o=a.styleSpec,u=o.light,f=a.style;if(r===void 0)return[];if(!d.l(r))return[new it("light",r,`object expected, ${d.n(r)} found`)];let m=[];for(const g in r){const x=g.match(d.K),w=g.match(d.U);m=m.concat(w&&u[w[1]]?Ei({key:g,value:r[g],valueSpec:{type:"string"},style:f,styleSpec:o}):x&&u[x[1]]&&u[x[1]].transition?Ei({key:g,value:r[g],valueSpec:o.transition,style:f,styleSpec:o}):u[g]?Ei({key:g,value:r[g],valueSpec:u[g],style:f,styleSpec:o}):[new it(g,r[g],`unknown property "${g}"`)])}return m}function qs(a){const r=a.value;if(!r)return[];const o=a.key;if(!d.l(r))return[new it(o,r,`object expected, ${d.n(r)} found`)];let u=[];const f=a.styleSpec,m=f["light-3d"],g=a.style,x=a.style.lights;for(const I of["type","id"])if(!(I in r))return u=u.concat([new it(o,r,`missing property "${I}"`)]),u;if(!d.H(r.type))return u=u.concat([new it(`${o}.type`,r.type,"string expected")]),u;if(x)for(let I=0;I<a.arrayIndex;I++){const R=d.u(r.type),P=x[I];d.u(P.type)===R&&u.push(new it(o,r.id,`duplicate light type "${r.type}", previously defined at line ${P.id.__line__}`))}const w=`properties_light_${r.type}`;if(!(w in f))return u=u.concat([new it(`${o}.type`,r,`Invalid light type ${r.type}`)]),u;const E=f[w];for(const I in r)if(I==="properties"){const R=r[I];if(!d.l(R))return u=u.concat([new it("properties",R,`object expected, ${d.n(R)} found`)]),u;for(const P in R){const B=P.match(d.K),V=P.match(d.U);u=u.concat(V&&E[V[1]]?Ei({key:I,value:R[P],valueSpec:{type:"string"},style:g,styleSpec:f}):B&&E[B[1]]&&E[B[1]].transition?Ei({key:I,value:r[I],valueSpec:f.transition,style:g,styleSpec:f}):E[P]?Ei({key:P,value:R[P],valueSpec:E[P],style:g,styleSpec:f}):[new Mn(a.key,R[P],`unknown property "${P}"`)])}}else u=u.concat(m[I]?Ei({key:I,value:r[I],valueSpec:m[I],style:g,styleSpec:f}):[new Mn(I,r[I],`unknown property "${I}"`)]);return u}function Zl(a){const r=a.value,o=a.key,u=a.style,f=a.styleSpec,m=f.terrain;if(r==null)return[];if(!d.l(r))return[new it("terrain",r,`object expected, ${d.n(r)} found`)];let g=[];for(const x in r){const w=x.match(d.K),E=x.match(d.U);g=g.concat(E&&m[E[1]]?Ei({key:x,value:r[x],valueSpec:{type:"string"},style:u,styleSpec:f}):w&&m[w[1]]&&m[w[1]].transition?Ei({key:x,value:r[x],valueSpec:f.transition,style:u,styleSpec:f}):m[x]?Ei({key:x,value:r[x],valueSpec:m[x],style:u,styleSpec:f}):[new Mn(x,r[x],`unknown property "${x}"`)])}if(r.source)if(d.H(r.source)){const x=u.sources&&Object.hasOwn(u.sources,r.source)?u.sources[r.source]:void 0,w=x&&d.u(x.type);x?w!=="raster-dem"&&g.push(new it(`${o}.source`,r.source,`terrain cannot be used with a source of type ${w}, it only be used with a "raster-dem" source type`)):g.push(new it(`${o}.source`,r.source,`source "${r.source}" not found`))}else g.push(new it(`${o}.source`,r.source,"source must be a string"));else g.push(new it(o,r,'terrain is missing required property "source"'));return g}function Bu(a){const r=a.value,o=a.style,u=a.styleSpec,f=u.fog;if(r===void 0)return[];if(!d.l(r))return[new it("fog",r,`object expected, ${d.n(r)} found`)];let m=[];for(const g in r){const x=g.match(d.K),w=g.match(d.U);m=m.concat(w&&f[w[1]]?Ei({key:g,value:r[g],valueSpec:{type:"string"},style:o,styleSpec:u}):x&&f[x[1]]&&f[x[1]].transition?Ei({key:g,value:r[g],valueSpec:u.transition,style:o,styleSpec:u}):f[g]?Ei({key:g,value:r[g],valueSpec:f[g],style:o,styleSpec:u}):[new Mn(g,r[g],`unknown property "${g}
3103"`)])}return m}const ku={"*":()=>[],array:jl,boolean:function(a){const r=a.value,o=a.key;return d.G(r)?[]:[new it(o,r,`boolean expected, ${d.n(r)} found`)]},number:Gs,color:function({key:a,value:r}){return d.H(r)?d.C.parse(d.u(r))===void 0?[new it(a,r,`color expected, "${r}" found`)]:[]:[new it(a,r,`color expected, ${d.n(r)} found`)]},enum:Hs,filter:Xr,function:sa,layer:Hl,object:zr,source:as,model:ls,light:Xa,"light-3d":qs,terrain:Zl,fog:Bu,string:la,formatted:function(a){return la(a).length===0?[]:Co(a)},resolvedImage:function(a){return la(a).length===0?[]:Co(a)},projection:function(a){const r=a.value,o=a.styleSpec,u=o.projection,f=a.style;if(d.l(r)){let m=[];for(const g in r)m=m.concat(Ei({key:g,value:r[g],valueSpec:u[g],style:f,styleSpec:o}));return m}return d.H(r)?[]:[new it("projection",r,`object or string expected, ${d.n(r)} found`)]},import:function(a){const r=a.key,{value:o,styleSpec:u}=a;if(!d.l(o))return[new it(r,o,"import must be an object")];const{data:f,...m}=o;Object.defineProperty(m,"__line__",{value:o.__line__,enumerable:!1});let g=zr({...a,value:m,valueSpec:u.import});d.u(m.id)===""&&g.push(new it(`${a.key}.id`,m,"import id can't be an empty string"));const x=d.u(m.id);return x!=="__proto__"&&x!=="constructor"&&x!=="prototype"||g.push(new it(`${a.key}.id`,m,`import id can't be "${String(x)}"`)),f&&(g=g.concat(Nu(f,u,{key:`${a.key}.data`}))),g},iconset:function(a){const r=a.value,o=a.key,u=a.styleSpec,f=a.style;if(!d.l(r))return[new it(o,r,"object expected")];if(!r.type)return[new it(o,r,'"type" is required')];const m=d.u(r.type);let g=[];if(g=g.concat(zr({key:o,value:r,valueSpec:u[`iconset_${m}`],style:f,styleSpec:u})),function(x,w){return!(x!=="source"||!w.source)}(m,r)){const x=f.sources&&Object.hasOwn(f.sources,r.source)?f.sources[r.source]:void 0,w=x&&d.u(x.type);x?w!=="raster-array"&&g.push(new it(o,r.source,`iconset cannot be used with a source of type ${String(w)}, it only be used with a "raster-array" source type`)):g.push(new it(o,r.source,`source "${r.source}" not found`))}return g},option:function(a){const r=a.styleSpec,o=a.value,u=d.l(o)&&d.u(o.array)===!0||!d.l(o)?void 0:d.u(o.type);return zr({...a,valueSpec:r.option,objectElementValidators:{default:f=>{const m=f.value;return d.l(m)?Ei({...f,valueSpec:{...f.valueSpec,type:"*",expression:void 0}}):u&&Array.isArray(m)?Ei({...f,valueSpec:{...f.valueSpec,type:u}}):Ei(f)}}})}};function Ei(a,r=!1){const o=a.value,u=a.valueSpec,f=a.styleSpec;if(u.expression){if(d.M(d.u(o)))return sa(a);if(d.x(d.y(o)))return Co(a)}if(u.type&&ku[u.type]){const m=ku[u.type](a);return r===!0&&m.length>0&&Array.isArray(a.value)?Co(a):m}return zr({...a,valueSpec:u.type?f[u.type]:u})}function zr(a){const r=a.key,o=a.value,u=a.valueSpec||{},f=a.objectElementValidators||{},m=a.style,g=a.styleSpec;if(!d.l(o))return[new it(r,o,`object expected, ${d.n(o)} found`)];let x=[];for(const w in o){if(!Object.hasOwn(o,w))continue;const E=w.split(".")[0],I=Object.hasOwn(u,E),R=Object.hasOwn(u,"*"),P=I?u[E]:R?u["*"]:void 0;let B;Object.hasOwn(f,E)?B=f[E]:I?B=Ei:Object.hasOwn(f,"*")?B=f["*"]:R&&(B=Ei),B?x=x.concat(B({key:(r&&`${r}.`)+w,value:o[w],valueSpec:P,style:m,styleSpec:g,object:o,objectKey:w},o)):x.push(new Mn(r,o[w],`unknown property "${w}"`))}for(const w in u){if(!Object.hasOwn(u,w)||Object.hasOwn(f,w))continue;const E=u[w];!E.required||E.default!==void 0||Object.hasOwn(o,w)&&o[w]!==void 0||x.push(new it(r,o,`missing required property "${w}"`))}return x}function Ya({key:a,value:r}){const o=la({key:a,value:r});if(o.length)return o;const u=r;return u.includes("{fontstack}")||o.push(new it(a,r,'"glyphs" url must include a "{fontstack}" token')),u.includes("{range}")||o.push(new it(a,r,'"glyphs" url must include a "{range}" token')),o}function Nu(a,r=d.s,o={}){return zr({key:o.key||"",value:a,valueSpec:{...r.$root,"*":{type:"*"}},styleSpec:r,style:a,objectElementValidators:{glyphs:Ya}})}function un(a){return a.slice().sort((r,o)=>r.line&&o.line?r.line-o.line:0)}const Un="setStyle",zc="addLayer",Ws="removeLayer",Ka="setPaintProperty",Fc="setLayerProperty",ca="setTerrain",Vu="removeImport",Ot="addIconset",Gr="removeIconset";function Ja(a,r,o){o.push({command:"addSource",args:[a,r[a]]})}function ua(a,r,o){r.push({command:"removeSource",args:[a]}),o[a]=!0}function Yh(a,r,o,u){ua(a,o,u),Ja(a,r,o)}function vt(a,r,o){let u;for(u in a[o])if(Object.hasOwn(a[o],u)&&u!=="data"&&!d.O(a[o][u],r[o][u]))return!1;for(u in r[o])if(Object.hasOwn(r[o],u)&&u!=="data"&&!d.O(a[o][u],r[o][u]))return!1;return!0}function cs(a,r,o,u,f,m){let g;for(g in r=r||{},a=a||{})Object.hasOwn(a,g)&&(d.O(a[g],r[g])||o.push({command:m,args:[u,g,r[g],f]}));for(g in r)Object.hasOwn(r,g)&&!Object.hasOwn(a,g)&&(d.O(a[g],r[g])||o.push({command:m,args:[u,g,r[g],f]}))}function xn(a){return a.id}function Is(a,r){return a[r.id]=r,a}const Qa=new d.C(1,0,0,1),Uu=new d.C(0,1,0,1),$l=new d.C(0,0,1,1),ql=new d.C(1,0,1,1),Wl=new d.C(0,1,1,1);function us(a,r,o,u,f,m,g){const x=a.context,w=a.transform,E=x.gl,I=w.projection.name==="globe",R=I?["PROJECTION_GLOBE_VIEW"]:[];let P=d.Q(o.projMatrix);if(I&&d.S(w.zoom)>0){const ve=d.V(o.canonical,w),Se=d.W(ve);P=d.X(new Float32Array(16),w.globeMatrix,Se),d.X(P,w.projMatrix,P)}const B=d.Y();B[12]+=2*f/(d.e.devicePixelRatio*w.width),B[13]+=2*m/(d.e.devicePixelRatio*w.height),d.X(P,B,P);const V=a.getOrCreateProgram("debug",{defines:R}),U=r.getTileByID(o.key);a.terrain&&a.terrain.setupElevationDraw(U,V);const G=d.Z.disabled,$=d._.disabled,Y=a.colorModeForRenderPass(),re="$debug";x.activeTexture.set(E.TEXTURE0),a.emptyTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),I?U._makeGlobeTileDebugBuffers(a.context,w):U._makeDebugTileBoundsBuffers(a.context,w.projection);const oe=U._tileDebugBuffer||a.debugBuffer,pe=U._tileDebugIndexBuffer||a.debugIndexBuffer,ce=U._tileDebugSegments||a.debugSegments;if(V.draw(a,E.LINE_STRIP,G,$,Y,d.$.disabled,d.a0(P,u.toPremultipliedRenderColor(null)),re,oe,pe,ce,null,null,null,[U._globeTileDebugBorderBuffer]),g){const ve=U.latestRawTileData,Se=Math.floor((ve&&ve.byteLength||0)/1024);let Re=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(Re+=` => ${o.overscaledZ}`),Re+=` ${U.state}`,Re+=` ${Se}kb`,function(Ue,Pe){Ue.initDebugOverlayCanvas();const Oe=Ue.debugOverlayCanvas,Xe=Ue.context.gl,ot=Ue.debugOverlayCanvas.getContext("2d");ot.clearRect(0,0,Oe.width,Oe.height),ot.shadowColor="white",ot.shadowBlur=2,ot.lineWidth=1.5,ot.strokeStyle="white",ot.textBaseline="top",ot.font="bold 36px Open Sans, sans-serif",ot.fillText(Pe,5,5),ot.strokeText(Pe,5,5),Ue.debugOverlayTexture.update(Oe),Ue.debugOverlayTexture.bind(Xe.LINEAR,Xe.CLAMP_TO_EDGE)}(a,Re)}const _e=r.getTile(o).tileSize,ue=512/Math.min(_e,512)*(o.overscaledZ/w.zoom)*.5,me=U._tileDebugTextBuffer||a.debugBuffer,Ie=U._tileDebugTextIndexBuffer||a.quadTriangleIndexBuffer,we=U._tileDebugTextSegments||a.debugSegments;V.draw(a,E.TRIANGLES,G,$,d.a1.alphaBlended,d.$.disabled,d.a0(P,d.C.transparent.toPremultipliedRenderColor(null),ue),re,me,Ie,we,null,null,null,[U._globeTileDebugTextBuffer])}function to(a,r,o,u){jn(a,0,r+o/2,a.transform.width,o,u)}function Oc(a,r,o,u){jn(a,r-o/2,0,o,a.transform.height,u)}function jn(a,r,o,u,f,m){const g=a.context,x=g.gl;x.enable(x.SCISSOR_TEST),x.scissor(r*d.e.devicePixelRatio,o*d.e.devicePixelRatio,u*d.e.devicePixelRatio,f*d.e.devicePixelRatio),g.clear({color:m}),x.disable(x.SCISSOR_TEST)}
vendor: 43,660 bytes, lines 3103-3104
3103function Bc(a,r,o){const u=a.context,f=u.gl,m=o.projMatrix,g=a.getOrCreateProgram("debug"),x=r.getTileByID(o.key);a.terrain&&a.terrain.setupElevationDraw(x,g);const w=d.Z.disabled,E=d._.disabled,I=a.colorModeForRenderPass(),R="$debug";u.activeTexture.set(f.TEXTURE0),a.emptyTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE);const P=x.queryGeometryDebugViz,B=x.queryBoundsDebugViz;if(P&&P.vertices.length>0){P.lazyUpload(u);const V=P.vertexBuffer,U=P.indexBuffer,G=P.segments;V!=null&&U!=null&&G!=null&&g.draw(a,f.LINE_STRIP,w,E,I,d.$.disabled,d.a0(m,P.color.toPremultipliedRenderColor(null)),R,V,U,G)}if(B&&B.vertices.length>0){B.lazyUpload(u);const V=B.vertexBuffer,U=B.indexBuffer,G=B.segments;V!=null&&U!=null&&G!=null&&g.draw(a,f.LINE_STRIP,w,E,I,d.$.disabled,d.a0(m,B.color.toPremultipliedRenderColor(null)),R,V,U,G)}}const Xl=(a,r,o,u,f,m,g,x)=>{const w=d.a2/m.tileSize;return{u_matrix:a,u_inv_rot_matrix:r,u_camera_to_center_distance:o.getCameraToCenterDistance(x),u_extrude_scale:[o.pixelsToGLUnits[0]/w,o.pixelsToGLUnits[1]/w],u_zoom_transition:u,u_tile_id:g,u_merc_center:f}},_i=(a,r,o,u)=>({u_matrix:a,u_inv_matrix:r,u_camera_to_center_distance:o.getCameraToCenterDistance(u),u_viewport_size:[o.width,o.height]});function $o(a,r,o){const u=r.createTileMatrix(a,a.worldSize,o.toUnwrapped());return d.X(new Float32Array(16),a.projMatrix,u)}function kc(a,r,o){if(r.projection.name===o.projection.name)return a.projMatrix;const u=o.clone();return u.setProjection(r.projection),$o(u,r.getProjection(),a)}function el(a,r,o){return r.name===o.projection.name?a.projMatrix:$o(o,r,a)}let hs;const Gn={loaded:!0,validateStyle:function(a,r=d.s){return un(Nu(a,r))},validateSource:a=>un(as(a)),validateLight:a=>un(Xa(a)),validateLights:a=>un(qs(a)),validateTerrain:a=>un(Zl(a)),validateFog:a=>un(Bu(a)),validateSnow:a=>un(function(r){const o=r.value,u=r.style,f=r.styleSpec,m=f.snow;if(o===void 0)return[];if(!d.l(o))return[new it("snow",o,`object expected, ${d.n(o)} found`)];let g=[];for(const x in o){const w=x.match(d.K);g=g.concat(w&&m[w[1]]&&m[w[1]].transition?Ei({key:x,value:o[x],valueSpec:f.transition,style:u,styleSpec:f}):m[x]?Ei({key:x,value:o[x],valueSpec:m[x],style:u,styleSpec:f}):[new Mn(x,o[x],`unknown property "${x}"`)])}return g}(a)),validateRain:a=>un(function(r){const o=r.value,u=r.style,f=r.styleSpec,m=f.rain;if(o===void 0)return[];if(!d.l(o))return[new it("rain",o,`object expected, ${d.n(o)} found`)];let g=[];for(const x in o){const w=x.match(d.K);g=g.concat(w&&m[w[1]]&&m[w[1]].transition?Ei({key:x,value:o[x],valueSpec:f.transition,style:u,styleSpec:f}):m[x]?Ei({key:x,value:o[x],valueSpec:m[x],style:u,styleSpec:f}):[new Mn(x,o[x],`unknown property "${x}"`)])}return g}(a)),validateLayer:a=>un(Hl(a)),validateFilter:a=>un(Xr(a)),validatePaintProperty:a=>un($s(a)),validateLayoutProperty:a=>un(qa(a)),validateModel:a=>un(ls(a)),diffStyles:function(a,r){if(!a)return[{command:Un,args:[r]}];let o=[];try{if(!d.O(a.version,r.version))return[{command:Un,args:[r]}];if(d.O(a.center,r.center)||o.push({command:"setCenter",args:[r.center]}),d.O(a.zoom,r.zoom)||o.push({command:"setZoom",args:[r.zoom]}),d.O(a.bearing,r.bearing)||o.push({command:"setBearing",args:[r.bearing]}),d.O(a.pitch,r.pitch)||o.push({command:"setPitch",args:[r.pitch]}),d.O(a.sprite,r.sprite)||o.push({command:"setSprite",args:[r.sprite]}),d.O(a.glyphs,r.glyphs)||o.push({command:"setGlyphs",args:[r.glyphs]}),d.O(a.imports,r.imports)||function(x=[],w=[],E){w=w||[];const I=(x=x||[]).map(xn),R=w.map(xn),P=x.reduce(Is,{}),B=w.reduce(Is,{}),V=I.slice();let U,G,$,Y;for(U=0,G=0;U<I.length;U++)$=I[U],Object.hasOwn(B,$)?G++:(E.push({command:Vu,args:[$]}),V.splice(V.indexOf($,G),1));for(U=0,G=0;U<R.length;U++)$=R[R.length-1-U],V[V.length-1-U]!==$&&(Object.hasOwn(P,$)?(E.push({command:Vu,args:[$]}),V.splice(V.lastIndexOf($,V.length-G),1)):G++,Y=V[V.length-U],E.push({command:"addImport",args:[B[$],Y]}),V.splice(V.length-U,0,$));for(const re of w){const oe=P[re.id];oe&&(delete oe.data,d.O(oe,re)||E.push({command:"updateImport",args:[re.id,re]}))}}(a.imports,r.imports,o),d.O(a.transition,r.transition)||o.push({command:"setTransition",args:[r.transition]}),d.O(a.light,r.light)||o.push({command:"setLight",args:[r.light]}),d.O(a.fog,r.fog)||o.push({command:"setFog",args:[r.fog]}),d.O(a.snow,r.snow)||o.push({command:"setSnow",args:[r.snow]}),d.O(a.rain,r.rain)||o.push({command:"setRain",args:[r.rain]}),d.O(a.projection,r.projection)||o.push({command:"setProjection",args:[r.projection]}),d.O(a.lights,r.lights)||o.push({command:"setLights",args:[r.lights]}),d.O(a.camera,r.camera)||o.push({command:"setCamera",args:[r.camera]}),d.O(a.iconsets,r.iconsets)||function(x,w,E){let I;for(I in w=w||{},x=x||{})Object.hasOwn(x,I)&&(Object.hasOwn(w,I)||E.push({command:Gr,args:[I]}));for(I in w){if(!Object.hasOwn(w,I))continue;const R=w[I];Object.hasOwn(x,I)?d.O(x[I],R)||(E.push({command:Gr,args:[I]}),E.push({command:Ot,args:[I,R]})):E.push({command:Ot,args:[I,R]})}}(a.iconsets,r.iconsets,o),!d.O(a["color-theme"],r["color-theme"]))return[{command:Un,args:[r]}];const u={},f=[];(function(x,w,E,I){let R;for(R in w=w||{},x=x||{})Object.hasOwn(x,R)&&(Object.hasOwn(w,R)||ua(R,E,I));for(R in w){if(!Object.hasOwn(w,R))continue;const P=w[R];Object.hasOwn(x,R)?d.O(x[R],P)||(x[R].type==="geojson"&&P.type==="geojson"&&vt(x,w,R)?E.push({command:"setGeoJSONSourceData",args:[R,P.data]}):Yh(R,w,E,I)):Ja(R,w,E)}})(a.sources,r.sources,f,u);const m=[];a.layers&&a.layers.forEach(x=>{x.source&&u[x.source]?o.push({command:Ws,args:[x.id]}):m.push(x)});let g=a.terrain;g&&u[g.source]&&(o.push({command:ca,args:[void 0]}),g=void 0),o=o.concat(f),d.O(g,r.terrain)||o.push({command:ca,args:[r.terrain]}),function(x,w,E){w=w||[];const I=(x=x||[]).map(xn),R=w.map(xn),P=x.reduce(Is,{}),B=w.reduce(Is,{}),V=I.slice(),U=Object.create(null);let G,$,Y,re,oe,pe,ce;for(G=0,$=0;G<I.length;G++)Y=I[G],Object.hasOwn(B,Y)?$++:(E.push({command:Ws,args:[Y]}),V.splice(V.indexOf(Y,$),1));for(G=0,$=0;G<R.length;G++)Y=R[R.length-1-G],V[V.length-1-G]!==Y&&(Object.hasOwn(P,Y)?(E.push({command:Ws,args:[Y]}),V.splice(V.lastIndexOf(Y,V.length-$),1)):$++,pe=V[V.length-G],E.push({command:zc,args:[B[Y],pe]}),V.splice(V.length-G,0,Y),U[Y]=!0);for(G=0;G<R.length;G++)if(Y=R[G],re=P[Y],oe=B[Y],!U[Y]&&!d.O(re,oe))if(d.O(re.source,oe.source)&&d.O(re["source-layer"],oe["source-layer"])&&d.O(re.type,oe.type)){for(ce in cs(re.layout,oe.layout,E,Y,null,"setLayoutProperty"),cs(re.paint,oe.paint,E,Y,null,Ka),d.O(re.slot,oe.slot)||E.push({command:"setSlot",args:[Y,oe.slot]}),d.O(re.filter,oe.filter)||E.push({command:"setFilter",args:[Y,oe.filter]}),d.O(re.minzoom,oe.minzoom)&&d.O(re.maxzoom,oe.maxzoom)||E.push({command:"setLayerZoomRange",args:[Y,oe.minzoom,oe.maxzoom]}),re)Object.hasOwn(re,ce)&&ce!=="layout"&&ce!=="paint"&&ce!=="filter"&&ce!=="metadata"&&ce!=="minzoom"&&ce!=="maxzoom"&&ce!=="slot"&&(ce.indexOf("paint.")===0?cs(re[ce],oe[ce],E,Y,ce.slice(6),Ka):d.O(re[ce],oe[ce])||E.push({command:Fc,args:[Y,ce,oe[ce]]}));for(ce in oe)Object.hasOwn(oe,ce)&&!Object.hasOwn(re,ce)&&ce!=="layout"&&ce!=="paint"&&ce!=="filter"&&ce!=="metadata"&&ce!=="minzoom"&&ce!=="maxzoom"&&ce!=="slot"&&(ce.indexOf("paint.")===0?cs(re[ce],oe[ce],E,Y,ce.slice(6),Ka):d.O(re[ce],oe[ce])||E.push({command:Fc,args:[Y,ce,oe[ce]]}))}else E.push({command:Ws,args:[Y]}),pe=V[V.lastIndexOf(Y)+1],E.push({command:zc,args:[oe,pe]})}(m,r.layers,o)}catch(u){console.warn("Unable to compute style diff:",u),o=[{command:Un,args:[r]}]}return o},drawDebug:function(a,r,o,u,f,m){for(let g=0;g<o.length;g++)if(f){const E=new d.C(u.r*.8,u.g*.8,u.b*.8,1);us(a,r,o[g],u,-1,-1,m),us(a,r,o[g],u,-1,1,m),us(a,r,o[g],u,1,1,m),us(a,r,o[g],u,1,-1,m),us(a,r,o[g],E,0,0,m)}else us(a,r,o[g],u,0,0,m)},drawDebugPadding:function(a){const r=a.transform.padding;to(a,a.transform.height-(r.top||0),3,Qa),to(a,r.bottom||0,3,Uu),Oc(a,r.left||0,3,$l),Oc(a,a.transform.width-(r.right||0),3,ql);const o=a.transform.centerPoint;(function(u,f,m,g){jn(u,f-1,m-10,2,20,g),jn(u,f-10,m-1,20,2,g)})(a,o.x,a.transform.height-o.y,Wl)},drawDebugQueryGeometry:function(a,r,o){for(let u=0;u<o.length;u++)Bc(a,r,o[u])},drawCollisionDebug:function(a,r,o,u,f,m,g){const x=a.context,w=x.gl,E=a.transform,I=[d.a7(E.center.lng),d.a8(E.center.lat)],R=o.layout.get("symbol-placement"),P=o.layout.get("text-variable-anchor"),B=o.layout.get("icon-rotation-alignment")==="map",V=o.layout.get("text-rotation-alignment")==="map",U=R!=="point",G=[];let $=0,Y=0;for(let ue=0;ue<u.length;ue++){const me=u[ue],Ie=r.getTile(me),we=Ie.getBucket(o);if(!we)continue;const ve=we.getProjection().createInversionMatrix(E,me.canonical),Se=[],Re=kc(me,we,E),Ue=!g&&B&&U,Pe=g&&V&&U,Oe=P&&we.hasTextData(),Xe=we.hasIconTextFit()&&Oe&&we.hasIconData(),ot=Ue||Pe||g&&Oe||Xe,tt=we.projection.name==="globe",Ye=tt?d.S(E.zoom):0;tt&&(Se.push("PROJECTION_GLOBE_VIEW"),ot&&Se.push("PROJECTED_POS_ON_VIEWPORT"));const mt=a.getOrCreateProgram("collisionBox",{defines:Se});let We=Re;f[0]===0&&f[1]===0||(We=a.translatePosMatrix(Re,Ie,f,m));const je=g?we.textCollisionBox:we.iconCollisionBox,Je=we.collisionCircleArray;if(Je.length>0){const rt=d.Y(),ct=We;d.a9(rt,we.placementInvProjMatrix,E.glCoordMatrix),d.a9(rt,rt,we.placementViewportMatrix),G.push({circleArray:Je,circleOffset:Y,transform:ct,invTransform:rt,projection:we.getProjection()}),$+=Je.length/4,Y=$}if(!je)continue;a.terrain&&a.terrain.setupElevationDraw(Ie,mt);const ft=tt?[me.canonical.x,me.canonical.y,1<<me.canonical.z]:[0,0,0];mt.draw(a,w.LINES,d.Z.disabled,d._.disabled,a.colorModeForRenderPass(),d.$.disabled,Xl(We,ve,E,Ye,I,Ie,ft,we.getProjection()),o.id,je.layoutVertexBuffer,je.indexBuffer,je.segments,null,E.zoom,null,[je.collisionVertexBuffer,je.collisionVertexBufferExt])}if(!g||!G.length)return;const re=a.getOrCreateProgram("collisionCircle"),oe=new d.aa;oe.resize(4*$),oe._trim();let pe=0;for(const ue of G)for(let me=0;me<ue.circleArray.length/4;me++){const Ie=4*me,we=ue.circleArray[Ie+0],ve=ue.circleArray[Ie+1],Se=ue.circleArray[Ie+2],Re=ue.circleArray[Ie+3];oe.emplace(pe++,we,ve,Se,Re,0),oe.emplace(pe++,we,ve,Se,Re,1),oe.emplace(pe++,we,ve,Se,Re,2),oe.emplace(pe++,we,ve,Se,Re,3)}(!hs||hs.length<2*$)&&(hs=function(ue){const me=2*ue,Ie=new d.ad;Ie.resize(me),Ie._trim();for(let we=0;we<me;we++){const ve=6*we;Ie.uint16[ve+0]=4*we+0,Ie.uint16[ve+1]=4*we+1,Ie.uint16[ve+2]=4*we+2,Ie.uint16[ve+3]=4*we+2,Ie.uint16[ve+4]=4*we+3,Ie.uint16[ve+5]=4*we+0}return Ie}($));const ce=x.createIndexBuffer(hs,!0),_e=x.createVertexBuffer(oe,d.ab.members,!0);for(const ue of G){const me=_i(ue.transform,ue.invTransform,E,ue.projection);re.draw(a,w.TRIANGLES,d.Z.disabled,d._.disabled,a.colorModeForRenderPass(),d.$.disabled,me,o.id,_e,ce,d.ac.simpleSegment(0,2*ue.circleOffset,ue.circleArray.length,ue.circleArray.length/2),null,E.zoom)}_e.destroy(),ce.destroy()}};async function qo(){return Promise.resolve()}function ha(a,r){let o=!1;if(r&&r.length)for(const u of r)u instanceof Mn?d.w(u.message):(a.fire(new d.f(new Error(u.message))),o=!0);return o}function Fr(a){return(...r)=>{const o=Gn[a];return o?o(...r):[]}}const io=Fr("validateStyle"),ju=Fr("validateSource"),Gu=Fr("validateLight"),Yl=Fr("validateLights"),Hu=Fr("validateTerrain"),Nc=Fr("validateFog"),Kl=Fr("validateSnow"),Vc=Fr("validateRain"),tl=Fr("validateLayer"),Z=Fr("validateFilter"),M=Fr("validatePaintProperty"),k=Fr("validateLayoutProperty"),q=Fr("validateModel"),J=d.s.light;let X;class Q extends d.E{constructor(r,o="flat"){super(),this._transitionable=new d.ae(X||(X=new d.af({anchor:new d.ag(J.anchor),position:new d.ah(J.position),color:new d.ag(J.color),intensity:new d.ag(J.intensity)}))),this.setLight(r,o),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(r,o,u={}){this._validate(Gu,r,u)||(this._transitionable.setTransitionOrValue(r),this.id=o)}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,o,u){return(!u||u.validate!==!1)&&ha(this,r.call(io,{value:o,style:{glyphs:!0,sprite:!0},styleSpec:d.s}))}}const ie=d.s.terrain;let ne=class extends d.E{constructor(a,r,o,u,f){super(),this.scope=o,this._transitionable=new d.ae(new d.af({source:new d.ag(ie.source),exaggeration:new d.ag(ie.exaggeration)}),o,u),this._transitionable.setTransitionOrValue(a,u),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=r,this.worldview=f}get(){return this._transitionable.serialize()}set(a,r){this._transitionable.setTransitionOrValue(a,r)}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 d.ai(a,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const a=this._transitionable._values.exaggeration;if(!a)return null;const r=a.value.expression;if(!r)return null;let o=-1,u=-1,f=1;for(const m of r.zoomStops)f=r.evaluate(new d.ai(m,{worldview:this.worldview})),f>.01?(o=m,u=-1):u=m;return f<.01&&o>0&&u>o?[o,u]:null}isZoomDependent(){const a=this._transitionable._values.exaggeration;return a!=null&&a.value!=null&&a.value.expression!=null&&a.value.expression instanceof d.aj}};function le(a,r){const o=a?a.terrain:null;return!!o&&(!r||!!r.projection.requiresDraping||!o.isZoomDependent()||o.getExaggeration(r.zoom)>0)}const ye=d.s.fog;class Ee extends d.E{constructor(r,o,u,f){super();const m=new d.af({range:new d.ag(ye.range),color:new d.ag(ye.color),"color-use-theme":new d.ag({type:"string","property-type":"data-constant",default:"default"}),"high-color":new d.ag(ye["high-color"]),"high-color-use-theme":new d.ag({type:"string","property-type":"data-constant",default:"default"}),"space-color":new d.ag(ye["space-color"]),"space-color-use-theme":new d.ag({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new d.ag(ye["horizon-blend"]),"star-intensity":new d.ag(ye["star-intensity"]),"vertical-range":new d.ag(ye["vertical-range"])});this._transitionable=new d.ae(m,u,f),this.set(r,f),this._transitioning=this._transitionable.untransitioned(),this._transform=o,this.properties=new d.ak(m),this.scope=u}get state(){const r=this._transform,o=r.projection.name==="globe",u=d.S(r.zoom),f=this.properties.get("range"),m=[2,4.5],g=.5/Math.tan(.5*r._fov),x=[f[0]+g,f[1]+g];return{range:o?[d.al(m[0],x[0],u),d.al(m[1],x[1],u)]:x,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(r,o,u={}){if(this._validate(Nc,r,u))return;const f={...r};for(const m of Object.keys(ye))f[m]===void 0&&(f[m]=ye[m].default);this._options=f,this._transitionable.setTransitionOrValue(this._options,o)}getOpacity(r){if(!this._transform.projection.supportsFog)return 0;const o=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:d.am(d.ao,d.an,r))*o.a}getOpacityAtLatLng(r,o){return this._transform.projection.supportsFog?d.ap(this.state,r,o):0}getOpacityForTile(r){if(!this._transform.projection.supportsFog)return[1,1];const o=this._transform.calculateFogTileMatrix(r.toUnwrapped());return d.aq(this.state,o,0,0,d.a2,d.a2,this._transform)}getOpacityForBounds(r,o,u,f,m){return this._transform.projection.supportsFog?d.aq(this.state,r,o,u,f,m,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(r){if(!this._transform.projection.supportsFog)return!1;const o=[4,5,6,7];for(const u of o){const f=r.points[u];let m;if(f[2]>=0)m=f;else{const g=r.points[u-4];m=d.ar(g,f,g[2]/(g[2]-f[2]))}if(d.as(this.state,m[0],m[1],0,this._transform)>=d.at)return!0}return!1}updateConfig(r){this._transitionable.setTransitionOrValue(this._options,r)}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,o,u){return(!u||u.validate!==!1)&&ha(this,r.call(io,{value:o,style:{glyphs:!0,sprite:!0},styleSpec:d.s}))}}let Le,Ne,Ge=class extends d.E{constructor(a,r,o,u){super();const f=Le||(Le=new d.af({density:new d.ag(d.s.snow.density),intensity:new d.ag(d.s.snow.intensity),color:new d.ag(d.s.snow.color),opacity:new d.ag(d.s.snow.opacity),vignette:new d.ag(d.s.snow.vignette),"vignette-color":new d.ag(d.s.snow["vignette-color"]),"center-thinning":new d.ag(d.s.snow["center-thinning"]),direction:new d.ag(d.s.snow.direction),"flake-size":new d.ag(d.s.snow["flake-size"])}));this._transitionable=new d.ae(f,o,u),this.set(a,u),this._transitioning=this._transitionable.untransitioned(),this.properties=new d.ak(f),this.scope=o}get state(){const a=this.properties.get("opacity"),r=this.properties.get("color"),o=this.properties.get("direction"),u=d.au(o[0]),f=-Math.max(d.au(o[1]),.01),m=[Math.cos(u)*Math.cos(f),Math.sin(u)*Math.cos(f),Math.sin(f)],g=this.properties.get("vignette"),x=this.properties.get("vignette-color"),w=new d.C(x.r,x.g,x.b,g);return{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new d.C(r.r,r.g,r.b,r.a*a),direction:m,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:w}}get(){return this._transitionable.serialize()}set(a,r,o={}){if(this._validate(Kl,a,o))return;const u={...a},f=d.s.snow;for(const m of Object.keys(f))u[m]===void 0&&(u[m]=f[m].default);this._options=u,this._transitionable.setTransitionOrValue(this._options,r)}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,r,o){return(!o||o.validate!==!1)&&ha(this,a.call(io,{value:r,style:{glyphs:!0,sprite:!0},styleSpec:d.s}))}},ut=class extends d.E{constructor(a,r,o,u){super();const f=Ne||(Ne=new d.af({density:new d.ag(d.s.rain.density),intensity:new d.ag(d.s.rain.intensity),color:new d.ag(d.s.rain.color),opacity:new d.ag(d.s.rain.opacity),vignette:new d.ag(d.s.rain.vignette),"vignette-color":new d.ag(d.s.rain["vignette-color"]),"center-thinning":new d.ag(d.s.rain["center-thinning"]),direction:new d.ag(d.s.rain.direction),"droplet-size":new d.ag(d.s.rain["droplet-size"]),"distortion-strength":new d.ag(d.s.rain["distortion-strength"])}));this._transitionable=new d.ae(f,o,u),this.set(a,u),this._transitioning=this._transitionable.untransitioned(),this.properties=new d.ak(f),this.scope=o}get state(){const a=this.properties.get("opacity"),r=this.properties.get("color"),o=this.properties.get("direction"),u=d.au(o[0]),f=-Math.max(d.au(o[1]),.01),m=[Math.cos(u)*Math.cos(f),Math.sin(u)*Math.cos(f),Math.sin(f)],g=this.properties.get("vignette-color"),x=new d.C(g.r,g.g,g.b,this.properties.get("vignette"));return{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new d.C(r.r,r.g,r.b,r.a*a),direction:m,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:x}}get(){return this._transitionable.serialize()}set(a,r,o={}){if(this._validate(Vc,a,o))return;const u={...a},f=d.s.rain;for(const m of Object.keys(f))u[m]===void 0&&(u[m]=f[m].default);this._options=u,this._transitionable.setTransitionOrValue(this._options,r)}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,r,o){return(!o||o.validate!==!1)&&ha(this,a.call(io,{value:r,style:{glyphs:!0,sprite:!0},styleSpec:d.s}))}};const nt={workerUrl:"",workerClass:null,workerParams:void 0};function Qe(a){return nt.workerClass!=null?new nt.workerClass:new self.Worker(nt.workerUrl,{name:a,type:"module",...nt.workerParams})}const gt="mapboxgl_preloaded_worker_pool";class at{constructor(r){this.active={},this.workers=null,this.name=r}acquire(r,o=at.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<o;){const u=Qe(`${this.name||""}WorkerPool: ${r}-${this.workers.length}`);this.workers.push(u)}return this.active[r]=!0,this.workers.slice()}release(r){delete this.active[r],this.workers&&this.numActive()===0&&(this.workers.forEach(o=>{o.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[gt]}numActive(){return Object.keys(this.active).length}}at.workerCount=2;class It{constructor(r,o,u="Worker",f=at.workerCount){this.workerPool=r,this.actors=[],this.currentActor=0,this.id=d.av();const m=this.workerPool.acquire(this.id,f);for(let g=0;g<m.length;g++){const x=new It.Actor(m[g],o,this.id);x.name=`${u} ${g}`,this.actors.push(x)}this.ready=!1,this.send("checkIfReady",null).then(()=>{this.ready=!0}).catch(()=>{})}send(r,o,u){return Promise.all(this.actors.map(f=>f.send(r,o,u)))}broadcast(r,o){for(const u of this.actors)u.notify(r,o)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(r=>{r.remove()}),this.actors=[],this.workerPool.release(this.id)}}It.Actor=d.aw;class Nt extends d.E{constructor(r,o,u,f){super(),this.scope=u,this._options=r,this.properties=new d.ak(o),this._transitionable=new d.ae(o,u,f),this._transitionable.setTransitionOrValue(r.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(r){this._transitionable.setTransitionOrValue(this._options.properties,r)}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(r,o){this._options=r,this._transitionable.setTransitionOrValue(r.properties,o)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}let Ut;const Gt=()=>Ut||(Ut=new d.af({color:new d.ag(d.s.properties_light_ambient.color),"color-use-theme":new d.ag({type:"string",default:"default","property-type":"data-constant"}),intensity:new d.ag(d.s.properties_light_ambient.intensity)}));let At;const xi=()=>At||(At=new d.af({direction:new d.ax(d.s.properties_light_directional.direction),color:new d.ag(d.s.properties_light_directional.color),"color-use-theme":new d.ag({type:"string",default:"default","property-type":"data-constant"}),intensity:new d.ag(d.s.properties_light_directional.intensity),"cast-shadows":new d.ag(d.s.properties_light_directional["cast-shadows"]),"shadow-quality":new d.ag(d.s.properties_light_directional["shadow-quality"]),"shadow-intensity":new d.ag(d.s.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new d.ag(d.s.properties_light_directional["shadow-draw-before-layer"])})),fi=(a,r,o,u,f,m,g,x,w,E=[0,0,1])=>({u_matrix:a,u_normal_matrix:r,u_opacity:o,u_faux_facade_ao_intensity:u,u_camera_pos:f,u_tile_to_meter:m,u_facade_emissive_chance:g,u_flood_light_color:x,u_flood_light_intensity:w,u_front_cutoff_params:E}),Bt=a=>({u_matrix:a}),Ht=a=>({u_matrix:a}),Ct=d.ay;async function Zt(){return Promise.resolve()}function pi(a,r,o,u,f,m,g,x){o.resetLayerRenderingStats(a);const w=a.context,E=w.gl,I=a.transform,R=o.paint.get("fill-extrusion-pattern"),P=o.paint.get("fill-extrusion-pattern-cross-fade"),B=R.constantOr(null),V=R.constantOr(1),U=o.paint.get("fill-extrusion-opacity"),G=a.style.enable3dLights(),$=o.paint.get(G&&!V?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),Y=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),$],re=o.layout.get("fill-extrusion-edge-radius"),oe=re>0&&!o.paint.get("fill-extrusion-rounded-roof"),pe=oe?0:re,ce=I.projection.name==="globe"?d.aD():0,_e=I.projection.name==="globe",ue=_e?d.S(I.zoom):0,me=[d.a7(I.center.lng),d.a8(I.center.lat)],Ie=o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",we=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Ie?null:o.lut).toArray01().slice(0,3),ve=o.paint.get("fill-extrusion-flood-light-intensity"),Se=o.paint.get("fill-extrusion-vertical-scale"),Re=o.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Ue=o.paint.get("fill-extrusion-height-alignment"),Pe=o.paint.get("fill-extrusion-base-alignment"),Oe=d.aE(a,o.paint.get("fill-extrusion-cutoff-fade-range")),Xe=o.paint.get("fill-extrusion-front-cutoff"),ot=di(I.pitch,Xe,!!a.terrain),tt=ot[2]<1;tt&&(a.maxFrontCutoffRawStart=Math.max(a.maxFrontCutoffRawStart,Xe[0]));const Ye=[];let mt;_e&&Ye.push("PROJECTION_GLOBE_VIEW"),Y[0]>0&&Ye.push("FAUX_AO"),oe&&Ye.push("ZERO_ROOF_RADIUS"),x&&Ye.push("HAS_CENTROID"),ve>0&&Ye.push("FLOOD_LIGHT"),Oe.shouldRenderCutoff&&Ye.push("RENDER_CUTOFF"),tt&&Ye.push("RENDER_FRONT_CUTOFF"),Re&&Ye.push("RENDER_WALL_MODE");const We=a.renderPass==="shadow",je=a.shadowRenderer,Je=We&&!!je,ft=We?d.$.disabled:d.$.backCCW;a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!0);let rt=[0,0,0];if(je){const Rt=a.style.directionalLight,Mt=a.style.ambientLight;Rt&&Mt&&(rt=d.aF(a.style,Rt,Mt)),We||(Ye.push("RENDER_SHADOWS"),je.useNormalOffset&&Ye.push("NORMAL_OFFSET")),mt=Ye.concat(["SHADOWS_SINGLE_CASCADE"])}const ct=Je?"fillExtrusionDepth":V?"fillExtrusionPattern":"fillExtrusion",xt=o.getLayerRenderingStats();for(const Rt of u){const Mt=r.getTile(Rt),Ft=Mt.getBucket(o);if(!Ft||Ft.projection.name!==I.projection.name)continue;let bi=!1;je&&(bi=je.getMaxCascadeForTile(Rt.toUnwrapped())===0);const yi=a.isTileAffectedByFog(Rt),kt=Ft.programConfigurations.get(o.id);let _t=!1;if(B&&Mt.imageAtlas){const Wt=Mt.imageAtlas,Ti=d.aG.from(B),tr=Ti.getPrimary().scaleSelf(d.e.devicePixelRatio).toString(),ni=Ti.getSecondary(),ii=Wt.patternPositions.get(tr),Ni=ni?Wt.patternPositions.get(ni.scaleSelf(d.e.devicePixelRatio).toString()):null;_t=!!ii&&!!Ni,ii&&kt.setConstantPatternPositions(ii,Ni)}P>0&&(_t||kt.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Ye.push("FILL_EXTRUSION_PATTERN_TRANSITION");const wi=a.getOrCreateProgram(ct,{config:kt,defines:bi?mt:Ye,overrideFog:yi});if(a.terrain&&a.terrain.setupElevationDraw(Mt,wi,{useMeterToDem:!0}),!Ft.centroidVertexBuffer){const Wt=wi.getAttributeLocation(E,"a_centroid_pos");Wt!==-1&&E.vertexAttribI4ui(Wt,0,0,0,0)}!We&&je&&je.setupShadows(Mt.tileID.toUnwrapped(),wi,"vector-tile"),V&&(a.context.activeTexture.set(E.TEXTURE0),Mt.imageAtlasTexture&&Mt.imageAtlasTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),kt.updatePaintBuffers());const sr=o.paint.get("fill-extrusion-vertical-gradient"),qi=1/Ft.tileToMeter;let Yt;if(We&&je){if(Si(Mt.tileID,Ft.maxHeight,a))continue;const Wt=je.calculateShadowPassMatrixFromTile(Mt.tileID.toUnwrapped());Yt=d.aM(Wt,pe,qi,Se,Ue,Pe)}else{const Wt=a.translatePosMatrix(Rt.expandedProjMatrix,Mt,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),Ti=I.projection.createInversionMatrix(I,Rt.canonical),tr=wi.fixedDefines.includes("LIGHTING_3D_MODE");Yt=V?d.aH(Wt,a,sr,U,Y,pe,qi,Rt,Mt,ce,Ue,Pe,ue,me,Ti,we,Se,P,tr):d.aI(Wt,a,sr,U,Y,pe,qi,Rt,ce,Ue,Pe,ue,me,Ti,we,Se,ve,rt,ot,tr)}a.uploadCommonUniforms(w,wi,Rt.toUnwrapped(),null,Oe);let Wi=Ft.segments;if(I.projection.name==="mercator"&&!We&&(Wi=Ft.getVisibleSegments(Mt.tileID,a.terrain,a.transform.getFrustum(0)),!Wi.get().length))continue;if(xt)if(We)for(const Wt of Wi.get())xt.numRenderedVerticesInShadowPass+=Wt.primitiveLength;else for(const Wt of Wi.get())xt.numRenderedVerticesInTransparentPass+=Wt.primitiveLength;const Mi=[];(a.terrain||x)&&Mi.push(Ft.centroidVertexBuffer),_e&&Mi.push(Ft.layoutVertexExtBuffer),Re&&Mi.push(Ft.wallVertexBuffer),wi.draw(a,w.gl.TRIANGLES,f,m,g,ft,Yt,o.id,Ft.layoutVertexBuffer,Ft.indexBuffer,Wi,o.paint,a.transform.zoom,kt,Mi)}a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!1)}class zt{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function di(a,r,o){if(!(r[2]<1)||o)return[0,0,1];const u=180*a/Math.PI;if(u<15)return[-.5,r[1],r[2]];const f=Math.min(1,Math.max(0,(u-15)/5)),m=f*f*(3-2*f);return[-.5*(1-m)+r[0]*m,r[1],r[2]]}function yr(a,r,o,u,f,m,g){u.centroidVertexArray.length===0&&u.createCentroidsBuffer();const x=m?m.findDEMTileFor(o):null;if(!(x&&x.dem||g))return;m&&x&&x.dem&&u.selfDEMTileTimestamp!==x.dem._timestamp&&(u.borderDoneWithNeighborZ=[-1,-1,-1,-1],u.selfDEMTileTimestamp=x.dem._timestamp);const w=($,Y)=>{($.flags|Y.flags)&d.aJ?($.flags|=d.aJ,Y.flags|=d.aJ):($.flags&=~d.aJ,Y.flags&=~d.aJ)},E=$=>new d.P(Math.ceil(($+d.aK)*d.aL),0),I=($,Y,re)=>{const oe=Math.ceil(($+d.aK)*d.aL),pe=Math.floor(Math.max(0,Math.min(d.a2-1,re))/4);return new d.P(oe,pe<<5|(3&Y)<<3|7)},R=$=>{const Y=r.getSource().minzoom,re=pe=>{const ce=r.getTileByID(pe);if(ce&&ce.hasData())return ce.getBucket(f)},oe=[0,-1,1];for(const pe of oe){if($.overscaledZ+pe<Y)continue;const ce=re($.calculateScaledKey($.overscaledZ+pe));if(ce)return ce}},P=[0,0,0],B=($,Y)=>(P[0]=Math.min($.min.y,Y.min.y),P[1]=Math.max($.max.y,Y.max.y),P[2]=d.a2-Y.min.x>$.max.x?Y.min.x-d.a2:$.max.x,P),V=($,Y)=>(P[0]=Math.min($.min.x,Y.min.x),P[1]=Math.max($.max.x,Y.max.x),P[2]=d.a2-Y.min.y>$.max.y?Y.min.y-d.a2:$.max.y,P),U=[($,Y)=>B($,Y),($,Y)=>B(Y,$),($,Y)=>V($,Y),($,Y)=>V(Y,$)],G=($,Y,re,oe,pe,ce,_e)=>{if(!m)return 0;const ue=[[ce?re:$,ce?$:re,0],[ce?re:Y,ce?Y:re,0]],me=_e<0?d.a2+_e:_e,Ie=[ce?me:($+Y)/2,ce?($+Y)/2:me,0];return re===0&&_e<0||re!==0&&_e>0?m.getForTilePoints(pe,[Ie],!0,oe):ue.push(Ie),m.getForTilePoints(o,ue,!0,x),Math.max(ue[0][2],ue[1][2],Ie[2])/m.exaggeration()};for(let $=0;$<4;$++){const Y=u.borderFeatureIndices[$];if(Y.length===0)continue;const re=d.aB[$](o),oe=R(re);if(!(oe&&oe instanceof d.aC))continue;const pe=m?m.findDEMTileFor(re):null;if(!(pe&&pe.dem||g)||(m&&pe&&pe.dem&&u.borderDEMTileTimestamp[$]!==pe.dem._timestamp&&(u.borderDoneWithNeighborZ[$]=-1,u.borderDEMTileTimestamp[$]=pe.dem._timestamp),u.borderDoneWithNeighborZ[$]===oe.canonical.z))continue;oe.centroidVertexArray.length===0&&oe.createCentroidsBuffer();const ce=($<2?1:5)-$,_e=oe.borderDoneWithNeighborZ[ce]!==u.canonical.z,ue=oe.borderFeatureIndices[ce];let me=0;if(u.canonical.z!==oe.canonical.z){for(const Se of Y)u.showCentroid(u.featuresOnBorder[Se]);if(_e)for(const Se of ue)oe.showCentroid(oe.featuresOnBorder[Se]);u.borderDoneWithNeighborZ[$]=oe.canonical.z,oe.borderDoneWithNeighborZ[ce]=u.canonical.z;continue}const Ie=new Map,we=new Set,ve=new Set;for(let Se=0;Se<ue.length;Se++){const Re=oe.featuresOnBorder[ue[Se]];Re.buildingId!==void 0&&Ie.set(Re.buildingId,Se)}for(const Se of Y){const Re=u.featuresOnBorder[Se],Ue=u.centroidData.get(Re.centroidDataIndex);if(Re.buildingId===void 0)continue;const Pe=Ie.get(Re.buildingId);if(Pe===void 0)continue;const Oe=oe.featuresOnBorder[ue[Pe]],Xe=oe.centroidData.get(Oe.centroidDataIndex);we.add(Se),ve.add(Pe),g&&w(Ue,Xe);const ot=Ue.groupCentroidPos.x!==0||Ue.groupCentroidPos.y!==0?Ue.groupCentroidPos:Re.centroid(),tt=Xe.groupCentroidPos.x!==0||Xe.groupCentroidPos.y!==0?Xe.groupCentroidPos:Oe.centroid(),Ye=$<2?Math.round((ot.y+tt.y)/2):Math.round((ot.x+tt.x)/2),mt=Re.intersectsCount()>1||Oe.intersectsCount()>1;{let We=0;if(pe&&pe.dem&&!mt){const je=U[$](Ue,Xe),Je=$%2?d.a2-1:0;We=G(je[0],Math.min(d.a2-1,je[1]),Je,pe,re,$<2,je[2])}Ue.centroidXY=I(We,$,Ye),Xe.centroidXY=I(We,ce,Ye)}if(u.writeCentroidToBuffer(Ue),oe.writeCentroidToBuffer(Xe),Re.buildingId!==void 0){for(const We of u.centroidData)We.buildingId===Re.buildingId&&We!==Ue&&(We.centroidXY=Ue.centroidXY,u.writeCentroidToBuffer(We));for(const We of oe.centroidData)We.buildingId===Re.buildingId&&We!==Xe&&(We.centroidXY=Xe.centroidXY,oe.writeCentroidToBuffer(We))}}for(const Se of Y){if(we.has(Se))continue;const Re=u.featuresOnBorder[Se],Ue=u.centroidData.get(Re.centroidDataIndex),Pe=Re.borders[$];let Oe;for(;me<ue.length;){if(ve.has(me)){me++;continue}Oe=oe.featuresOnBorder[ue[me]];const Xe=Oe.borders[ce];if(Xe[1]>Pe[0]+3||Xe[0]>Pe[0]-3)break;oe.showCentroid(Oe),me++}if(Oe&&me<ue.length){let Xe=me,ot=0;for(;;)if(ve.has(me)){if(++me===ue.length)break;Oe=oe.featuresOnBorder[ue[me]]}else{if(Oe.borders[ce][0]>Pe[1]-3||(ot++,++me===ue.length))break;Oe=oe.featuresOnBorder[ue[me]]}for(;Xe<ue.length&&ve.has(Xe);)Xe++;if(Xe>=ue.length){u.showCentroid(Re);continue}Oe=oe.featuresOnBorder[ue[Xe]];let tt=!1;if(ot>=1){const We=Oe.borders[ce];Math.abs(Pe[0]-We[0])<3&&Math.abs(Pe[1]-We[1])<3&&(ot=1,tt=!0,me=Xe+1)}else if(ot===0){u.showCentroid(Re);continue}const Ye=oe.centroidData.get(Oe.centroidDataIndex);g&&tt&&w(Ue,Ye);const mt=Re.intersectsCount()>1||Oe.intersectsCount()>1;if(ot>1)me=Xe,Ue.centroidXY=Ye.centroidXY=new d.P(0,0);else if(pe&&pe.dem&&!mt){const We=U[$](Ue,Ye),je=$%2?d.a2-1:0,Je=G(We[0],Math.min(d.a2-1,We[1]),je,pe,re,$<2,We[2]);Ue.centroidXY=Ye.centroidXY=E(Je)}else mt?Ue.centroidXY=Ye.centroidXY=new d.P(0,0):(Ue.centroidXY=u.encodeBorderCentroid(Re),Ye.centroidXY=oe.encodeBorderCentroid(Oe));u.writeCentroidToBuffer(Ue),oe.writeCentroidToBuffer(Ye)}else u.showCentroid(Re)}u.borderDoneWithNeighborZ[$]=oe.canonical.z,oe.borderDoneWithNeighborZ[ce]=u.canonical.z}(u.needsCentroidUpdate||!u.centroidVertexBuffer&&u.centroidVertexArray.length!==0)&&u.uploadCentroid(a)}const vi=[1,0,0],dr=[0,1,0],Qi=[0,0,1];function Si(a,r,o){const u=o.transform,f=o.shadowRenderer;if(!f)return!0;const m=o.frameCounter,g=o.currentShadowCascade;let x=o._shadowCullCache;if(!x||x.frame!==m||x.cascade!==g){const $=u.tileSize*f._cascades[g].scale,Y=u.scaleZoom($),re=f.shadowDirection,oe=[re[0],re[1],-re[2]],pe=[vi,dr,Qi,oe,[oe[0],0,oe[2]],[0,oe[1],oe[2]]];x={frame:m,cascade:g,cameraFrustum:d.az.fromInvProjectionMatrix(u.invProjMatrix,u.worldSize,Y,u.projection.name!=="globe"),edges:pe,shadowDir:oe,ws:$,zoom:Y},o._shadowCullCache=x}const{cameraFrustum:w,edges:E,shadowDir:I,ws:R,zoom:P}=x;let B=r;if(u.elevation){const $=u.elevation.getMinMaxForTile(a);$&&(B+=$.max)}B/=d.aA(u.center.lat,P);const V=f.computeSimplifiedTileShadowVolume(a.toUnwrapped(),B,R,I);if(!V)return!1;const{vertices:U,planes:G}=V;return w.intersectsPrecise(U,G,E)===0||f.getCurrentCascadeFrustum().intersectsPrecise(U,G,E)===0}const Li=new Float32Array(16),Ii=new Float32Array(16);function nr(a){const{painter:r,source:o,layer:u,coords:f}=a;let m=a.defines;const g=r.context,x=r.renderPass==="shadow",w=r.renderPass==="light-beam",E=r.shadowRenderer,I=d.aA(r.transform.center.lat,r.transform.zoom),R=d.aE(r,u.paint.get("building-cutoff-fade-range"));R.shouldRenderCutoff&&(m=m.concat("RENDER_CUTOFF"));const P=u.paint.get("building-front-cutoff"),B=P[2]<1&&!r.terrain,V=di(r.transform.pitch,P,!!r.terrain);B&&(m=m.concat("RENDER_FRONT_CUTOFF"),r.maxFrontCutoffRawStart=Math.max(r.maxFrontCutoffRawStart,P[0])),a.floodLightIntensity>0&&(m=m.concat("FLOOD_LIGHT"));for(const U of f){const G=o.getTile(U),$=G.getBucket(u);if(!$)continue;E&&E.getMaxCascadeForTile(U.toUnwrapped())===0&&(m=m.concat("SHADOWS_SINGLE_CASCADE"));const Y=$.programConfigurations.get(u.id);let re,oe;const pe=r.translatePosMatrix(U.expandedProjMatrix,G,[0,0],"map");d.aN(Li,pe,[1,1,a.verticalScale]);const ce=Li;let _e;if(x&&E){if(Si(G.tileID,$.maxHeight*I,r))continue;const me=E.calculateShadowPassMatrixFromTile(G.tileID.toUnwrapped());d.aN(me,me,[1,1,a.verticalScale]),_e=Ht(me),re=oe=r.getOrCreateProgram("buildingDepth",{config:Y,defines:m,overrideFog:!1})}else if(w)re=oe=r.getOrCreateProgram("buildingBloom",{config:Y,defines:m,overrideFog:!1}),_e=Bt(ce);else{const me=r.transform.calculatePosMatrix(U.toUnwrapped(),r.transform.worldSize);d.aN(me,me,[1,1,a.verticalScale]),d.aN(Ii,me,[1,-1,1/I]),d.aO(Ii,Ii),d.aP(Ii,Ii);const Ie=Ii,we=r.transform.getFreeCameraOptions().position,ve=1<<U.canonical.z;if(_e=fi(ce,Ie,a.opacity,a.facadeAOIntensity,[((we.x-U.wrap)*ve-U.canonical.x)*d.a2,(we.y*ve-U.canonical.y)*d.a2,we.z*ve*d.a2],$.tileToMeter,a.facadeEmissiveChance,a.floodLightColor,a.floodLightIntensity,V),oe=r.getOrCreateProgram("building",{config:Y,defines:m,overrideFog:!1}),a.depthOnly===!0)re=oe;else{const Se=m.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);re=r.getOrCreateProgram("building",{config:Y,defines:Se,overrideFog:!1})}E&&(E.setupShadowsFromMatrix(me,oe,!0),re!==oe&&re.setShadowUniformValues(g,E.getShadowUniformValues()))}const ue=(me,Ie)=>{if(w){const we=me.entranceBloom;Ie.draw(r,g.gl.TRIANGLES,a.depthMode,d._.disabled,a.blendMode,d.$.disabled,_e,u.id,we.layoutVertexBuffer,we.indexBuffer,we.segmentsBucket,u.paint,r.transform.zoom,Y,[we.layoutAttenuationBuffer,we.layoutColorBuffer])}else{const we=me.segmentsBucket;let ve=[me.layoutNormalBuffer,me.layoutCentroidBuffer,me.layoutColorBuffer,me.layoutFloodLightDataBuffer];me.layoutFacadePaintBuffer&&(ve=ve.concat([me.layoutFacadeDataBuffer,me.layoutFacadeVerticalRangeBuffer,me.layoutFacadePaintBuffer])),Ie.draw(r,g.gl.TRIANGLES,a.depthMode,d._.disabled,a.blendMode,x?d.$.disabled:d.$.backCW,_e,u.id,me.layoutVertexBuffer,me.indexBuffer,we,u.paint,r.transform.zoom,Y,ve)}};r.uploadCommonUniforms(g,oe,U.toUnwrapped(),null,R),$.buildingWithoutFacade&&ue($.buildingWithoutFacade,oe),$.buildingWithFacade&&(re!==oe&&r.uploadCommonUniforms(g,re,U.toUnwrapped(),null,R),ue($.buildingWithFacade,re))}}function Hr(a,r,o,u,f,m,g,x,w,E,I,R,P,B){const V=a.context.gl,U=a.depthModeForSublayer(1,d.Z.ReadOnly,V.LEQUAL,!0),G=d.al(.1,3,I),$=a._showOverdrawInspector,Y=R,re=new zt;if(!$){const oe=new d._({func:V.ALWAYS,mask:255},255,255,V.KEEP,V.KEEP,V.REPLACE),pe=new d.a1([V.ONE,V.ONE,V.ONE,V.ONE],d.C.transparent,[!1,!1,!1,!0],V.MIN);d.aQ(re,a,r,o,u,U,oe,pe,d.$.disabled,f,"sdf",m,g,x,w,E,G,Y,!1,void 0)}{const oe=$?d._.disabled:new d._({func:V.EQUAL,mask:255},255,255,V.KEEP,V.DECR,V.DECR),pe=$?a.colorModeForRenderPass():new d.a1([V.ONE_MINUS_DST_ALPHA,V.DST_ALPHA,V.ONE,V.ONE],d.C.transparent,[!0,!0,!0,!0]);d.aQ(re,a,r,o,u,U,oe,pe,d.$.disabled,f,"color",m,g,x,w,E,G,Y,!1,void 0)}}class Zr{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(r,o,u,f,m){if(u<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let g=null,x=Number.MAX_VALUE,w=Number.MAX_VALUE,E=!1;const I=this._previousClosestBuildingId?r[this._previousClosestBuildingId]:null;this._previousClosestBuildingId&&I&&this._isBuildingVisible(I,f,m)&&(E=!0,w=this._calculateDistance(o,I));for(const[R,P]of Object.entries(r)){if(!this._isBuildingVisible(P,f,m))continue;const B=this._calculateDistance(o,P);B<x&&(x=B,g=R)}return E&&g&&this._previousClosestBuildingId&&g!==this._previousClosestBuildingId?x>w*this._hysteresisRatio&&(g=this._previousClosestBuildingId):E&&!g&&(g=this._previousClosestBuildingId),this._previousClosestBuildingId=g,g}_calculateDistance(r,o){if(!o.center)return Number.MAX_VALUE;const u=r.lat-o.center[1],f=r.lng-o.center[0];return u*u+f*f}_isBuildingVisible(r,o,u){if(!u)return!1;for(const f of r.floorIds){const m=r.floors[f];if(!m.geometry)continue;const g=m.geometry;if(g.type==="Polygon"){const x=this._convertRingToPoints(g.coordinates[0]);if(d.aT(x,u))return!0}else if(g.type==="MultiPolygon"){const x=this._convertMultiPolygonToPoints(g.coordinates);if(d.aU(u,x))return!0}}return!1}_convertRingToPoints(r){return r.map(o=>new d.P(o[0],o[1]))}_convertMultiPolygonToPoints(r){return r.map(o=>o.length===0?[]:o[0].map(u=>new d.P(u[0],u[1])))}}const fr=.05,ro=(a,r,o,u,f,m,g,x,w,E,I,R)=>({u_matrix:a,u_normalize_matrix:r,u_globe_matrix:o,u_merc_matrix:u,u_grid_matrix:f,u_tl_parent:m,u_scale_parent:E,u_fade_t:I.mix,u_opacity:I.opacity,u_image0:0,u_image1:1,u_raster_elevation:R,u_zoom_transition:g,u_merc_center:x,u_cutoff_params:w}),Ai=(a,r,o,u,f,m,g,x,w,E)=>({u_particle_texture:a,u_particle_texture_side_len:r,u_tile_offset:o,u_velocity:u,u_color_ramp:m,u_velocity_res:f,u_max_speed:g,u_uv_offset:x,u_data_scale:[255*w[0],255*w[1]],u_data_offset:E,u_particle_pos_scale:1.1,u_particle_pos_offset:[fr,fr]}),gi=(a,r,o,u,f,m,g,x,w,E)=>({u_particle_texture:a,u_particle_texture_side_len:r,u_velocity:o,u_velocity_res:u,u_max_speed:f,u_speed_factor:m,u_reset_rate:g,u_rand_seed:Math.random(),u_uv_offset:x,u_data_scale:[255*w[0],255*w[1]],u_data_offset:E,u_particle_pos_scale:1.1,u_particle_pos_offset:[fr,fr]});function Yr(a,[r,o,u,f],[m,g]){if(m===g)return[0,0,0,0];const x=255*(a-1)/(a*(g-m));return[r*x,o*x,u*x,f*x]}function wr(a,r,[o,u]){return o===u?0:.5/a+(r-o)*(a-1)/(a*(u-o))}var Vt=d.a_([{name:"a_index",type:"Int16",components:1}]);class $i{constructor(r,o,u,f){const m={width:u[0],height:u[1],data:null},g=r.gl;this.targetColorTexture=new d.T(r,m,g.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new d.T(r,m,g.RGBA8,{useMipmap:!1}),this.context=r,this.updateParticleTexture(o,f),this.lastInvalidatedAt=0}updateParticleTexture(r,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());const u=this.context.gl,f=o.width*o.height;this.particleTexture0=new d.T(this.context,o,u.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new d.T(this.context,o,u.RGBA8,{premultiply:!1,useMipmap:!1});const m=new d.a$;m.reserve(f);for(let g=0;g<f;g++)m.emplaceBack(g);this.particleIndexBuffer=this.context.createVertexBuffer(m,Vt.members,!0),this.particleSegment=d.ac.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=o.width}update(r){return!(this.lastInvalidatedAt<r&&(this.lastInvalidatedAt=d.e.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function Or(a,r,o,u,f){if(f>0){const m=d.e.now(),g=(m-a.timeAdded)/f,x=r?(m-r.timeAdded)/f:-1,w=o.getSource(),E=u.coveringZoomLevel({tileSize:w.tileSize,roundZoom:w.roundZoom}),I=!r||Math.abs(r.tileID.overscaledZ-E)>Math.abs(a.tileID.overscaledZ-E),R=I&&a.refreshedUponExpiration?1:d.b0(I?g:1-x,0,1);return r?{opacity:1,mix:1-R,isFading:g<1}:{opacity:R,mix:0,isFading:g<1}}return{opacity:1,mix:0,isFading:!1}}function Rn(a,r,o){if(!a)return null;const u=r.getTextureDescriptor(a,o,!0);if(!u)return null;let{texture:f,mix:m,offset:g,tileSize:x,buffer:w,format:E}=u;if(!f||!E)return null;let I=!1;return E==="uint32"&&(I=!0,m[3]=0,m=Yr(d.b9,m,[0,o.paint.get("raster-particle-max-speed")]),g=wr(d.b9,g,[0,o.paint.get("raster-particle-max-speed")])),{texture:f,textureOffset:[w/(x+2*w),x/(x+2*w)],tileSize:x,scalarData:I,scale:m,offset:g,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[E]]}}function tn(a){const r=a._nearZ,o=a.projection.farthestPixelDistance(a),u=o-r,f=.2*a.height,m=r+f;return[r,o,(m-f-r)/u,(m-r)/u]}var Br=`#ifdef RASTER_ARRAY
3104uniform 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;
3104ivec4 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;}
3105#endif
3106uniform 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;}`;d.ba["_prelude_raster_particle.glsl"]||(d.ba["_prelude_raster_particle.glsl"]=Br);var no={building:d.bb(`#include "_prelude_fog.fragment.glsl"
3107#include "_prelude_shadow.fragment.glsl"
3108#include "_prelude_lighting.glsl"
3109#include "_prelude_indicator_cutout.fragment.glsl"
3110#include "_prelude_feature_cutout.fragment.glsl"
3111const 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;
3112#ifdef RENDER_FRONT_CUTOFF
3113in float v_front_cutoff_opacity;
3114#endif
3115#ifdef INDICATOR_CUTOUT
3116#ifdef FEATURE_CUTOUT
3117in vec4 v_ground_roof;
3118#endif
3119#endif
3120#ifdef BUILDING_FAUX_FACADE
3121in 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;
3122#endif
3123#ifdef RENDER_SHADOWS
3124in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
3125#endif
3126#ifdef FLOOD_LIGHT
3127in highp float v_flood_radius;in float v_has_flood_light;
3128#endif
3129uniform 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));}
3130#ifdef BUILDING_FAUX_FACADE
3131highp 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;
3132#if 0
3133if (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;
3134#else
3135if (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;
3135out_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;
3136#endif
3137return out_color;}
3138#endif
3139vec3 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;
3140#ifdef BUILDING_FAUX_FACADE
3141if (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);}
3142#endif
3143vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;
3144#ifdef RENDER_SHADOWS
3145#ifdef RENDER_CUTOFF
3146shadowed_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;}
3147#else
3148shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
3149#endif
3150#else
3151shadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));
3152#endif
3153color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);
3154#ifdef FLOOD_LIGHT
3155float 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);
3156#endif
3157color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);
3158#ifdef FOG
3159color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));
3160#endif
3161color*=u_opacity;
3162#ifdef INDICATOR_CUTOUT
3163#ifdef FEATURE_CUTOUT
3164{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}
3165#else
3166color=applyCutout(color,v_pos.z);
3167#endif
3168#endif
3169#ifdef RENDER_FRONT_CUTOFF
3170if (v_front_cutoff_opacity < 1.0) {int index=viewport_dither_index(gl_FragCoord.xy);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}
3171#endif
3172#ifdef FEATURE_CUTOUT
3173color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);
3174#endif
3175glFragColor=color;
3176#ifdef DEBUG_SHOW_NORMALS
3177color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;
3178#endif
3179#ifdef OVERDRAW_INSPECTOR
3180glFragColor=vec4(1.0);
3181#endif
3182HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
3183#include "_prelude_shadow.vertex.glsl"
3184in vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;
3185#ifdef FLOOD_LIGHT
3186in int a_flood_light_wall_radius_1i16;
3187#endif
3188#ifdef BUILDING_FAUX_FACADE
3189in uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;
3190#endif
3191uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;
3192#ifdef RENDER_FRONT_CUTOFF
3193uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;
3194#endif
3195#ifdef INDICATOR_CUTOUT
3196#ifdef FEATURE_CUTOUT
3197out vec4 v_ground_roof;
3198#endif
3199#endif
3200out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;
3201#ifdef BUILDING_FAUX_FACADE
3202out 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;
3203#endif
3204#ifdef RENDER_SHADOWS
3205uniform 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;
3206#endif
3207#ifdef FLOOD_LIGHT
3208out highp float v_flood_radius;out float v_has_flood_light;
3209#endif
3210const 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));}
3211#ifdef BUILDING_FAUX_FACADE
3212mat3 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);}
3213#endif
3214#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive
3215#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive
3216void main() {
3217#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive
3218#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive
3219#ifdef FLOOD_LIGHT
3220v_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);
3221#endif
3222vec4 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);
3223#ifdef BUILDING_FAUX_FACADE
3224vec4 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;}
3225#endif
3226v_pos=a_pos_3f;
3227#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
3228float halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 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;
3229#endif
3230#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
3231vec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);
3232#endif
3233#ifdef RENDER_CUTOFF
3234v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;
3235#endif
3236#ifdef RENDER_SHADOWS
3237vec3 shadow_pos=v_pos;
3238#ifdef NORMAL_OFFSET
3239vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();
3240#endif
3241v_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);
3242#endif
3243#ifdef FOG
3244v_fog_pos=fog_position(v_pos);
3245#endif
3246#ifdef RENDER_FRONT_CUTOFF
3247v_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));
3247float 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);}
3248#endif
3249gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;
3250#ifdef INDICATOR_CUTOUT
3251#ifdef FEATURE_CUTOUT
3252vec4 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);
3253#endif
3254#endif
3255}`),buildingBloom:d.bb(`in vec4 v_color_emissive;
3256#pragma mapbox: define-attribute highp vec4 bloom_attenuation
3257float saturate(float val) {return clamp(val,0.0,1.0);}void main() {
3258#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
3259float emission=v_color_emissive.a;float opacity=1.0;
3260#ifdef HAS_ATTRIBUTE_a_bloom_attenuation
3261float 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);
3262#endif
3263#ifdef RENDER_CUTOFF
3264opacity*=v_cutoff_opacity;
3265#endif
3266glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f;
3267#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive
3268#pragma mapbox: define-attribute highp vec4 bloom_attenuation
3269out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
3270#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive
3271#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
3272#ifdef HAS_ATTRIBUTE_a_part_color_emissive
3273vec4 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);
3274#else
3275v_color_emissive=vec4(1.0);
3276#endif
3277gl_Position=u_matrix*vec4(a_pos_3f,1.0);
3278#ifdef RENDER_CUTOFF
3279v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
3280#endif
3281}`),buildingDepth:d.bb("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:d.bb(`#include "_prelude_fog.fragment.glsl"
3282#include "_prelude_lighting.glsl"
3283uniform 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;
3284#ifdef LIGHTING_3D_MODE
3285out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;
3286#endif
3287#ifdef FOG
3288highp 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));
3289#endif
3290glFragColor=vec4(out_color*color.a,color.a);
3291#ifdef OVERDRAW_INSPECTOR
3292glFragColor=vec4(1.0);
3293#endif
3294HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
3295uniform 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;
3296#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
3297in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;
3298#ifdef PROJECTION_GLOBE_VIEW
3299vec3 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;
3300#ifdef FOG
3301v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
3302#endif
3303#else
3304uv=vec2(a_texture_pos)/8192.0;
3304gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);
3305#ifdef FOG
3306v_fog_pos=fog_position(vec2(a_pos));
3307#endif
3308#endif
3309v_pos0=uv;
3310#ifdef VIEWPORT_ORIGIN_TOP_LEFT
3311v_pos0.y=1.0-v_pos0.y;
3312#endif
3313v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:d.bb("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"
3314in 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(
3315mod(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:d.bb("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;
3316#ifdef VIEWPORT_ORIGIN_TOP_LEFT
3317v_tex_pos.y=1.0-v_tex_pos.y;
3318#endif
3319gl_Position=vec4(a_pos,0.0,1.0);}`),rasterParticleUpdate:d.bb(`#include "_prelude_raster_particle.glsl"
3320uniform 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(
3321linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)
3322);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:d.bb("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;}",`
3323in 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; 
3324uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; 
3325uniform float u_horizontalOscillationRate; 
3326uniform 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);
3326simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+
3327localY*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:d.bb("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;}",`
3328in 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; 
3329uniform float u_velocity; 
3330uniform 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; 
3331pos+=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+
3332localY*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:d.bb("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);}"),elevatedStructuresDepth:d.bb("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;}"),elevatedStructures:d.bb(`#include "_prelude_fog.fragment.glsl"
3333#include "_prelude_lighting.glsl"
3334#include "_prelude_shadow.fragment.glsl"
3335#include "_prelude_indicator_cutout.fragment.glsl"
3336#include "_prelude_feature_cutout.fragment.glsl"
3337in vec3 v_normal;in float v_height;
3338#ifdef RENDER_SHADOWS
3339in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;
3340#endif
3341vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
3341vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)
3342{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;uniform float u_opacity_multiplier;
3343#pragma mapbox: define highp vec4 structure_color
3344void main() {
3345#pragma mapbox: initialize highp vec4 structure_color
3346vec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);
3347#ifdef FEATURE_CUTOUT
3348cutout_factors=get_cutout_factors(gl_FragCoord);
3349#endif
3350#ifdef LIGHTING_3D_MODE
3351vec3 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);
3352#ifdef RENDER_SHADOWS
3353float 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);
3354#else
3355color=apply_lighting(color,transformed_normal);
3356#endif
3357color=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);}
3358#endif
3359#ifdef FOG
3360color=fog_apply(color,v_fog_pos);
3361#endif
3362vec4 out_color=vec4(color,1.0);
3363#ifdef INDICATOR_CUTOUT
3364out_color=applyCutout(out_color,v_height);
3365#endif
3366#ifdef FEATURE_CUTOUT
3367out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,v_height);
3368#endif
3369out_color*=u_opacity_multiplier;glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
3370#include "_prelude_shadow.vertex.glsl"
3371in 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;
3372#ifdef RENDER_SHADOWS
3373uniform 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;
3374#endif
3375#pragma mapbox: define highp vec4 structure_color
3376void main() {
3377#pragma mapbox: initialize highp vec4 structure_color
3378v_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);
3379#ifdef RENDER_SHADOWS
3380vec3 shd_pos0=pos;vec3 shd_pos1=pos;
3381#ifdef NORMAL_OFFSET
3382vec3 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();
3383#endif
3384v_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;
3385#endif
3386#ifdef FOG
3387v_fog_pos=fog_position(vec2(a_pos));
3388#endif
3389}`),elevatedStructuresDepthReconstruct:d.bb(`#include "_prelude_feature_cutout.fragment.glsl"
3390#ifdef DEPTH_RECONSTRUCTION
3391in float v_height;
3392#endif
3393void main() {
3394#ifdef DEPTH_RECONSTRUCTION
3395if (v_height >=0.0)
3396discard;
3397#else
3398#ifdef FEATURE_CUTOUT
3399apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);
3400#endif
3401#endif
3402glFragColor=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;
3403#ifdef DEPTH_RECONSTRUCTION
3404out float v_height;
3405#endif
3406void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);
3407#ifdef DEPTH_RECONSTRUCTION
3408if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;
3409#endif
3410gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`)};d.bb(Br,"");const oo=d.a_([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),Ci=d.a_([{type:"Float32",name:"a_pos_2f",components:2}]);class ar{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(r,o){const u=r.getOrCreateProgram("vignette");
vendor: 194,874 bytes, line 3410
3410if(!this.vignetteVx||!this.vignetteIdx){const g=new d.bc,x=new d.ad;g.emplaceBack(-1,-1),g.emplaceBack(1,-1),g.emplaceBack(1,1),g.emplaceBack(-1,1),x.emplaceBack(0,1,2),x.emplaceBack(0,2,3),this.vignetteVx=r.context.createVertexBuffer(g,Ci.members),this.vignetteIdx=r.context.createIndexBuffer(x)}const f=d.ac.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){r.uploadCommonUniforms(r.context,u);const g={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};u.draw(r,r.context.gl.TRIANGLES,d.Z.disabled,d._.disabled,d.a1.alphaBlended,d.$.disabled,g,"vignette",this.vignetteVx,this.vignetteIdx,f)}var m}}class kr{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(r,o){const u=r.getFreeCameraOptions().position,f=u.toAltitude(),m=u.toLngLat(),g=d.au(m.lng),x=d.au(m.lat),w=r.pixelsPerMeter/o,E=g*d.bj,I=d.bj*Math.log(Math.tan(Math.PI/4+x/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{const R=-this._offsetYPrev+I,P=-this._elevationPrev+f;this._accumulatedOffsetX+=(-this._offsetXPrev+E)*w,this._accumulatedOffsetY+=R*w,this._accumulatedElevation+=P*w,this._offsetXPrev=E,this._offsetYPrev=I,this._elevationPrev=f}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Pn(a,r){return[-(a[0]-Math.floor(a[0]/r)*r),-(a[1]-Math.floor(a[1]/r)*r),-(a[2]-Math.floor(a[2]/r)*r)]}function vn(a){const r=d.bi(1323123451230),o=[];for(let u=0;u<a;++u){const f=2*r()-1,m=2*r()-1,g=2*r()-1;o.push(d.bh(f,m,g))}return o}function rn(a,r,o,u,f){const m=d.b0((f-o)/(u-o),0,1);return d.al(a,r,m)}class $r{constructor(r){this._movement=new kr,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new ar,this._ppmScaleFactor=r}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(r,o){const u=r.transform;this._movement.update(u,this._ppmScaleFactor);const f=u.starsProjMatrix,m=d.bd([]);d.be(m,m,d.au(90)-u._pitch),d.bf(m,m,-u.angle);const g=d.bg(new Float32Array(16),m),x=new Float32Array([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),w=d.aP([],x),E=d.X([],w,g),I=Date.now()/1e3;return this._accumulatedTimeFromStart+=(I-this._prevTime)*o,this._prevTime=I,{projectionMatrix:f,modelviewMatrix:E}}}const so=d.a_([{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}]),Wo=(a,r)=>({u_matrix:a,u_depth_bias:r}),Hn=(a,r)=>({u_matrix:a,u_ground_shadow_factor:r,u_opacity_multiplier:1}),or=(a,r,o,u,f)=>({u_matrix:a,u_camera_pos:[r[0],r[1],r[2]],u_depth_bias:o,u_height_scale:u,u_reset_depth:f}),bn={building:a=>({u_matrix:new d.a5(a),u_normal_matrix:new d.a5(a),u_opacity:new d.a4(a),u_faux_facade_ao_intensity:new d.a4(a),u_camera_pos:new d.a6(a),u_tile_to_meter:new d.a4(a),u_facade_emissive_chance:new d.a4(a),u_flood_light_color:new d.a6(a),u_flood_light_intensity:new d.a4(a),u_front_cutoff_params:new d.a6(a)}),buildingBloom:a=>({u_matrix:new d.a5(a)}),buildingDepth:a=>({u_matrix:new d.a5(a)}),elevatedStructuresDepth:a=>({u_matrix:new d.a5(a),u_depth_bias:new d.a4(a)}),elevatedStructures:a=>({u_matrix:new d.a5(a),u_ground_shadow_factor:new d.a6(a),u_opacity_multiplier:new d.a4(a)}),elevatedStructuresDepthReconstruct:a=>({u_matrix:new d.a5(a),u_camera_pos:new d.a6(a),u_depth_bias:new d.a4(a),u_height_scale:new d.a4(a),u_reset_depth:new d.a4(a)}),rasterParticle:a=>({u_matrix:new d.a5(a),u_normalize_matrix:new d.a5(a),u_globe_matrix:new d.a5(a),u_merc_matrix:new d.a5(a),u_grid_matrix:new d.aZ(a),u_tl_parent:new d.a3(a),u_scale_parent:new d.a4(a),u_fade_t:new d.a4(a),u_opacity:new d.a4(a),u_image0:new d.aX(a),u_image1:new d.aX(a),u_raster_elevation:new d.a4(a),u_zoom_transition:new d.a4(a),u_merc_center:new d.a3(a),u_cutoff_params:new d.aY(a)}),rasterParticleTexture:a=>({u_texture:new d.aX(a),u_opacity:new d.a4(a)}),rasterParticleDraw:a=>({u_particle_texture:new d.aX(a),u_particle_texture_side_len:new d.a4(a),u_tile_offset:new d.a3(a),u_velocity:new d.aX(a),u_color_ramp:new d.aX(a),u_velocity_res:new d.a3(a),u_max_speed:new d.a4(a),u_uv_offset:new d.a3(a),u_data_scale:new d.a3(a),u_data_offset:new d.a4(a),u_particle_pos_scale:new d.a4(a),u_particle_pos_offset:new d.a3(a)}),rasterParticleUpdate:a=>({u_particle_texture:new d.aX(a),u_particle_texture_side_len:new d.a4(a),u_velocity:new d.aX(a),u_velocity_res:new d.a3(a),u_max_speed:new d.a4(a),u_speed_factor:new d.a4(a),u_reset_rate:new d.a4(a),u_rand_seed:new d.a4(a),u_uv_offset:new d.a3(a),u_data_scale:new d.a3(a),u_data_offset:new d.a4(a),u_particle_pos_scale:new d.a4(a),u_particle_pos_offset:new d.a3(a)}),snowParticle:a=>({u_modelview:new d.a5(a),u_projection:new d.a5(a),u_time:new d.a4(a),u_cam_pos:new d.a6(a),u_velocityConeAperture:new d.a4(a),u_velocity:new d.a4(a),u_horizontalOscillationRadius:new d.a4(a),u_horizontalOscillationRate:new d.a4(a),u_boxSize:new d.a4(a),u_billboardSize:new d.a4(a),u_simpleShapeParameters:new d.a3(a),u_screenSize:new d.a3(a),u_thinningCenterPos:new d.a3(a),u_thinningShape:new d.a6(a),u_thinningAffectedRatio:new d.a4(a),u_thinningParticleOffset:new d.a4(a),u_particleColor:new d.aY(a),u_direction:new d.a6(a)}),rainParticle:a=>({u_modelview:new d.a5(a),u_projection:new d.a5(a),u_time:new d.a4(a),u_cam_pos:new d.a6(a),u_texScreen:new d.aX(a),u_velocityConeAperture:new d.a4(a),u_velocity:new d.a4(a),u_boxSize:new d.a4(a),u_rainDropletSize:new d.a3(a),u_distortionStrength:new d.a4(a),u_rainDirection:new d.a6(a),u_color:new d.aY(a),u_screenSize:new d.a3(a),u_thinningCenterPos:new d.a3(a),u_thinningShape:new d.a6(a),u_thinningAffectedRatio:new d.a4(a),u_thinningParticleOffset:new d.a4(a),u_shapeDirectionalPower:new d.a4(a),u_shapeNormalPower:new d.a4(a),u_mode:new d.a4(a)}),vignette:a=>({u_vignetteShape:new d.a6(a),u_vignetteColor:new d.aY(a)})};function Oi(a,r){const o=1<<a.canonical.z,u=(r.x*o-a.canonical.x-a.wrap*o)*d.a2,f=(r.y*o-a.canonical.y)*d.a2,m=d.bm(r.z,r.y);return d.bh(u,f,m)}function Tr(a){let r=0;for(const o of a)r|=o.frcMask;return r}class ao{constructor(r=[]){this.tiles=r}getTile(r){for(const o of this.tiles)if(o.tileId.z===r.z&&o.tileId.x===r.x&&o.tileId.y===r.y)return o;return null}getTileOrParent(r){for(let o=r.z;o>0;--o){const u=Math.floor(r.x/(1<<r.z-o)),f=Math.floor(r.y/(1<<r.z-o));for(const m of this.tiles)if(m.tileId.z===o&&m.tileId.x===u&&m.tileId.y===f&&m.frcMask!==0)return m}return null}getFullCoverageMask(r){let o=null,u=0;for(let R=r.z;R>0;--R){const P=Math.floor(r.x/(1<<r.z-R)),B=Math.floor(r.y/(1<<r.z-R));for(const V of this.tiles)if(V.tileId.z===R&&V.tileId.x===P&&V.tileId.y===B){o=V,u=R;break}if(o)break}if(!o||o.frcMask===0)return null;const f=1<<r.z-u,m=d.a2/f,g=r.x%f*m,x=r.y%f*m,w=g+m,E=x+m;let I=0;for(const R of o.polygons)R.frcMask!==0&&(R.hasGeometry()?R.rings.length===0||r.z<=u||As(R.rings,g,x,w,E)&&(I|=R.frcMask):I|=R.frcMask);return I!==0?I:null}equals(r){if(this.tiles.length!==r.length)return!1;for(let o=0;o<this.tiles.length;++o){const u=this.tiles[o],f=r[o];if(u.tileId.z!==f.tileId.z||u.tileId.x!==f.tileId.x||u.tileId.y!==f.tileId.y||u.frcMask!==f.frcMask||u.polygons.length!==f.polygons.length)return!1}return!0}empty(){return this.tiles.length===0}}function As(a,r,o,u,f){const m=[0,0,0,0],g=[r,u,u,r],x=[o,o,f,f];for(const w of a){const E=w.length;if(!(E<2))for(let I=0,R=E-1;I<E;R=I++){const P=w[R].x,B=w[R].y,V=w[I].x,U=w[I].y;for(let Y=0;Y<4;++Y)B>x[Y]!=U>x[Y]&&g[Y]<P+(V-P)*(x[Y]-B)/(U-B)&&m[Y]++;let G=0,$=0;if(P<r?G|=1:P>u&&(G|=2),B<o?G|=4:B>f&&(G|=8),V<r?$|=1:V>u&&($|=2),U<o?$|=4:U>f&&($|=8),!(G&$)&&(G===0||$===0||hn(P,B,V,U,r,o,u,f)))return!1}}for(let w=0;w<4;++w)if(!(1&m[w]))return!1;return!0}function hn(a,r,o,u,f,m,g,x){const w=(E,I,R,P,B,V,U,G)=>{const $=(R-E)*(V-I)-(P-I)*(B-E),Y=(R-E)*(G-I)-(P-I)*(U-E);if($>0&&Y>0||$<0&&Y<0)return!1;const re=(U-B)*(I-V)-(G-V)*(E-B),oe=(U-B)*(P-V)-(G-V)*(R-B);return!(re>0&&oe>0||re<0&&oe<0)};return!!(w(a,r,o,u,f,m,g,m)||w(a,r,o,u,g,m,g,x)||w(a,r,o,u,f,x,g,x)||w(a,r,o,u,f,m,f,x))}class il{constructor(){this._tileCoverages=[],this._snapshot=new ao}clear(){this._tileCoverages=[]}addTileCoverage(r,o){this._tileCoverages.push({tileId:r,polygons:o,frcMask:Tr(o)})}empty(){return this._tileCoverages.length===0}updateSnapshotIfNeeded(){if(this._snapshot.equals(this._tileCoverages))return this._snapshot;const r=this._tileCoverages.map(o=>({tileId:o.tileId,polygons:o.polygons,frcMask:o.frcMask}));return this._snapshot=new ao(r),this._snapshot}}function Mo(a,r){const o={};if(!r)return o;for(const u of a){const f=u.layerIds.map(m=>r.getLayer(m)).filter(Boolean);if(f.length!==0){u.layers=f,u.stateDependentLayerIds&&(u.stateDependentLayers=u.stateDependentLayerIds.map(m=>f.filter(g=>g.id===m)[0])),u.updateExpressions&&u.updateExpressions(f);for(const m of f)o[m.fqid]=u}}return o}const wn=32,Ro=33,Xo=new Uint16Array(8184);for(let a=0;a<2046;a++){let r=a+2,o=0,u=0,f=0,m=0,g=0,x=0;for(1&r?f=m=g=wn:o=u=x=wn;(r>>=1)>1;){const E=o+f>>1,I=u+m>>1;1&r?(f=o,m=u,o=g,u=x):(o=f,u=m,f=g,m=x),g=E,x=I}const w=4*a;Xo[w+0]=o,Xo[w+1]=u,Xo[w+2]=f,Xo[w+3]=m}const Dn=new Uint16Array(2178),Er=new Uint8Array(1089),Yo=new Uint16Array(1089);function ds(a){return a===0?-.03125:a===32?.03125:0}var Cs=d.a_([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);const lt={type:2,extent:d.a2,loadGeometry:()=>[[new d.P(0,0),new d.P(d.a2+1,0),new d.P(d.a2+1,d.a2+1),new d.P(0,d.a2+1),new d.P(0,0)]]};let Xs,Pt=0;class Ms{constructor(r,o,u,f,m,g){this.tileID=r,this.uid=d.av(),this.uses=0,this.tileSize=o,this.tileZoom=u,this.dashIdealZ=r.overscaledZ,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=m,f&&f.style&&(this._lastUpdatedBrightness=f.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",f&&f.transform&&(this.projection=f.transform.projection),this.worldview=g,this._hasAppearances=null}registerFadeDuration(r){const o=r+this.timeAdded;o<d.e.now()||this.fadeEndTime!==void 0&&o<this.fadeEndTime||(this.fadeEndTime=o)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=d.bp(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(r,o,u){if(this.unloadVectorData(),this.state="loaded",r){r.featureIndex&&(this.latestFeatureIndex=r.featureIndex,r.rawTileData?(this.latestRawTileData=r.rawTileData,this.latestFeatureIndex.rawTileData=r.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=r.collisionBoxArray,this.buckets=Mo(r.buckets,o.style),r.frcCoveragePolygons&&r.frcCoveragePolygons.length>0&&(this.frcCoveragePolygons=r.frcCoveragePolygons),this.hasDeferredRoadStructure=!!r.hasDeferredRoadStructure,r.parsedElevationFeatures!==void 0&&(this.parsedElevationFeatures=r.parsedElevationFeatures,this.parsedElevationGeneration=++Pt),this.hasDeferredElevationFeatures=!!r.hasDeferredElevationFeatures,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!r.hasTunnelGeometry;for(const f in this.buckets){const m=this.buckets[f];if(m instanceof d.bu){if(this.hasSymbolBuckets=!0,!u)break;m.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const f in this.buckets){const m=this.buckets[f];if(m instanceof d.bu&&m.hasRTLText){this.hasRTLText=!0,d.bN();break}}this.queryPadding=0;for(const f in this.buckets){const m=this.buckets[f],g=o.style.getOwnLayer(f);if(!g)continue;const x=g.queryRadius(m)||0;this.queryPadding=Math.max(this.queryPadding,x)}r.imageAtlas&&(this.imageAtlas=o.style.imageManager.imageAtlasCache.getOrCache(r.imageAtlas)),r.glyphAtlasImage&&(this.glyphAtlasImage=r.glyphAtlasImage),r.lineAtlas&&(this.lineAtlas=r.lineAtlas),this._lastUpdatedBrightness=r.brightness}else this.collisionBoxArray=new d.bt}unloadVectorData(){if(this.hasData()){for(const r in this.buckets)this.buckets[r].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(r,o,u){r&&(r.resourceTiming&&(this.resourceTiming=r.resourceTiming),this.buckets={...this.buckets,...Mo(r.buckets,o.style)},r.featureIndex&&(this.latestFeatureIndex=r.featureIndex))}getBucket(r){return this.buckets[r.fqid]}upload(r,o){for(const m in this.buckets){const g=this.buckets[m];if(g.uploadPending()){let x={},w=[],E={zoom:0,pitch:0,brightness:0,worldview:""};if(o){if(o.style){w=o.style.listImages();const I=g.layers[0],R=I.sourceLayer||"_geojsonTileLayer",P=o.style.getLayerSourceCache(I);P&&(x=P._state.getState(R,void 0))}E={zoom:o.transform.zoom||0,pitch:o.transform.pitch||0,brightness:o.style.getBrightness()||0,worldview:o.worldview||""}}g.upload(r,this.tileID.canonical,x,w,E)}}const u=r.gl,f=this.imageAtlas;f&&o&&(this.imageAtlasTexture=o.style.imageManager.imageAtlasCache.getTextureForAtlas(f,r,u.RGBA8),f.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new d.T(r,this.glyphAtlasImage,u.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new d.T(r,this.lineAtlas.image,u.R8),this.lineAtlas.uploaded=!0)}prepare(r,o,u){if(this.imageAtlas&&this.imageAtlasTexture&&o){const P=o.style.getLut(u);this.imageAtlas.patchUpdatedImages(r,this.imageAtlasTexture,u,P)}if(!o||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const f=o.style.getBrightness(),m=o.style.listImages(),g=m.length,x=o.style._changes.getUpdatedPaintProperties(),w=Object.keys(this.buckets).some(P=>this.buckets[P].layers.some(B=>x.has(B.fqid))),E=Object.keys(this.buckets).some(P=>this.buckets[P].layers.some(B=>B.hasTransition&&B.hasTransition())),I=this._firstPrepareComplete&&g!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(o));const R=this._lastUpdatedBrightness!==f;this._lastAvailableImagesCount=g,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||f||this._hasAppearances||w||E||I)&&(!(this._hasAppearances||w||E||I)&&this._lastUpdatedBrightness&&f&&Math.abs(this._lastUpdatedBrightness-f)<.001||(this.updateBuckets(o,R,void 0,I||w||E,x,m),this._lastUpdatedBrightness=f))}evaluateQueryRenderedFeaturePadding(){let r=0;for(const o in this.buckets){const u=this.buckets[o];u.evaluateQueryRenderedFeaturePadding&&(r=Math.max(r,u.evaluateQueryRenderedFeaturePadding()))}return r}queryRenderedFeatures(r,o,u,f,m,g,x){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const w=this.evaluateQueryRenderedFeaturePadding(),E=function(I,R){const P=d.bL([],[.5*I.width,.5*-I.height,1]);return d.bM(P,P,[1,-1,0]),d.X(P,P,I.calculateProjMatrix(R.toUnwrapped())),Float32Array.from(P)}(m,this.tileID);return this.latestFeatureIndex.query(r,{tilespaceGeometry:o,pixelPosMatrix:E,transform:f,availableImages:u,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:w,scope:x})}querySourceFeatures(r,o){const u=this.latestFeatureIndex;if(!u||!u.rawTileData)return;const f=u.loadVTLayers(),m=o?o.sourceLayer:"",g=f._geojsonTileLayer||f[m];if(!g)return;const x=d.bv(o&&o.filter),{z:w,x:E,y:I}=this.tileID.canonical,R={z:w,x:E,y:I};for(let P=0;P<g.length;P++){const B=g.feature(P);if(x.needGeometry){const G=d.bw(B,!0);if(!x.filter(new d.ai(this.tileID.overscaledZ,{worldview:this.worldview}),G,this.tileID.canonical))continue}else if(!x.filter(new d.ai(this.tileID.overscaledZ,{worldview:this.worldview}),B))continue;const V=u.getId(B,m),U=new d.bx(B,w,E,I,V);U.tile=R,r.push(U)}}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(r){const o=this.expirationTime;if(r.cacheControl){const u=d.by(r.cacheControl);u["max-age"]&&(this.expirationTime=Date.now()+1e3*u["max-age"])}else r.expires&&(this.expirationTime=new Date(r.expires).getTime());if(this.expirationTime){const u=Date.now();let f=!1;if(this.expirationTime>u)f=!1;else if(o)if(this.expirationTime<o)f=!0;else{const m=this.expirationTime-o;m?this.expirationTime=u+Math.max(m,3e4):f=!0}else f=!0;f?(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(r,o){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!r)return;const u=r.style.listImages();this.updateBuckets(r,!1,o,void 0,void 0,u)}hasAppearances(r){for(const o in this.buckets)if(r.style.hasLayer(o)&&this.buckets[o].layers.some(u=>u.appearances&&u.appearances.length>0))return!0;return!1}updateBuckets(r,o,u,f,m,g){if(!this.latestFeatureIndex||!r.style)return;const x=g||r.style.listImages(),w=r.style.getBrightness(),E=m||new Set;for(const I in this.buckets){if(!r.style.hasLayer(I))continue;const R=this.buckets[I],P=R.layers[0],B=P.sourceLayer||"_geojsonTileLayer",V=r.style.getLayerSourceCache(P),U=R.layers.some(ce=>E.has(ce.fqid)),G=(f||U)&&R instanceof d.bu?r.style.getOwnLayer(I):void 0;let $=u&&u[B]||{};V&&!u&&($=V._state.getState(B,void 0));const Y=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},re=Object.keys($).length>0&&!o;R.hasAppearances=R.layers.some(ce=>ce.appearances&&ce.appearances.length>0);const oe=re?R.stateDependentLayers:R.layers;if(re&&R.stateDependentLayers.length!==0||o||U||f){const ce=this.latestFeatureIndex.loadVTLayers()[B];if(R.update($,ce,x,Y,oe,o,w,this.tileID.canonical),(f||U)&&(!o||o&&R instanceof d.bu&&(!R.text.uboBinder||R.text.uboBinder.isLightConstant||!R.icon.uboBinder||R.icon.uboBinder.isLightConstant))&&R instanceof d.bu&&G&&G.type==="symbol"){const _e=R;_e.text&&_e.text.uboBinder&&_e.text.uboBinder.updateDynamicExpressions(G,ce,this.tileID.canonical,x,$,w),_e.icon&&_e.icon.uboBinder&&_e.icon.uboBinder.updateDynamicExpressions(G,ce,this.tileID.canonical,x,$,w)}if(R instanceof d.bu){const _e=R,ue=r.context;_e.text&&_e.text.uboBinder&&_e.text.uboBinder.upload(ue),_e.icon&&_e.icon.uboBinder&&_e.icon.uboBinder.upload(ue)}}if(re&&R.stateDependentLayers.length!==0||o||R.hasAppearances){const ce={zoom:r.transform.zoom,pitch:r.transform.pitch,brightness:r.style.getBrightness()||0,worldview:r.worldview},_e=R.updateAppearances(this.tileID.canonical,$,x,ce,r.imageManager,re&&R.stateDependentLayers.length!==0);if(_e&&_e.hasUboChanges){const ue=r.context;R instanceof d.bu&&R.text&&R.text.uboBinder&&R.text.uboBinder.upload(ue),R instanceof d.bu&&R.icon&&R.icon.uboBinder&&R.icon.uboBinder.upload(ue)}}(R instanceof d.bz||R instanceof d.bA)&&r._terrain&&r._terrain.enabled&&V&&R.uploadPending()&&r._terrain._clearRenderCacheForTile(V.id,this.tileID);const pe=r&&r.style&&r.style.getOwnLayer(I);pe&&(this.queryPadding=Math.max(this.queryPadding,pe.queryRadius(R)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<d.e.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(r){this.symbolFadeHoldUntil=d.e.now()+r}setTexture(r,o){const u=o.context,f=u.gl;this.texture=this.texture||o.getTileTexture(r.width),this.texture&&this.texture instanceof d.T?this.texture.update(r):(this.texture=new d.T(u,r,f.RGBA8,{useMipmap:!0}),this.texture.bind(f.LINEAR,f.CLAMP_TO_EDGE))}setDependencies(r,o){const u={};for(const f of o)u[f]=!0;this.dependencies[r]=u}hasDependency(r,o){for(const u of r){const f=this.dependencies[u];if(f){for(const m of o)if(f[m])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(r,o){if(!o||o.name==="mercator"||this._tileDebugBuffer)return;const u=d.bB(lt,this.tileID.canonical,this.tileTransform)[0],f=new d.bC,m=new d.bD;for(let g=0;g<u.length;g++){const{x,y:w}=u[g];f.emplaceBack(x,w),m.emplaceBack(g)}m.emplaceBack(0),this._tileDebugIndexBuffer=r.createIndexBuffer(m),this._tileDebugBuffer=r.createVertexBuffer(f,d.bE.members),this._tileDebugSegments=d.ac.simpleSegment(0,0,f.length,m.length)}_makeTileBoundsBuffers(r,o){if(this._tileBoundsBuffer||!o||o.name==="mercator")return;const u=d.bB(lt,this.tileID.canonical,this.tileTransform)[0];let f,m;if(this.isRaster){const g=function(x,w){const E=d.bp(x,w),I=Math.pow(2,x.z);for(let G=0;G<Ro;G++)for(let $=0;$<Ro;$++){const Y=d.bq((x.x+($+ds($))/wn)/I),re=d.br((x.y+(G+ds(G))/wn)/I),oe=w.project(Y,re),pe=G*Ro+$;Dn[2*pe+0]=Math.round((oe.x*E.scale-E.x)*d.a2),Dn[2*pe+1]=Math.round((oe.y*E.scale-E.y)*d.a2)}Er.fill(0),Yo.fill(0);for(let G=2045;G>=0;G--){const $=4*G,Y=Xo[$+0],re=Xo[$+1],oe=Xo[$+2],pe=Xo[$+3],ce=Y+oe>>1,_e=re+pe>>1,ue=ce+_e-re,me=_e+Y-ce,Ie=re*Ro+Y,we=pe*Ro+oe,ve=_e*Ro+ce,Se=Math.hypot((Dn[2*Ie+0]+Dn[2*we+0])/2-Dn[2*ve+0],(Dn[2*Ie+1]+Dn[2*we+1])/2-Dn[2*ve+1])>=16;Er[ve]=Er[ve]||(Se?1:0),G<1022&&(Er[ve]=Er[ve]||Er[(re+me>>1)*Ro+(Y+ue>>1)]||Er[(pe+me>>1)*Ro+(oe+ue>>1)])}const R=new d.bs,P=new d.ad;let B=0;function V(G,$){const Y=$*Ro+G;return Yo[Y]===0&&(R.emplaceBack(Dn[2*Y+0],Dn[2*Y+1],G*d.a2/wn,$*d.a2/wn),Yo[Y]=++B),Yo[Y]-1}function U(G,$,Y,re,oe,pe){const ce=G+Y>>1,_e=$+re>>1;if(Math.abs(G-oe)+Math.abs($-pe)>1&&Er[_e*Ro+ce])U(oe,pe,G,$,ce,_e),U(Y,re,oe,pe,ce,_e);else{const ue=V(G,$),me=V(Y,re),Ie=V(oe,pe);P.emplaceBack(ue,me,Ie)}}return U(0,0,wn,wn,wn,0),U(wn,wn,0,0,0,wn),{vertices:R,indices:P}}(this.tileID.canonical,o);f=g.vertices,m=g.indices}else{f=new d.bs,m=new d.ad;for(const{x,y:w}of u)f.emplaceBack(x,w,0,0);const g=d.bF(f.int16.subarray(0,4*f.length),void 0,4);for(let x=0;x<g.length;x+=3)m.emplaceBack(g[x],g[x+1],g[x+2])}this._tileBoundsBuffer=r.createVertexBuffer(f,Cs.members),this._tileBoundsIndexBuffer=r.createIndexBuffer(m),this._tileBoundsSegments=d.ac.simpleSegment(0,0,f.length,m.length)}_makeGlobeTileDebugBuffers(r,o){const u=o.projection;if(!u||u.name!=="globe"||o.freezeTileCoverage)return;const f=this.tileID.canonical,m=d.V(f,o),g=d.b4(m),x=d.S(o.zoom);let w;x>0&&(w=d.aO(new Float64Array(16),o.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(r,f,o,g,w,x),this._makeGlobeTileDebugTextBuffer(r,f,o,g,w,x)}_globePoint(r,o,u,f,m,g,x){let w=d.bG(r,o,u);if(g){const E=1<<u.z,I=d.a7(f.center.lng),R=d.a8(f.center.lat),P=(u.x+.5)/E-I;let B=0;P>.5?B=-1:P<-.5&&(B=1);let V=(r/d.a2+u.x)/E+B,U=(o/d.a2+u.y)/E;V=(V-I)*f._pixelsPerMercatorPixel+I,U=(U-R)*f._pixelsPerMercatorPixel+R;const G=[V*f.worldSize,U*f.worldSize,0];d.bH(G,G,g),w=d.bI(w,G,x)}return d.bH(w,w,m)}_makeGlobeTileDebugBorderBuffer(r,o,u,f,m,g){const x=new d.bC,w=new d.bD,E=new d.bJ,I=(P,B,V,U,G)=>{const $=(V-P)/(G-1),Y=(U-B)/(G-1),re=x.length;for(let oe=0;oe<G;oe++){const pe=P+oe*$,ce=B+oe*Y;x.emplaceBack(pe,ce);const _e=this._globePoint(pe,ce,o,u,f,m,g);E.emplaceBack(_e[0],_e[1],_e[2]),w.emplaceBack(re+oe)}},R=d.a2;I(0,0,R,0,16),I(R,0,R,R,16),I(R,R,0,R,16),I(0,R,0,0,16),this._tileDebugIndexBuffer=r.createIndexBuffer(w),this._tileDebugBuffer=r.createVertexBuffer(x,d.bE.members),this._globeTileDebugBorderBuffer=r.createVertexBuffer(E,d.bK.members),this._tileDebugSegments=d.ac.simpleSegment(0,0,x.length,w.length)}_makeGlobeTileDebugTextBuffer(r,o,u,f,m,g){const x=d.a2/4,w=new d.bC,E=new d.ad,I=new d.bJ,R=25;E.reserve(32),w.reserve(R),I.reserve(R);const P=(B,V)=>R*B+V;for(let B=0;B<R;B++){const V=B*x;for(let U=0;U<R;U++){const G=U*x;w.emplaceBack(G,V);const $=this._globePoint(G,V,o,u,f,m,g);I.emplaceBack($[0],$[1],$[2])}}for(let B=0;B<4;B++)for(let V=0;V<4;V++){const U=P(B,V),G=P(B,V+1),$=P(B+1,V),Y=P(B+1,V+1);E.emplaceBack(U,G,$),E.emplaceBack($,G,Y)}this._tileDebugTextIndexBuffer=r.createIndexBuffer(E),this._tileDebugTextBuffer=r.createVertexBuffer(w,d.bE.members),this._globeTileDebugTextBuffer=r.createVertexBuffer(I,d.bK.members),this._tileDebugTextSegments=d.ac.simpleSegment(0,0,R,32)}destroy(r=!0){for(const o in this.buckets)this.buckets[o].destroy(r);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),r&&this.texture&&this.texture instanceof d.T&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof d.T&&(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"}}class Zu{constructor(r,o){this.max=r,this.onRemove=o,this.reset()}reset(){for(const r in this.data)for(const o of this.data[r])o.timeout&&clearTimeout(o.timeout),this.onRemove(o.value);return this.data={},this.order=[],this}add(r,o,u){const f=r.wrapped().key;this.data[f]===void 0&&(this.data[f]=[]);const m={value:o,timeout:void 0};if(u!==void 0&&(m.timeout=setTimeout(()=>{this.remove(r,m)},u)),this.data[f].push(m),this.order.push(f),this.order.length>this.max){const g=this._getAndRemoveByKey(this.order[0]);g&&this.onRemove(g)}return this}has(r){return r.wrapped().key in this.data}getAndRemove(r){return this.has(r)?this._getAndRemoveByKey(r.wrapped().key):null}_getAndRemoveByKey(r){const o=this.data[r].shift();return o.timeout&&clearTimeout(o.timeout),this.data[r].length===0&&delete this.data[r],this.order.splice(this.order.indexOf(r),1),o.value}getByKey(r){const o=this.data[r];return o?o[0].value:null}get(r){return this.has(r)?this.data[r.wrapped().key][0].value:null}remove(r,o){if(!this.has(r))return this;const u=r.wrapped().key,f=o===void 0?0:this.data[u].indexOf(o),m=this.data[u][f];return this.data[u].splice(f,1),m.timeout&&clearTimeout(m.timeout),this.data[u].length===0&&delete this.data[u],this.onRemove(m.value),this.order.splice(this.order.indexOf(u),1),this}setMaxSize(r){for(this.max=r;this.order.length>this.max;){const o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(r){const o=[];for(const u in this.data)for(const f of this.data[u])r(f.value)||o.push(f);for(const u of o)this.remove(u.value.tileID,u)}}class $u{constructor(){this.state=Object.create(null),this.stateChanges=Object.create(null),this.deletedStates=Object.create(null)}updateState(r,o,u){const f=String(o);if(this.stateChanges[r]=this.stateChanges[r]||Object.create(null),this.stateChanges[r][f]=this.stateChanges[r][f]||Object.create(null),Object.assign(this.stateChanges[r][f],u),this.deletedStates[r]===null){this.deletedStates[r]=Object.create(null);for(const m in this.state[r])m!==f&&(this.deletedStates[r][m]=null)}else if(this.deletedStates[r]&&this.deletedStates[r][f]===null){this.deletedStates[r][f]=Object.create(null);for(const m in this.state[r][f])u[m]||(this.deletedStates[r][f][m]=null)}else for(const m in u)this.deletedStates[r]&&this.deletedStates[r][f]&&this.deletedStates[r][f][m]===null&&delete this.deletedStates[r][f][m]}removeFeatureState(r,o,u){if(this.deletedStates[r]===null)return;const f=String(o);if(this.deletedStates[r]=this.deletedStates[r]||Object.create(null),u&&o!==void 0)this.deletedStates[r][f]!==null&&(this.deletedStates[r][f]=this.deletedStates[r][f]||Object.create(null),this.deletedStates[r][f][u]=null);else if(o!==void 0)if(this.stateChanges[r]&&this.stateChanges[r][f])for(u in this.deletedStates[r][f]=Object.create(null),this.stateChanges[r][f])this.deletedStates[r][f][u]=null;else this.deletedStates[r][f]=null;else this.deletedStates[r]=null}getState(r,o){const u=this.state[r]||Object.create(null),f=this.stateChanges[r]||Object.create(null),m=this.deletedStates[r];if(m===null)return Object.create(null);if(o!==void 0){const x=String(o),w=Object.assign(Object.create(null),u[x],f[x]);if(m){const E=m[o];if(E===null)return Object.create(null);for(const I in E)delete w[I]}return w}const g=Object.assign(Object.create(null),u,f);if(m)for(const x in m)delete g[x];return g}initializeTileState(r,o){r.refreshFeatureState(o)}coalesceChanges(r,o){const u=Object.create(null);for(const f in this.stateChanges){this.state[f]=this.state[f]||Object.create(null);const m=Object.create(null);for(const g in this.stateChanges[f])this.state[f][g]||(this.state[f][g]=Object.create(null)),Object.assign(this.state[f][g],this.stateChanges[f][g]),m[g]=this.state[f][g];u[f]=m}for(const f in this.deletedStates){this.state[f]=this.state[f]||Object.create(null);const m=Object.create(null);if(this.deletedStates[f]===null)for(const g in this.state[f])m[g]=Object.create(null),this.state[f][g]=Object.create(null);else for(const g in this.deletedStates[f]){if(this.deletedStates[f][g]===null)this.state[f][g]=Object.create(null);else if(this.state[f][g])for(const x of Object.keys(this.deletedStates[f][g]))delete this.state[f][g][x];m[g]=this.state[f][g]}u[f]=u[f]||Object.create(null),Object.assign(u[f],m)}if(this.stateChanges=Object.create(null),this.deletedStates=Object.create(null),Object.keys(u).length!==0)for(const f in r)r[f].refreshFeatureState(o,u)}}class Tn extends d.E{constructor(r,o,u){super(),this.id=r,this._renderSourceType=u,this._maxzoomOverride=null,this.setSource(o),this._tiles={},this._cache=new Zu(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 $u,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(r){this.map=r,this._minTileCacheSize=this._minTileCacheSize===void 0&&r?r._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&r?r._maxTileCacheSize:this._maxTileCacheSize}setSource(r){r.on("data",o=>{o.dataType==="source"&&o.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&o.dataType==="source"&&o.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const r in this._tiles)if(!this._tiles[r].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const r=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,r&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(r){this._maxzoomOverride=r}_loadTile(r,o){return r.renderSourceType=this._renderSourceType,r.isExtraShadowCaster=this._shadowCasterTiles[r.tileID.key],this._source.loadTile(r,o)}_unloadTile(r){if(this._source.unloadTile)return this._source.unloadTile(r)}_abortTile(r){if(this._source.abortTile)return this._source.abortTile(r)}serialize(){return this._source.serialize()}prepare(r){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const o in this._tiles){const u=this._tiles[o];u.upload(r,this.map?this.map.painter:void 0),u.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(r=>r.tileID).sort(da).map(r=>r.key)}getRenderableIds(r,o){const u=[];for(const f in this._tiles)this._isIdRenderable(+f,r,o)&&u.push(this._tiles[f]);return r?u.sort((f,m)=>{const g=f.tileID,x=m.tileID,w=new d.P(g.canonical.x,g.canonical.y)._rotate(this.transform.angle),E=new d.P(x.canonical.x,x.canonical.y)._rotate(this.transform.angle);return g.overscaledZ-x.overscaledZ||E.y-w.y||E.x-w.x}).map(f=>f.tileID.key):u.map(f=>f.tileID).sort(da).map(f=>f.key)}hasRenderableParent(r){const o=this.findLoadedParent(r,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(r,o,u){return this._tiles[r]&&this._tiles[r].hasData()&&!this._coveredTiles[r]&&(o||!this._tiles[r].holdingForFade())&&(u||!this._shadowCasterTiles[r])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const r in this._tiles)this._tiles[r].state!=="errored"&&this._reloadTile(+r,"reloading")}}_reloadTile(r,o){const u=this._tiles[r];u&&(u.state!=="loading"&&(u.state=o),this._loadTile(u,this._tileLoaded.bind(this,u,r,o)))}_tileLoaded(r,o,u,f,m){if(f){if(r.state="errored",d.bO(f)){if(this._source.fire(new d.h("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:r})),!(r.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const x=this.map.painter.terrain;this.update(this.transform,x.getScaledDemTileSize(),!0),x.resetTileLookupCache(this.id)}else this.update(this.transform)}else this._source.fire(new d.f(f,{tile:r}));return}r.timeAdded=d.e.now(),u==="expired"&&(r.refreshedUponExpiration=!0),this._setTileReloadTimer(o,r),this._source.type==="raster-dem"&&r.dem&&this._backfillDEM(r),this._state.initializeTileState(r,this.map?this.map.painter:null);let g=new Headers;m&&m.headers&&(g=m.headers),this._source.fire(new d.h("data",{dataType:"source",tile:r,coord:r.tileID,sourceCacheId:this.id,responseHeaders:g}))}_hasTunnelGeometry(){for(const r in this._tiles){const o=this._tiles[r];if(o&&o.hasTunnelGeometry)return!0}return!1}_backfillDEM(r){const o=this.getRenderableIds();for(let f=0;f<o.length;f++){const m=o[f];if(r.neighboringTiles&&r.neighboringTiles[m]){const g=this.getTileByID(m);u(r,g),u(g,r)}}function u(f,m){if(!f.dem||f.dem.borderReady)return;f.needsHillshadePrepare=!0,f.needsDEMTextureUpload=!0;let g=m.tileID.canonical.x-f.tileID.canonical.x;const x=m.tileID.canonical.y-f.tileID.canonical.y,w=Math.pow(2,f.tileID.canonical.z),E=m.tileID.key;g===0&&x===0||Math.abs(x)>1||(Math.abs(g)>1&&(Math.abs(g+w)===1?g+=w:Math.abs(g-w)===1&&(g-=w)),m.dem&&f.dem&&(f.dem.backfillBorder(m.dem,g,x),f.neighboringTiles&&f.neighboringTiles[E]&&(f.neighboringTiles[E].backfilled=!0)))}}getTile(r){return this.getTileByID(r.key)}getTileByID(r){return this._tiles[r]}_retainLoadedChildren(r,o,u,f){for(const m in this._tiles){let g=this._tiles[m];if(f[m]||!g.hasData()||g.tileID.overscaledZ<=o||g.tileID.overscaledZ>u)continue;let x=g.tileID;for(;g&&g.tileID.overscaledZ>o+1;){const E=g.tileID.scaledTo(g.tileID.overscaledZ-1);g=this._tiles[E.key],g&&g.hasData()&&(x=E)}let w=x;for(;w.overscaledZ>o;)if(w=w.scaledTo(w.overscaledZ-1),r[w.key]){f[x.key]=x;const E=this._tiles[x.key];E&&(E.dashIdealZ=w.overscaledZ);break}}}findLoadedParent(r,o){if(r.key in this._loadedParentTiles){const u=this._loadedParentTiles[r.key];return u&&u.tileID.overscaledZ>=o?u:null}for(let u=r.overscaledZ-1;u>=o;u--){const f=r.scaledTo(u),m=this._getLoadedTile(f);if(m)return m}}_getLoadedTile(r){const o=this._tiles[r.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?r.wrapped().key:r.canonical.key)}updateCacheSize(r,o){o=o||this._source.tileSize;const u=Math.ceil(r.width/o)+1,f=Math.ceil(r.height/o)+1,m=Math.floor(u*f*5),g=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,m):m,x=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,g):g;this._cache.setMaxSize(x)}handleWrapJump(r){const o=Math.round((r-(this._prevLng===void 0?r:this._prevLng))/360);if(this._prevLng=r,o){const u={};for(const f in this._tiles){const m=this._tiles[f];m.tileID=m.tileID.unwrapTo(m.tileID.wrap+o),u[m.tileID.key]=m}this._tiles=u;for(const f in this._timers)clearTimeout(this._timers[f]),delete this._timers[f];for(const f in this._tiles)this._setTileReloadTimer(+f,this._tiles[f])}}update(r,o,u,f,m){if(this.transform=r,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!u)return;this.updateCacheSize(r,o),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const g=this._source.type==="batched-model";let x,w=this._source.maxzoom;this._maxzoomOverride!==null&&(w=Math.min(w,this._maxzoomOverride));const E=this.map&&this.map.painter?this.map.painter._terrain:null;if(E&&E.sourceCache===this&&E.attenuationRange()){const B=E.attenuationRange()[0],V=Math.floor(B)-Math.log2(E.getDemUpscale());w>V&&(w=V)}const I=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)x=r.getVisibleUnwrappedCoordinates(this._source.tileID).map(B=>new d.bP(B.canonical.z,B.wrap,B.canonical.z,B.canonical.x,B.canonical.y));else if(this.tileCoverLift!==0){const B=r.clone();B.tileCoverLift=this.tileCoverLift,x=B.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:w,roundZoom:this._source.roundZoom&&!u,reparseOverscaled:I,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:g}),this._source.minzoom<=1&&r.projection.name==="globe"&&(x.push(new d.bP(1,0,1,0,0)),x.push(new d.bP(1,0,1,1,0)),x.push(new d.bP(1,0,1,0,1)),x.push(new d.bP(1,0,1,1,1)))}else if(x=r.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:w,roundZoom:this._source.roundZoom&&!u,reparseOverscaled:I,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:g}),this._source.hasTile){const B=this._source.hasTile.bind(this._source);x=x.filter(V=>B(V))}}else x=[];if(x.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){const B=r.coveringZoomLevel({tileSize:o||this._source.tileSize,roundZoom:this._source.roundZoom&&!u}),V=Math.min(B,w);if(g){const U=r.extendTileCover(x,V);for(const G of U)x.push(G)}else if(m){const U=this.transform.getFrustum(V),G=r.extendTileCoverToNearPlane(x,U,V);for(const $ of G)x.push($);if(V>=18&&this._hasTunnelGeometry()){const $=r.extendTileCoverForTunnels(x,U,V,20);for(const Y of $)x.push(Y)}}else if(this.castsShadows&&f){const U=r.extendTileCover(x,V,f,16);for(const G of U)this._shadowCasterTiles[G.key]=!0,x.push(G)}}for(const B in this._tiles){const V=this._tiles[B];V.dashIdealZ=V.tileID.overscaledZ}const R=this._updateRetainedTiles(x);if(this._supportsFading&&x.length!==0){const B={},V={},U=d.e.now(),G=Object.keys(R);for(const Y of G){const re=R[Y],oe=this._tiles[Y];if(!oe||oe.fadeEndTime!==void 0&&oe.fadeEndTime<=U)continue;const pe=this.findLoadedParent(re,Math.max(re.overscaledZ-Tn.maxOverzooming,this._source.minzoom));pe&&(this._addTile(pe.tileID),B[pe.tileID.key]=pe.tileID),V[Y]=re}const $=x.at(-1).overscaledZ;for(const Y in this._tiles){const re=this._tiles[Y];if(R[Y]||!re.hasData())continue;let oe=re.tileID;for(;oe.overscaledZ>$;){oe=oe.scaledTo(oe.overscaledZ-1);const pe=this._tiles[oe.key];if(pe&&pe.hasData()&&V[oe.key]){R[Y]=re.tileID;break}}}for(const Y in B)R[Y]||(this._coveredTiles[Y]=!0,R[Y]=B[Y])}for(const B in R)this._tiles[B].clearFadeHold();const P=d.bQ(this._tiles,R);for(const B of P){const V=this._tiles[B];V.hasSymbolBuckets&&!V.holdingForFade()?V.setHoldDuration(this.map._fadeDuration):V.hasSymbolBuckets&&!V.symbolFadeFinished()||this._removeTile(+B)}this._updateLoadedParentTileCache(),this._renderSourceType===d.bR.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const r in this._tiles)this._tiles[r].holdingForFade()&&this._removeTile(+r)}_updateRetainedTiles(r){const o={};if(r.length===0)return o;const u={},f=r.reduce((E,I)=>Math.min(E,I.overscaledZ),1/0),m=r[0].overscaledZ,g=Math.max(m-Tn.maxOverzooming,this._source.minzoom),x=Math.max(m+Tn.maxUnderzooming,this._source.minzoom),w={};for(const E of r){const I=this._addTile(E);o[E.key]=E,I.hasData()||f<this._source.maxzoom&&(w[E.key]=E)}this._retainLoadedChildren(w,f,x,o);for(const E of r){let I=this._tiles[E.key];if(I.hasData())continue;if(E.canonical.z>=this._source.maxzoom){const P=E.children(this._source.maxzoom)[0],B=this.getTile(P);if(B&&B.hasData()){o[P.key]=P,B.dashIdealZ=E.overscaledZ;continue}}else{const P=E.children(this._source.maxzoom);if(o[P[0].key]&&o[P[1].key]&&o[P[2].key]&&o[P[3].key])continue}let R=I.wasRequested();for(let P=E.overscaledZ-1;P>=g;--P){const B=E.scaledTo(P);if(u[B.key]||(u[B.key]=!0,I=this.getTile(B),!I&&R&&(I=this._addTile(B)),I&&(o[B.key]=B,I.dashIdealZ=E.overscaledZ,R=I.wasRequested(),I.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const r in this._tiles){const o=[];let u,f=this._tiles[r].tileID;for(;f.overscaledZ>0;){if(f.key in this._loadedParentTiles){u=this._loadedParentTiles[f.key];break}o.push(f.key);const m=f.scaledTo(f.overscaledZ-1);if(u=this._getLoadedTile(m),u)break;f=m}for(const m of o)this._loadedParentTiles[m]=u}}_addTile(r){let o=this._tiles[r.key];if(o)return o.isExtraShadowCaster!==!0||this._shadowCasterTiles[r.key]||this._reloadTile(r.key,"reloading"),o;o=this._cache.getAndRemove(r),o&&(this._setTileReloadTimer(r.key,o),o.tileID=r,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[r.key]&&(clearTimeout(this._cacheTimers[r.key]),delete this._cacheTimers[r.key],this._setTileReloadTimer(r.key,o)));const u=!!o;if(!u){const f=this.map?this.map.painter:null,m=this._source.tileSize*r.overscaleFactor();o=this._source.type==="raster-array"?function(g,x,w,E,I){if(!Xs)throw new Error("Raster-array module is not loaded.");return Xs(g,x,w,E,I)}(r,m,this.transform.tileZoom,f,this._isRaster):new Ms(r,m,this.transform.tileZoom,f,this._isRaster,this._source.worldview),this._loadTile(o,this._tileLoaded.bind(this,o,r.key,o.state))}return o.uses++,this._tiles[r.key]=o,u||this._source.fire(new d.h("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o}_setTileReloadTimer(r,o){r in this._timers&&(clearTimeout(this._timers[r]),delete this._timers[r]);const u=o.getExpiryTimeout();u&&(this._timers[r]=setTimeout(()=>{this._reloadTile(r,"expired"),delete this._timers[r]},u))}_removeTile(r){const o=this._tiles[r];o&&(o.uses--,delete this._tiles[r],this._timers[r]&&(clearTimeout(this._timers[r]),delete this._timers[r]),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(const r in this._tiles)this._removeTile(+r);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(r,o,u){const f=[],m=this.transform;if(!m)return f;const g=m.projection.name==="globe",x=d.a7(m.center.lng),w=m.getFreeCameraOptions().position||new d.bS(0,0,0);for(const E in this._tiles){const I=this._tiles[E];if(u&&I.clearQueryDebugViz(),I.holdingForFade())continue;let R;if(g){const P=I.tileID.canonical;if(P.z===0){const B=[Math.abs(d.b0(x,...dn(P,-1))-x),Math.abs(d.b0(x,...dn(P,1))-x)];R=[0,2*B.indexOf(Math.min(...B))-1]}else{const B=[Math.abs(d.b0(x,...dn(P,-1))-x),Math.abs(d.b0(x,...dn(P,0))-x),Math.abs(d.b0(x,...dn(P,1))-x)];R=[B.indexOf(Math.min(...B))-1]}}else R=[0];for(const P of R){const B=r.containsTile(I,m,o,P,w);B&&f.push(B)}}return f}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(r){return this._getRenderableCoordinates(r)}_getRenderableCoordinates(r,o){if(!this.transform)return[];const u=this.getRenderableIds(r,o).map(m=>this._tiles[m].tileID),f=this.transform.projection.name==="globe";for(const m of u)m.projMatrix=this.transform.calculateProjMatrix(m.toUnwrapped()),m.expandedProjMatrix=f?this.transform.calculateProjMatrix(m.toUnwrapped(),!1,!0):m.projMatrix;return u}sortCoordinatesByDistance(r){if(!this.transform)return r.slice();const o=r.slice(),u=this.transform._camera.position,f=this.transform._camera.forward(),m={};for(const g of o){const x=1/(1<<g.canonical.z);m[g.key]=((g.canonical.x+.5)*x+g.wrap-u[0])*f[0]+((g.canonical.y+.5)*x-u[1])*f[1]-u[2]*f[2]}return o.sort((g,x)=>m[g.key]-m[x.key]),o}hasTransition(){if(this._source.hasTransition())return!0;if(this._supportsFading){const r=d.e.now();for(const o in this._tiles){const u=this._tiles[o];if(u.fadeEndTime!==void 0&&u.fadeEndTime>=r)return!0}}return!1}setFeatureState(r,o,u){this._state.updateState(r=r||"_geojsonTileLayer",o,u)}removeFeatureState(r,o,u){this._state.removeFeatureState(r=r||"_geojsonTileLayer",o,u)}getFeatureState(r,o){return this._state.getState(r=r||"_geojsonTileLayer",o)}setDependencies(r,o,u){const f=this._tiles[r];f&&f.setDependencies(o,u)}reloadTilesForDependencies(r,o){for(const u in this._tiles)this._tiles[u].hasDependency(r,o)&&this._reloadTile(+u,"reloading");this._cache.filter(u=>!u.hasDependency(r,o))}_preloadTiles(r,o){if(!this._sourceLoaded){const w=()=>{this._sourceLoaded&&(this._source.off("data",w),this._preloadTiles(r,o))};return void this._source.on("data",w)}const u=new Map,f=Array.isArray(r)?r:[r],m=this.map.painter.terrain,g=this.usedForTerrain&&m?m.getScaledDemTileSize():this._source.tileSize;for(const w of f){const E=w.coveringTiles({tileSize:g,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const I of E)u.set(I.key,I);this.usedForTerrain&&w.updateElevation(!1)}const x=Array.from(u.values());d.bT(x,(w,E)=>{const I=new Ms(w,this._source.tileSize*w.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(I,R=>{this._source.type==="raster-dem"&&I.dem&&this._backfillDEM(I),E(R,I)})},o)}}function da(a,r){const o=Math.abs(2*a.wrap)-+(a.wrap<0),u=Math.abs(2*r.wrap)-+(r.wrap<0);return a.overscaledZ-r.overscaledZ||u-o||r.canonical.y-a.canonical.y||r.canonical.x-a.canonical.x}function dn(a,r){const o=1<<a.z;return[a.x/o+r,(a.x+1)/o+r]}function rl(a,r){if(a.z<=r.z){const u=r.z-a.z;return r.x>>u===a.x&&r.y>>u===a.y}const o=a.z-r.z;return a.x>>o===r.x&&a.y>>o===r.y}function fa(a,r){return a.sourceFQID!==r.sourceFQID?a.sourceFQID<r.sourceFQID?-1:1:a.tileId.z!==r.tileId.z?a.tileId.z-r.tileId.z:a.tileId.x!==r.tileId.x?a.tileId.x-r.tileId.x:a.tileId.y-r.tileId.y}Tn.maxOverzooming=10,Tn.maxUnderzooming=3;class st{constructor(r=[]){this.tiles=r}getTilesIntersecting(r){const o=[];for(const u of this.tiles)rl(u.tileId,r)&&o.push(u);return o}equals(r){if(this.tiles.length!==r.length)return!1;for(let o=0;o<this.tiles.length;++o){const u=this.tiles[o],f=r[o];if(u.sourceFQID!==f.sourceFQID||u.tileId.z!==f.tileId.z||u.tileId.x!==f.tileId.x||u.tileId.y!==f.tileId.y||u.generation!==f.generation)return!1}return!0}empty(){return this.tiles.length===0}}class ti{constructor(){this._tiles=[],this._snapshot=new st,this._snapshotChanged=!1}clear(){this._tiles.length=0}consumeSnapshotChanged(){const r=this._snapshotChanged;return this._snapshotChanged=!1,r}addTileElevation(r,o,u,f){this._tiles.push({sourceFQID:r,tileId:o,features:u,generation:f})}updateSnapshotIfNeeded(){return this._tiles.sort(fa),this._snapshot.equals(this._tiles)||(this._snapshot=new st(this._tiles.slice()),this._snapshotChanged=!0),this._snapshot}}function $t(a,r){const o=[];for(const u of a.getTilesIntersecting(r))o.push(`${u.tileId.z}/${u.tileId.x}/${u.tileId.y}:${u.generation}`);return o.sort(),o.join("|")}function nn(a,r){const o=d.bW(a);return o===r||!o&&!r}function lo(a,r){return a._mergedOtherSourceCaches[r]||a._mergedSymbolSourceCaches[r]||a._mergedHdRoadElevationSourceCaches[r]}function qt(a){const r=a.sourceLayer;return!!r&&r.startsWith("hd_road_")}function co(a){return!!a.layout&&(a.type==="line"&&a.layout.get("line-elevation-reference")==="hd-road-markup"||a.type==="circle"&&a.layout.get("circle-elevation-reference")==="hd-road-markup"||a.type==="symbol"&&a.layout.get("symbol-elevation-reference")==="hd-road-markup"||a.type==="fill"&&a.layout.get("fill-elevation-reference")==="hd-road-markup")}function fs(a){const r=new Set;for(const o in a._mergedLayers){const u=a._mergedLayers[o];co(u)&&r.add(d.m(u.source,u.scope))}return r}function pa(a){const r=fs(a),o=new Set;for(const u in a._mergedLayers){const f=a._mergedLayers[u];if(!f.source||!qt(f))continue;const m=d.m(f.source,f.scope);r.has(m)||o.add(m)}return o}function ji(a){const r=fs(a);if(r.size===0)return!1;const o=Bi(a);for(const u of r)for(const f of o)if(u!==f)return!0;return!1}function Bi(a){const r=new Set;for(const o in a._mergedLayers){const u=a._mergedLayers[o];u.source&&qt(u)&&r.add(d.m(u.source,u.scope))}return r}function Po(a,r,o){const u=fs(a);if(u.size===0)return;if(!o){const m=Bi(a);for(const g of m)u.delete(g)}if(u.size===0)return;const f=[a._mergedOtherSourceCaches,a._mergedSymbolSourceCaches];for(const m of f)for(const g in m){if(!u.has(g))continue;const x=m[g];for(const w in x._tiles){const E=x._tiles[w];E&&(r&&!r(E)||(E.hasDeferredElevationFeatures=!1,x._reloadTile(+w,"reloading")))}}}class Ln{constructor(){this.elevationSourceCaches={},this.manager=new ti,this._needsCrossSourceElevation=!1,this._ingestFQIDs=new Set,this._terrainActiveLast=void 0}}function Jl(a){a.map&&a.map.painter&&(a.map.painter.elevationCoverageSnapshot=null,a.map.painter.elevationProvidersReady=void 0)}function nl(a){a._crossSourceElevationActive=!1,function(r){const o=r._hdElevation,u=!!(r.map&&r.map.painter&&r.map.painter.elevationCoverageSnapshot);return o?!o._needsCrossSourceElevation&&o._ingestFQIDs.size===0&&o.manager._tiles.length===0&&!u:!u}(a)||(Jl(a),a._hdElevation&&(a._hdElevation._needsCrossSourceElevation=!1,a._hdElevation._ingestFQIDs.clear(),a._hdElevation.manager.clear(),a._hdElevation._terrainActiveLast=void 0))}function Ql(a,r,o){const u=d.m(o.id,a.scope);if(r.elevationSourceCaches[u])return;const f=`hd-road-elevation:${o.id}`,m=d.m(f,a.scope),g=a._sourceCaches[f]=new Tn(m,o,d.bR.HdRoadElevation);r.elevationSourceCaches[u]=g,g.onAdd(a.map);const x=a._otherSourceCaches[o.id];x&&x._sourceLoaded&&(g._sourceLoaded=!0)}function ma(a,r){if(le(a,a.map&&a.map.transform))return r.manager.clear(),void(a.map.painter&&(a.map.painter.elevationCoverageSnapshot=null));if(!r._needsCrossSourceElevation)return void Jl(a);for(const x of r._ingestFQIDs){const w=lo(a,x);w&&(w.used=!0)}r.manager.clear();let o=!0;for(const x of r._ingestFQIDs){const w=lo(a,x);if(!w)continue;const E=w._tiles;for(const I in E){const R=E[I];if(!R||!R.loaded())continue;const P=R.parsedElevationFeatures;P!==void 0?r.manager.addTileElevation(x,R.tileID.canonical,P,R.parsedElevationGeneration):o=!1}}const u=r.manager._snapshot,f=r.manager.updateSnapshotIfNeeded();a.map.painter&&(a.map.painter.elevationCoverageSnapshot=f.empty()?null:f);const m=o&&function(x,w){for(const E of w){const I=lo(x,E);if(!I||!I._sourceLoaded)return!1;for(const R in I._tiles){const P=I._tiles[R];if(P&&(P.state==="loading"||P.state==="reloading"))return!1}}return!0}(a,pa(a));a.map.painter&&(a.map.painter.elevationProvidersReady=m);const g=r.manager.consumeSnapshotChanged();(g||m)&&Po(a,x=>{return!!x.hasDeferredElevationFeatures||g&&(w=f,$t(u,E=x.tileID.canonical)!==$t(w,E));var w,E})}const Sr=a=>({u_matrix:a});function uo(a,r){const o=a.context.gl;return new d._({func:o.EQUAL,mask:255},a._tileClippingMaskIDs[r.key]||0,0,o.KEEP,o.KEEP,o.KEEP)}function fn(a,r){const o=a.context.gl;return new d._({func:o.EQUAL,mask:255},255&~(a._tileClippingMaskIDs[r.key]||0),0,o.KEEP,o.KEEP,o.KEEP)}function Uc(a,r){if(!a.frcCoverageSnapshot||!a.frcCoverageRenderer)return null;const o=a.frcCoverageSnapshot.getTileOrParent(r.canonical);if(!o||o.frcMask===0)return null;const u=a.frcCoverageRenderer.getBuffers(o.tileId);if(!u)return null;const f=new d.bX(o.tileId.z,o.tileId.x,o.tileId.y),m=new d.bY(r.wrap,f);return{buffers:u,projMatrix:a.transform.calculateProjMatrix(m),coverageTile:o}}function Ys(a,r,o){if(!a.frcCoverageSnapshot)return;const u=a.context,f=u.gl,m=a.getOrCreateProgram("clippingMask");u.setColorMode(d.a1.disabled),u.setDepthMode(d.Z.disabled);for(const g of r){const x=Uc(a,g);if(!x)continue;const w=x.buffers.frcLevelSegments[o];w&&m.draw(a,f.TRIANGLES,d.Z.disabled,new d._({func:f.EQUAL,mask:255},a._tileClippingMaskIDs[g.key]||0,255,f.KEEP,f.KEEP,f.INVERT),d.a1.disabled,d.$.disabled,Sr(x.projMatrix),`$frc_coverage_${o}`,x.buffers.vertexBuffer,x.buffers.indexBuffer,w)}}function Nr(a,r,o){if(!a.frcCoverageSnapshot)return;const u=a.context,f=u.gl,m=a.getOrCreateProgram("clippingMask");u.setColorMode(d.a1.disabled),u.setDepthMode(d.Z.disabled);for(const g of r){const x=Uc(a,g);if(!x)continue;const w=x.buffers.frcLevelSegments[o];w&&m.draw(a,f.TRIANGLES,d.Z.disabled,new d._({func:f.EQUAL,mask:255},255&~(a._tileClippingMaskIDs[g.key]||0),255,f.KEEP,f.KEEP,f.INVERT),d.a1.disabled,d.$.disabled,Sr(x.projMatrix),`$frc_coverage_restore_${o}`,x.buffers.vertexBuffer,x.buffers.indexBuffer,w)}}function Do(a,r,o,u,f){if(r.length===0)return;let m=0;for(const x of r)m|=x.frcMask;const g=r.map(x=>x.coord);for(let x=0;x<9;++x)if(m&1<<x){if(Ys(a,g,x),u)for(const w of r)w.frcMask&1<<x&&u(w,x,uo(a,w.coord));if(o>0&&f)for(const w of r)w.frcMask&1<<x&&f(w,x,fn(a,w.coord));Nr(a,g,x)}}function Ko(a){for(const r of a)if(r.rings.length>0&&r.rings[0].length>0)return!0;return!1}function xr(a){const r=a.frcCoverageFadeRange;return!r||r[1]<=r[0]?0:1-Math.max(0,Math.min(1,(a.transform.zoom-r[0])/(r[1]-r[0])))}const ec={loaded:!0,drawBuilding:function(a,r,o,u){a.currentLayer<a.firstLightBeamLayer&&(a.firstLightBeamLayer=a.currentLayer);const f=o.paint.get("building-ambient-occlusion-ground-intensity"),m=o.paint.get("building-ambient-occlusion-ground-radius"),g=o.paint.get("building-ambient-occlusion-ground-attenuation"),x=o.paint.get("building-opacity");if(x<=0)return;let w=f>0&&m>0,E=!0;const I=o.paint.get("building-vertical-scale");if(I<=0)return;a.shadowRenderer||(E=!1);const R=a.conflationActive&&a.style.isLayerClipped(o,r.getSource()),P=a.style.order.indexOf(o.fqid);if(function(B,V,U,G,$,Y){for(const re of Y){const oe=V.getTile(re).getBucket(U);oe&&($&&oe.updateReplacement(re,B.replacementSource,G),oe.uploadUpdatedIndexBuffer(B.context))}}(a,r,o,P,R,u),function(B,V,U,G){for(const $ of G){const Y=V.getTile($).getBucket(U);Y&&Y.needsEvaluation()&&Y.uploadUpdatedColorBuffer(B.context)}}(a,r,o,u),o.resetLayerRenderingStats(a),a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!0),a.renderPass==="shadow"&&a.shadowRenderer){const B=[],V=a.shadowRenderer.getShadowPassDepthMode();nr({painter:a,source:r,layer:o,coords:u,defines:B,blendMode:d.a1.disabled,depthMode:V,opacity:x,verticalScale:I,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(a.renderPass==="translucent"){let B=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];E&&(B=B.concat("RENDER_SHADOWS")),a.shadowRenderer&&a.shadowRenderer.useNormalOffset&&(B=B.concat("NORMAL_OFFSET"));const V=o.paint.get("building-facade-emissive-chance"),U=o.paint.get("building-ambient-occlusion-intensity"),G=o.paint.get("building-flood-light-intensity"),$=o.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",Y=o.paint.get("building-flood-light-color").toNonPremultipliedRenderColor($?null:o.lut).toArray01().slice(0,3),re=o.paint.get("building-flood-light-ground-attenuation"),oe=G>0,pe=new d.Z(a.context.gl.LEQUAL,d.Z.ReadWrite,a.depthRangeFor3D);x<1&&nr({painter:a,source:r,layer:o,coords:u,defines:B,blendMode:d.a1.disabled,depthMode:pe,opacity:x,verticalScale:I,facadeEmissiveChance:V,facadeAOIntensity:U,floodLightIntensity:G,floodLightColor:Y,depthOnly:!0});const ce=a.colorModeForRenderPass();nr({painter:a,source:r,layer:o,coords:u,defines:B,blendMode:ce,depthMode:pe,opacity:x,verticalScale:I,facadeEmissiveChance:V,facadeAOIntensity:U,floodLightIntensity:G,floodLightColor:Y});const _e=o.paint.get("building-front-cutoff");di(a.transform.pitch,_e,!!a.terrain),w&&Hr(a,r,o,u,!0,x,f,m,G,Y,g,R),oe&&Hr(a,r,o,u,!1,x,f,m,G,Y,re,R)}else if(a.renderPass==="light-beam"){const B=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],V=new d.Z(a.context.gl.LEQUAL,d.Z.ReadOnly,a.depthRangeFor3D);nr({painter:a,source:r,layer:o,coords:u,defines:B,blendMode:d.a1.alphaBlended,depthMode:V,opacity:x,verticalScale:I,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}a.shadowRenderer&&(a.shadowRenderer.useNormalOffset=!1),a.resetStencilClippingMasks()},BuildingTileBorderManager:class{constructor(){this.visibleTiles=[]}updateBorders(a,r){const o=[],u=[],f=a._getRenderableCoordinates(!1,!0);for(const x of f){const w=a.getTile(x);if(!w.hasData())continue;const E=w.getBucket(r);E&&(E.isEmpty()||(o.push(x.key),u.push({bucket:E,tileID:x.canonical})))}let m=o.length!==this.visibleTiles.length;if(!m){o.sort();for(let x=0;x<o.length;x++)if(o[x]!==this.visibleTiles[x]){m=!0;break}}if(!m)return;const g=new Set;this.visibleTiles=o,u.sort((x,w)=>x.tileID.z-w.tileID.z||x.tileID.x-w.tileID.x||x.tileID.y-w.tileID.y);for(const x of u){const w=new Array,E=new Array,I=x.bucket;for(const R of I.featuresOnBorder)I.footprints[R.footprintIndex].hiddenFlags&d.aR||(g.has(R.featureId)?E.push(R.footprintIndex):(g.add(R.featureId),w.push(R.footprintIndex)));I.updateFootprintHiddenFlags(w,d.aS,!1),I.updateFootprintHiddenFlags(E,d.aS,!0)}}},drawRasterParticle:function(a,r,o,u,f,m){a.renderPass==="offscreen"&&function(g,x,w,E){if(!E.length)return;const I=g.context,R=I.gl,P=x.getSource();if(P.type!=="raster-array")return;const B=Math.ceil(Math.sqrt(w.paint.get("raster-particle-count")));let V=w.particlePositionRGBAImage;if(!V||V.width!==B){const re=function(oe){const pe=oe*oe,ce=new Uint8Array(4*pe),_e=.9090909090909091;for(let ue=0;ue<pe;ue++){const me=_e*(d.b8(2*ue+0)+fr),Ie=_e*(d.b8(2*ue+1)+fr),we=255*me%1,ve=255*Ie%1,Se=we,Re=Ie-ve/255,Ue=ve;ce[4*ue+0]=255*(me-we/255),ce[4*ue+1]=255*Se,ce[4*ue+2]=255*Re,ce[4*ue+3]=255*Ue}return ce}(B);V=w.particlePositionRGBAImage=new d.b({width:B,height:B},re)}let U=w.particleFramebuffer;U?U.width!==B&&(U.destroy(),U=w.particleFramebuffer=I.createFramebuffer(B,B,1,null)):U=w.particleFramebuffer=I.createFramebuffer(B,B,1,null);const G=[];for(const re of E){const oe=x.getTile(re);if(!oe)continue;const pe=Rn(oe,P,w);if(!pe)continue;const ce=[oe.tileSize,oe.tileSize];let _e=w.tileFramebuffer;_e||(_e=w.tileFramebuffer=I.createFramebuffer(ce[0],ce[1],1,null));let ue=oe.rasterParticleState;ue||(ue=oe.rasterParticleState=new $i(I,re,ce,V));const me=ue.update(w.lastInvalidatedAt);ue.particleTextureDimension!==B&&ue.updateParticleTexture(re,V);const Ie=ue.targetColorTexture;ue.targetColorTexture=ue.backgroundColorTexture,ue.backgroundColorTexture=Ie;const we=ue.particleTexture0;ue.particleTexture0=ue.particleTexture1,ue.particleTexture1=we,G.push([re,pe,ue,me])}if(G.length===0)return;const $=d.e.now(),Y=w.previousDrawTimestamp?.001*($-w.previousDrawTimestamp):.0167;if(w.previousDrawTimestamp=$,w.hasColorMap()){I.activeTexture.set(R.TEXTURE0+2);let re=w.colorRampTexture;re||(re=w.colorRampTexture=new d.T(I,w.colorRamp,R.RGBA8)),re.bind(R.LINEAR,R.CLAMP_TO_EDGE)}I.bindFramebuffer.set(w.tileFramebuffer.framebuffer),function(re,oe,pe){const ce=re.context,_e=ce.gl,ue=oe.tileFramebuffer;ce.activeTexture.set(_e.TEXTURE0);const me={u_texture:0,u_opacity:1.05*(we=oe.paint.get("raster-particle-fade-opacity-factor"))/(we+.05)},Ie=re.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var we;for(const ve of pe){const[,,Se,Re]=ve;ue.colorAttachment0.set(Se.targetColorTexture.texture),ce.viewport.set([0,0,ue.width,ue.height]),ce.clear({color:d.C.transparent}),Re&&(Se.backgroundColorTexture.bind(_e.NEAREST,_e.CLAMP_TO_EDGE),Ie.draw(re,_e.TRIANGLES,d.Z.disabled,d._.disabled,d.a1.alphaBlended,d.$.disabled,me,oe.id,re.viewportBuffer,re.quadTriangleIndexBuffer,re.viewportSegments))}}(g,w,G),function(re,oe,pe,ce){const _e=re.context,ue=_e.gl,me=pe.tileFramebuffer,Ie=re.transform.projection.name==="globe",we=pe.paint.get("raster-particle-max-speed");for(const ve of ce){const[Se,Re,Ue]=ve;_e.activeTexture.set(ue.TEXTURE0+0),Re.texture.bind(ue.LINEAR,ue.CLAMP_TO_EDGE),me.colorAttachment0.set(Ue.targetColorTexture.texture);const Pe=re.getOrCreateProgram("rasterParticleDraw",{defines:Re.defines,overrideFog:!1});_e.activeTexture.set(ue.TEXTURE0+1);const Oe=Re.scalarData?[]:[0,1,2,3].map(tt=>d.aB[tt](Se));Oe.push(Se);const Xe=Se.canonical.x,ot=Se.canonical.y;for(const tt of Oe){const Ye=oe.getTile(Ie?tt.wrapped():tt);if(!Ye)continue;const mt=Ye.rasterParticleState;if(!mt)continue;const We=tt.canonical.x+(1<<tt.canonical.z)*(tt.wrap-Se.wrap),je=tt.canonical.y;mt.particleTexture0.bind(ue.NEAREST,ue.CLAMP_TO_EDGE);const Je=Ai(1,mt.particleTexture0.size[0],[We-Xe,je-ot],0,Re.texture.size,2,we,Re.textureOffset,Re.scale,Re.offset);Pe.draw(re,ue.POINTS,d.Z.disabled,d._.disabled,d.a1.alphaBlended,d.$.disabled,Je,pe.id,mt.particleIndexBuffer,void 0,mt.particleSegment)}}}(g,x,w,G),I.bindFramebuffer.set(w.particleFramebuffer.framebuffer),function(re,oe,pe,ce){const _e=re.context,ue=_e.gl,me=oe.paint.get("raster-particle-max-speed"),Ie=ce*oe.paint.get("raster-particle-speed-factor")*.15,we=function(Se){return Math.pow(Se,6)}(.01+1*oe.paint.get("raster-particle-reset-rate-factor")),ve=oe.particleFramebuffer;_e.viewport.set([0,0,ve.width,ve.height]);for(const Se of pe){const[,Re,Ue]=Se;_e.activeTexture.set(ue.TEXTURE0+0),Re.texture.bind(ue.LINEAR,ue.CLAMP_TO_EDGE),_e.activeTexture.set(ue.TEXTURE0+1);const Pe=Ue.particleTexture0;Pe.bind(ue.NEAREST,ue.CLAMP_TO_EDGE);const Oe=gi(1,Pe.size[0],0,Re.texture.size,me,Ie,we,Re.textureOffset,Re.scale,Re.offset);ve.colorAttachment0.set(Ue.particleTexture1.texture),_e.clear({color:d.C.transparent}),re.getOrCreateProgram("rasterParticleUpdate",{defines:Re.defines}).draw(re,ue.TRIANGLES,d.Z.disabled,d._.disabled,d.a1.unblended,d.$.disabled,Oe,oe.id,re.viewportBuffer,re.quadTriangleIndexBuffer,re.viewportSegments)}}(g,w,G,Y)}(a,r,o,u),a.renderPass==="translucent"&&(function(g,x,w,E){const I=g.context,R=I.gl,P=x.getSource().tileSize,B=5*(1-d.am(d.b1,d.b1+1,g.transform.zoom))*P+w.paint.get("raster-particle-elevation"),V=!g.options.moving,U=g.transform.projection.name==="globe";if(!E.length)return;const[G,$]=g.stencilConfigForOverlap(E),Y=[];U&&Y.push("PROJECTION_GLOBE_VIEW");const re=g.stencilModeFor3D();for(const oe of $){const pe=oe.toUnwrapped(),ce=x.getTile(oe);if(!ce.rasterParticleState)continue;const _e=ce.rasterParticleState,ue=100;ce.registerFadeDuration(ue);const me=x.findLoadedParent(oe,0),Ie=Or(ce,me,x,g.transform,ue);let we,ve;g.terrain&&g.terrain.prepareDrawTile(),I.activeTexture.set(R.TEXTURE0),_e.targetColorTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),I.activeTexture.set(R.TEXTURE1),me&&me.rasterParticleState?(me.rasterParticleState.targetColorTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),we=Math.pow(2,me.tileID.overscaledZ-ce.tileID.overscaledZ),ve=[ce.tileID.canonical.x*we%1,ce.tileID.canonical.y*we%1]):_e.targetColorTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE);const Se=U?g.transform.expandedFarZProjMatrix:g.transform.calculateProjMatrix(pe,V),Re=g.transform,Ue=tn(Re),Pe=d.b2(oe.canonical),Oe=d.b3(Pe.getCenter().lat);let Xe,ot,tt,Ye,mt;U?(Xe=Float32Array.from(d.b4(d.b5(oe.canonical))),ot=Float32Array.from(Re.globeMatrix),tt=Float32Array.from(d.b6(Re)),Ye=[d.a7(Re.center.lng),d.a8(Re.center.lat)],mt=Float32Array.from(d.b7(oe.canonical,Pe,Oe,Re.worldSize/Re._pixelsPerMercatorPixel))):(Xe=new Float32Array(16),ot=new Float32Array(9),tt=new Float32Array(16),Ye=[0,0],mt=new Float32Array(9));const We=ro(Se,Xe,ot,tt,mt,ve||[0,0],d.S(g.transform.zoom),Ye,Ue,we||1,Ie,B),je=g.isTileAffectedByFog(oe),Je=g.getOrCreateProgram("rasterParticle",{defines:Y,overrideFog:je});if(g.uploadCommonUniforms(I,Je,pe),U){const ft=new d.Z(R.LEQUAL,d.Z.ReadOnly,g.depthRangeFor3D),rt=0,ct=g.globeSharedBuffers;if(ct){const[xt,Rt,Mt]=ct.getGridBuffers(Oe,rt!==0);Je.draw(g,R.TRIANGLES,ft,re,d.a1.alphaBlended,g.renderElevatedRasterBackface?d.$.frontCCW:d.$.backCCW,We,w.id,xt,Rt,Mt)}}else{const ft=g.depthModeForSublayer(0,d.Z.ReadOnly),rt=G[oe.overscaledZ],{tileBoundsBuffer:ct,tileBoundsIndexBuffer:xt,tileBoundsSegments:Rt}=g.getTileBoundsBuffers(ce);Je.draw(g,R.TRIANGLES,ft,rt,d.a1.alphaBlended,d.$.disabled,We,w.id,ct,xt,Rt)}}g.resetStencilClippingMasks()}(a,r,o,u),a.style.map.triggerRepaint())},prepareRasterParticle:function(a,r,o){const u=r.getSource();if(u.type!=="raster-array"||!u.loaded())return;const f=a.sourceLayer||u.rasterLayerIds&&u.rasterLayerIds[0];if(!f)return;const m=a.paint.get("raster-particle-array-band")||u.getInitialBand(f);if(m==null)return;const g=r.getIds().map(x=>r.getTileByID(x));for(const x of g)x.updateNeeded(a.id,m)&&u.prepareTile(x,f,a.id,m)},Rain:class extends $r{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){const r=a.context;if(!this.particlesVx){const o=vn(this.particlesCount),u=new d.bk,f=new d.ad;let m=0;const g=d.bi(1323123451230);for(let x=0;x<o.length;++x){const w=o[x],E=[2*g()-1,g(),g(),g()];u.emplaceBack(w[0],w[1],w[2],-1,-1,...E),u.emplaceBack(w[0],w[1],w[2],1,-1,...E),u.emplaceBack(w[0],w[1],w[2],1,1,...E),u.emplaceBack(w[0],w[1],w[2],-1,1,...E),f.emplaceBack(m+0,m+1,m+2),f.emplaceBack(m+0,m+2,m+3),m+=4}this.particlesVx=r.createVertexBuffer(u,oo.members),this.particlesIdx=r.createIndexBuffer(f)}}getDrawParams(a){if(!a.style.rain)return null;const r=a.style.rain.state,o=structuredClone(this._params);o.intensity=r.density,o.timeFactor=r.intensity,o.color=structuredClone(r.color),o.screenThinning.intensity=r.centerThinning,o.dropletSizeX=r.dropletSize[0],o.dropletSizeYScale=r.dropletSize[1]/r.dropletSize[0],o.distortionStrength=100*r.distortionStrength;const u=structuredClone(this._vignetteParams);return u.strength=1,u.color=structuredClone(r.vignetteColor),{params:o,vignetteParams:u,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(r.direction)}}draw(a){const r=this.getDrawParams(a);if(!r)return;const{params:o,revealParams:u,direction:f,vignetteParams:m}=r,g=a.transform.zoom;if(u.revealStart>g)return;const x=rn(0,1,u.revealStart,u.revealStart+u.revealRange,g);if(!this.particlesVx||!this.particlesIdx)return;m.strength*=x;const w=this.updateOnRender(a,o.timeFactor),E=a.context,I=E.gl,R=a.transform;this.screenTexture&&this.screenTexture.size[0]===a.width&&this.screenTexture.size[1]===a.height||(this.screenTexture=new d.T(E,{width:a.width,height:a.height,data:null},I.RGBA8)),o.distortionStrength>0&&(E.activeTexture.set(I.TEXTURE0),this.screenTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE),I.copyTexSubImage2D(I.TEXTURE_2D,0,0,0,0,0,a.width,a.height));const P=a.getOrCreateProgram("rainParticle");a.uploadCommonUniforms(E,P),E.activeTexture.set(I.TEXTURE0),this.screenTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE);const B=[o.color.r,o.color.g,o.color.b,o.color.a],V=(U,G)=>{const $=Pn(this._movement.getPosition(),U),Y=o.dropletSizeX,re=o.dropletSizeX*o.dropletSizeYScale,oe=a.width/2,pe=a.height/2,ce=rn(0,o.screenThinning.start,0,1,o.screenThinning.intensity),_e=rn(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),ue=rn(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),me=(Ie={modelview:w.modelviewMatrix,projection:w.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:$,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:U,rainDropletSize:[Y,re],distortionStrength:o.distortionStrength,rainDirection:f,color:B,screenSize:[R.width,R.height],thinningCenterPos:[oe,pe],thinningShape:[ce,_e,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:ue,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:G?0:1},{u_modelview:Float32Array.from(Ie.modelview),u_projection:Float32Array.from(Ie.projection),u_time:Ie.time,u_cam_pos:Ie.camPos,u_texScreen:0,u_velocityConeAperture:Ie.velocityConeAperture,u_velocity:Ie.velocity,u_boxSize:Ie.boxSize,u_rainDropletSize:Ie.rainDropletSize,u_distortionStrength:Ie.distortionStrength,u_rainDirection:Ie.rainDirection,u_color:Ie.color,u_screenSize:Ie.screenSize,u_thinningCenterPos:Ie.thinningCenterPos,u_thinningShape:Ie.thinningShape,u_thinningAffectedRatio:Ie.thinningAffectedRatio,u_thinningParticleOffset:Ie.thinningParticleOffset,u_shapeDirectionalPower:Ie.shapeDirectionalPower,u_shapeNormalPower:Ie.shapeNormalPower,u_mode:Ie.mode});var Ie;const we=Math.round(o.intensity*this.particlesCount),ve=d.ac.simpleSegment(0,0,4*we,2*we);P.draw(a,I.TRIANGLES,d.Z.disabled,d._.disabled,d.a1.alphaBlended,d.$.disabled,me,"rain_particles",this.particlesVx,this.particlesIdx,ve)};o.distortionStrength>0&&V(o.boxSize,!0),V(o.boxSize,!1),this._vignette.draw(a,m)}},Snow:class extends $r{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){const r=a.context;if(!this.particlesVx){const o=vn(this.particlesCount),u=new d.bl,f=new d.ad;let m=0;const g=d.bi(1323123451230);for(let x=0;x<o.length;++x){const w=o[x],E=g(),I=g(),R=g(),P=[x/o.length,E,I,R],B=[g(),g()];u.emplaceBack(w[0],w[1],w[2],-1,-1,...P,...B),u.emplaceBack(w[0],w[1],w[2],1,-1,...P,...B),u.emplaceBack(w[0],w[1],w[2],1,1,...P,...B),u.emplaceBack(w[0],w[1],w[2],-1,1,...P,...B),f.emplaceBack(m+0,m+1,m+2),f.emplaceBack(m+0,m+2,m+3),m+=4}this.particlesVx=r.createVertexBuffer(u,so.members),this.particlesIdx=r.createIndexBuffer(f)}}getDrawParams(a){if(!a.style.snow)return null;const r=a.style.snow.state,o=structuredClone(this._params);o.intensity=r.density,o.timeFactor=r.intensity,o.color=structuredClone(r.color),o.screenThinning.intensity=r.centerThinning,o.billboardSize=2.79*r.flakeSize;const u=structuredClone(this._vignetteParams);return u.strength=1,u.color=structuredClone(r.vignetteColor),{params:o,vignetteParams:u,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(r.direction)}}draw(a){const r=this.getDrawParams(a);if(!r)return;const{params:o,revealParams:u,direction:f,vignetteParams:m}=r,g=a.transform.zoom;if(u.revealStart>g)return;const x=rn(0,1,u.revealStart,u.revealStart+u.revealRange,g);m.strength*=x;const w=this.updateOnRender(a,o.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const E=a.context,I=E.gl,R=a.transform,P=a.getOrCreateProgram("snowParticle");a.uploadCommonUniforms(E,P),((B,V,U)=>{const G=Pn(this._movement.getPosition(),B),$=R.width/2,Y=R.height/2,re=rn(0,U.screenThinning.start,0,1,U.screenThinning.intensity),oe=rn(.001,U.screenThinning.range,0,1,U.screenThinning.intensity),pe=rn(0,U.screenThinning.particleOffset,0,1,U.screenThinning.intensity),ce=(_e={modelview:w.modelviewMatrix,projection:w.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:G,velocityConeAperture:U.velocityConeAperture,velocity:U.velocity,horizontalOscillationRadius:U.horizontalOscillationRadius,horizontalOscillationRate:U.horizontalOscillationRate,boxSize:B,billboardSize:1*U.billboardSize,simpleShapeParameters:[U.shapeFadeStart,U.shapeFadePower],screenSize:[R.width,R.height],thinningCenterPos:[$,Y],thinningShape:[re,oe,Math.pow(10,U.screenThinning.fadePower)],thinningAffectedRatio:U.screenThinning.affectedRatio,thinningParticleOffset:pe,color:[U.color.r,U.color.g,U.color.b,U.color.a],direction:f},{u_modelview:Float32Array.from(_e.modelview),u_projection:Float32Array.from(_e.projection),u_time:_e.time,u_cam_pos:_e.camPos,u_velocityConeAperture:_e.velocityConeAperture,u_velocity:_e.velocity,u_horizontalOscillationRadius:_e.horizontalOscillationRadius,u_horizontalOscillationRate:_e.horizontalOscillationRate,u_boxSize:_e.boxSize,u_billboardSize:_e.billboardSize,u_simpleShapeParameters:_e.simpleShapeParameters,u_screenSize:_e.screenSize,u_thinningCenterPos:_e.thinningCenterPos,u_thinningShape:_e.thinningShape,u_thinningAffectedRatio:_e.thinningAffectedRatio,u_thinningParticleOffset:_e.thinningParticleOffset,u_particleColor:_e.color,u_direction:_e.direction});var _e;const ue=Math.round(U.intensity*this.particlesCount),me=d.ac.simpleSegment(0,0,4*ue,2*ue);this.particlesVx&&this.particlesIdx&&P.draw(a,I.TRIANGLES,d.Z.disabled,d._.disabled,d.a1.alphaBlended,d.$.disabled,ce,"snow_particles",this.particlesVx,this.particlesIdx,me)})(o.boxSize,0,o),this._vignette.draw(a,m)}},shaders:no,programUniforms:bn,drawElevatedStructures:function(a){const{painter:r,sourceCache:o,layer:u,coords:f,colorMode:m}=a,g=r.context.gl,x=a.painter.shadowRenderer,w=!!x&&x.enabled,E=new d.Z(r.context.gl.LEQUAL,d.Z.ReadOnly,r.depthRangeFor3D);let I=[0,0,0];if(w){const P=r.style.directionalLight,B=r.style.ambientLight;P&&B&&(I=d.aF(r.style,P,B))}const R=P=>{for(const B of f){const V=o.getTile(B),U=V.getBucket(u);if(!U)continue;const G=U.hdExt?U.hdExt.elevatedStructures:void 0;if(!G)continue;let $,Y;if(P?($=G.renderableBridgeSegments,Y=G.bridgeProgramConfigurations.get(u.id)):($=G.renderableTunnelSegments,Y=G.tunnelProgramConfigurations.get(u.id)),!$||$.segments[0].primitiveLength===0)continue;Y.updatePaintBuffers(),r.prepareDrawTile();const re=r.isTileAffectedByFog(B),oe=[];w&&oe.push("RENDER_SHADOWS","NORMAL_OFFSET");const pe=r.getOrCreateProgram("elevatedStructures",{config:Y,overrideFog:re,defines:oe}),ce=r.translatePosMatrix(B.projMatrix,V,u.paint.get("fill-translate"),u.paint.get("fill-translate-anchor"));w&&x.setupShadows(V.tileID.toUnwrapped(),pe,"vector-tile");const _e=Hn(ce,I);r.uploadCommonUniforms(r.context,pe,B.toUnwrapped()),pe.draw(r,g.TRIANGLES,E,d._.disabled,m,d.$.backCCW,_e,u.id,G.vertexBuffer,G.indexBuffer,$,u.paint,r.transform.zoom,Y,[G.vertexBufferNormal])}};R(!0),R(!1)},drawElevatedFillShadows:function(a){const{painter:r,sourceCache:o,layer:u,coords:f}=a,m=r.context.gl,g=a.painter.shadowRenderer;for(const x of f){const w=o.getTile(x),E=w.getBucket(u);if(!E)continue;const I=E.hdExt?E.hdExt.elevatedStructures:void 0;if(!I||!I.shadowCasterSegments||I.shadowCasterSegments.segments[0].primitiveLength===0)continue;r.prepareDrawTile();const R=E.bufferData.programConfigurations.get(u.id),P=r.isTileAffectedByFog(x),B=r.getOrCreateProgram("elevatedStructuresDepth",{config:R,overrideFog:P}),V=g.calculateShadowPassMatrixFromTile(w.tileID.toUnwrapped());r.uploadCommonUniforms(r.context,B,x.toUnwrapped());const U=Wo(V,0);B.draw(r,m.TRIANGLES,g.getShadowPassDepthMode(),d._.disabled,d.a1.disabled,d.$.disabled,U,u.id,I.vertexBuffer,I.indexBuffer,I.shadowCasterSegments,u.paint,r.transform.zoom,R)}},drawDepthPrepass:function(a,r,o,u,f){if(!r||!o.layout||o.layout.get("fill-elevation-reference")==="none"||o.paint.get("fill-opacity").constantOr(1)===0)return;const m=a.context.gl,g=new d.Z(a.context.gl.LEQUAL,d.Z.ReadWrite,a.depthRangeFor3D),x=new d.Z(a.context.gl.GREATER,d.Z.ReadWrite,a.depthRangeFor3D),w=function(B){let V=.01;return B.isOrthographic&&(V=d.al(1e-4,V,d.bo(B.pitch>=d.bn?1:B.pitch/d.bn))),2*V}(a.transform),E=a.transform.getFreeCameraOptions().position,I="elevatedStructuresDepthReconstruct",R=a.getOrCreateProgram(I,{defines:["DEPTH_RECONSTRUCTION"]}),P=a.getOrCreateProgram(I);for(const B of u){const V=r.getTile(B),U=V.getBucket(o);if(!U||!U.hdExt)continue;const G=U.hdExt.elevatedStructures,$=U.hdExt.elevationBufferData;if(!G||!G.depthSegments||!$)continue;const Y=$.heightRange,re=Oi(B.toUnwrapped(),E),oe=a.translatePosMatrix(B.projMatrix,V,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));let pe,ce,_e,ue;if(f==="initialize"){if(!Y||Y.min>=1||G.depthSegments.segments[0].primitiveLength===0)continue;pe=or(oe,re,w,1,0),ce=g,_e=G.depthSegments,ue=R}else if(f==="reset"){if(!Y||Y.min>=0||G.maskSegments.segments[0].primitiveLength===0)continue;pe=or(oe,re,0,0,1),ce=x,_e=G.maskSegments,ue=R}else if(f==="geometry"){if(G.depthSegments.segments[0].primitiveLength===0)continue;pe=or(oe,re,w,1,0),ce=g,_e=G.depthSegments,ue=P}ue.draw(a,m.TRIANGLES,ce,d._.disabled,d.a1.disabled,d.$.disabled,pe,o.id,G.vertexBuffer,G.indexBuffer,_e,o.paint,a.transform.zoom)}},drawGroundShadowMask:function(a,r,o,u){if(!r||!o.layout||o.layout.get("fill-elevation-reference")==="none"||o.paint.get("fill-opacity").constantOr(1)===0)return;const f=a.context.gl,m=new d.Z(f.LEQUAL,d.Z.ReadOnly,a.depthRangeFor3D),g=new d._({func:f.ALWAYS,mask:255},255,255,f.KEEP,f.KEEP,f.REPLACE),x=a.transform.getFreeCameraOptions().position,w=a.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const E of u){const I=r.getTile(E),R=I.getBucket(o);if(!R)continue;const P=R.hdExt?R.hdExt.elevatedStructures:void 0;if(!P||!P.depthSegments||P.depthSegments.segments[0].primitiveLength===0)continue;const B=Oi(E.toUnwrapped(),x),V=a.translatePosMatrix(E.projMatrix,I,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor")),U=or(V,B,0,1,0);w.draw(a,f.TRIANGLES,m,g,d.a1.disabled,d.$.disabled,U,o.id,P.vertexBuffer,P.indexBuffer,P.depthSegments,o.paint,a.transform.zoom)}},IndoorManager:class extends d.E{constructor(a,r=!1){super(),this._style=a,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Zr,this._initialLoadDone=!1,d.aV(["_updateUI"],this);const o=()=>{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))};r?(this._initialLoadDone=!0,o()):this._style.on("style.load",o)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(a){a===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=a,this._recalculateActiveFloors())}setActiveFloorsVisibility(a){this._updateActiveFloors(a),this._updateIndoorSelector()}setIndoorData(a){let r=!1;for(const[o,u]of Object.entries(a.buildings))if(this._buildings[o])for(const f of u.floorIds)this._buildings[o].floorIds.add(f),this._buildings[o].floors[f]?this._mergeFloors(this._buildings[o].floors[f],u.floors[f]):(this._buildings[o].floors[f]=u.floors[f],r=!0);else this._buildings[o]=u,r=!0;r&&this._recalculateActiveFloors()}getIndoorTileOptions(a,r){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(a,r),indoorState:this._indoorState}:null}getControlState(){const a=this._buildings,r=this._closestBuildingId,o=r&&a?a[r]:void 0;if(!o)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let u=null;for(const m of o.floorIds)if(this._activeFloors&&this._activeFloors.has(m)){u=m;break}const f=Array.from(o.floorIds).map(m=>({id:m,name:o.floors[m].name,zIndex:o.floors[m].zIndex})).sort((m,g)=>g.zIndex-m.zIndex).filter((m,g,x)=>g===0||m.zIndex!==x[g-1].zIndex);return{selectedFloorId:u,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:f}}_updateUI(){this._initialLoadDone=!0;const a=this._style.map.transform,r=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,a.center,a.zoom,a.getBounds(),this._makeViewportPolygon());if(r!==this._closestBuildingId){const o=this._closestBuildingId;this._closestBuildingId=r,this._onBuildingTransition(o,r),this._updateIndoorSelector()}}_onBuildingTransition(a,r){if(!this._indoorState)return;!r&&a?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):!!r&&!a&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new d.h("selector-update",this.getControlState()))}_updateActiveFloors(a){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:a,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;const a=d.aW.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(r,o){if(r===o)return!0;if(!r||!o||r.size!==o.size)return!1;for(const u of r)if(!o.has(u))return!1;return!0})(a,this._activeFloors)||(this._activeFloors=a,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(a,r){r.geometry&&(a.geometry?(a.geometry.type==="Polygon"&&(a.geometry={type:"MultiPolygon",coordinates:[a.geometry.coordinates]}),r.geometry.type==="Polygon"?a.geometry.coordinates.push(r.geometry.coordinates):r.geometry.type==="MultiPolygon"&&a.geometry.coordinates.push(...r.geometry.coordinates)):a.geometry=r.geometry)}_makeViewportPolygon(){const a=this._style.map.transform,r=a.width,o=a.height;return[a.pointLocation(new d.P(0,0)),a.pointLocation(new d.P(r,0)),a.pointLocation(new d.P(r,o)),a.pointLocation(new d.P(0,o))].map(u=>new d.P(u.lng,u.lat))}},HdCoverageState:class{constructor(){this.coverageSourceCaches={},this.manager=new il}},updateFrcCoverage:function(a,r){r.manager.clear();for(const u in a._mergedHdRoadCoverageSourceCaches){const f=a._mergedHdRoadCoverageSourceCaches[u]._tiles;for(const m in f){const g=f[m];if(!g||!g.loaded())continue;const x=g.frcCoveragePolygons;r.manager.addTileCoverage(g.tileID.canonical,x&&x.length>0?x:[])}}const o=r.manager.updateSnapshotIfNeeded();if(a.map.painter&&(a.map.painter.frcCoverageSnapshot=o.empty()?null:o),!o.empty()){const u=[a._mergedOtherSourceCaches,a._mergedSymbolSourceCaches];for(const f of u)for(const m in f){const g=f[m];for(const x in g._tiles){const w=g._tiles[x];w&&w.hasDeferredRoadStructure&&(w.hasDeferredRoadStructure=!1,g._reloadTile(+x,"reloading"))}}}},updateHdCoverageSourceCache:function(a,r,o){if(o.type!=="fill"||o.sourceLayer!==d.bU||r.coverageSourceCaches[o.source])return;const u=a.getOwnSource(o.source);if(!u||u.type!=="vector")return;const f=`hd-road-coverage:${o.source}`,m=d.m(f,a.scope),g=a._sourceCaches[f]=new Tn(m,u,d.bR.HdRoadCoverage);r.coverageSourceCaches[o.source]=g,g.setMaxzoomOverride(14),g.onAdd(a.map);const x=a._otherSourceCaches[o.source];x&&x._sourceLoaded&&(g._sourceLoaded=!0)},updateFrcCoverageFadeRange:function(a,r){let o=null,u=null;const f={globals:{zoom:0}};a.forEachFragmentStyle(m=>{if(o)return;const g=m.stylesheet?m.stylesheet.schema:null;if(!g||!g.sdCoverageFadeRange)return;const x=d.m("sdCoverageFadeRange",m.scope),w=m.options?m.options.get(x):void 0,E=w?w.value||w.default:null;if(E){const B=E.evaluate(f);Array.isArray(B)&&B.length===2&&(B[0]>0||B[1]>0)&&(o=[B[0],B[1]])}const I=d.m("sdCoverageSourceLayers",m.scope),R=m.options?m.options.get(I):void 0,P=R?R.value||R.default:null;if(P){const B=P.evaluate(f);Array.isArray(B)&&B.length>0&&(u=B)}else{const B=a.stylesheet&&a.stylesheet.imports||[];for(const V of B)if(V.id===m.scope){const U=V.config?V.config.sdCoverageSourceLayers:void 0;Array.isArray(U)&&U.length>0&&(u=U);break}}}),r.frcCoverageFadeRange=o,r.frcCoverageSourceLayers=o!=null?u||["road","structure"]:[]},HdElevationState:Ln,setupAndUpdateElevationCoverage:function(a){if(!function(m){for(const g in m._mergedLayers)if(co(m._mergedLayers[g]))return!0;return!1}(a))return void nl(a);const r=le(a,a.map&&a.map.transform);a._hdElevation||(a._hdElevation=new Ln);const o=a._hdElevation._terrainActiveLast;if(a._hdElevation._terrainActiveLast=r,o!==void 0&&o!==r&&Po(a,void 0,!0),r)return void(a.map.painter&&(a.map.painter.elevationCoverageSnapshot=null));if(!ji(a))return void nl(a);o===void 0&&Po(a,void 0,!0);const u=a._hdElevation;u._needsCrossSourceElevation=!0,a._crossSourceElevationActive=!0,u._ingestFQIDs=Bi(a);const f=pa(a);a.forEachFragmentStyle(m=>{for(const g of f){if(!nn(g,m.scope))continue;const x=d.bV(g);if(m._otherSourceCaches[x]||m._symbolSourceCaches[x])continue;const w=m.getOwnSource(x);w&&w.type==="vector"&&(m._hdElevation||(m._hdElevation=new Ln),Ql(m,m._hdElevation,w))}}),a.mergeSources(),ma(a,u)},updateElevationCoverage:ma,updateHdElevationSourceCache:Ql,markElevationIngestSourceCachesUsed:function(a){if(!a._hdElevation||!a._hdElevation._needsCrossSourceElevation)return;const r=a._hdElevation._ingestFQIDs;if(r)for(const o of r){const u=lo(a,o);u&&(u.used=!0)}},updateCrossSourceElevationGate:function(a){a._crossSourceElevationActive=ji(a);const r=a._mergedHdRoadElevationSourceCaches;r&&Object.keys(r).length!==0&&(a._hdElevation||(a._hdElevation=new Ln),a._hdElevation._needsCrossSourceElevation=a._crossSourceElevationActive)},buildElevationRequestParams:function(a,r,o){if(r.renderSourceType===d.bR.HdRoadElevation||le(a.style,a.transform)||!o)return null;const u=a.painter?a.painter.elevationCoverageSnapshot:null,f=!(!a.painter||!a.painter.elevationProvidersReady);return u?function(m,g,x){const w=m.getTilesIntersecting(g);if(w.length===0)return{registry:[],hasCoveringTile:!1,allProvidersReady:x};const E=[];for(const I of w)for(const R of I.features)E.push({tileId:I.tileId,feature:R});return E.sort((I,R)=>I.feature.id-R.feature.id),{registry:E,hasCoveringTile:!0,allProvidersReady:x}}(u,r.tileID.canonical,f):{registry:[],hasCoveringTile:!1,allProvidersReady:f}},FrcCoverageRenderer:class{constructor(){this.tileBuffers=new Map,this._context=null}update(a,r){this._context=a;const o=new Set;for(const u of r){if(u.frcMask===0)continue;let f=!1;for(const g of u.polygons)if(g.hasGeometry()){f=!0;break}if(!f)continue;const m=`${u.tileId.z}/${u.tileId.x}/${u.tileId.y}`;if(o.add(m),!this.tileBuffers.has(m)){const g=this._createBuffers(a,u);g&&this.tileBuffers.set(m,g)}}for(const u of this.tileBuffers.keys())if(!o.has(u)){const f=this.tileBuffers.get(u);f.vertexBuffer.destroy(),f.indexBuffer.destroy();for(const m of f.frcLevelSegments)m&&m.destroy();this.tileBuffers.delete(u)}}getBuffers(a){return this.tileBuffers.get(`${a.z}/${a.x}/${a.y}`)||null}destroy(){for(const a of this.tileBuffers.values()){a.vertexBuffer.destroy(),a.indexBuffer.destroy();for(const r of a.frcLevelSegments)r&&r.destroy()}this.tileBuffers.clear()}_createBuffers(a,r){const o=new d.bC,u=new d.ad,f=[];for(const g of r.polygons){if(!g.hasGeometry()||g.rings.length===0)continue;const x=o.length,w=u.length,E=o.length,I=[],R=[];let P=0;for(let V=0;V<g.rings.length;V++){const U=g.rings[V];if(!(U.length<3)){V>0&&R.push(P);for(const G of U)o.emplaceBack(G.x,G.y),I.push(G.x,G.y),P++}}const B=d.bF(I,R.length>0?R:void 0);for(let V=0;V<B.length;V+=3)u.emplaceBack(E+B[V],E+B[V+1],E+B[V+2]);f.push({vertexOffset:x,indexOffset:w,vertexCount:o.length-x,indexCount:u.length-w,frcMask:g.frcMask})}if(o.length===0)return null;const m=new Array(9).fill(null);for(let g=0;g<9;++g){const x=1<<g;if(!(r.frcMask&x))continue;let w=1/0,E=0,I=0,R=!1;for(const P of f)P.frcMask&x&&(w=Math.min(w,P.indexOffset),E=Math.max(E,P.indexOffset+P.indexCount),I=Math.max(I,P.vertexOffset+P.vertexCount),R=!0);R&&(m[g]=d.ac.simpleSegment(0,w,I,E-w))}return{vertexBuffer:a.createVertexBuffer(o,d.bE.members),indexBuffer:a.createIndexBuffer(u),frcLevelSegments:m}}},drawFillFrcCoverageFirstPass:function(a){const{painter:r,bucket:o,coord:u,elevatedGeometry:f}=a,m=o.sourceLayerName==="road",g=o.sourceLayerName==="structure";if(!m&&!g||!r.frcCoverageSnapshot||f)return"fallthrough";const x=r.frcCoverageSnapshot.getTileOrParent(u.canonical);if(!x||x.frcMask===0)return"fallthrough";const w=o.hdExt&&o.hdExt.frcData,E=!!w&&!w.empty(),I=Ko(x.polygons);if(g&&!I)return"skip";if(g&&I)return a.polygonCoverageTiles.push({coord:a.coord,bufferData:a.bufferData,program:a.program,programConfiguration:a.programConfiguration,uniformValues:a.uniformValues,depthMode:a.depthMode,dynamicBuffers:a.dynamicBuffers,indexBuffer:a.indexBuffer,segments:a.segments,frcMask:x.frcMask}),"deferred";if(m&&E&&w){const R=x.frcMask,P=r.transform.zoom;for(const[B,V]of w.frcPerLevel)R&1<<B||V.segments.length!==0&&a.program.draw(r,a.drawMode,a.depthMode,a.stencilMode,a.colorMode,d.$.disabled,a.uniformValues,a.layer.id,a.bufferData.layoutVertexBuffer,a.indexBuffer,V,a.layer.paint,P,a.programConfiguration,a.dynamicBuffers);return w.frcNonRoadSegments.segments.length>0&&a.program.draw(r,a.drawMode,a.depthMode,a.stencilMode,a.colorMode,d.$.disabled,a.uniformValues,a.layer.id,a.bufferData.layoutVertexBuffer,a.indexBuffer,w.frcNonRoadSegments,a.layer.paint,P,a.programConfiguration,a.dynamicBuffers),"drawn"}return"fallthrough"},drawFillFrcCoverageSecondPass:function(a,r,o,u,f){if(o.length===0)return;const m=xr(a),g=a.transform.zoom,x=(w,E,I)=>{I!==1&&(w.uniformValues.u_opacity_multiplier=I),w.program.draw(a,u,w.depthMode,E,f,d.$.disabled,w.uniformValues,r.id,w.bufferData.layoutVertexBuffer,w.indexBuffer,w.segments,r.paint,g,w.programConfiguration,w.dynamicBuffers),I!==1&&(w.uniformValues.u_opacity_multiplier=1)};Do(a,o,m,(w,E,I)=>x(w,I,1),(w,E,I)=>x(w,I,m))},drawLineFrcCoverageDetect:function(a,r,o,u,f,m,g,x,w,E){const I=r.hdExt&&r.hdExt.frcData;if(!I||I.frcPerLevel.size===0||!a.frcCoverageSnapshot||u)return null;const R=a.frcCoverageSnapshot.getTileOrParent(o.canonical);if(!R||R.frcMask===0)return null;const P=Ko(R.polygons),B=a.frcCoverageFadeRange,V=B!=null&&a.transform.zoom>=B[0];if(P&&V){let U=!1;for(const G of I.frcPerLevel.keys())if(R.frcMask&1<<G){U=!0;break}U&&E.push({coord:o,bucket:r,uniformValues:f,programConfiguration:m,program:g,depthMode:x,colorMode:w,frcMask:R.frcMask})}return{coverageTile:R,frcMask:R.frcMask,active:V,hasPolygonGeometry:P}},drawLineFrcRenderLine:function(a,r,o,u){const f=a.hdExt&&a.hdExt.frcData;if(!f)return;const m=r.frcMask;for(const[x,w]of f.frcPerLevel)m&1<<x||u(o,w);const g=f.frcNonRoadSegments;g.segments.length>0&&u(o,g)},drawLineFrcFadePass:function(a,r,o,u,f,m,g){if(u.hasPolygonGeometry)return;const x=r.hdExt&&r.hdExt.frcData;if(!x||!a.frcCoverageFadeRange)return;const[w,E]=a.frcCoverageFadeRange;if(w>=E)return;const I=1-Math.max(0,Math.min(1,(a.transform.zoom-w)/(E-w)));if(I<=0)return;const R=f?m:a.stencilModeForClipping(o),P=u.frcMask;for(const[B,V]of x.frcPerLevel)P&1<<B&&g(R,V,I)},drawLineFrcCoverageSecondPass:function(a,r,o){if(o.length===0)return;const u=a.context.gl,f=xr(a),m=a.transform.zoom,g=(x,w,E,I)=>{const R=x.bucket.hdExt&&x.bucket.hdExt.frcData,P=R&&R.frcPerLevel.get(w);P&&P.segments.length!==0&&(I!==1&&(x.uniformValues.u_opacity_multiplier=I),x.program.draw(a,u.TRIANGLES,x.depthMode,E,x.colorMode,d.$.disabled,x.uniformValues,r.id,x.bucket.layoutVertexBuffer,x.bucket.indexBuffer,P,r.paint,m,x.programConfiguration,[x.bucket.layoutVertexBuffer2,x.bucket.patternVertexBuffer,x.bucket.zOffsetVertexBuffer,x.bucket.elevationIdColVertexBuffer,x.bucket.elevationGroundScaleVertexBuffer]),I!==1&&(x.uniformValues.u_opacity_multiplier=1))};Do(a,o,f,(x,w,E)=>g(x,w,E,1),(x,w,E)=>g(x,w,E,f))}},Tt=ec;async function Zn(){return Promise.resolve()}class _a{constructor(r,o,u){this.screenBounds=r,this.cameraPoint=u.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=o,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,u)}static createFromScreenPoints(r,o){let u,f;if(r instanceof d.P||typeof r[0]=="number"){const m=d.P.convert(r);u=[m],f=o.isPointAboveHorizon(m)}else{const m=d.P.convert(r[0]),g=d.P.convert(r[1]),x=m.add(g)._div(2);u=[m,g],f=d.bZ(m,g).every(w=>o.isPointAboveHorizon(w))&&o.isPointAboveHorizon(x)}return new _a(u,f,o)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(r){return d.bZ(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const o=this.screenBounds[0],u=this.screenBounds.length===1?this.screenBounds[0].add(new d.P(1,1)):this.screenBounds[1],f=d.bZ(o,u,0,!1);return this.cameraPoint.y>u.y&&(this.cameraPoint.x>o.x&&this.cameraPoint.x<u.x?f.splice(3,0,this.cameraPoint):this.cameraPoint.x>=u.x?f[2]=this.cameraPoint:this.cameraPoint.x<=o.x&&(f[3]=this.cameraPoint)),d.b_(f,r)}bufferedCameraGeometryGlobe(r){const o=this.screenBounds[0],u=this.screenBounds.length===1?this.screenBounds[0].add(new d.P(1,1)):this.screenBounds[1],f=d.bZ(o,u,r),m=this.cameraPoint.clone(),g=+(m.x>o.x)+ +(m.x>u.x);switch(3*(+(m.y>o.y)+ +(m.y>u.y))+g){case 0:f[0]=m,f[4]=m.clone();break;case 1:f.splice(1,0,m);break;case 2:f[1]=m;break;case 3:f.splice(4,0,m);break;case 5:f.splice(2,0,m);break;case 6:f[3]=m;break;case 7:f.splice(3,0,m);break;case 8:f[2]=m}return f}containsTile(r,o,u,f=0,m){const g=Math.max(r.queryPadding,r.evaluateQueryRenderedFeaturePadding())/o._pixelsPerMercatorPixel+1,x=u?this._bufferedCameraMercator(g,o):this._bufferedScreenMercator(g,o);let w=r.tileID.wrap+(x.unwrapped?f:0);const E=x.polygon.map(G=>d.b$(r.tileTransform,G,w));if(!d.c0(E,0,0,d.a2,d.a2))return;w=r.tileID.wrap+(this.screenGeometryMercator.unwrapped?f:0);const I=this.screenGeometryMercator.polygon.map(G=>d.c1(r.tileTransform,G,w)),R=I.map(G=>new d.P(G[0],G[1])),P=d.c1(r.tileTransform,m,w),B=I.map(G=>{const $=d.c2(G,G,P);return d.c3($,$),new d.c4(P,$)}),V=d.c5(r,1,o.zoom)*o._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:R,tilespaceRays:B,bufferedTilespaceGeometry:E,bufferedTilespaceBounds:(U=d.c6(E),U.min.x=d.b0(U.min.x,0,d.a2),U.min.y=d.b0(U.min.y,0,d.a2),U.max.x=d.b0(U.max.x,0,d.a2),U.max.y=d.b0(U.max.y,0,d.a2),U),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:V};var U}_bufferedScreenMercator(r,o){const u=tc(r);if(this._screenRaycastCache[u])return this._screenRaycastCache[u];{let f;return f=o.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(r),o):{polygon:this.bufferedScreenGeometry(r).map(m=>o.pointCoordinate3D(m)),unwrapped:!0},this._screenRaycastCache[u]=f,f}}_bufferedCameraMercator(r,o){const u=tc(r);if(this._cameraRaycastCache[u])return this._cameraRaycastCache[u];{let f;return f=o.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(r),o):{polygon:this.bufferedCameraGeometry(r).map(m=>o.pointCoordinate3D(m)),unwrapped:!0},this._cameraRaycastCache[u]=f,f}}_projectAndResample(r,o){const u=function(m,g){const x=d.X([],g.pixelMatrix,g.globeMatrix),w=[0,-d.c8,0,1],E=[0,d.c8,0,1],I=[0,0,0,1];d.c7(w,w,x),d.c7(E,E,x),d.c7(I,I,x);const R=new d.P(w[0]/w[3],w[1]/w[3]),P=new d.P(E[0]/E[3],E[1]/E[3]),B=d.c9(m,R)&&w[3]<I[3],V=d.c9(m,P)&&E[3]<I[3];if(!B&&!V)return null;const U=function(ue,me,Ie){for(let we=1;we<ue.length;we++){const ve=ga(me.pointCoordinate3D(ue[we-1]).x),Se=ga(me.pointCoordinate3D(ue[we]).x);if(Ie<0){if(ve<Se)return{idx:we,t:-ve/(Se-1-ve)}}else if(Se<ve)return{idx:we,t:(1-ve)/(Se+1-ve)}}return null}(m,g,B?-1:1);if(!U)return null;const{idx:G,t:$}=U;let Y=G>1?ol(m.slice(0,G),g):[],re=G<m.length?ol(m.slice(G),g):[];Y=Y.map(ue=>new d.P(ga(ue.x),ue.y)),re=re.map(ue=>new d.P(ga(ue.x),ue.y));const oe=[...Y];oe.length===0&&oe.push(re.at(-1));const pe=oe.at(-1),ce=d.al(pe.y,(re.length===0?Y[0]:re[0]).y,$);let _e;return _e=B?[new d.P(0,ce),new d.P(0,0),new d.P(1,0),new d.P(1,ce)]:[new d.P(1,ce),new d.P(1,1),new d.P(0,1),new d.P(0,ce)],oe.push(..._e),re.length===0?oe.push(Y[0]):oe.push(...re),{polygon:oe.map(ue=>new d.bS(ue.x,ue.y)),unwrapped:!1}}(r,o);if(u)return u;const f=function(m,g){let x=!1,w=-1/0,E=0;for(let R=0;R<m.length-1;R++)m[R].x>w&&(w=m[R].x,E=R);for(let R=0;R<m.length-1;R++){const P=(E+R)%(m.length-1),B=m[P],V=m[P+1];Math.abs(B.x-V.x)>.5&&(B.x<V.x?(B.x+=1,P===0&&(m.at(-1).x+=1)):(V.x+=1,P+1===m.length-1&&(m[0].x+=1)),x=!0)}const I=d.a7(g.center.lng);return x&&I<Math.abs(I-1)&&m.forEach(R=>{R.x-=1}),{polygon:m,unwrapped:x}}(ol(r,o).map(m=>new d.P(ga(m.x),m.y)),o);return{polygon:f.polygon.map(m=>new d.bS(m.x,m.y)),unwrapped:f.unwrapped}}}function ol(a,r){return d.ca(a,o=>{const u=r.pointCoordinate3D(o);o.x=u.x,o.y=u.y},1/256)}function ga(a){return a<0?1+a%1:a%1}function tc(a){return 100*a|0}class ya extends d.E{constructor(r,o,u,f){if(super(),this.id=r,this.dispatcher=u,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,d.cb(o,["url","scheme","tileSize","promoteId"])),this._options={type:"vector",...o},this._collectResourceTiming=!!o.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(f),this._tileWorkers={},this._deduped=new d.cc}load(r){this._loaded=!1,this.fire(new d.h("dataloading",{dataType:"source"}));const o=Array.isArray(this.map._language)?this.map._language.join():this.map._language,u=this.map.getWorldview(),f=(g,x)=>{this._tileJSONRequest=null,this._loaded=!0,g?(o&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${o}`),u&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${u}`),this.fire(new d.f(g))):x&&(this._setTileJSON(x),Tt.updateCrossSourceElevationGate&&this.map.style&&Tt.updateCrossSourceElevationGate(this.map.style),d.ck(x.tiles,this.map._requestManager._customAccessToken),this.fire(new d.h("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new d.h("data",{dataType:"source",sourceDataType:"content"}))),r&&r(g)};this.provider=this._options.provider;const m=d.cd(this._options);return m instanceof Error?(this._loaded=!0,this.fire(new d.f(m)),void(r&&r())):this.provider&&!m?(this._loaded=!0,this.fire(new d.f(new Error(`TileProvider "${this.provider}" is not registered`))),void(r&&r())):void(this._tileJSONRequest=m?this.loadTileJSONWithProvider(m,f):d.ce(this._options,this.map._requestManager,o,u,f))}loadTileJSONWithProvider(r,o){this.provider=r.name;const u=new AbortController;return(async()=>{const{request:f,options:m}=await d.cl(this._options,this.map._requestManager,u.signal);if(u.signal.aborted)return;const g=await this.dispatcher.send("loadTileProvider",{name:r.name,url:r.url,source:this.id,scope:this.scope,type:this.type,options:m,request:f},{signal:u.signal});if(u.signal.aborted)return;const x=g?g.find(E=>E!=null):null,w=d.cm(this._options,x,this.map._requestManager);w instanceof Error?o(w):o(null,w)})().catch(f=>{u.signal.aborted||o(f)}),{cancel:()=>u.abort()}}_setTileJSON(r){if(Object.assign(this,r),this.hasWorldviews=!!r.worldview_options,r.worldview_default&&(this.worldviewDefault=r.worldview_default),r.vector_layers){this.vectorLayers=r.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const o of r.vector_layers)this.vectorLayerIds.push(o.id),r.worldview&&r.worldview[o.source]&&this.localizableLayerIds.add(o.id)}this.tileBounds=d.cf.fromTileJSON(r)}loaded(){return this._loaded}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}onAdd(r){this.map=r,this.load()}reload(){this.cancelTileJSONRequest();const r=d.m(this.id,this.scope);this.load(()=>this.map.style.clearSource(r))}setTiles(r){return this._options.tiles=r,this.reload(),this}setUrl(r){return this.url=r,this._options.url=r,this.reload(),this}onRemove(r){this.cancelTileJSONRequest()}serialize(){return{...this._options}}async loadTile(r,o){const u=r.tileID.canonical.url(this.tiles,this.scheme),f=this.map._requestManager.normalizeTileURL(u),m=!r.actor||r.state==="expired";if(!m&&r.state==="loading")return void(r.reloadCallback=o);m&&(r.actor=this._tileWorkers[f]=this._tileWorkers[f]||this.dispatcher.getActor());const g=new AbortController;r.request=g;try{const x=await this.map._requestManager.transformRequest(f,d.R.Tile,g.signal);if(g.signal.aborted)return o(null);this.dispatchTile(r,f,u,x,g,m,o)}catch(x){if(g.signal.aborted)return o(null);o(x)}}dispatchTile(r,o,u,f,m,g,x){const w=this.map.style?this.map.style.getLut(this.scope):null,E=w?{image:w.image.clone()}:null,I=!(!this.map.style||!this.map.style._crossSourceElevationActive),R=!(!this.map.style||!I),P={request:f,data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,maxZoom:this.maxzoom,lut:E,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:d.e.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:r.renderSourceType,frcCoverage:(()=>{const V=this.map.painter,U=V?V.frcCoverageFadeRange:null;if(U==null)return null;const G=V?V.frcCoverageSnapshot:null,$=this.map.transform.zoom<U[0],Y=G?G.getTileOrParent(r.tileID.canonical):null,re=r.tileID.overscaledZ>=Math.ceil(U[1]),oe=G&&re?G.getFullCoverageMask(r.tileID.canonical):null;return{frcMask:re?oe??null:null,resolved:$||G!=null,polygons:Y&&Y.frcMask!==0?Y.polygons:null,tileZoom:Y&&Y.frcMask!==0?Y.tileId.z:null,sourceLayers:V?V.frcCoverageSourceLayers:["road","structure"]}})(),terrainEnabled:le(this.map.style,this.map.transform),crossSourceElevationEnabled:R,elevation:Tt.buildElevationRequestParams?Tt.buildElevationRequestParams(this.map,r,I):null,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:r.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&&d.cg(u)&&(P.localizableLayerIds=this.localizableLayerIds),P.request.collectResourceTiming=this._collectResourceTiming,g)if(this.dispatcher.ready||this.provider)r.request=r.actor.sendCancelable("loadTile",P,{},B.bind(this));else{const V=d.ch.call({deduped:this._deduped},P,(U,G)=>{r.aborted||(U||!G?B.call(this,U):(P.data={rawData:G.rawData.slice(0),headers:G.headers},r.actor&&(r.request=r.actor.sendCancelable("loadTile",P,{},B.bind(this)))))},!0);m.signal.addEventListener("abort",V,{once:!0})}else r.request=r.actor.sendCancelable("reloadTile",P,{},B.bind(this));function B(V,U){return delete r.request,r.aborted?x(null):V?x(V):(U&&U.resourceTiming&&(r.resourceTiming=U.resourceTiming),this.map._refreshExpiredTiles&&U&&r.setExpiryData(d.ci(U.headers)),void(function(){if(r.aborted)return x(null);r.loadVectorData(U,this.map.painter),d.cj(this.dispatcher),x(null,U),r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)}).call(this))}}abortTile(r){r.request&&(r.request.abort(),delete r.request),r.actor&&r.actor.notify("abortTile",{uid:r.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(r,o){r.actor&&r.actor.notify("removeTile",{uid:r.uid,type:this.type,source:this.id,scope:this.scope}),r.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class jc extends d.E{constructor(r,o,u,f){super(),this.id=r,this.dispatcher=u,this.setEventedParent(f),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options={type:"raster",...o},Object.assign(this,d.cb(o,["url","scheme","tileSize"]))}load(r){this._loaded=!1,this.fire(new d.h("dataloading",{dataType:"source"}));const o=this.map.getWorldview(),u=(m,g)=>{this._tileJSONRequest=null,this._loaded=!0,m?this.fire(new d.f(m)):g&&(Object.assign(this,g),g.raster_layers&&(this.rasterLayers=g.raster_layers,this.rasterLayerIds=this.rasterLayers.map(x=>x.id)),this.tileBounds=d.cf.fromTileJSON(g),d.ck(g.tiles),this.fire(new d.h("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new d.h("data",{dataType:"source",sourceDataType:"content"}))),r&&r(m)};this.provider=typeof this._options.provider=="string"?this._options.provider:void 0,this._tileProvider=void 0;const f=d.cd(this._options);return f instanceof Error?(this._loaded=!0,this.fire(new d.f(f)),void(r&&r())):this.provider&&!f?(this._loaded=!0,this.fire(new d.f(new Error(`TileProvider "${this.provider}" is not registered`))),void(r&&r())):void(this._tileJSONRequest=f?this.loadTileJSONWithProvider(f,u):d.ce(this._options,this.map._requestManager,null,o,u))}loadTileJSONWithProvider(r,o){this.provider=r.name;const u=new AbortController;return(async()=>{const{request:f,options:m}=await d.cl(this._options,this.map._requestManager,u.signal);if(u.signal.aborted)return;const g=await d.cn(r.name,r.url);if(u.signal.aborted)return;const x=new g(m);let w=null;if(x.load&&f&&(w=await x.load({request:f}),u.signal.aborted))return;this._tileProvider=x;const E=d.cm(this._options,w,this.map._requestManager);E instanceof Error?o(E):o(null,E)})().catch(f=>{u.signal.aborted||o(new Error(`Could not load tile provider ${r.name}`,{cause:f}))}),{cancel:()=>u.abort()}}loaded(){return this._loaded}onAdd(r){this.map=r,this.load()}reload(){this.cancelTileJSONRequest();const r=d.m(this.id,this.scope);this.load(()=>this.map.style.clearSource(r))}setTiles(r){return this._options.tiles=r,this.reload(),this}setUrl(r){return this.url=r,this._options.url=r,this.reload(),this}onRemove(r){this.cancelTileJSONRequest()}serialize(){return{...this._options}}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}async loadTile(r,o){const u=d.e.devicePixelRatio>=2,f=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),u,this.tileSize),m=new AbortController;if(r.request=m,this._tileProvider)this.loadTileWithProvider(r,this._tileProvider,f,m,o);else try{const g=await this.map._requestManager.transformRequest(f,d.R.Tile,m.signal);if(m.signal.aborted)return delete r.request,o(null);const{data:x,headers:w}=await d.a(g,m.signal);if(delete r.request,r.aborted)return o(null);const E=d.ci(w);this.map._refreshExpiredTiles&&r.setExpiryData(E),r.setTexture(x,this.map.painter),r.state="loaded",d.cj(this.dispatcher),o(null)}catch(g){if(delete r.request,m.signal.aborted)return o(null);r.state="errored",o(g)}}async loadTileWithProvider(r,o,u,f,m){const{z:g,x,y:w}=r.tileID.canonical;try{const E=await this.map._requestManager.transformRequest(u,d.R.Tile,f.signal);if(f.signal.aborted)return m(null);const I=await o.loadTile({z:g,x,y:w},{request:E,signal:f.signal});if(f.signal.aborted)return m(null);if(I==null){const P=new Error("Tile not found");return P.status=404,r.state="errored",m(P)}if(I.data==null)return r.state="loaded",m(null);const R=I.data instanceof ImageBitmap?I.data:await createImageBitmap(new Blob([I.data]));if(f.signal.aborted)return m(null);r.setTexture(R,this.map.painter),r.state="loaded",this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:I.cacheControl,expires:I.expires}),m(null)}catch(E){if(f.signal.aborted)return m(null);r.state="errored",m(new Error(`Could not load tile from ${u}`,{cause:E}))}finally{delete r.request}}abortTile(r,o){r.request&&(r.request.abort(),delete r.request),o&&o()}unloadTile(r,o){r.texture&&r.texture instanceof d.T?(r.destroy(!1),r.texture&&r.texture instanceof d.T&&this.map.painter.saveTileTexture(r.texture)):r.destroy(),o&&o()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function qu(a,r,o,u,f,m,g,x){const w=[a,r,1,o,u,1,f,m,1],E=[g,x,1],I=d.cu([],w),[R,P,B]=d.ct(E,E,I);return d.cv(w,w,[R,0,0,0,P,0,0,0,B])}function Rs(a,r,o,u,f,m,g,x){const w=function(E,I,R,P,B,V,U,G){const $=qu(0,0,1,0,1,1,0,1),Y=qu(E,I,R,P,B,V,U,G),re=d.cu([],$);return d.cv(Y,Y,re)}(a,r,o,u,f,m,g,x);return[w[2]/w[8]/d.a2,w[5]/w[8]/d.a2]}function Wu(a){return[a[0],Math.min(Math.max(a[1],-d.cp),d.cp)]}class ho extends d.E{constructor(r,o,u,f){super(),this.id=r,this.dispatcher=u,this.coordinates=o.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(f),this.options=o,this._dirty=!1}async load(r,o){if(this._loaded=o||!1,this.fire(new d.h("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return r&&(this.coordinates=r),this._loaded=!0,void this._finishLoading();const u=new AbortController;this._imageRequest=u;try{const f=await this.map._requestManager.transformRequest(this.url,d.R.Image,u.signal),{data:m}=await d.a(f,u.signal);this._imageRequest=null,this._loaded=!0,this.image=m,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),this._finishLoading()}catch(f){if(u.signal.aborted)return;this._imageRequest=null,this._loaded=!0,this.fire(new d.f(f))}}loaded(){return this._loaded}updateImage(r){return r.url?(this._imageRequest&&r.url!==this.options.url&&(this._imageRequest.abort(),this._imageRequest=null),this.options.url=r.url,this.load(r.coordinates,this._loaded),this):this}setTexture(r){if(!(r.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new d.co(this.map.painter.context,r.handle),this.width=r.dimensions[0],this.height=r.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new d.h("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(r){this.map=r,this.load()}onRemove(r){this._imageRequest&&(this._imageRequest.abort(),this._imageRequest=null),!this.texture||this.texture instanceof d.co||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(r){if(this.coordinates=r,this._boundsArray=void 0,this._unsupportedCoords=!1,!r.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let o=r[0][1],u=r[0][1];for(const m of r)m[1]>u&&(u=m[1]),m[1]<o&&(o=m[1]);const f=(u+o)/2;if(f>d.cp?this.onNorthPole=!0:f<-d.cp&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const m=r.map(d.bS.fromLngLat);this.tileID=function(g){let x=1/0,w=1/0,E=-1/0,I=-1/0;for(const U of g)x=Math.min(x,U.x),w=Math.min(w,U.y),E=Math.max(E,U.x),I=Math.max(I,U.y);const R=Math.max(E-x,I-w),P=Math.max(0,Math.floor(-Math.log2(R))),B=Math.pow(2,P);let V=Math.floor((x+E)/2*B);return V>1&&(V-=1),new d.bX(P,V,Math.floor((w+I)/2*B))}(m),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new d.h("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof d.co||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(r){for(const pe in this.tiles){const ce=this.tiles[pe];ce.state!=="loaded"&&(ce.state="loaded",ce.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const o=d.bp(new d.bX(0,0,0),this.map.transform.projection),u=[o.projection.project(this.coordinates[0][0],this.coordinates[0][1]),o.projection.project(this.coordinates[1][0],this.coordinates[1][1]),o.projection.project(this.coordinates[2][0],this.coordinates[2][1]),o.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(pe){const ce=pe[1].x-pe[0].x,_e=pe[1].y-pe[0].y,ue=pe[2].x-pe[1].x,me=pe[2].y-pe[1].y,Ie=pe[3].x-pe[2].x,we=pe[3].y-pe[2].y,ve=pe[0].x-pe[3].x,Se=pe[0].y-pe[3].y,Re=ce*me-ue*_e,Ue=ue*we-Ie*me,Pe=Ie*Se-ve*we,Oe=ve*_e-ce*Se;return Re>0&&Ue>0&&Pe>0&&Oe>0||Re<0&&Ue<0&&Pe<0&&Oe<0}(u))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const f=d.bp(this.tileID,this.map.transform.projection),[m,g,x,w]=this.coordinates.map(pe=>{const ce=f.projection.project(pe[0],pe[1]);return d.b$(f,ce)._round()});this.perspectiveTransform=Rs(m.x,m.y,g.x,g.y,x.x,x.y,w.x,w.y);const E=this._boundsArray=new d.bs;E.emplaceBack(m.x,m.y,0,0),E.emplaceBack(g.x,g.y,d.a2,0),E.emplaceBack(w.x,w.y,0,d.a2),E.emplaceBack(x.x,x.y,d.a2,d.a2),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=r.createVertexBuffer(E,Cs.members),this.boundsSegments=d.ac.simpleSegment(0,0,4,2);const I=d.cs,R=I+1,P=I+1,B=R*P,V=I*I*2,U=[],G=function(pe){return[Wu(pe[0]),Wu(pe[1]),Wu(pe[2]),Wu(pe[3])]}(this.coordinates),[$,Y,re,oe]=function(pe){let ce=pe[0][0],_e=ce,ue=pe[0][1],me=ue;for(let Ie=1;Ie<pe.length;Ie++)pe[Ie][0]<ce?ce=pe[Ie][0]:pe[Ie][0]>_e&&(_e=pe[Ie][0]),pe[Ie][1]<ue?ue=pe[Ie][1]:pe[Ie][1]>me&&(me=pe[Ie][1]);return[ce,ue,_e-ce,me-ue]}(G);{const pe=new d.bs,[ce,_e,ue,me]=function(Ye){let mt=Ye[0].x,We=mt,je=Ye[0].y,Je=je;for(let ft=1;ft<Ye.length;ft++)Ye[ft].x<mt?mt=Ye[ft].x:Ye[ft].x>We&&(We=Ye[ft].x),Ye[ft].y<je?je=Ye[ft].y:Ye[ft].y>Je&&(Je=Ye[ft].y);return[mt,je,We-mt,Je-je]}(u),Ie=Ye=>[(Ye.x-ce)/ue,(Ye.y-_e)/me],[we,ve,Se,Re]=u.map(Ie),Ue=function(Ye,mt,We,je,Je,ft,rt,ct){const xt=qu(0,0,1,0,1,1,0,1),Rt=qu(Ye,mt,We,je,Je,ft,rt,ct),Mt=d.cu([],Rt);return d.cv(xt,xt,Mt)}(we[0],we[1],ve[0],ve[1],Se[0],Se[1],Re[0],Re[1]);this.elevatedGlobePerspectiveTransform=Rs(we[0],we[1],ve[0],ve[1],Se[0],Se[1],Re[0],Re[1]);const Pe=(Ye,mt)=>{U.push(Ye.lng);const We=Math.round((Ye.lng-$)/re*d.a2),je=Math.round((Ye.lat-Y)/oe*d.a2),Je=Ie(mt),ft=d.ct([],[Je[0],Je[1],1],Ue),rt=Math.round(ft[0]/ft[2]*d.a2),ct=Math.round(ft[1]/ft[2]*d.a2);pe.emplaceBack(We,je,rt,ct)},Oe=u[3].x-u[0].x,Xe=u[3].y-u[0].y,ot=u[2].x-u[1].x,tt=u[2].y-u[1].y;for(let Ye=0;Ye<P;Ye++){const mt=Ye/I,We=[u[0].x+mt*Oe,u[0].y+mt*Xe],je=[u[1].x+mt*ot,u[1].y+mt*tt],Je=je[0]-We[0],ft=je[1]-We[1];for(let rt=0;rt<R;rt++){const ct=rt/I,xt={x:We[0]+Je*ct,y:We[1]+ft*ct};Pe(o.projection.unproject(xt.x,xt.y),xt)}}this.elevatedGlobeVertexBuffer=r.createVertexBuffer(pe,Cs.members)}{this.maxLongitudeTriangleSize=0;let pe=[],ce=new d.ad;const _e=(ue,me,Ie)=>{ce.emplaceBack(ue,me,Ie);const we=U[ue],ve=U[me],Se=U[Ie],Re=Math.min(Math.min(we,ve),Se),Ue=Math.max(Math.max(we,ve),Se)-Re;Ue>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Ue),pe.push(Re+Ue/2)};for(let ue=0;ue<I;ue++)for(let me=0;me<I;me++){const Ie=ue*R+me,we=Ie+1,ve=Ie+R,Se=ve+1;_e(Ie,ve,we),_e(we,ve,Se)}[pe,ce]=function(ue,me){const Ie=Array.from({length:ue.length},(Se,Re)=>Re);Ie.sort((Se,Re)=>ue[Se]-ue[Re]);const we=[],ve=new d.ad;for(let Se=0;Se<Ie.length;Se++){const Re=Ie[Se];we.push(ue[Re]);const Ue=3*Re,Pe=Ue+1;ve.emplaceBack(me.uint16[Ue],me.uint16[Pe],me.uint16[Pe+1])}return[we,ve]}(pe,ce),this.elevatedGlobeTrianglesCenterLongitudes=pe,this.elevatedGlobeIndexBuffer=r.createIndexBuffer(ce)}this.elevatedGlobeSegments=d.ac.simpleSegment(0,0,B,V),this.elevatedGlobeGridMatrix=new Float32Array([0,re/d.a2,0,oe/d.a2,0,0,Y,$,0])}prepare(){const r=Object.keys(this.tiles).length!==0;if(this.tileID&&!r)return;const o=this.map.painter.context,u=o.gl;!this._dirty||this.texture instanceof d.co||(this.texture?this.texture.update(this.image):(this.texture=new d.T(o,this.image,u.RGBA8),this.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE)),this._dirty=!1),r&&this._prepareData(o)}loadTile(r,o){this.tileID&&this.tileID.equals(r.tileID.canonical)?(this.tiles[String(r.tileID.wrap)]=r,r.buckets={},o(null)):(r.state="errored",o(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(r){const o=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!o)return null;const u=this.elevatedGlobeTrianglesCenterLongitudes;let f=(m=r+180)+360*Math.round((u[0]-m)/360);var m;const g=new d.ac,x=(R,P)=>{g.segments.push({vertexOffset:0,primitiveOffset:R,vertexLength:o.segments[0].vertexLength,primitiveLength:P,sortKey:void 0,vaos:{}})},w=.51*this.maxLongitudeTriangleSize;if(Math.abs(u[0]-f)<=w){const R=d.cq(u,0,u.length,f+w);return R===u.length||x(R,d.cr(u,R+1,u.length,f+360-w)-R),g}f<u[0]&&(f+=360);const E=d.cr(u,0,u.length,f-w);if(E===u.length)return x(0,u.length),g;x(0,E-0);const I=d.cq(u,E+1,u.length,f+w);return I!==u.length&&x(I,u.length-I),g}}const En={vector:ya,raster:jc,"raster-dem":class extends jc{constructor(a,r,o,u){super(a,r,o,u),this.type="raster-dem",this.maxzoom=22,this._options={type:"raster-dem",...r},this.encoding=r.encoding||"mapbox"}loadTileJSONWithProvider(a,r){this.provider=a.name;const o=new AbortController;return(async()=>{const{request:u,options:f}=await d.cl(this._options,this.map._requestManager,o.signal);if(o.signal.aborted)return;const m=await this.dispatcher.send("loadTileProvider",{name:a.name,url:a.url,source:this.id,scope:this.scope,type:this.type,options:f,request:u},{signal:o.signal});if(o.signal.aborted)return;const g=m?m.find(w=>w!=null):null,x=d.cm(this._options,g,this.map._requestManager);x instanceof Error?r(x):r(null,x)})().catch(u=>{o.signal.aborted||r(u)}),{cancel:()=>o.abort()}}async loadTile(a,r){if(a.actor&&a.state!=="expired")return;const o=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);a.actor=this.dispatcher.getActor();const u=new AbortController;a.request=u;try{const f=await this.map._requestManager.transformRequest(o,d.R.Tile,u.signal);if(u.signal.aborted)return r(null);a.request=a.actor.sendCancelable("loadTile",{uid:a.uid,tileID:a.tileID,source:this.id,type:this.type,scope:this.scope,request:f,encoding:this.encoding},{},(function(m,g){return delete a.request,a.aborted?r(null):m?(a.state="errored",r(m)):(g&&(this.map._refreshExpiredTiles&&a.setExpiryData(d.ci(g.headers)),g.borderReady||a.neighboringTiles||(a.neighboringTiles=this._getNeighboringTiles(a.tileID)),a.dem=g.dem,a.dem.onDeserialize(),a.needsHillshadePrepare=!0,a.needsDEMTextureUpload=!0),a.state="loaded",void r(null))}).bind(this))}catch(f){if(u.signal.aborted)return r(null);a.state="errored",r(f)}}abortTile(a,r){a.request&&(a.request.abort(),delete a.request),a.actor&&a.actor.notify("abortTile",{uid:a.uid,type:this.type,source:this.id,scope:this.scope}),r&&r()}_getNeighboringTiles(a){const r=a.canonical,o=Math.pow(2,r.z),u=(r.x-1+o)%o,f=r.x===0?a.wrap-1:a.wrap,m=(r.x+1+o)%o,g=r.x+1===o?a.wrap+1:a.wrap,x={};return x[new d.bP(a.overscaledZ,f,r.z,u,r.y).key]={backfilled:!1},x[new d.bP(a.overscaledZ,g,r.z,m,r.y).key]={backfilled:!1},r.y>0&&(x[new d.bP(a.overscaledZ,f,r.z,u,r.y-1).key]={backfilled:!1},x[new d.bP(a.overscaledZ,a.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},x[new d.bP(a.overscaledZ,g,r.z,m,r.y-1).key]={backfilled:!1}),r.y+1<o&&(x[new d.bP(a.overscaledZ,f,r.z,u,r.y+1).key]={backfilled:!1},x[new d.bP(a.overscaledZ,a.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},x[new d.bP(a.overscaledZ,g,r.z,m,r.y+1).key]={backfilled:!1}),x}},geojson:class extends d.E{constructor(a,r,o,u){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(u),this._data=r.data,this._options={...r},this._collectResourceTiming=r.collectResourceTiming,r.maxzoom!==void 0&&(this.maxzoom=r.maxzoom),r.minzoom!==void 0&&(this.minzoom=r.minzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;const f=d.a2/this.tileSize;this.workerOptions={source:this.id,scope:this.scope,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(r.buffer!==void 0?r.buffer:128)*f,tolerance:(r.tolerance!==void 0?r.tolerance:.375)*f,extent:d.a2,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:r.clusterMaxZoom!==void 0?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:d.a2,radius:(r.clusterRadius!==void 0?r.clusterRadius:50)*f,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter,dynamic:r.dynamic,...r.workerOptions}}onAdd(a){this.map=a,this.setData(this._data)}setData(a){return this._data=a,this._updateWorkerData(),this}updateData(a){if(!this._options.dynamic)return this.fire(new d.f(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 d.f(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"){const r=new Map;for(const o of this._data.features)r.set(o.id,o);for(const o of a.features)r.set(o.id,o);this._data.features=[...r.values()]}else this._data=a;return this._updateWorkerData(!0),this}getClusterExpansionZoom(a,r){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:a,source:this.id,scope:this.scope}).then(o=>r(null,o)).catch(o=>r(o)),this}getClusterChildren(a,r){return this.actor.send("geojson.getClusterChildren",{clusterId:a,source:this.id,scope:this.scope}).then(o=>r(null,o)).catch(o=>r(o)),this}getClusterLeaves(a,r,o,u){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:a,limit:r,offset:o}).then(f=>u(null,f)).catch(f=>u(f)),this}async _updateWorkerData(a=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new d.h("dataloading",{dataType:"source"})),this._loaded=!1;const r={append:a,...this.workerOptions};r.scope=this.scope;const o=this._data,u=new AbortController;this._pendingLoad=u;try{if(typeof o=="string"){if(r.request=await this.map._requestManager.transformRequest(d.e.resolveURL(o),d.R.Source,u.signal),u.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);r.request.collectResourceTiming=this._collectResourceTiming}else r.data=JSON.stringify(o);const f=await this.actor.send(`${this.type}.loadData`,r,{signal:u.signal});this._loaded=!0,this._pendingLoad=null;const m={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&f&&f.resourceTiming&&f.resourceTiming[this.id]&&(m.resourceTiming=f.resourceTiming[this.id]),a&&(this._partialReload=!0),this.fire(new d.h("data",m)),this._partialReload=!1,this._metadataFired=!0}catch(f){if(u.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);this._loaded=!0,this._pendingLoad=null,this.fire(new d.f(f))}this._coalesce&&(this._updateWorkerData(a),this._coalesce=!1)}loaded(){return this._loaded}reload(){const a=d.m(this.id,this.scope);this.map.style.clearSource(a),this._updateWorkerData()}loadTile(a,r){const o=a.actor?"reloadTile":"loadTile";a.actor=this.actor;const u=this.map.style?this.map.style.getLut(this.scope):null,f=u?{image:u.image.clone()}:null,m=this._partialReload,g={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:f,scope:this.scope,pixelRatio:d.e.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.sendCancelable(o,g,{},(x,w)=>m&&!w?(a.state="loaded",r(null)):(delete a.request,a.destroy(!1),a.aborted?r(null):x?r(x):(a.loadVectorData(w,this.map.painter,o==="reloadTile"),void r(null))))}abortTile(a){a.request&&(a.request.abort(),delete a.request),a.aborted=!0}unloadTile(a,r){this.actor.notify("removeTile",{uid:a.uid,type:this.type,source:this.id,scope:this.scope}),a.destroy()}onRemove(a){this._pendingLoad&&this._pendingLoad.abort()}serialize(){return{...this._options,type:this.type,data:this._data}}hasTransition(){return!1}},video:class extends ho{constructor(a,r,o,u){super(a,r,o,u),this.roundZoom=!0,this.type="video",this.options=r}async load(){this._loaded=!1;const a=this.options,r=new AbortController;this._imageRequest=r;try{const o=await Promise.all(a.urls.map(async f=>(await this.map._requestManager.transformRequest(f,d.R.Source,r.signal)).url));if(r.signal.aborted)return;this.urls=o;const u=await d.cw(o);if(r.signal.aborted)return;this._imageRequest=null,this.video=u,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(o){if(r.signal.aborted)return;this.fire(new d.f(o))}finally{this._loaded=!0}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(a){if(this.video){const r=this.video.seekable;a<r.start(0)||a>r.end(0)?this.fire(new d.f(new it(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=a}}getVideo(){return this.video}onAdd(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;const a=this.map.painter.context,r=a.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new d.T(a,this.video,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(a)}serialize(){return{type:"video",urls:this.options.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ho,canvas:class extends ho{constructor(a,r,o,u){super(a,r,o,u),r.coordinates?Array.isArray(r.coordinates)&&r.coordinates.length===4&&!r.coordinates.some(f=>!Array.isArray(f)||f.length!==2||f.some(m=>typeof m!="number"))||this.fire(new d.f(new it(`sources.${a}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new d.f(new it(`sources.${a}`,null,'missing required property "coordinates"'))),r.animate&&typeof r.animate!="boolean"&&this.fire(new d.f(new it(`sources.${a}`,null,'optional "animate" property must be a boolean value'))),r.canvas?typeof r.canvas=="string"||r.canvas instanceof HTMLCanvasElement||this.fire(new d.f(new it(`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 d.f(new it(`sources.${a}`,null,'missing required property "canvas"'))),this.options=r,this.animate=r.animate===void 0||r.animate}async 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 d.f(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;const r=this.map.painter.context;this.texture?!a&&!this._playing||this.texture instanceof d.co||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new d.T(r,this.canvas,r.gl.RGBA8,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const a of[this.canvas.width,this.canvas.height])if(isNaN(a)||a<=0)return!0;return!1}},custom:class extends d.E{constructor(a,r,o,u){super(),this.id=a,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=r,this.setEventedParent(u),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new d.f(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new d.f(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new d.cf(this._implementation.bounds,this.minzoom,this.maxzoom));const f=r;f.update=this._update.bind(this),f.clearTiles=this._clearTiles.bind(this),f.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,d.cb(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return d.cb(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new d.h("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new d.h("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(a){this.map=a,this._loaded=!1,this.fire(new d.h("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){const{x:r,y:o,z:u}=a.canonical;return this._implementation.hasTile({x:r,y:o,z:u})}return!this.tileBounds||this.tileBounds.contains(a.canonical)}async loadTile(a,r){const{x:o,y:u,z:f}=a.tileID.canonical,m=new AbortController;a.request=m;try{const g=await this._implementation.loadTile({x:o,y:u,z:f},{signal:m.signal});if(delete a.request,a.aborted)return a.state="unloaded",r(null);if(g===void 0)return a.state="errored",r(null);if(g===null)return this.loadTileData(a,{width:this.tileSize,height:this.tileSize,data:null}),a.state="loaded",r(null);if(!function(x){return x instanceof ImageData||x instanceof HTMLCanvasElement||x instanceof ImageBitmap||x instanceof HTMLImageElement}(g))return a.state="errored",r(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`));this.loadTileData(a,g),a.state="loaded",r(null)}catch(g){if(m.signal.aborted)return;a.state="errored",r(g)}}loadTileData(a,r){a.setTexture(r,this.map.painter)}unloadTile(a,r){if(a.texture&&a.texture instanceof d.T?(a.destroy(!1),a.texture&&a.texture instanceof d.T&&this.map.painter.saveTileTexture(a.texture)):a.destroy(),this._implementation.unloadTile){const{x:o,y:u,z:f}=a.tileID.canonical;this._implementation.unloadTile({x:o,y:u,z:f})}r&&r()}abortTile(a,r){a.request&&(a.request.abort(),delete a.request),r&&r()}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(){const a=d.m(this.id,this.scope);this.map.style.clearSource(a)}_update(){this.fire(new d.h("data",{dataType:"source",sourceDataType:"content"}))}}},Xu=function(a,r,o,u){const f=xa(r.type);if(!f)throw new Error(`Unknown source type "${r.type}"`);const m=new f(a,r,o,u);if(m.id!==a)throw new Error(`Expected Source id to be ${a} instead of ${m.id}`);return d.aV(["load","abort","unload","serialize","prepare"],m),m},xa=function(a){return Object.hasOwn(En,a)?En[a]:void 0};function fo([a,r],o,u,{scaled:f=!0}={}){const{tileSize:m,buffer:g}=u,{x,y:w,z:E}=o;if(!isFinite(x)||!isFinite(w)||!isFinite(E))throw new Error("Invalid MRT header");const I=2**E,R=I*d.a7(a),P=I*d.a8(r);return function([B,V],U,{scaled:G=!0}={}){if(!U)throw new Error("bandView is undefined");const{data:$,tileSize:Y,buffer:re,offset:oe,scale:pe,dimension:ce}=U;if(B<-re||B>Y+re||V<-re||V>Y+re)throw new Error(`Point (${B}, ${V}) out of bounds for tileSize=${Y}, buffer=${re}`);const _e=(V+re)*(Y+2*re)+(B+re);if(new Uint32Array($.buffer)[_e]===4294967295)return null;let ue=[];ue=G?[]:new U.data.constructor(ce);for(let me=0;me<ce;me++)ue[me]=Math.round(1e12*($[ce*_e+me]*pe+oe))/1e12;return ue}([Math.min(Math.max(-g,Math.floor((R-x)*m)),m-1+g),Math.min(Math.max(-g,Math.floor((P-w)*m)),m-1+g)],u,{scaled:f})}d.cA.setPbf(d.cB);class $n extends Ms{constructor(r,o,u,f,m){super(r,o,u,f,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(r){return this._mrt&&this._mrt.getLayer(r)}setTexturePerLayer(r,o,u){const f=u.context,m=f.gl;let g=this.texturePerLayer.get(r)||u.getTileTexture(o.width);g&&g instanceof d.T?g.update(o,{premultiply:!1}):g=new d.T(f,o,m.RGBA8,{premultiply:!1}),this.texturePerLayer.has(r)||this.texturePerLayer.set(r,g)}flushQueues(r){const o=this._workQueuePerLayer.get(r)||[],u=this._fetchQueuePerLayer.get(r)||[];for(;o.length;)o.pop()();for(;u.length;)u.pop()()}flushAllQueues(){for(const r of this._workQueuePerLayer.keys()){const o=this._workQueuePerLayer.get(r)||[];for(;o.length;)o.pop()()}for(const r of this._fetchQueuePerLayer.keys()){const o=this._fetchQueuePerLayer.get(r)||[];for(;o.length;)o.pop()()}}fetchHeader(r=16384,o){const u=this._mrt=new d.cA(30),f={...this.requestParams,headers:{Range:"bytes=0-"+(r-1)}};this.entireBuffer=null;const m=new AbortController;return this.request=m,d.cC(f,m.signal).then(({data:g,headers:x})=>{try{const w=u.getHeaderLength(g);if(w>r)return void(this.request=this.fetchHeader(w,o));u.parseHeader(g),this._isHeaderLoaded=!0;let E=0;for(const I of Object.values(u.layers))E=Math.max(E,I.dataIndex.at(-1).lastByte);g.byteLength>=E&&(this.entireBuffer=g),o(null,this.entireBuffer||g,x)}catch(w){o(w)}}).catch(g=>{m.signal.aborted||o(g)}),this.request}fetchBandForRender(r,o,u,f){this.fetchBand(r,o,u,m=>{if(m)return void f(m);this.updateTextureDescriptor(r,o,u);const g=this.textureDescriptorPerLayer.get(o);f(null,g?g.img:null)})}fetchBand(r,o,u,f){const m=this._mrt;if(!this._isHeaderLoaded||!m)return void f(new Error("Tile header is not ready"));const g=this.actor;if(!g)return void f(new Error("Can't fetch tile band without an actor"));let x;const w=d.m(String(u),d.m(this.tileID.key,r));let E=this._taskQueue.get(w);E?E.add(f):(E=new Set,E.add(f),this._taskQueue.set(w,E));const I=(V,U)=>{x.complete(V,U),V?f(V):(E.forEach(G=>G(null,U)),this._taskQueue.delete(w))},R=(V,U)=>{if(V)return f(V);let G,$=!1;if(o!==null){const re=this._workQueuePerLayer.get(o)||[];re.push(()=>{$=!0,G&&G.abort(),x.cancel()}),this._workQueuePerLayer.has(o)||this._workQueuePerLayer.set(o,re)}const Y=()=>{$||(G=g.sendCancelable("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:U,task:x},{},I))};this.workerReady!==void 0?this.workerReady.then(Y).catch(re=>f(re)):Y()};let P;try{P=m.getLayer(r)}catch(V){if(this.state==="reloading")return;throw V}if(!P)return void f(new Error(`Unknown sourceLayer "${r}"`));if(P.hasDataForBand(u))return E.forEach(V=>V(null,null)),void this._taskQueue.delete(w);const B=P.getDataRange([u]);if(x=m.createDecodingTask(B),!x||x.tasks.length)if(o!==null&&this.flushQueues(o),this.entireBuffer)R(null,this.entireBuffer.slice(B.firstByte,B.lastByte+1));else{const V={...this.requestParams,headers:{Range:`bytes=${B.firstByte}-${B.lastByte}`}},U=new AbortController;if(d.cC(V,U.signal).then(({data:G})=>R(null,G)).catch(G=>{U.signal.aborted||R(G)}),o!==null){const G=this._fetchQueuePerLayer.get(o)||[];G.push(()=>{U.abort(),x.cancel()}),this._fetchQueuePerLayer.has(o)||this._fetchQueuePerLayer.set(o,G)}}}updateNeeded(r,o){return(!this.textureDescriptorPerLayer.get(r)||this.textureDescriptorPerLayer.get(r).band!==o||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(r,o,u){if(!this._mrt)return;const f=this._mrt.getLayer(r);if(!f||!f.hasBand(u)||!f.hasDataForBand(u))return;const{bytes:m,tileSize:g,buffer:x,offset:w,scale:E}=f.getBandView(u),I=g+2*x,R=new d.b({width:I,height:I},m),P=this.texturePerLayer.get(o);P&&P instanceof d.T&&P.update(R,{premultiply:!1}),this.textureDescriptorPerLayer.set(o,{layer:r,band:u,img:R,buffer:x,offset:w,tileSize:g,format:f.pixelFormat,mix:[E,256*E,65536*E,16777216*E]})}destroy(r=!1){if(super.destroy(r),delete this._mrt,!r)for(const o of this.texturePerLayer.values())o&&o instanceof d.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}}Xs=(a,r,o,u,f)=>new $n(a,r,o,u,f);const qn={RasterArrayTileSource:class extends jc{get partial(){return!this.map.style.imageManager.hasImageProviderForSource(this.id,this.scope)}constructor(a,r,o,u){super(a,r,o,u),this.type="raster-array",this.maxzoom=22,this._loadTilePending={},this._loadTileLoaded={},this._options={type:"raster-array",...r}}triggerRepaint(a){const r=this.map.painter._terrain,o=this.map.style.getSourceCache(this.id);r&&r.enabled&&o&&r._clearRenderCacheForTile(o.id,a.tileID),this.map.triggerRepaint()}async loadTile(a,r){const o=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);a.source=this.id,a.scope=this.scope,this._workerReady===void 0&&(this._workerReady=this.dispatcher.send("ensureRasterArraySource",void 0).then(()=>{}),this._workerReady.catch(()=>{})),a.workerReady=this._workerReady,a.actor||(a.actor=this.dispatcher.getActor());const u=new AbortController;a.request=u;const f=(m,g,x)=>{if(delete a.request,a.aborted)return r(null);if(m)return a.state="errored",r(m);if(this.map._refreshExpiredTiles&&g&&a.setExpiryData(d.ci(x)),this.partial&&a.state!=="expired")a.state="empty";else if(!this.partial){if(!g)return r(null);a.state="loaded",a._isHeaderLoaded=!0,a._mrt=g}r(null)};try{const m=await this.map._requestManager.transformRequest(o,d.R.Tile,u.signal);if(u.signal.aborted)return r(null);a.requestParams=m;const g={request:m,uid:a.uid,tileID:a.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};a.request=this.partial?a.fetchHeader(void 0,(x,w,E)=>{f(x,w,E)}):a.actor.sendCancelable("loadTile",g,{},(x,w)=>x?f(x):w?void f(null,w.mrt,w.headers):f(null,null))}catch(m){if(u.signal.aborted)return r(null);a.state="errored",r(m)}}abortTile(a){a.request&&(a.request.abort(),delete a.request),a.actor&&a.actor.notify("abortTile",{uid:a.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(a,r){const o=a.texturePerLayer;if(a.flushAllQueues(),o.size){a.destroy(!1);for(const u of o.values())this.map.painter.saveTileTexture(u)}else a.destroy()}prepareTile(a,r,o,u){a._isHeaderLoaded&&(a.state!=="empty"&&(a.state="reloading"),a.fetchBandForRender(r,o,u,(f,m)=>{f?(a.state="errored",this.fire(new d.f(f))):m&&(a._isHeaderLoaded=!0,a.setTexturePerLayer(o,m,this.map.painter),a.state="loaded"),this.triggerRepaint(a)}))}getInitialBand(a){if(!this.rasterLayers)return 0;const r=this.rasterLayers.find(({id:f})=>f===a),o=r&&r.fields,u=o&&o.bands&&o.bands;return u?u[0]:0}getTextureDescriptor(a,r,o){if(!a)return;const u=r.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!u)return;let f=null;r instanceof d.cx?f=r.paint.get("raster-array-band"):r instanceof d.cy&&(f=r.paint.get("raster-particle-array-band"));const m=f||this.getInitialBand(u);if(m!=null)if(a.textureDescriptorPerLayer.get(r.id)){if(!a.updateNeeded(r.id,m)||o)return{...a.textureDescriptorPerLayer.get(r.id),texture:a.texturePerLayer.get(r.id)}}else this.prepareTile(a,u,r.id,m)}getImages(a,r){const o=new Map;for(const u of a)for(const f of r){const[m,g]=f.split("/"),x=u.getLayer(m);if(!x||!x.hasBand(g)||!x.hasDataForBand(g))continue;const{bytes:w,tileSize:E,buffer:I}=x.getBandView(g),R=E+2*I,P={data:new d.b({width:R,height:R},w),pixelRatio:2,sdf:!1,usvg:!1,version:0};o.set(f,P)}return o}queryRasterArrayValueByBandId(a,r,o){const u=r._mrt;return new Promise(f=>{const m={},g=new Set;for(const[x,w]of Object.entries(u.layers)){if(o.layerName&&x!==o.layerName)continue;const E={};m[x]=E;for(const{bands:I}of w.dataIndex)for(const R of I)o.bands&&!o.bands.includes(R)||(g.add(d.m(x,R)),r.fetchBand(x,null,R,P=>{d.e.frame(()=>{E[R]=P?null:fo([a.lng,a.lat],u,w.getBandView(R)),g.delete(d.m(x,R)),g.size===0&&f(m)})}))}g.size===0&&f(m)})}_loadTileForQuery(a){if(this._loadTileLoaded[a.uid])return Promise.resolve(a._mrt);if(a.uid in this._loadTilePending)return this._loadTilePending[a.uid];const r=this._fetchTileForQuery(a);return this._loadTilePending[a.uid]=r,r}async _fetchTileForQuery(a){const r=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);try{const o={request:await this.map._requestManager.transformRequest(r,d.R.Tile),uid:a.uid,tileID:a.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},u=await a.actor.send("loadTile",o);if(!u)return null;const f=u.mrt;return this.map._refreshExpiredTiles&&a.setExpiryData(d.ci(u.headers)),a._mrt=f,a._isHeaderLoaded=!0,a.state="loaded",this._loadTileLoaded[a.uid]=!0,f}finally{delete this._loadTilePending[a.uid]}}async queryRasterArrayValueByAllBands(a,r,o){return await this._loadTileForQuery(r)?this.queryRasterArrayValueByBandId(a,r,o):null}queryRasterArrayValue(a,r){const o=d.cz.convert(a),u=this.findLoadedParent(o);return u&&u._mrt?r.bands||!this.partial?this.queryRasterArrayValueByBandId(o,u,r):this.queryRasterArrayValueByAllBands(o,u,r):Promise.resolve(null)}findLoadedParent(a){const r=d.bS.fromLngLat(a,this.map.transform.tileSize),o=this.maxzoom+1,u=1<<o,f=Math.floor(r.x),m=Math.floor((r.x-f)*u),g=Math.floor(r.y*u);if(m<0||m>=u||g<0||g>=u)return null;const x=this.map.style.getSourceCache(this.id),w=new d.bP(o,f,o,m,g);return x.findLoadedParent(w,this.minzoom)}}},vr=qn,Ks={model:()=>Zt().then(()=>Ct.ModelSource),"batched-model":()=>Zt().then(()=>Ct.Tiled3dModelSource),"raster-array":()=>async function(){return Promise.resolve()}().then(()=>vr.RasterArrayTileSource)};class d_ extends d.E{constructor(r,o,u,f){super(),this.id=r,this.type=o.type,this._options=o,this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.setEventedParent(f)}hasTransition(){return!1}loaded(){return!1}onAdd(r){}onRemove(r){}loadTile(r,o){}serialize(){return this._options}}function Df(a,r,o=""){return`${o}:${r.id||""}:${r.layer.id}:${function(u){if("layerId"in u)return`layer:${u.layerId}`;{const{featuresetId:f,importId:m}=u;return`featureset:${f}${m?`:import:${m}`:""}`}}(a.target)}`}function Lf(a,r,o,u=""){if(a.uniqueFeatureID){const f=Df(a,r,u);if(o.has(f))return!0;o.add(f)}return!1}function zf(a,r,o,u,f=!1,m=void 0){const g=r.sourceCache.transform,x=r.sourceCache.tilesIn(a,r.has3DLayers,f);x.sort(Jh);const w=[];for(const E of x){const I=E.tile.queryRenderedFeatures(r,E,o,u,g,f,m);Object.keys(I).length&&w.push({wrappedTileID:E.tile.tileID.wrapped().key,queryResults:I})}for(const E in r.layers){const I=r.layers[E];if(I.styleLayer){const R=I.styleLayer.queryRenderedFeatures(a,r.sourceCache,u);Object.keys(R).length&&w.push({wrappedTileID:0,queryResults:R})}}return w.length===0?{}:function(E){const I={},R={};for(const P of E){const B=P.queryResults,V=P.wrappedTileID,U=R[V]=R[V]||{};for(const G in B){const $=B[G],Y=U[G]=U[G]||{},re=I[G]=I[G]||[];for(const oe of $)Y[oe.featureIndex]||(Y[oe.featureIndex]=!0,re.push(oe))}}return I}(w)}function f_(a,r,o,u,f,m){const g={},x=u.queryRenderedSymbols(a),w=[];for(const E of Object.keys(x).map(Number))w.push(f[E]);w.sort(Jh);for(const E of w){const I=E.featureIndex.lookupSymbolFeatures(x[E.bucketInstanceId],E.bucketIndex,E.sourceLayerIndex,r,o,m);for(const R in I){const P=g[R]=g[R]||[],B=I[R];B.sort((V,U)=>{const G=E.featureSortOrder;if(G){const $=G.indexOf(V.featureIndex);return G.indexOf(U.featureIndex)-$}return U.featureIndex-V.featureIndex});for(const V of B)P.push(V)}}return g}function Kh(a,r){const o=a.getRenderableIds().map(m=>a.getTileByID(m)),u=[],f={};for(let m=0;m<o.length;m++){const g=o[m],x=g.tileID.canonical.key;f[x]||(f[x]=!0,g.querySourceFeatures(u,r))}return u}function Jh(a,r){const o=a.tileID,u=r.tileID;return o.overscaledZ-u.overscaledZ||o.canonical.y-u.canonical.y||o.wrap-u.wrap||o.canonical.x-u.canonical.x}class Ff{constructor(r){this.style=r,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const r=!1,o=!1;for(const u in this.style._mergedLayers){const f=this.style._mergedLayers[u];if(f.type==="fill-extrusion"||f.type==="building")this.layers.push({layer:f,visible:r,visibilityChanged:o});else if(f.type==="model"){const m=this.style.getLayerSource(f);m&&m.type==="batched-model"&&this.layers.push({layer:f,visible:r,visibilityChanged:o})}}}onNewFrame(r){this.layersGotHidden=!1;for(const o of this.layers){const u=o.layer;let f=!1;u.type==="fill-extrusion"?f=!u.isHidden(r)&&u.paint.get("fill-extrusion-opacity")>0:u.type==="building"?f=!u.isHidden(r)&&u.paint.get("building-opacity")>0:u.type==="model"&&(f=!u.isHidden(r)&&u.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!f&&o.visible,o.visible=f}}updateZOffset(r,o){this.currentBuildingBuckets=[];for(const f of this.layers){const m=f.layer,g=this.style.getLayerSourceCache(m);let x=1;m.type==="fill-extrusion"?x=f.visible?m.paint.get("fill-extrusion-vertical-scale"):0:m.type==="building"&&(x=f.visible?m.paint.get("building-vertical-scale"):0);let w=g?g.getTile(o):null;if(!w&&g)for(const E in g._tiles){const I=g._tiles[E];if(o.canonical.isChildOf(I.tileID.canonical)){w=I;break}}this.currentBuildingBuckets.push({bucket:w?w.getBucket(m):null,tileID:w?w.tileID:o,verticalScale:x})}r.hasAnyZOffset=!1;let u=!1;for(let f=0;f<r.symbolInstances.length;f++){const m=r.symbolInstances.get(f),g=m.zOffset,x=this._getHeightAtTileOffset(o,m.tileAnchorX,m.tileAnchorY);m.zOffset=x!==Number.NEGATIVE_INFINITY?x:g,u||g===m.zOffset||(u=!0),r.hasAnyZOffset||m.zOffset===0||(r.hasAnyZOffset=!0)}u&&(r.zOffsetBuffersNeedUpload=!0,r.zOffsetSortDirty=!0)}hasLayerForSourceCache(r){for(const{layer:o}of this.layers){const u=this.style.getLayerSourceCache(o);if(u&&u.id===r)return!0}return!1}_mapCoordToOverlappingTile(r,o,u,f){let m=o,g=u;if(r.canonical.z!==f.canonical.z){const x=f.canonical,w=1/(1<<r.canonical.z-x.z);m=(o+r.canonical.x*d.a2)*w-x.x*d.a2|0,g=(u+r.canonical.y*d.a2)*w-x.y*d.a2|0}return{tileX:m,tileY:g}}_getHeightAtTileOffset(r,o,u){let f,m;for(let g=0;g<this.layers.length;++g){const x=this.layers[g].layer;if(x.type!=="fill-extrusion"&&x.type!=="building")continue;const{bucket:w,tileID:E,verticalScale:I}=this.currentBuildingBuckets[g];if(!w)continue;const{tileX:R,tileY:P}=this._mapCoordToOverlappingTile(r,o,u,E),B=w.getHeightAtTileCoord(R,P);B&&B.height!==void 0&&(B.hidden?f=B.height:m=Math.max(B.height*I,m||0))}if(m!==void 0)return m;for(let g=0;g<this.layers.length;++g){const x=this.layers[g];if(x.layer.type!=="model"||!x.visible)continue;const{bucket:w,tileID:E}=this.currentBuildingBuckets[g];if(!w)continue;const{tileX:I,tileY:R}=this._mapCoordToOverlappingTile(r,o,u,E),P=w.getHeightAtTileCoord(I,R);if(P&&!P.hidden)return P.height===void 0&&f!==void 0?Math.min(P.maxHeight,f)*P.verticalScale:P.height?P.height*P.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}let ic;function Qh(){return ic||(ic=new at),ic}function sl(a,r){const o={},u=a,f=r,m=o;for(const g in u)g!=="ref"&&(m[g]=u[g]);return d.cD.forEach(g=>{g in f&&(m[g]=f[g])}),o}function Gc(a){a=a.slice();const r=Object.create(null);for(const o of a)r[o.id]=o;for(let o=0;o<a.length;o++){const u=a[o];if(u&&"ref"in u){const f=r[u.ref];f&&(a[o]=sl(u,f))}}return a}class qe{constructor(r,o,u,f){this.opacity=r?Math.max(0,Math.min(1,r.opacity+(r.placed?o:-o))):f&&u?1:0,this.placed=u}isHidden(){return this.opacity===0&&!this.placed}}class rc{constructor(r,o,u,f,m,g=!1){this.text=new qe(r?r.text:null,o,u,m),this.icon=new qe(r?r.icon:null,o,f,m),this.clipped=g}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class nc{constructor(r,o,u,f=!1){this.text=r,this.icon=o,this.skipFade=u,this.clipped=f}}class Of{constructor(){this.invProjMatrix=d.Y(),this.viewportMatrix=d.Y(),this.circles=[]}}class oc{constructor(r,o,u,f,m){this.bucketInstanceId=r,this.featureIndex=o,this.sourceLayerIndex=u,this.bucketIndex=f,this.tileID=m}}class al{constructor(r){this.crossSourceCollisions=r,this.maxGroupID=0,this.collisionGroups={}}get(r){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[r]){const o=++this.maxGroupID;this.collisionGroups[r]={ID:o,predicate:u=>u.collisionGroupID===o}}return this.collisionGroups[r]}}function va(a,r,o,u,f){const{horizontalAlign:m,verticalAlign:g}=d.cM(a),x=-(m-.5)*r,w=-(g-.5)*o,E=d.cN(a,u);return new d.P(x+E[0]*f,w+E[1]*f)}function Hc(a,r,o,u,f){const m=new d.P(a,r);return o&&m._rotate(u?f:-f),m}function Jo(a,r,o,u){const{leftJustifiedTextSymbolIndex:f,centerJustifiedTextSymbolIndex:m,rightJustifiedTextSymbolIndex:g,verticalPlacedTextSymbolIndex:x,crossTileID:w}=o,E=d.cO(r),I=u===d.cL.vertical?x:E==="left"?f:E==="center"?m:E==="right"?g:-1;f>=0&&(a.text.placedSymbolArray.get(f).crossTileID=I>=0&&f!==I?0:w),m>=0&&(a.text.placedSymbolArray.get(m).crossTileID=I>=0&&m!==I?0:w),g>=0&&(a.text.placedSymbolArray.get(g).crossTileID=I>=0&&g!==I?0:w),x>=0&&(a.text.placedSymbolArray.get(x).crossTileID=I>=0&&x!==I?0:w)}function Zc(a,r,o){const u=r===d.cL.horizontal||r===d.cL.horizontalOnly?r:0,f=r===d.cL.vertical?r:0,{leftJustifiedTextSymbolIndex:m,centerJustifiedTextSymbolIndex:g,rightJustifiedTextSymbolIndex:x,verticalPlacedTextSymbolIndex:w}=o,E=a.text.placedSymbolArray;m>=0&&(E.get(m).placedOrientation=u),g>=0&&(E.get(g).placedOrientation=u),x>=0&&(E.get(x).placedOrientation=u),w>=0&&(E.get(w).placedOrientation=f)}class Bf{constructor(r,o,u,f,m,g,x,w){this.transform=r.clone(),this.projection=r.projection.name,this.algorithm=f,this.collisionIndex=this.algorithm.createCollisionDetector(this.transform,g,w),this.buildingIndex=x,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new al(u),this.collisionCircleArrays={},this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(r,o,u,f,m=1){const g=u.getBucket(o),x=u.latestFeatureIndex;if(!g||!x||o.fqid!==g.layerIds[0])return;const w=g.layers[0].layout,E=g.layers[0].paint,I=u.collisionBoxArray,R=Math.pow(2,this.transform.zoom-u.tileID.overscaledZ),P=u.tileSize/d.a2,B=u.tileID.toUnwrapped();this.transform.setProjection(g.projection);const V=(U=u.tileID,G=g.getProjection(),$=this.transform,G.name===this.projection?$.calculateProjMatrix(U.toUnwrapped()):$o($,G,U));var U,G,$;const Y=w.get("text-pitch-alignment")==="map",re=w.get("text-rotation-alignment")==="map";o.compileFilter(o.options);const oe=o.dynamicFilter(),pe=o.dynamicFilterNeedsFeature(),ce=o.dynamicFilterNeedsGeometry(),_e=this.transform.calculatePixelsToTileUnitsMatrix(u),ue=d.cE(V,u.tileID.canonical,Y,re,this.transform,g.getProjection(),_e);let me=null;const Ie=g.getProjection().createInversionMatrix(this.transform,u.tileID.canonical);if(Y){const ot=d.cF(V,u.tileID.canonical,Y,re,this.transform,g.getProjection(),_e);me=d.X([],this.transform.labelPlaneMatrix,ot)}let we=null;oe&&u.latestFeatureIndex&&(we={unwrappedTileID:B,dynamicFilter:oe,dynamicFilterNeedsFeature:pe,needGeometry:ce}),this.retainedQueryData[g.bucketInstanceId]=new oc(g.bucketInstanceId,x,g.sourceLayerIndex,g.index,u.tileID);const[ve,Se]=g.layers[0].layout.get("text-size-scale-range"),Re=d.b0(m,ve,Se),[Ue,Pe]=w.get("icon-size-scale-range"),Oe=d.b0(m,Ue,Pe),Xe={bucket:g,layout:w,paint:E,posMatrix:V,invMatrix:Ie,mercatorCenter:[d.a7(this.transform.center.lng),d.a8(this.transform.center.lat)],textLabelPlaneMatrix:ue,labelToScreenMatrix:me,clippingData:we,scale:R,textPixelRatio:P,holdingForFade:u.holdingForFade(),collisionBoxArray:I,partiallyEvaluatedTextSize:d.cG(g.textSizeData,this.transform.zoom,Re),partiallyEvaluatedIconSize:d.cG(g.iconSizeData,this.transform.zoom,Oe),collisionGroup:this.collisionGroups.get(g.sourceID),latestFeatureIndex:u.latestFeatureIndex};if(f)for(const ot of g.sortKeyRanges){const{sortKey:tt,symbolInstanceStart:Ye,symbolInstanceEnd:mt}=ot;r.push({sortKey:tt,symbolInstanceStart:Ye,symbolInstanceEnd:mt,parameters:Xe})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:g.symbolInstances.length,parameters:Xe})}placeLayerBucketPart(r,o,u,f=1){this.algorithm.placeLayerBucketPart(this,r,o,u,f)}commit(r){this.commitTime=r,this.zoomAtLastRecencyCheck=this.transform.zoom;const o=this.prevPlacement;let u=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;const f=o?o.symbolFadeChange(r):1,m=o?o.opacities:{},g=o?o.variableOffsets:{},x=o?o.placedOrientations:{};for(const w in this.placements){const E=this.placements[w],I=m[w];I?(this.opacities[w]=new rc(I,f,E.text,E.icon,null,E.clipped),u=u||E.text!==I.text.placed||E.icon!==I.icon.placed):(this.opacities[w]=new rc(null,f,E.text,E.icon,E.skipFade,E.clipped),u=u||E.text||E.icon)}for(const w in m){const E=m[w];if(!this.opacities[w]){const I=new rc(E,f,!1,!1);I.isHidden()||(this.opacities[w]=I,u=u||E.text.placed||E.icon.placed)}}for(const w in g)this.variableOffsets[w]||!this.opacities[w]||this.opacities[w].isHidden()||(this.variableOffsets[w]=g[w]);for(const w in x)this.placedOrientations[w]||!this.opacities[w]||this.opacities[w].isHidden()||(this.placedOrientations[w]=x[w]);u?this.lastPlacementChangeTime=r:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:r)}updateLayerOpacities(r,o,u,f,m=!1,g=1){f&&(this.lastReplacementSourceUpdateTime=f.updateTime);const x=new Set;for(const w of o){const E=w.getBucket(r);if(E&&w.latestFeatureIndex&&r.fqid===E.layerIds[0]&&(this.updateBucketOpacities(E,x,w,w.collisionBoxArray,u,f,w.tileID,r.scope),E.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(E,w.tileID),E.elevationType==="road"&&E.hdExt&&E.hdExt.updateRoadElevation(E,w.tileID.canonical),E.updateZOffset(),m&&w.collisionBoxArray)){const I=E.layers[0].layout,[R,P]=I.get("text-size-scale-range"),[B,V]=I.get("icon-size-scale-range"),U=d.b0(g,R,P),G=d.b0(g,B,V);E.updateCollisionDebugBuffers(this.transform.zoom,w.collisionBoxArray,U,G)}}}updateBucketOpacities(r,o,u,f,m,g,x,w){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const E=r.layers[0].layout,I=r.layers[0].paint,R=!!r.layers[0].dynamicFilter(),P=new rc(null,0,!1,!1,!0),B=E.get("text-allow-overlap"),V=E.get("icon-allow-overlap"),U=E.get("text-variable-anchor"),G=E.get("text-rotation-alignment")==="map",$=E.get("text-pitch-alignment")==="map",Y=I.get("symbol-z-offset"),re=E.get("symbol-elevation-reference")==="sea",oe=!Y.isConstant(),pe=new rc(null,0,B&&(V||!r.hasIconData()||E.get("icon-optional")),V&&(B||!r.hasTextData()||E.get("text-optional")),!0);!r.collisionArrays&&f&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(f);const ce=(ue,me,Ie)=>{for(let we=0;we<me/4;we++)ue.opacityVertexArray.emplaceBack(Ie)};let _e=0;g&&r.updateReplacement(x,g),this.collisionIndex.clearClippedSymbolsForBucket(r.bucketInstanceId);for(let ue=0;ue<r.symbolInstances.length;ue++){const me=r.symbolInstances.get(ue),{numHorizontalGlyphVertices:Ie,numVerticalGlyphVertices:we,crossTileID:ve,numIconVertices:Se,tileAnchorX:Re,tileAnchorY:Ue}=me;let Pe=null;const Oe=this.retainedQueryData[r.bucketInstanceId];oe&&me&&Oe&&(Pe=u.latestFeatureIndex.loadFeature({featureIndex:me.featureIndex,bucketIndex:Oe.bucketIndex,sourceLayerIndex:Oe.sourceLayerIndex,layoutVertexArrayOffset:0}));const Xe=Y.evaluate(Pe,{}),ot=o.has(ve);let tt=this.opacities[ve];ot?tt=P:tt||(tt=pe,this.opacities[ve]=tt),o.add(ve);const Ye=Ie>0||we>0,mt=Se>0,We=this.placedOrientations[ve],je=We===d.cL.vertical,Je=We===d.cL.horizontal||We===d.cL.horizontalOnly;!Ye&&!mt||tt.isHidden()||_e++;let ft=!1;if((Ye||mt)&&g)for(const rt of r.activeReplacements){if(d.cH(rt,m,d.cI.Symbol,w)||rt.min.x>Re||Re>rt.max.x||rt.min.y>Ue||Ue>rt.max.y)continue;const ct=d.cJ(Re,Ue,x.canonical,rt.footprintTileId.canonical);if(ft=d.cK(ct,rt.footprint),ft)break}if(ft&&this.collisionIndex.markSymbolAsClipped(r.bucketInstanceId,me.featureIndex),Ye){const rt=ft?ba:Ps(tt.text);ce(r.text,Ie,je?ba:rt),ce(r.text,we,Je?ba:rt);const ct=tt.text.isHidden(),{leftJustifiedTextSymbolIndex:xt,centerJustifiedTextSymbolIndex:Rt,rightJustifiedTextSymbolIndex:Mt,verticalPlacedTextSymbolIndex:Ft}=me,bi=r.text.placedSymbolArray,yi=ct||je?1:0;xt>=0&&(bi.get(xt).hidden=yi),Rt>=0&&(bi.get(Rt).hidden=yi),Mt>=0&&(bi.get(Mt).hidden=yi),Ft>=0&&(bi.get(Ft).hidden=ct||Je?1:0);const kt=this.variableOffsets[ve];kt&&Jo(r,kt.anchor,me,We);const _t=this.placedOrientations[ve];_t&&(Jo(r,"left",me,_t),Zc(r,_t,me))}if(mt){const rt=ft?ba:Ps(tt.icon),{placedIconSymbolIndex:ct,verticalPlacedIconSymbolIndex:xt}=me,Rt=r.icon.placedSymbolArray,Mt=tt.icon.isHidden()?1:0;ct>=0&&(ce(r.icon,Se,je?ba:rt),Rt.get(ct).hidden=Mt),xt>=0&&(ce(r.icon,me.numVerticalIconVertices,Je?ba:rt),Rt.get(xt).hidden=Mt)}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const rt=r.collisionArrays[ue];if(rt){let ct=new d.P(0,0),xt=!0;if(rt.textBox||rt.verticalTextBox){if(U){const Mt=this.variableOffsets[ve];Mt?(ct=va(Mt.anchor,Mt.width,Mt.height,Mt.textOffset,Mt.textScale),G&&ct._rotate($?this.transform.angle:-this.transform.angle)):xt=!1}R&&(xt=!tt.clipped),rt.textBox&&$c(r.textCollisionBox.collisionVertexArray,tt.text.placed,!xt||je,Xe,re,ct.x,ct.y),rt.verticalTextBox&&$c(r.textCollisionBox.collisionVertexArray,tt.text.placed,!xt||Je,Xe,re,ct.x,ct.y)}const Rt=xt&&!!(!Je&&rt.verticalIconBox);rt.iconBox&&$c(r.iconCollisionBox.collisionVertexArray,tt.icon.placed,Rt,Xe,re,me.hasIconTextFit?ct.x:0,me.hasIconTextFit?ct.y:0),rt.verticalIconBox&&$c(r.iconCollisionBox.collisionVertexArray,tt.icon.placed,!Rt,Xe,re,me.hasIconTextFit?ct.x:0,me.hasIconTextFit?ct.y:0)}}}if(r.fullyClipped=_e===0,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const ue=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=ue.invProjMatrix,r.placementViewportMatrix=ue.viewportMatrix,r.collisionCircleArray=ue.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(r){return this.fadeDuration===0?1:(r-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(r){return Math.max(0,(this.transform.zoom-r)/1.5)}hasTransitions(r){return r-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(r,o){const u=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*u>r}isStale(){return this.stale}setStale(){this.stale=!0}}function $c(a,r,o,u,f,m,g){a.emplaceBack(r?1:0,o?1:0,m||0,g||0,u,f?1:0),a.emplaceBack(r?1:0,o?1:0,m||0,g||0,u,f?1:0),a.emplaceBack(r?1:0,o?1:0,m||0,g||0,u,f?1:0),a.emplaceBack(r?1:0,o?1:0,m||0,g||0,u,f?1:0)}const ed=Math.pow(2,25),ll=Math.pow(2,24),qc=Math.pow(2,17),Wc=Math.pow(2,16),kf=Math.pow(2,9),Nf=Math.pow(2,8),Yu=Math.pow(2,1);function Ps(a){if(a.opacity===0&&!a.placed)return 0;if(a.opacity===1&&a.placed)return 4294967295;const r=a.placed?1:0,o=Math.floor(127*a.opacity);return o*ed+r*ll+o*qc+r*Wc+o*kf+r*Nf+o*Yu+r}const ba=0;class cl{constructor(r,o){this.reset(r,o)}reset(r,o){this.points=r||[],this._distances=[0];for(let u=1;u<this.points.length;u++)this._distances[u]=this._distances[u-1]+this.points[u].dist(this.points[u-1]);this.length=this._distances.at(-1),this.padding=Math.min(o||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(r){if(this.points.length===1)return this.points[0];r=d.b0(r,0,1);let o=1,u=this._distances[o];const f=r*this.paddedLength+this.padding;for(;u<f&&o<this._distances.length;)u=this._distances[++o];const m=o-1,g=this._distances[m],x=u-g,w=x>0?(f-g)/x:0;return this.points[m].mult(1-w).add(this.points[o].mult(w))}}const Lo=100;class ul{constructor(r,o){this.gridRightBoundary=0,this.gridBottomBoundary=0,this.clippedSymbols=new Map,this.reset(r,o)}reset(r,o){const u=r.width+200,f=r.height+200;u!==this.gridRightBoundary||f!==this.gridBottomBoundary?(this.grid=new d.cP(u,f,25),this.ignoredGrid=new d.cP(u,f,25)):(this.grid.clear(),this.ignoredGrid.clear()),this.transform=r,this.fogState=o,this.pitchfactor=Math.cos(r._pitch)*r.cameraToCenterDistance,this.screenRightBoundary=r.width+Lo,this.screenBottomBoundary=r.height+Lo,this.gridRightBoundary=u,this.gridBottomBoundary=f,this.clippedSymbols.clear()}clearClippedSymbolsForBucket(r){this.clippedSymbols.delete(r)}markSymbolAsClipped(r,o){let u=this.clippedSymbols.get(r);u||(u=new Set,this.clippedSymbols.set(r,u)),u.add(o)}placeCollisionBox(r,o,u,f,m,g,x,w,E,I,R){let P=u.projectedAnchorX,B=u.projectedAnchorY,V=u.projectedAnchorZ;const U=u.tileAnchorX,G=u.tileAnchorY,$=u.elevation,Y=u.tileID,re=r.getProjection();if($&&Y){const[Se,Re,Ue]=re.upVector(Y.canonical,u.tileAnchorX,u.tileAnchorY),Pe=re.upVectorScale(Y.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;P+=Se*$*Pe,B+=Re*$*Pe,V+=Ue*$*Pe}const oe=r.projection.name==="globe",pe=r.projection.name==="globe"?d.S(this.transform.zoom):0;if(Y&&oe&&pe<1&&!g){const Se=1<<Y.canonical.z,Re=d.cQ(U,G);d.cR(Re,Re,1/d.a2),d.cS(Re,Re,d.cQ(Y.canonical.x,Y.canonical.y)),d.cR(Re,Re,1/Se),d.cT(Re,Re,d.cQ(f[0],f[1])),Re[0]=d.cU(Re[0],-.5,.5),d.cR(Re,Re,d.a2);const Ue=d.cV(Re[0],Re[1],d.a2/(2*Math.PI),1);d.c7(Ue,Ue,m),P=d.al(P,Ue[0],pe),B=d.al(B,Ue[1],pe),V=d.al(V,Ue[2],pe)}const ce=this.projectAndGetPerspectiveRatio(I,P,B,V,u.tileID,re.name==="globe"||!!$||this.transform.pitch>0,re),_e=E*ce.perspectiveRatio,ue=(u.x1*o+x.x-u.padding)*_e+ce.point.x,me=(u.y1*o+x.y-u.padding)*_e+ce.point.y,Ie=(u.x2*o+x.x+u.padding)*_e+ce.point.x,we=(u.y2*o+x.y+u.padding)*_e+ce.point.y,ve=ce.perspectiveRatio<=.55||ce.occluded;return!this.isInsideGrid(ue,me,Ie,we)||!w&&this.grid.hitTest(ue,me,Ie,we,R)||ve?{box:[],offscreen:!1,occluded:ce.occluded}:{box:[ue,me,Ie,we],offscreen:this.isOffscreen(ue,me,Ie,we),occluded:!1}}placeCollisionCircles(r,o,u,f,m,g,x,w,E,I,R,P,B,V,U,G){const $=[],Y=this.transform.elevation,re=r.getProjection(),oe=r.elevationType==="road",pe=!!Y||oe,ce=d.cW.getAtTileOffsetFunc(G,this.transform.center.lat,this.transform.worldSize,re),_e=new d.P(u.tileAnchorX,u.tileAnchorY),ue=new d.P(u.tileAnchorX,u.tileAnchorY);let{x:me,y:Ie,z:we}=re.projectTilePoint(ue.x,ue.y,G.canonical),ve=null;if(pe){ve=oe&&r.hdExt?r.hdExt.makeRoadSymbolElevationParams(r,r.text,f,G,ce,Y,re,this.transform.center.lat,this.transform.worldSize):{getElevation:ce,elevation:Y,elevationFeature:null};const[ft,rt,ct]=ve.getElevation(_e,Y,ve.elevationFeature);me+=ft,Ie+=rt,we+=ct}const Se=re.name==="globe",Re=this.projectAndGetPerspectiveRatio(w,me,Ie,we,G,Se||!!Y||this.transform.pitch>0,re),{perspectiveRatio:Ue}=Re,Pe=(P?x/Ue:x*Ue)/d.d1,Oe=d.cX(me,Ie,we,E),Xe=u.lineOffsetX*Pe,ot=u.lineOffsetY*Pe,tt=d.au(r.layers[0].layout.get("text-max-angle")),Ye=Math.cos(tt),mt=Re.signedDistanceFromCamera>0?d.cY(Pe,g,Xe,ot,oe&&u.flipState===1,Oe,ue,u,m,E,{},pe&&!P?ve:null,P&&pe,re,G,P,Ye):null;let We=!1,je=!1,Je=!0;if(mt&&!Re.occluded){const ft=.5*V*Ue+U,rt=new d.P(-100,-100),ct=new d.P(this.screenRightBoundary,this.screenBottomBoundary),xt=new cl,{first:Rt,last:Mt}=mt,Ft=Rt.path.length;let bi=[];for(let _t=Ft-1;_t>=1;_t--)bi.push(Rt.path[_t]);for(let _t=1;_t<Mt.path.length;_t++)bi.push(Mt.path[_t]);const yi=2.5*ft;I&&(bi=bi.map(([_t,wi,sr],qi)=>(pe&&!Se&&(sr=ve.getElevation(qi<Ft-1?Rt.tilePath[Ft-1-qi]:Mt.tilePath[qi-Ft+2],Y,ve.elevationFeature)[2]),d.cX(_t,wi,sr,I))),bi.some(_t=>_t[3]<=0)&&(bi=[]));let kt=[];if(bi.length>0){let _t=1/0,wi=-1/0,sr=1/0,qi=-1/0;for(const Yt of bi)_t=Math.min(_t,Yt[0]),sr=Math.min(sr,Yt[1]),wi=Math.max(wi,Yt[0]),qi=Math.max(qi,Yt[1]);wi>=rt.x&&_t<=ct.x&&qi>=rt.y&&sr<=ct.y&&(kt=[bi.map(Yt=>new d.P(Yt[0],Yt[1]))],(_t<rt.x||wi>ct.x||sr<rt.y||qi>ct.y)&&(kt=d.cZ(kt,rt.x,rt.y,ct.x,ct.y)))}for(const _t of kt){xt.reset(_t,.25*ft);let wi=0;wi=xt.length<=.5*ft?1:Math.ceil(xt.paddedLength/yi)+1;for(let sr=0;sr<wi;sr++){const qi=sr/Math.max(wi-1,1),Yt=xt.lerp(qi),Wi=Yt.x+Lo,Mi=Yt.y+Lo;$.push(Wi,Mi,ft,0);const Wt=Wi-ft,Ti=Mi-ft,tr=Wi+ft,ni=Mi+ft;if(Je=Je&&this.isOffscreen(Wt,Ti,tr,ni),je=je||this.isInsideGrid(Wt,Ti,tr,ni),!o&&this.grid.hitTestCircle(Wi,Mi,ft,B)&&(We=!0,!R))return{circles:[],offscreen:!1,collisionDetected:We,occluded:!1}}}}return{circles:!R&&We||!je?[]:$,offscreen:Je,collisionDetected:We,occluded:Re.occluded}}queryRenderedSymbols(r){if(r.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const o=[];let u=1/0,f=1/0,m=-1/0,g=-1/0;for(const I of r){const R=new d.P(I.x+Lo,I.y+Lo);u=Math.min(u,R.x),f=Math.min(f,R.y),m=Math.max(m,R.x),g=Math.max(g,R.y),o.push(R)}const x=this.grid.query(u,f,m,g).concat(this.ignoredGrid.query(u,f,m,g)),w={},E={};for(const I of x){const R=I.key;if(w[R.bucketInstanceId]===void 0&&(w[R.bucketInstanceId]={}),w[R.bucketInstanceId][R.featureIndex])continue;const P=this.clippedSymbols.get(R.bucketInstanceId);if(P&&P.has(R.featureIndex))continue;const B=[new d.P(I.x1,I.y1),new d.P(I.x2,I.y1),new d.P(I.x2,I.y2),new d.P(I.x1,I.y2)];d.aT(o,B)&&(w[R.bucketInstanceId][R.featureIndex]=!0,E[R.bucketInstanceId]===void 0&&(E[R.bucketInstanceId]=[]),E[R.bucketInstanceId].push(R.featureIndex))}return E}insertCollisionBox(r,o,u,f,m){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:u,featureIndex:f,collisionGroupID:m},r[0],r[1],r[2],r[3])}insertCollisionCircles(r,o,u,f,m){const g=o?this.ignoredGrid:this.grid,x={bucketInstanceId:u,featureIndex:f,collisionGroupID:m};for(let w=0;w<r.length;w+=4)g.insertCircle(x,r[w],r[w+1],r[w+2])}projectAndGetPerspectiveRatio(r,o,u,f,m,g,x){const w=[o,u,f,1];let E=!1;f||this.transform.pitch>0?(d.c7(w,w,r),this.fogState&&m&&x.name!=="globe"&&(E=d.c_(this.fogState,o,u,f,m.toUnwrapped(),this.transform)>d.d2)):d.c$(w,w,r);const I=w[3];return{point:new d.P((w[0]/I+1)/2*this.transform.width+Lo,(-w[1]/I+1)/2*this.transform.height+Lo),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(x)/I*.5,1.5),signedDistanceFromCamera:I,occluded:g&&w[2]>I||E}}isOffscreen(r,o,u,f){return u<Lo||r>=this.screenRightBoundary||f<Lo||o>this.screenBottomBoundary}isInsideGrid(r,o,u,f){return u>=0&&r<this.gridRightBoundary&&f>=0&&o<this.gridBottomBoundary}getViewportMatrix(){const r=d.d0([]);return d.bM(r,r,[-100,-100,0]),r}}const Ku={default:new class{createCollisionDetector(a,r,o){return o instanceof ul?(o.reset(a,r),o):new ul(a,r)}shouldPause(a){return a>2}placeLayerBucketPart(a,r,o,u,f=1){const{bucket:m,layout:g,paint:x,posMatrix:w,textLabelPlaneMatrix:E,labelToScreenMatrix:I,clippingData:R,textPixelRatio:P,mercatorCenter:B,invMatrix:V,holdingForFade:U,collisionBoxArray:G,partiallyEvaluatedTextSize:$,partiallyEvaluatedIconSize:Y,collisionGroup:re,latestFeatureIndex:oe}=r.parameters,pe=g.get("text-optional"),ce=g.get("icon-optional"),_e=g.get("text-allow-overlap"),ue=g.get("icon-allow-overlap"),me=g.get("text-rotation-alignment")==="map",Ie=g.get("icon-rotation-alignment")==="map",we=g.get("text-pitch-alignment")==="map",ve=x.get("symbol-z-offset"),Se=g.get("symbol-elevation-reference")==="sea",Re=g.get("symbol-placement"),Ue=g.get("text-variable-anchor"),Pe=me&&Re!=="point",Oe=Ie&&Re!=="point",Xe=Ue&&m.hasTextData(),ot=m.hasIconTextFit()&&Xe&&m.hasIconData();a.transform.setProjection(m.projection);const tt=Xe||Pe,Ye=Oe||ot;let mt=_e&&(ue||!m.hasIconData()||ce),We=ue&&(_e||!m.hasTextData()||pe);const je=!ve.isConstant();!m.collisionArrays&&G&&m.deserializeCollisionBoxes(G);const Je=(rt,ct,xt)=>{const{crossTileID:Rt,numVerticalGlyphVertices:Mt}=rt;let Ft=null;if(R&&R.dynamicFilterNeedsFeature||je){const Fi=a.retainedQueryData[m.bucketInstanceId],mi=oe.loadFeature({featureIndex:rt.featureIndex,bucketIndex:Fi.bucketIndex,sourceLayerIndex:Fi.sourceLayerIndex,layoutVertexArrayOffset:0}),oi=mi.properties?mi.properties.worldview:null;if(m.localizable&&m.worldview&&typeof oi=="string")if(oi==="all")mi.properties.$localized=!0;else{if(!oi.split(",").includes(m.worldview))return;mi.properties.$localized=!0,mi.properties.worldview=m.worldview}Ft=R&&R.needGeometry?d.bw(mi,!0):mi}if(R&&!(0,R.dynamicFilter)({zoom:a.transform.zoom,pitch:a.transform.pitch,worldview:m.worldview},Ft,a.retainedQueryData[m.bucketInstanceId].tileID.canonical,new d.P(rt.tileAnchorX,rt.tileAnchorY),a.transform.calculateDistanceTileData(R.unwrappedTileID)))return a.placements[Rt]=new nc(!1,!1,!1,!0),void o.add(Rt);const bi=ve.evaluate(Ft,{});if((rt.zOffset||0)+(bi||0)>0&&a.frontCutoffStart>0){const Fi=2*a.frontCutoffStart-1,mi=[rt.tileAnchorX,rt.tileAnchorY,0,1],oi=d.c7(d.d3(),mi,w);if(oi[1]/oi[3]<Fi)return a.placements[Rt]=new nc(!1,!1,!1,!0),void o.add(Rt)}if(o.has(Rt))return;if(U)return void(a.placements[Rt]=new nc(!1,!1,!1));let yi=!1,kt=!1,_t=!0,wi=!1,sr=!1,qi=null,Yt={box:null,offscreen:null,occluded:null},Wi={box:null},Mi=null,Wt=null,Ti=null,tr=0,ni=0,ii=0;xt.textFeatureIndex?tr=xt.textFeatureIndex:rt.useRuntimeCollisionCircles&&(tr=rt.featureIndex),xt.verticalTextFeatureIndex&&(ni=xt.verticalTextFeatureIndex);const Ni=Fi=>{Fi.tileID=a.retainedQueryData[m.bucketInstanceId].tileID;const mi=a.transform.elevation;if(m.elevationType==="road")Fi.elevation=Se?bi:bi+d.cW.getAtTileOffset(Fi.tileID,new d.P(Fi.tileAnchorX,Fi.tileAnchorY),mi,null);else{const oi=m.hdExt?m.hdExt.elevationFeatures[rt.elevationFeatureIndex]:void 0;Fi.elevation=Se?bi:bi+d.cW.getAtTileOffset(Fi.tileID,new d.P(Fi.tileAnchorX,Fi.tileAnchorY),mi,oi)}Fi.elevation+=rt.zOffset},Ar=xt.textBox;if(Ar){Ni(Ar);const Fi=oi=>{let ir=d.cL.horizontal;if(m.allowVerticalPlacement&&!oi&&a.prevPlacement){const qr=a.prevPlacement.placedOrientations[Rt];qr&&(a.placedOrientations[Rt]=qr,ir=qr,Zc(m,ir,rt))}return ir},mi=(oi,ir)=>{if(m.allowVerticalPlacement&&Mt>0&&xt.verticalTextBox){for(const qr of m.writingModes)if(qr===d.cL.vertical?(Yt=ir(),Wi=Yt):Yt=oi(),Yt&&Yt.box&&Yt.box.length)break}else Yt=oi()};if(Ue){let oi=Ue;if(a.prevPlacement&&a.prevPlacement.variableOffsets[Rt]){const Vi=a.prevPlacement.variableOffsets[Rt];oi.indexOf(Vi.anchor)>0&&(oi=oi.filter(Kt=>Kt!==Vi.anchor),oi.unshift(Vi.anchor))}const ir=(Vi,Kt,Cr)=>{const Vr=m.getSymbolInstanceTextSize($,rt,a.transform.zoom,ct),Qo=(Vi.x2-Vi.x1)*Vr+2*Vi.padding,es=(Vi.y2-Vi.y1)*Vr+2*Vi.padding,Ls=rt.hasIconTextFit&&!ue?Kt:null;Ls&&Ni(Ls);let ko={box:[],offscreen:!1,occluded:!1};const Ra=_e?2*oi.length:oi.length;for(let gs=0;gs<Ra;++gs){const li=this.attemptAnchorPlacement(a,oi[gs%oi.length],Vi,B,V,tt,Qo,es,Vr,me,we,P,w,re,gs>=oi.length,rt,ct,m,Cr,Ls,$,Y);if(li&&(ko=li.placedGlyphBoxes,ko&&ko.box&&ko.box.length)){yi=!0,qi=li.shift;break}}return ko};mi(()=>ir(Ar,xt.iconBox,d.cL.horizontal),()=>{const Vi=xt.verticalTextBox;return Vi&&Ni(Vi),m.allowVerticalPlacement&&!(Yt&&Yt.box&&Yt.box.length)&&Mt>0&&Vi?ir(Vi,xt.verticalIconBox,d.cL.vertical):{box:null,offscreen:null,occluded:null}}),Yt&&(yi=Yt.box,_t=Yt.offscreen,wi=Yt.occluded);const qr=Fi(!(!Yt||!Yt.box));if(!yi&&a.prevPlacement){const Vi=a.prevPlacement.variableOffsets[Rt];Vi&&(a.variableOffsets[Rt]=Vi,Jo(m,Vi.anchor,rt,qr))}}else{const oi=(ir,qr)=>{const Vi=m.getSymbolInstanceTextSize($,rt,a.transform.zoom,ct),Kt=a.collisionIndex.placeCollisionBox(m,Vi,ir,B,V,tt,new d.P(0,0),_e,P,w,re.predicate);return Kt&&Kt.box&&Kt.box.length&&(Zc(m,qr,rt),a.placedOrientations[Rt]=qr),Kt};mi(()=>oi(Ar,d.cL.horizontal),()=>{const ir=xt.verticalTextBox;return m.allowVerticalPlacement&&Mt>0&&ir?(Ni(ir),oi(ir,d.cL.vertical)):{box:null,offscreen:null,occluded:null}}),Fi(!!(Yt&&Yt.box&&Yt.box.length))}}if(Mi=Yt,yi=Mi&&Mi.box&&Mi.box.length>0,_t=Mi&&Mi.offscreen,wi=Mi&&Mi.occluded,rt.useRuntimeCollisionCircles){const Fi=rt.centerJustifiedTextSymbolIndex>=0?rt.centerJustifiedTextSymbolIndex:rt.verticalPlacedTextSymbolIndex,mi=m.text.placedSymbolArray.get(Fi),oi=d.d4(m.textSizeData,$,mi),ir=g.get("text-padding");Wt=a.collisionIndex.placeCollisionCircles(m,_e,mi,Fi,m.lineVertexArray,m.glyphOffsetArray,oi,w,E,I,u,we,re.predicate,rt.collisionCircleDiameter*oi/d.d1,ir,a.retainedQueryData[m.bucketInstanceId].tileID),yi=_e||Wt.circles.length>0&&!Wt.collisionDetected,_t=_t&&Wt.offscreen,wi=Wt.occluded}if(xt.iconFeatureIndex&&(ii=xt.iconFeatureIndex),xt.iconBox){const Fi=mi=>{Ni(mi);const oi=rt.hasIconTextFit&&qi?Hc(qi.x,qi.y,me,we,a.transform.angle):new d.P(0,0),ir=m.getSymbolInstanceIconSize(Y,a.transform.zoom,rt.placedIconSymbolIndex);return a.collisionIndex.placeCollisionBox(m,ir,mi,B,V,Ye,oi,ue,P,w,re.predicate)};Wi&&Wi.box&&Wi.box.length&&xt.verticalIconBox?(Ti=Fi(xt.verticalIconBox),kt=Ti.box.length>0):(Ti=Fi(xt.iconBox),kt=Ti.box.length>0),_t=_t&&Ti.offscreen,sr=Ti.occluded}const go=pe||rt.numHorizontalGlyphVertices===0&&Mt===0,In=ce||rt.numIconVertices===0;if(go||In?In?go||(kt=kt&&yi):yi=kt&&yi:kt=yi=kt&&yi,yi&&Mi&&Mi.box&&a.collisionIndex.insertCollisionBox(Mi.box,g.get("text-ignore-placement"),m.bucketInstanceId,Wi&&Wi.box&&ni?ni:tr,re.ID),kt&&Ti&&a.collisionIndex.insertCollisionBox(Ti.box,g.get("icon-ignore-placement"),m.bucketInstanceId,ii,re.ID),Wt&&(yi&&a.collisionIndex.insertCollisionCircles(Wt.circles,g.get("text-ignore-placement"),m.bucketInstanceId,tr,re.ID),u)){const Fi=m.bucketInstanceId;let mi=a.collisionCircleArrays[Fi];mi===void 0&&(mi=a.collisionCircleArrays[Fi]=new Of);for(let oi=0;oi<Wt.circles.length;oi+=4)mi.circles.push(Wt.circles[oi+0]),mi.circles.push(Wt.circles[oi+1]),mi.circles.push(Wt.circles[oi+2]),mi.circles.push(Wt.collisionDetected?1:0)}const _s=m.projection.name!=="globe";mt=mt&&(_s||!wi),We=We&&(_s||!sr),a.placements[Rt]=new nc(yi||mt,kt||We,_t||m.justReloaded),o.add(Rt)},ft=a.retainedQueryData[m.bucketInstanceId].tileID;if(m.elevationType==="offset"&&a.buildingIndex&&a.buildingIndex.updateZOffset(m,ft),m.elevationType==="road"&&m.hdExt&&m.hdExt.updateRoadElevation(m,ft.canonical),m.updateZOffset(),m.sortFeaturesByY){const rt=m.getSortedSymbolIndexes(a.transform.angle);for(let ct=rt.length-1;ct>=0;--ct){const xt=rt[ct];Je(m.symbolInstances.get(xt),xt,m.collisionArrays[xt])}m.hasAnyZOffset&&d.w(`${m.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(m.hasAnyZOffset){const rt=m.getSortedIndexesByZOffset();for(let ct=0;ct<rt.length;++ct){const xt=rt[ct];Je(m.symbolInstances.get(xt),xt,m.collisionArrays[xt])}}else for(let rt=r.symbolInstanceStart;rt<r.symbolInstanceEnd;rt++)Je(m.symbolInstances.get(rt),rt,m.collisionArrays[rt]);if(u&&m.bucketInstanceId in a.collisionCircleArrays){const rt=a.collisionCircleArrays[m.bucketInstanceId];d.aO(rt.invProjMatrix,w),rt.viewportMatrix=a.collisionIndex.getViewportMatrix()}m.justReloaded=!1}attemptAnchorPlacement(a,r,o,u,f,m,g,x,w,E,I,R,P,B,V,U,G,$,Y,re,oe,pe){const{textOffset0:ce,textOffset1:_e,crossTileID:ue}=U,me=[ce,_e],Ie=va(r,g,x,me,w),we=a.collisionIndex.placeCollisionBox($,w,o,u,f,m,Hc(Ie.x,Ie.y,E,I,a.transform.angle),V,R,P,B.predicate);if(re){const ve=$.getSymbolInstanceIconSize(pe,a.transform.zoom,U.placedIconSymbolIndex);if(a.collisionIndex.placeCollisionBox($,ve,re,u,f,m,Hc(Ie.x,Ie.y,E,I,a.transform.angle),V,R,P,B.predicate).box.length===0)return}if(we.box.length>0){let ve;return a.prevPlacement&&a.prevPlacement.variableOffsets[ue]&&a.prevPlacement.placements[ue]&&a.prevPlacement.placements[ue].text&&(ve=a.prevPlacement.variableOffsets[ue].anchor),a.variableOffsets[ue]={textOffset:me,width:g,height:x,anchor:r,textScale:w,prevAnchor:ve},Jo($,r,U,Y),$.allowVerticalPlacement&&(Zc($,Y,U),a.placedOrientations[ue]=Y),{shift:Ie,placedGlyphBoxes:we}}}}};class p_{constructor(r){this._sortAcrossTiles=r.layout.get("symbol-z-order")!=="viewport-y"&&r.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(r,o,u,f,m,g){const x=this._bucketParts;for(;this._currentTileIndex<r.length;)if(o.getBucketParts(x,f,r[this._currentTileIndex],this._sortAcrossTiles,g),this._currentTileIndex++,m())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,x.sort((w,E)=>w.sortKey-E.sortKey));this._currentPartIndex<x.length;)if(o.placeLayerBucketPart(x[this._currentPartIndex],this._seenCrossTileIDs,u,g),this._currentPartIndex++,m())return!0;return!1}}class td{constructor(){this._retiredCI=null}startNewPlacement(r,o,u,f,m,g,x,w,E){return this.placement=new Bf(r,f,m,Ku[E||"default"],g,x,w,this._retiredCI),this._retiredCI=null,this._currentPlacementIndex=o.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=u,this._fadeDuration=f,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(r,o,u,f,m){const g=d.e.now(),x=()=>!this.isFullPlacementRequested()&&this._fadeDuration!==0&&this.placement.algorithm.shouldPause(d.e.now()-g);for(;this._currentPlacementIndex>=0;){const w=o[r[this._currentPlacementIndex]],E=this.placement.collisionIndex.transform.zoom;if(w.type==="symbol"&&w.visibility!=="none"&&(!w.minzoom||w.minzoom<=E)&&(!w.maxzoom||w.maxzoom>E)){const I=w,R=I.layout.get("symbol-z-elevate"),P=I.layout.get("symbol-sort-key").constantOr(1)!==void 0,B=I.layout.get("symbol-z-order"),V=B==="viewport-y"||B==="auto"&&!(B!=="viewport-y"&&P),U=I.layout.get("text-allow-overlap")||I.layout.get("icon-allow-overlap")||I.layout.get("text-ignore-placement")||I.layout.get("icon-ignore-placement"),G=V&&U,$=this._inProgressLayer=this._inProgressLayer||new p_(I),Y=d.m(w.source,w.scope);if($.continuePlacement(R||G?f[Y]:u[Y],this.placement,this._showCollisionBoxes,w,x,m))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(r){return this._retiredCI=this.placement.prevPlacement?this.placement.prevPlacement.collisionIndex:null,this.placement.commit(r),this.placement}}const Ju=512/d.a2/2;class id{constructor(r,o,u){this.tileID=r,this.bucketInstanceId=u,this.index=new d.d5(o.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const f=r.canonical.x*d.a2,m=r.canonical.y*d.a2;for(let g=0;g<o.length;g++){const{key:x,crossTileID:w,tileAnchorX:E,tileAnchorY:I}=o.get(g),R=Math.floor((f+E)*Ju),P=Math.floor((m+I)*Ju);this.index.add(R,P),this.keys.push(x),this.crossTileIDs.push(w)}this.index.finish()}findMatches(r,o,u){const f=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z),m=Ju/Math.pow(2,o.canonical.z-this.tileID.canonical.z),g=o.canonical.x*d.a2,x=o.canonical.y*d.a2;for(let w=0;w<r.length;w++){const E=r.get(w);if(E.crossTileID)continue;const{key:I,tileAnchorX:R,tileAnchorY:P}=E,B=Math.floor((g+R)*m),V=Math.floor((x+P)*m),U=this.index.range(B-f,V-f,B+f,V+f).sort((G,$)=>G-$);for(const G of U){const $=this.crossTileIDs[G];if(this.keys[G]===I&&!u.has($)){u.add($),E.crossTileID=$;break}}}}}class m_{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class __{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(r){const o=Math.round((r-this.lng)/360);if(o!==0)for(const u in this.indexes){const f=this.indexes[u],m={};for(const g in f){const x=f[g];x.tileID=x.tileID.unwrapTo(x.tileID.wrap+o),m[x.tileID.key]=x}this.indexes[u]=m}this.lng=r}addBucket(r,o,u){if(this.indexes[r.overscaledZ]&&this.indexes[r.overscaledZ][r.key]){if(this.indexes[r.overscaledZ][r.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(r.overscaledZ,this.indexes[r.overscaledZ][r.key])}for(let m=0;m<o.symbolInstances.length;m++)o.symbolInstances.get(m).crossTileID=0;this.usedCrossTileIDs[r.overscaledZ]||(this.usedCrossTileIDs[r.overscaledZ]=new Set);const f=this.usedCrossTileIDs[r.overscaledZ];for(const m in this.indexes){const g=this.indexes[m];if(Number(m)>r.overscaledZ)for(const x in g){const w=g[x];w.tileID.isChildOf(r)&&w.findMatches(o.symbolInstances,r,f)}else{const x=g[r.scaledTo(Number(m)).key];x&&x.findMatches(o.symbolInstances,r,f)}}for(let m=0;m<o.symbolInstances.length;m++){const g=o.symbolInstances.get(m);g.crossTileID||(g.crossTileID=u.generate(),f.add(g.crossTileID))}return this.indexes[r.overscaledZ]===void 0&&(this.indexes[r.overscaledZ]={}),this.indexes[r.overscaledZ][r.key]=new id(r,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(r,o){for(const u of o.crossTileIDs)this.usedCrossTileIDs[r].delete(u)}removeStaleBuckets(r){let o=!1;for(const u in this.indexes){const f=this.indexes[u];for(const m in f)r[f[m].bucketInstanceId]||(this.removeBucketCrossTileIDs(u,f[m]),delete f[m],o=!0)}return o}}class g_{constructor(){this.layerIndexes={},this.crossTileIDs=new m_,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(r,o,u,f){let m=this.layerIndexes[r.fqid];m===void 0&&(m=this.layerIndexes[r.fqid]=new __);let g=!1;const x={};f.name!=="globe"&&m.handleWrapJump(u);for(const w of o){const E=w.getBucket(r);E&&r.fqid===E.layerIds[0]&&(E.bucketInstanceId||(E.bucketInstanceId=++this.maxBucketInstanceId),m.addBucket(w.tileID,E,this.crossTileIDs)&&(g=!0),x[E.bucketInstanceId]=!0)}return m.removeStaleBuckets(x)&&(g=!0),g}pruneUnusedLayers(r){const o={};r.forEach(u=>{o[u]=!0});for(const u in this.layerIndexes)o[u]||delete this.layerIndexes[u]}}class y_ extends d.E{constructor(r){super(),this.requestManager=r,this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null)}async loadModel(r,o){try{const u=await this.requestManager.transformRequest(o,d.R.Model);return this.modelByURL[o]?(await Zt(),Ct.loadModel?await Ct.loadModel(u.url,r,o):null):null}catch(u){if(u.status===404)return null;this.fire(new d.f(new Error(`Could not load model ${r} from ${o}`,{cause:u})))}}load(r,o,u={forceReload:!1}){this.models[o]||(this.models[o]=Object.create(null));const f=Object.keys(r),m=[],g=[];for(const x of f){const w=r[x];this.hasURLBeenRequested(w)&&!u.forceReload||(this.modelByURL[w]={modelId:x,scope:o},m.push(this.loadModel(x,w)),g.push(x)),this.models[o][x]||(this.models[o][x]={model:null,numReferences:1})}this.numModelsLoading[o]=(this.numModelsLoading[o]||0)+g.length,Promise.allSettled(m).then(x=>{for(let w=0;w<x.length;w++){const{status:E}=x[w];if(E==="rejected")continue;const{value:I}=x[w];this.models[o][g[w]]||(this.models[o][g[w]]={model:null,numReferences:1}),this.models[o][g[w]].model=I}this.numModelsLoading[o]-=g.length,this.fire(new d.h("data",{dataType:"style"}))}).catch(x=>{this.fire(new d.f(new Error(`Could not load models: ${x.message}`)))})}isLoaded(){for(const r in this.numModelsLoading)if(this.numModelsLoading[r]>0)return!1;return!0}hasModel(r,o,u={exactIdMatch:!1}){return!!(u.exactIdMatch?this.getModel(r,o):this.getModelByURL(this.modelUris[o][r]))}getModel(r,o){return this.models[o]||(this.models[o]=Object.create(null)),this.models[o][r]?this.models[o][r].model:void 0}getModelByURL(r){if(!r)return null;const o=this.modelByURL[r];return o?this.models[o.scope][o.modelId].model:null}hasModelBeenAdded(r,o){return this.models[o]&&this.models[o][r]!==void 0}getModelURIs(r){return this.modelUris[r]||Object.create(null)}addModel(r,o,u){this.models[u]||(this.models[u]=Object.create(null)),this.modelUris[u]||(this.modelUris[u]=Object.create(null));const f=this.requestManager.normalizeModelURL(o);if((this.hasModel(r,u,{exactIdMatch:!0})||this.hasModelBeenAdded(r,u))&&this.modelUris[u][r]===f)this.models[u][r].numReferences++;else if(this.hasURLBeenRequested(f)){const{scope:m,modelId:g}=this.modelByURL[f];this.models[m][g].numReferences++}else this.modelUris[u][r]=f,this.load({[r]:this.modelUris[u][r]},u)}addModelURLs(r,o){this.models[o]||(this.models[o]=Object.create(null)),this.modelUris[o]||(this.modelUris[o]=Object.create(null));const u=this.modelUris[o];for(const f of Object.keys(r))u[f]=this.requestManager.normalizeModelURL(r[f])}reloadModels(r){this.load(this.modelUris[r],r,{forceReload:!0})}addModelsFromBucket(r,o){this.models[o]||(this.models[o]=Object.create(null)),this.modelUris[o]||(this.modelUris[o]=Object.create(null));const u=Object.create(null);for(const f of r)this.hasModel(f,o,{exactIdMatch:!0})||this.hasURLBeenRequested(f)?this.models[o][f].numReferences++:this.modelUris[o][f]&&!this.hasURLBeenRequested(f)?u[f]=this.modelUris[o][f]:!this.hasURLBeenRequested(f)&&De(f,!1)&&(this.modelUris[o][f]=this.requestManager.normalizeModelURL(f),u[f]=this.modelUris[o][f]);this.load(u,o)}hasURLBeenRequested(r){return this.modelByURL[r]!==void 0}removeModel(r,o,u=!1,f=!1){if(this.models[o]&&this.models[o][r]&&(this.models[o][r].numReferences--,this.models[o][r].numReferences===0||f)){const m=this.modelUris[o][r];u||delete this.modelUris[o][r],delete this.modelByURL[m];const g=this.models[o][r].model;if(!g)return;delete this.models[o][r],g.destroy()}}destroy(){for(const r of Object.keys(this.models))for(const o of Object.keys(this.models[r])){const u=this.models[r][o].model;delete this.models[r][o],u&&u.destroy()}this.models=Object.create(null),this.models[""]=Object.create(null),this.modelUris=Object.create(null),this.modelUris[""]=Object.create(null),this.modelByURL=Object.create(null),this.numModelsLoading=Object.create(null)}listModels(r){return this.models[r]||(this.models[r]=Object.create(null)),Object.keys(this.models[r])}upload(r,o){this.models[o]||(this.models[o]=Object.create(null));for(const u in this.models[o])this.models[o][u].model&&this.models[o][u].model.upload(r.context)}}const Vf=["RENDER_SHADOWS","NORMAL_OFFSET"],x_=new Set(["symbol","circle"]),sc=class Ny{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null}needsBuild(){return this._needsBuild}buildQueue(r,o,u){this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;const f=!!u.fog,m=u.hasTerrain(),g=!(!u.projection||u.projection.name!=="globe"),x=m||g,w=!(!u.directionalLight||!u.directionalLight.shadowsEnabled()),E=u.map&&u.map.painter,I=!E||!E.context.extParallelShaderCompile,R=!!E&&E.emissiveMode==="mrt-fallback",P=(B,V=[],U={})=>{this._queue.push({programId:B,params:{...U.params,defines:V,overrideFog:!!U.fog,overrideTerrain:!!U.terrain,overrideGlobe:!!U.globe,overrideRtt:!!U.rtt,precompiled:!0}})};for(const B of r){if(B.visibility==="none")continue;const V=B.getProgramIds();if(V)for(const U of V){if(x_.has(U))continue;const G=B.getDefaultProgramParams(U,o.zoom,u._styleColorTheme.lut);if(!G)continue;const $=E?E.getShaderSource(U):null,Y=x&&(!$||$.usedDefines.has("RENDER_TO_TEXTURE")),re=R&&Y?(G.defines||[]).concat("USE_MRT1"):G.defines;if(I){P(U,G.defines,{params:G}),Y&&P(U,re,{params:G,rtt:!0});continue}const oe=f&&(!$||$.usedDefines.has("FOG")),pe=m&&!B.isDraped()&&(!$||$.usedDefines.has("TERRAIN")),ce=g&&(!$||$.usedDefines.has("GLOBE")),_e=w&&B.hasElevation()&&(!$||$.usedDefines.has("RENDER_SHADOWS"));for(const ue of _e?[!1,!0]:[!1]){const me=ue?(G.defines||[]).concat(Vf):G.defines||[];for(const Ie of pe?[!1,!0]:[!1])for(const we of ce?[!1,!0]:[!1])for(const ve of oe?[!1,!0]:[!1])P(U,me,{params:G,fog:ve,terrain:Ie,globe:we})}Y&&P(U,re,{params:G,rtt:!0})}}if(P("clippingMask"),m)for(const B of[!1,!0])P("terrainRaster",B?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:f});if(!I){if(r.some(B=>B.type==="hillshade")&&P("hillshadePrepare"),w)for(const B of[!1,!0])for(const V of[!1,!0]){const U=[];B&&U.push("RENDER_CUTOFF"),U.push("RENDER_SHADOWS"),V&&U.push("NORMAL_OFFSET"),P("groundShadow",U),f&&P("groundShadow",U,{fog:!0})}if(g){for(const B of[[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(const V of[!1,!0]){const U=[...B,"PROJECTION_GLOBE_VIEW"];V&&U.push("CUSTOM_ANTIALIASING"),P("globeRaster",U,{terrain:m,globe:!0,fog:f})}for(const B of[!1,!0]){const V=B?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];P("globeAtmosphere",V,{fog:!0,terrain:m,globe:B}),P("globeAtmosphere",[...V,"ALPHA_PASS"],{fog:!0,terrain:m,globe:B})}P("stars",[],{fog:f,terrain:m,globe:!0})}}}_executeBatch(r,o,u){if(u.map&&u.map.isMoving())return void(this._idleHandle=d.e.requestIdleCallback(x=>this._executeBatch(x,o,u)));o.context.sweepPendingPrograms();const f=o.context.extParallelShaderCompile?Ny.DEADLINE_MARGIN_KHR_MS:Ny.DEADLINE_MARGIN_SYNC_MS;let m=0;for(;this._queue.length>0;){const x=this._queue.shift();if(!x||(o.style=u,o._fogVisible=!!x.params.overrideFog,o.getOrCreateProgram(x.programId,x.params),m++,r.timeRemaining()<=f))break}const g=this._queue.length===0||r.timeRemaining()>f;m>0&&g&&o.context.gl.flush(),this._idleHandle=this._queue.length>0||o.context._pendingPrograms.size>0?d.e.requestIdleCallback(x=>this._executeBatch(x,o,u)):null}processQueue(r,o){this._queue.length!==0&&(this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._idleHandle=d.e.requestIdleCallback(u=>this._executeBatch(u,r,o)))}reset(){this._idleHandle!=null&&typeof cancelIdleCallback<"u"&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0}};sc.DEADLINE_MARGIN_KHR_MS=5,sc.DEADLINE_MARGIN_SYNC_MS=25;let v_=sc;const Qu=d.s.colorTheme,rd=new d.af({data:new d.ag(Qu.data)});function eh(a){if(!a.metadata||!a.metadata.content_area)return;const r=d.e.devicePixelRatio,{left:o,top:u,width:f,height:m}=a.metadata.content_area,g=o*r,x=u*r;return[g,x,g+f*r,x+m*r]}function Uf(a){if(a)return a.map(([r,o])=>[r*d.e.devicePixelRatio,o*d.e.devicePixelRatio])}class b_{constructor(r,o,u){this.id=r,this.scope=o,this.sourceCache=u,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(r){this.missingRequests.has(r.name)||this.pendingRequests.has(r.name)||this.pendingRequests.add(r.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const r=new Map;if(!this.sourceCache.loaded())return r;const o=this.sourceCache.getVisibleCoordinates();if(o.length===0)return r;const u=this.sourceCache.getSource();if(u.type!=="raster-array")return r;const f=o.map(g=>this.sourceCache.getTile(g)),m=u.getImages(f,Array.from(this.pendingRequests));for(const[g,x]of m)r.set(d.I.from({name:g,iconsetId:this.id}),x),this.pendingRequests.delete(g);for(const g of this.pendingRequests)this.missingRequests.add(g);return this.pendingRequests.clear(),r}}const hl=(a,r)=>ha(a,r&&r.filter(o=>o.identifier!=="source.canvas")),nd=new Set(["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"]),jf=new Set(["setCenter","setZoom","setBearing","setP
3410itch"]),dl=new Set(["background","sky","slot","custom"]),Xc={version:8,layers:[],sources:{}},Yc={duration:300,delay:0};class fl extends d.E{constructor(r,o={}){super(),this.map=r,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={...Yc},this._buildingIndex=new Ff(this),this.crossTileSymbolIndex=new g_,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers=Object.create(null),this._mergedIndoor={},this._indoorEnabled=!1,this._mergedSourceCaches={},this._mergedOtherSourceCaches=Object.create(null),this._mergedSymbolSourceCaches=Object.create(null),this._mergedFillExtrusionSourceCaches=Object.create(null),this._mergedHdRoadCoverageSourceCaches=Object.create(null),this._mergedHdRoadElevationSourceCaches=Object.create(null),this._hdCoverage=null,this._hdElevation=null,this._crossSourceElevationActive=!1,this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=o.styleChanges||new Os,this._hasDataDrivenEmissive=!1,this.indoorManager=null,this.dispatcher=o.dispatcher?o.dispatcher:new It(Qh(),this);const u={referrer:d.d7(),config:d.dp()};if(this.map.painter&&this.map.painter.context){const m=this.map.painter.context.maxUniformBufferBindings,g=Math.floor(this.map.painter.context.maxUniformBlockSize/4);u.contextOptions={maxBindingPoints:m,maxUniformBlockSizeDwords:g}}this.isRootStyle()&&this.dispatcher.broadcast("setGlobalParams",u),o.imageManager?this.imageManager=o.imageManager:(this.imageManager=new lr(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=o.glyphManager?o.glyphManager:new d.d8(r._requestManager,o.localFontFamily?d.d9.all:o.localIdeographFontFamily?d.d9.ideographs:d.d9.none,o.localFontFamily||o.localIdeographFontFamily,o.fontstackCompositing),o.modelManager?this.modelManager=o.modelManager:(this.modelManager=new y_(r._requestManager),this.modelManager.setEventedParent(this)),this._layers=Object.create(null),this._sourceCaches={},this._otherSourceCaches=Object.create(null),this._symbolSourceCaches=Object.create(null),this._fillExtrusionSourceCaches=Object.create(null),this._hdCoverage=null,this._hdElevation=null,this._crossSourceElevationActive=!1,this._loaded=!1,this._initialBroadcastDone=!1,this._programPrecompiler=this.map._precompilePrograms&&this.isRootStyle()?new v_:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=o.configOptions?o.configOptions:new Map,this._layerExpressionDependencies=o.layerExpressionDependencies?o.layerExpressionDependencies:new Map,this._config=o.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:o.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=o.initialConfig;const f=this;this._rtlTextPluginCallback=fl.registerForPluginStateChange(m=>{f.dispatcher.send("syncRTLPluginState",{pluginStatus:m.pluginStatus,pluginURL:m.pluginURL}).then(g=>{if(d.da(null),g.every(x=>x))for(const x in f._sourceCaches){const w=f._sourceCaches[x],E=w.getSource().type;E!=="vector"&&E!=="geojson"||w.reload()}}).catch(g=>{d.da(g)})}),this.on("data",m=>{if(m.dataType!=="source"||m.sourceDataType!=="metadata")return;const g=this.getOwnSource(m.sourceId);if(g&&g.vectorLayerIds)for(const x in this._layers){const w=this._layers[x];w.source===g.id&&this._validateLayer(w)}})}load(r){return r?(typeof r=="string"?this.loadURL(r):this.loadJSON(r),this):this}_getGlobalId(r){if(!r)return null;if(typeof r=="string"){if(d.cg(r))return r;const o=d.db(r);if(!o.startsWith("http"))try{return new URL(o,location.href).toString()}catch{return o}return o}return`json://${d.dc(JSON.stringify(r))}`}_diffStyle(r,o,u){this.globalId=this._getGlobalId(r),qo();const f=(m,g)=>{try{g(null,this.setState(m,u))}catch(x){g(x,!1)}};if(typeof r=="string"){const m=this.map._requestManager.normalizeStyleURL(r),g=new AbortController;this._request={cancel:()=>g.abort()},(async()=>{const x=await this.map._requestManager.transformRequest(m,d.R.Style,g.signal),{data:w}=await d.g(x,g.signal);this._request=null,f(w,o)})().catch(x=>{this._request=null,g.signal.aborted||this.fire(new d.f(x))})}else typeof r=="object"&&f(r,o)}loadURL(r,o={}){this.fire(new d.h("dataloading",{dataType:"style"}));const u=typeof o.validate=="boolean"?o.validate:!d.cg(r);u&&qo(),this.globalId=this._getGlobalId(r),r=this.map._requestManager.normalizeStyleURL(r,o.accessToken),this.resolvedImports.add(r);const f=this.importsCache.get(r);if(f)return void this._load(f,u);const m=new AbortController;this._request={cancel:()=>m.abort()},(async()=>{const g=await this.map._requestManager.transformRequest(r,d.R.Style,m.signal),{data:x}=await d.g(g,m.signal);this._request=null,this.importsCache.set(r,x),this._load(x,u)})().catch(g=>{this._request=null,m.signal.aborted||this.fire(new d.f(g))})}loadJSON(r,o={}){this.fire(new d.h("dataloading",{dataType:"style"}));const u=o.validate!==!1;u&&qo(),this.globalId=this._getGlobalId(r),this._request=d.e.frame(()=>{this._request=null,this._load(r,u)})}loadEmpty(){this.fire(new d.h("dataloading",{dataType:"style"})),this._load(Xc,!1)}_loadImports(r,o,u){if(this.importDepth>=4)return d.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const f=[];for(const m of r){const g=this._createFragmentStyle(m),x=new Promise(I=>{g.once("style.import.load",I),g.once("error",I)}).then(()=>{this.mergeAll(),this.fire(new d.h("data",{dataType:"style"}))});if(f.push(x),this.resolvedImports.has(m.url)){g.loadEmpty();continue}const w=m.data||this.importsCache.get(m.url);w?(m.data?(g.fire(new d.h("dataloading",{dataType:"style"})),g.globalId=g._getGlobalId(w),o&&qo(),queueMicrotask(()=>{g._load(w,o)})):g.loadJSON(w,{validate:o}),this._isInternalStyle(w)&&(g.globalId=null)):m.url?g.loadURL(m.url,{validate:o}):g.loadEmpty();const E={style:g,id:m.id,config:m.config};if(u){const I=this.fragments.findIndex(({id:R})=>R===u);this.fragments=this.fragments.slice(0,I).concat(E).concat(this.fragments.slice(I))}else this.fragments.push(E)}return Promise.allSettled(f)}getImportGlobalIds(r=this,o=new Set){for(const u of r.fragments)u.style.globalId&&o.add(u.style.globalId),this.getImportGlobalIds(u.style,o);return[...o.values()]}_createFragmentStyle(r){const o=this.scope?d.m(r.id,this.scope):r.id;let u;const f=this._initialConfig&&this._initialConfig[o];(r.config||f)&&(u={...r.config,...f});const m=new fl(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:u,configOptions:this.options,colorThemeOverride:r["color-theme"],layerExpressionDependencies:this._layerExpressionDependencies});return m.setEventedParent(this.map,{style:m}),m}_reloadImports(r=!1){this.mergeAll(),this._updateMapProjection(),r||this.updateConfigDependencies(),this._updateLayers(this._dependentLayerIds(o=>o.isIndoorDependent)),this.map._triggerCameraUpdate(this.camera),(!r||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(r&&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(r){return this.isRootStyle()&&(r.fragment||!!r.schema&&r.fragment!==!1)}async _load(r,o){if(this._isInternalStyle(r)){const m={id:"basemap",data:r,url:""},g={...Xc,imports:[m],...r.center?{center:r.center}:{},...r.bearing?{bearing:r.bearing}:{},...r.pitch?{pitch:r.pitch}:{},...r.zoom?{zoom:r.zoom}:{},...r.light?{light:r.light}:{}};return this._importedAsBasemap=!0,void this._load(g,o)}if(this.updateConfig(this._config,r.schema),o&&(await qo(),!this.dispatcher.actors.length||hl(this,io(r))))return;this._loaded=!0;for(const m in r.sources)this.addSource(m,r.sources[m],{validate:!1,isInitialLoad:!0});this.stylesheet=d.dd(r);const u=()=>{if(r.iconsets)for(const E in r.iconsets)this.addIconset(E,r.iconsets[E]);r.sprite?this._loadIconset(r.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope})),!this.glyphManager.url&&r.glyphs&&this.glyphManager.setURL(r.glyphs);
vendor: 241,400 bytes, lines 3410-3415
3410const m=Gc(this.stylesheet.layers);if(this._order=m.map(E=>E.id),this.stylesheet.light&&d.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"){const E=this.stylesheet.lights[0];this.light=new Q(E.properties,E.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Q(this.stylesheet.light)),this._layers=Object.create(null);let g=!1;for(const E of m){const I=d.dj(E,this.scope,this._styleColorTheme.lut,this.options);this._layerExpressionDependencies.set(I.fqid,new Bs(I)),this._hasAppearances=this._hasAppearances||I.getAppearances().length!==0,I.setEventedParent(this,{layer:{id:I.id}}),this._layers[I.id]=I,this._updateHdCoverageSourceCache(I)&&(g=!0);const R=this.getOwnLayerSourceCache(I),P=!!this.directionalLight&&this.directionalLight.shadowsEnabled();R&&I.canCastShadows()&&P&&(R.castsShadows=!0)}if(g&&Zn().then(()=>{if(!this.map)return;for(const I in this._layers)this._updateHdCoverageSourceCache(this._layers[I]);this.map.style.mergeAll();const E=this.map.transform;for(const I in this.map.style._mergedHdRoadCoverageSourceCaches){const R=this.map.style._mergedHdRoadCoverageSourceCaches[I];R.used=!0,E&&R.update(E)}this.map._update()}),this.glyphManager.url){const E=new Set;for(const I in this._layers){const R=this._layers[I];if(R.type==="symbol"&&R.layout){const P=R.layout.get("text-font");P&&P.value&&P.value.kind==="constant"&&E.add(P.value.value.join(","))}}for(const I of E)this.glyphManager.prefetchRange(I,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const x=this.stylesheet.terrain;x&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(x,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 d.h("data",{dataType:"style"}));const w=this.isRootStyle();r.imports?this._loadImports(r.imports,o).then(()=>{this._reloadImports(!0),this.fire(new d.h(w?"style.load":"style.import.load"))}).catch(E=>{this.fire(new d.f(new Error("Failed to load imports",E))),this.fire(new d.h(w?"style.load":"style.import.load"))}):(this._reloadImports(!0),this.fire(new d.h(w?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const f=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(f){const m=this._evaluateColorThemeData(f);this._loadColorTheme(m).then(()=>{u()}).catch(g=>{d.w(`Couldn't load color theme from the stylesheet: ${g}`),u()})}else this._styleColorTheme.lut=null,u()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(r=>r.style.hasAppearances())}mergeAll(){let r,o,u,f,m,g,x,w,E,I;const R={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(P=>{if(P.stylesheet){if(P.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),P.light!=null&&(r=P.light),P.stylesheet.lights)for(const B of P.stylesheet.lights)B.type==="ambient"&&P.ambientLight!=null&&(o=P.ambientLight),B.type==="directional"&&P.directionalLight!=null&&(u=P.directionalLight);f=this._prioritizeTerrain(f,P.terrain,P.stylesheet.terrain),P.stylesheet.fog&&P.fog!=null&&(m=P.fog),P.stylesheet.snow&&P.snow!=null&&(g=P.snow),P.stylesheet.rain&&P.rain!=null&&(x=P.rain),P.stylesheet.camera!=null&&(I=P.stylesheet.camera),P.stylesheet.projection!=null&&(w=P.stylesheet.projection),P.stylesheet.transition!=null&&(E=P.stylesheet.transition),R[P.scope]=P._styleColorTheme}}),this.light=r,this.ambientLight=o,this.directionalLight=u,this.fog=m,this.snow=g,this.rain=x,this._styleColorThemeForScope=R,f===null?delete this.terrain:this.terrain=f,this.camera=I||{"camera-projection":"perspective"},this.projection=w||{name:"mercator"},this.transition={...Yc,...E},this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset()}forEachFragmentStyle(r){const o=u=>{for(const f of u.fragments)o(f.style);r(u)};o(this)}_prioritizeTerrain(r,o,u){const f=r&&r.drapeRenderMode===0;return u===null?o&&o.drapeRenderMode===0?o:f?r:null:o!=null&&(!r||f||o&&o.drapeRenderMode===1)?o:r}mergeTerrain(){let r;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(o=>{r=this._prioritizeTerrain(r,o.terrain,o.stylesheet.terrain)}),r===null?delete this.terrain:this.terrain=r,this._programPrecompiler&&this._programPrecompiler.reset()}mergeProjection(){let r;this.forEachFragmentStyle(o=>{o.stylesheet.projection!=null&&(r=o.stylesheet.projection)}),this.projection=r||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset()}mergeSources(){const r={},o=Object.create(null),u=Object.create(null),f=Object.create(null),m=Object.create(null),g=Object.create(null);this.forEachFragmentStyle(x=>{for(const w in x._sourceCaches){const E=d.m(w,x.scope);r[E]=x._sourceCaches[w]}for(const w in x._otherSourceCaches){const E=d.m(w,x.scope);o[E]=x._otherSourceCaches[w]}for(const w in x._symbolSourceCaches){const E=d.m(w,x.scope);u[E]=x._symbolSourceCaches[w]}for(const w in x._fillExtrusionSourceCaches){const E=d.m(w,x.scope);f[E]=x._fillExtrusionSourceCaches[w]}if(x._hdCoverage){const w=x._hdCoverage.coverageSourceCaches;for(const E in w)m[d.m(E,x.scope)]=w[E]}if(x._hdElevation){const w=x._hdElevation.elevationSourceCaches;for(const E in w)g[E]=w[E]}}),this._mergedSourceCaches=r,this._mergedOtherSourceCaches=o,this._mergedSymbolSourceCaches=u,this._mergedFillExtrusionSourceCaches=f,this._mergedHdRoadCoverageSourceCaches=m,this._mergedHdRoadElevationSourceCaches=g,Object.keys(m).length>0&&!this._hdCoverage&&Tt.HdCoverageState&&(this._hdCoverage=new Tt.HdCoverageState),Tt.updateCrossSourceElevationGate&&Tt.updateCrossSourceElevationGate(this)}mergeIndoor(){this._mergedIndoor={},this.forEachFragmentStyle(r=>{if(r.stylesheet&&r.stylesheet.indoor)for(const o of Object.values(r.stylesheet.indoor)){const u=o,f=d.m(u.sourceId,r.scope);this._mergedIndoor[f]=new Set(u.sourceLayers||[])}}),this._updateIndoorEnabled()}_updateIndoorEnabled(){const r=this._indoorEnabled;if(this._indoorEnabled=!1,Object.keys(this._mergedIndoor).length>0)for(const o of this._mergedOrder){const u=this._mergedLayers[o];if(u.visibility!=="none"&&this._mergedIndoor[d.m(u.source,u.scope)]){this._indoorEnabled=!0;break}}!this._indoorEnabled||r||this.indoorManager||Zn().then(()=>{this._initIndoorManager()})}_initIndoorManager(){if(!this.indoorManager&&Tt.IndoorManager&&this.isRootStyle()&&Object.keys(this._mergedIndoor).length!==0&&(this.indoorManager=new Tt.IndoorManager(this,this._loaded),this._loaded))for(const r of Object.keys(this._mergedIndoor)){const o=this._mergedSourceCaches[r]||this._mergedOtherSourceCaches[r];o&&o.reload()}}mergeLayers(){const r={},o=[],u=Object.create(null);this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(g=>{for(const x of g._order){const w=g._layers[x];if(w.type==="slot"){const E=d.bV(x);if(r[E])continue;r[E]=[]}w.slot&&r[w.slot]?r[w.slot].push(w):o.push(w)}}),this._mergedOrder=[];let f=-1;const m=(g=[])=>{for(const x of g)if(x.type==="slot"){const w=d.bV(x.id);r[w]&&m(r[w]),this._mergedSlots.push(w)}else{const w=d.m(x.id,x.scope);this._mergedOrder.push(w),u[w]=x,x.is3D(!!this.terrain)&&(this._has3DLayers=!0,f=this._mergedOrder.length-1),x.type==="circle"&&(this._hasCircleLayers=!0),x.type==="symbol"&&(this._hasSymbolLayers=!0),x.type==="clip"&&(this._clipLayerPresent=!0)}};if(m(o),this._has3DLayers){const g={};for(let x=0;x<this._mergedOrder.length;++x){const w=this._mergedOrder[x];g[w]=x===f?1:x<f?u[w].hasOcclusionOpacityProperties?2:0:4}this._mergedOrder.sort((x,w)=>g[x]-g[w])}this._mergedLayers=u,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(r){return this.stylesheet.camera={...this.stylesheet.camera,...r},this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(r){return r.data?function(o,u,f){const m={...u};for(const x of Object.keys(Qu))m[x]===void 0&&(m[x]=Qu[x].default);const g=new d.ae(rd,o,new Map(f));return g.setTransitionOrValue(m,f),g.untransitioned().possiblyEvaluate(new d.ai(0,{worldview:void 0}))}(this.scope,r,this.options).get("data"):null}_loadColorTheme(r){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const o=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((u,f)=>{const m="data:image/png;base64,";if(!r||r.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void u();let g=r;g.startsWith(m)||(g=m+g);const x=d.I.from("mapbox-reserved-lut"),w=new Image;w.src=g,w.onerror=()=>{this._styleColorTheme.lutLoading=!1,f(new Error("Failed to load image data"))},w.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==o)return void u();this._styleColorTheme.lutLoading=!1;const{width:E,height:I,data:R}=d.e.getImageData(w);if(I>32)return void f(new Error("The height of the image must be less than or equal to 32 pixels."));if(E!==I*I)return void f(new Error("The width of the image must be equal to the height squared."));this.getImage(x)&&this.removeImage(x),this.addImage(x,{data:new d.b({width:E,height:I},R),pixelRatio:1,sdf:!1,usvg:!1,version:0});const P=this.imageManager.getImage(x,this.scope);P?(this._styleColorTheme.lut={image:P.data,data:r},u()):f(new Error("Missing LUT image."))}})}getLut(r){const o=this._styleColorThemeForScope[r];return o?o.lut:null}setProjection(r){r?this.stylesheet.projection=r: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.hasTerrain()||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(r){const o=new AbortController;this._spriteRequest=o,function(u,f,m,g){let x,w,E;const I=d.e.devicePixelRatio>1?"@2x":"";function R(P){E||P&&m.aborted||(P&&(E=P),function(){if(E)g(E);else if(x&&w){const B=d.e.getImageData(w),V={};for(const U in x){const{width:G,height:$,x:Y,y:re,sdf:oe,pixelRatio:pe,stretchX:ce,stretchY:_e,content:ue}=x[U],me=new d.b({width:G,height:$});d.b.copy(B,me,{x:Y,y:re},{x:0,y:0},{width:G,height:$},null),V[U]={data:me,pixelRatio:pe!==void 0?pe:1,sdf:oe!==void 0&&oe,stretchX:ce,stretchY:_e,content:ue,usvg:!1,version:0}}g(null,V)}}())}(async function(){const P=await f.transformRequest(f.normalizeSpriteURL(u,I,".json"),d.R.SpriteJSON,m),{data:B}=await d.g(P,m);E||(x=B)})().then(()=>R(void 0),P=>R(P)),async function(){const P=await f.transformRequest(f.normalizeSpriteURL(u,I,".png"),d.R.SpriteImage,m),{data:B}=await d.a(P,m);E||(w=B)}().then(()=>R(void 0),P=>R(P))}(r,this.map._requestManager,o.signal,(u,f)=>{if(this._spriteRequest=null,u)this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new d.f(u));else if(f){const m=new Map;for(const g in f)m.set(d.I.from(g),f[g]);this.addImages(m,!0)}this.imageManager.setLoaded(!0,this.scope),this.fire(new d.h("data",{dataType:"style"}))})}addIconset(r,o){if(o.type==="sprite")return void this._loadSprite(o.url);const u=this.getOwnSourceCache(o.source);if(!u)return void this.fire(new d.f(new Error(`Source "${o.source}" as specified by iconset "${r}" does not exist and cannot be used as an iconset source`)));if(u.getSource().type!=="raster-array")return void this.fire(new d.f(new Error(`Source "${o.source}" as specified by iconset "${r}" is not a "raster-array" source and cannot be used as an iconset source`)));const f=new b_(r,this.scope,u);this.imageManager.addImageProvider(f,this.scope)}removeIconset(r){this.imageManager.removeImageProvider(r,this.scope)}_loadIconset(r){if(!d.cg(r)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(r);const o=this.map._spriteFormat==="auto",u=new AbortController;this._spriteRequest=u,async function(f,m,g,x){try{const w=await m.transformRequest(m.normalizeIconsetURL(f),d.R.Iconset,g),{data:E}=await d.cC(w,g),I={},R=function(P){const B={icons:[]};let V;for(;V=P.nextField(void 0);)V===1&&B.icons.push(zu(P,P.readVarint()+P.pos));return B}(new d.cB(E));for(const P of R.icons){const B={version:1,pixelRatio:d.e.devicePixelRatio,content:eh(P),stretchX:P.metadata?Uf(P.metadata.stretch_x_areas):void 0,stretchY:P.metadata?Uf(P.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:P};I[P.name]=B}x(null,I)}catch(w){g.aborted||x(w)}}(r,this.map._requestManager,u.signal,(f,m)=>{if(this._spriteRequest=null,f)o?this._loadSprite(r):(this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new d.f(f)));else if(m){const g=new Map;for(const x in m)g.set(d.I.from(x),m[x]);this.addImages(g,!0)}this.imageManager.setLoaded(!0,this.scope),this.fire(new d.h("data",{dataType:"style"}))})}_validateLayer(r){const o=this.getOwnSource(r.source);if(!o)return;const u=r.sourceLayer;u&&(o.type==="geojson"||o.vectorLayerIds&&!o.vectorLayerIds.includes(u))&&this.fire(new d.f(new Error(`Source layer "${u}" does not exist on source "${o.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const r in this._sourceCaches)if(!this._sourceCaches[r].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:r}of this.fragments)if(!r.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((r,o)=>{const u=this.fragments[o];return u&&u.style&&(r.data=u.style.serialize()),r})}_serializeSources(){const r={};for(const o in this._sourceCaches){const u=this._sourceCaches[o].getSource();r[u.id]||(r[u.id]=u.serialize())}return r}_serializeLayers(r){const o=[];for(const u of r){const f=this._layers[u];f&&f.type!=="custom"&&o.push(f.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(const r in this._sourceCaches)if(this._sourceCaches[r].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const r in this._mergedLayers){const o=this._mergedLayers[r];if(o._transitionablePaint&&o._transitionablePaint._values){const u=o._transitionablePaint._values["line-emissive-strength"];if(u&&u.value&&u.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(r){return r?this.order:this._mergedOrder}isLayerDraped(r){return!!this.terrain&&r.isDraped(this.getLayerSourceCache(r))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(r){const o=this.getOwnLayer(r);if(o)return o;this.fire(new d.f(new Error(`The layer '${r}' does not exist in the map's style.`)))}_checkSource(r){const o=this.getOwnSource(r);if(o)return o;this.fire(new d.f(new Error(`The source '${r}' does not exist in the map's style.`)))}_resolveLayerFragment(r){const o=this.getLayer(r);if(!o)return void this.fire(new d.f(new Error(`The layer '${r}' does not exist in the map's style.`)));const u=this.getFragmentStyle(o.scope);return u?{layer:o,fragment:u}:void 0}handleIdle(){const r=this.map.painter;r&&(r.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(r,this))}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset()}update(r){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r);const o=this.calculateLightsBrightness();r.brightness=o||0;let u=!1;o!==this._brightness&&(this._brightness=o,u=!0),r.worldview!==this._worldview&&(this._worldview=r.worldview,u=!0),u&&this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness,worldview:this._worldview});const f=this._changes.isDirty();let m=!1;if(this._changes.isDirty()){const E=this._changes.getLayerUpdatesByScope();for(const I in E){const{updatedIds:R,removedIds:P}=E[I];(R||P)&&(this._updateWorkerLayers(I,R,P),m=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(r),this.light&&this.light.updateTransitions(r),this.ambientLight&&this.ambientLight.updateTransitions(r),this.directionalLight&&this.directionalLight.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this.snow&&this.snow.updateTransitions(r),this.rain&&this.rain.updateTransitions(r),this._changes.reset()}const g={};for(const E in this._mergedSourceCaches){const I=this._mergedSourceCaches[E];g[E]=I.used,I.used=!1,I.tileCoverLift=0}const x={};for(const E of this._mergedOrder){const I=this._mergedLayers[E];if((I.visibility!=="none"||I.hasTransition())&&I.recalculate(r,this._availableImages),!I.isHidden(r.zoom)){I.mayUse("HD")&&(I.prepare(),Zn()),I.mayUse("Standard")&&(I.prepare(),Zt());const R=this.getLayerSourceCache(I);R&&(R.used=!0,R.tileCoverLift=Math.max(R.tileCoverLift,I.tileCoverLift()))}if(I.source){const R=d.m(I.source,I.scope),P=this._mergedHdRoadCoverageSourceCaches[R];P&&!P.used&&(P.used=!0)}if(I.type==="fill-extrusion"){const R=d.m(I.source,I.scope);if(R in this._mergedFillExtrusionSourceCaches){const P=I.layout&&I.layout.get("source-max-zoom");if(P!=null){const B=x[R];x[R]=B==null?P:Math.min(B,P)}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){const E=this._mergedOrder.map(I=>this._mergedLayers[I]);this._programPrecompiler.buildQueue(E,r,this)}for(const E in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[E].setMaxzoomOverride(x[E]??null);this.terrain&&m&&this.mergeLayers();const w=this.imageManager.getPendingImageProviders();for(const E of w)E.sourceCache.used=!0;for(const E in g){const I=this._mergedSourceCaches[E];g[E]!==I.used&&I.getSource().fire(new d.h("data",{sourceDataType:"visibility",dataType:"source",sourceId:I.getSource().id}))}this.light&&this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.snow&&this.snow.recalculate(r),this.rain&&this.rain.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),f&&this.fire(new d.h("data",{dataType:"style"}))}updateImageProviders(){const r=this.imageManager.getPendingImageProviders();for(const o of r){const u=o.resolvePendingRequests(),f=this.getFragmentStyle(o.scope);f&&f.addImages(u)}}_updateTilesForChangedImages(){const r={};for(const o in this._mergedSourceCaches){const u=this._mergedSourceCaches[o].getSource().scope;r[u]=r[u]||this._changes.getUpdatedImages(u),r[u].length!==0&&this._mergedSourceCaches[o].reloadTilesForDependencies(["icons","patterns"],r[u])}for(const o in r)this._changes.resetUpdatedImages(o)}_updateWorkerLayers(r,o,u){const f=this.getFragmentStyle(r);f&&this.dispatcher.broadcast("updateLayers",{layers:o?f._serializeLayers(o):[],scope:r,removedIds:u||[],options:f.options})}setState(r,o){if(this._checkLoaded(),hl(this,io(r)))return!1;if((r=d.dd(r)).layers=Gc(r.layers),!Gn.diffStyles)throw new Error("Debug module not loaded; cannot diff style.");const u=Gn.diffStyles(this.serialize(),r).filter(g=>!jf.has(g.command));if(u.length===0)return!1;const f=u.filter(g=>!nd.has(g.command));if(f.length>0)throw new Error(`Unimplemented: ${f.map(g=>g.command).join(", ")}.`);const m=[];return u.forEach(g=>{m.push(this[g.command](...g.args))}),o&&Promise.all(m).then(o).catch(o),this.stylesheet=r,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(r=!1){this._availableImages=this.imageManager.listImages(this.scope);const o={scope:this.scope,images:this._availableImages};r&&(o.isSpriteLoaded=!0),this.dispatcher.broadcast("setImages",o)}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(r,o){if(r.size===0)return o&&this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this;for(const[u,f]of r.entries()){if(this.getImage(u))return this.fire(new d.f(new Error(`An image with the name "${u.name}" already exists.`)));this.imageManager.addImage(u,this.scope,f),this._changes.updateImage(u,this.scope)}return this._updateWorkerImages(o),this.fire(new d.h("data",{dataType:"style"})),this}addImage(r,o){return this.getImage(r)?this.fire(new d.f(new Error(`An image with the name "${r.name}" already exists.`))):(this.imageManager.addImage(r,this.scope,o),this._changes.updateImage(r,this.scope),this._updateWorkerImages(),this.fire(new d.h("data",{dataType:"style"})),this)}updateImage(r,o,u=!1){this.imageManager.updateImage(r,this.scope,o),u&&(this._changes.updateImage(r,this.scope),this._updateWorkerImages(),this.fire(new d.h("data",{dataType:"style"})))}getImage(r){return this.imageManager.getImage(r,this.scope)}removeImage(r){return this.getImage(r)?(this.imageManager.removeImage(r,this.scope),this._changes.updateImage(r,this.scope),this._updateWorkerImages(),this.fire(new d.h("data",{dataType:"style"})),this):this.fire(new d.f(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(r){return this.modelManager.addModelURLs(r,this.getActualScope()),this._updateWorkerModels(),this.fire(new d.h("data",{dataType:"style"})),this}addModel(r,o,u={}){return this._checkLoaded(),this._validate(q,`models.${r}`,o,null,u)||(this.modelManager.addModel(r,o,this.getActualScope()),this.fire(new d.h("data",{dataType:"style"}))),this}hasModel(r){return this.modelManager.hasModel(r,this.getActualScope())}removeModel(r){return this.hasModel(r)?(this.modelManager.removeModel(r,this.getActualScope(),!1,!0),this.fire(new d.h("data",{dataType:"style"})),this):this.fire(new d.f(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(r,o,u={}){if(this._checkLoaded(),this.getOwnSource(r)!==void 0)throw new Error(`There is already a source with ID "${r}".`);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(ju,`sources.${r}`,o,null,u))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);const f=Object.hasOwn(Ks,o.type)&&!xa(o.type),m=f?new d_(r,o,this.dispatcher,this):Xu(r,o,this.dispatcher,this);m.scope=this.scope;const g=w=>{w.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(w.id),source:w.serialize(),sourceId:w.id}))};g(m);const x=w=>{const E=(w===d.bR.Symbol?"symbol:":w===d.bR.FillExtrusion?"fill-extrusion:":"other:")+m.id,I=d.m(E,this.scope),R=this._sourceCaches[E]=new Tn(I,m,w);w===d.bR.Symbol?this._symbolSourceCaches[m.id]=R:w===d.bR.FillExtrusion?this._fillExtrusionSourceCaches[m.id]=R:this._otherSourceCaches[m.id]=R,R.onAdd(this.map)};x(d.bR.Other),o.type!=="vector"&&o.type!=="geojson"||(x(d.bR.Symbol),o.type==="vector"&&x(d.bR.FillExtrusion)),m.onAdd&&m.onAdd(this.map),f&&async function(w){if(xa(w))return;const E=Ks[w];if(!E)throw new Error(`Unknown source type "${w}"`);const I=await E();I&&!xa(w)&&function(R,P){En[R]=P}(w,I)}(o.type).then(()=>{const w=xa(o.type),E=this._otherSourceCaches[r];if(!E||E.getSource()!==m)return;if(!w)return void this.fire(new d.f(new Error(`Could not load module for source type "${o.type}".`)));const I=Xu(r,o,this.dispatcher,this);I.scope=this.scope,g(I),E.setSource(I),I.onAdd&&I.onAdd(this.map),this._changes.setDirty()}),u.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(r){this._checkLoaded();const o=this.getOwnSource(r);if(!o)throw new Error("There is no source with this ID");for(const f in this._layers)if(this._layers[f].source===r)return this.fire(new d.f(new Error(`Source "${r}" cannot be removed while layer "${f}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===r)return this.fire(new d.f(new Error(`Source "${r}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const f=Object.entries(this.stylesheet.iconsets).find(([m,g])=>g.type==="source"&&g.source===r);if(f)return this.fire(new d.f(new Error(`Source "${r}" cannot be removed while iconset "${f[0]}" is using it.`)))}const u=this.getOwnSourceCaches(r);for(const f of u){const m=d.bV(f.id);delete this._sourceCaches[m],this._changes.discardSourceCacheUpdate(f.id),f.fire(new d.h("data",{sourceDataType:"metadata",dataType:"source",sourceId:f.getSource().id})),f.setEventedParent(null),f.clearTiles()}return delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],delete this._fillExtrusionSourceCaches[r],this._hdCoverage&&delete this._hdCoverage.coverageSourceCaches[r],this._hdElevation&&delete this._hdElevation.elevationSourceCaches[d.m(r,this.scope)],this.mergeSources(),o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this.dispatcher.broadcast("removeSource",{type:o.type,source:r,scope:o.scope}),this._changes.setDirty(),this}setGeoJSONSourceData(r,o){this._checkLoaded(),this.getOwnSource(r).setData(o),this._changes.setDirty()}getOwnSource(r){const o=this.getOwnSourceCache(r);return o&&o.getSource()}getOwnSources(){const r=[];for(const o in this._otherSourceCaches){const u=this.getOwnSourceCache(o);u&&r.push(u.getSource())}return r}areTilesLoaded(){const r=this._mergedSourceCaches;for(const o in r){const u=r[o]._tiles;for(const f in u){const m=u[f];if(m.state!=="loaded"&&m.state!=="errored")return!1}}return!0}setLights(r){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!r)return delete this.ambientLight,void delete this.directionalLight;const o=this._getTransitionParameters();for(const m of r){if(this._validate(Yl,"lights",m))return;switch(m.type){case"ambient":if(this.ambientLight){const g=this.ambientLight;g.set(m),g.updateTransitions(o)}else this.ambientLight=new Nt(m,Gt(),this.scope,this.options);break;case"directional":if(this.directionalLight){const g=this.directionalLight;g.set(m),g.updateTransitions(o)}else this.directionalLight=new Nt(m,xi(),this.scope,this.options)}}const u=Object.assign(o,{worldview:this.map.getWorldview()}),f=new d.ai(this.z||0,u);this.ambientLight&&this.ambientLight.recalculate(f),this.directionalLight&&this.directionalLight.recalculate(f),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness})}calculateLightsBrightness(){const r=this.directionalLight,o=this.ambientLight;if(!r||!o)return;const u=P=>.2126*(P[0]<=.03928?P[0]/12.92:Math.pow((P[0]+.055)/1.055,2.4))+.7152*(P[1]<=.03928?P[1]/12.92:Math.pow((P[1]+.055)/1.055,2.4))+.0722*(P[2]<=.03928?P[2]/12.92:Math.pow((P[2]+.055)/1.055,2.4)),f=r.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),m=r.properties.get("intensity"),g=r.properties.get("direction"),x=1-d.de(g.x,g.y,g.z)[2]/90,w=u(f)*m*x,E=o.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),I=o.properties.get("intensity"),R=u(E)*I;return Number(((w+R)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const r=[];return this.directionalLight&&r.push(this.directionalLight.get()),this.ambientLight&&r.push(this.ambientLight.get()),r}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(r){if(r==null||r===""&&this.isRootStyle())return this;if(d.df(r)){const o=d.dg(r),u=this.fragments.find(({id:m})=>m===o);if(!u)return;const f=d.bV(r);return u.style.getFragmentStyle(f)}{const o=this.fragments.find(({id:u})=>u===r);return o?o.style:void 0}}setFeaturesetSelectors(r){if(!r)return;const o=(u,f="")=>`${u}::${f}`;this._featuresetSelectors={};for(const u in r){const f={},m=this._featuresetSelectors[u]=[];for(const g of r[u].selectors){if(g.featureNamespace){const w=this.getOwnLayer(g.layer);if(!w){d.w(`Layer is undefined for selector: ${g.layer}`);continue}const E=o(w.source,w.sourceLayer);if(E in f&&f[E]!==g.featureNamespace){d.w(`"featureNamespace ${g.featureNamespace} of featureset ${u}'s selector is not associated to the same source, skip this selector`);continue}f[E]=g.featureNamespace}let x;if(g.properties)for(const w in g.properties){const E=d.c(g.properties[w]);E.result==="success"&&(x=x||{},x[w]=E.value)}m.push({layerId:g.layer,namespace:g.featureNamespace,properties:x,uniqueFeatureID:g._uniqueFeatureID})}}}getFeaturesetDescriptors(r){const o=this.getFragmentStyle(r);if(!o||!o.stylesheet.featuresets)return[];const u=[];for(const f in o.stylesheet.featuresets)u.push({featuresetId:f,importId:o.scope?o.scope:void 0});return u}getFeaturesetLayers(r,o){const u=this.getFragmentStyle(o),f=u.stylesheet.featuresets;if(!f||!f[r])return this.fire(new d.f(new Error(`The featureset '${r}' does not exist in the map's style and cannot be queried.`))),[];const m=[];for(const g of f[r].selectors){const x=u.getOwnLayer(g.layer);x&&m.push(x)}return m}getConfigProperty(r,o){const u=this.getFragmentStyle(r);if(!u)return null;const f=d.m(o,u.scope),m=u.options.get(f),g=m?m.value||m.default:null;return g?g.serialize():null}isIndoorEnabled(){return this._indoorEnabled}getIndoorSourceLayers(r,o){const u=d.m(r,o);return this._mergedIndoor[u]}setIndoorData(r,o){this.indoorManager&&this.indoorManager.setIndoorData(o)}updateIndoorDependentLayers(){this._updateLayers(this._dependentLayerIds(r=>r.isIndoorDependent)),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(r,o,u){const f=this.getFragmentStyle(r);if(!f)return;const m=f.stylesheet.schema;if(!m||!m[o])return;const g=d.dh(u,m[o]);if(g.result!=="success")return void hl(this,g.value);const x=g.value.expression,w=d.m(o,f.scope),E=f.options.get(w);if(!E)return;let I;const{minValue:R,maxValue:P,stepValue:B,type:V,values:U}=m[o],G=d.dh(m[o].default,m[o]);G.result==="success"&&(I=G.value.expression),I?(this.options.set(w,{...E,value:x,default:I,minValue:R,maxValue:P,stepValue:B,type:V,values:U}),this.updateConfigDependencies(o)):this.fire(new d.f(new Error(`No schema defined for the config option "${o}" in the "${r}" fragment.`)))}getConfig(r){const o=this.getFragmentStyle(r);if(!o)return null;const u=o.stylesheet.schema;if(!u)return null;const f={};for(const m in u){const g=d.m(m,o.scope),x=o.options.get(g),w=x?x.value||x.default:null;f[m]=w?w.serialize():null}return f}setConfig(r,o){const u=this.getFragmentStyle(r);u&&(u.updateConfig(o,u.stylesheet.schema),this.updateConfigDependencies())}getSchema(r){const o=this.getFragmentStyle(r);return o?o.stylesheet.schema:null}setSchema(r,o){const u=this.getFragmentStyle(r);u&&(u.stylesheet.schema=o,u.updateConfig(u._config,o),this.updateConfigDependencies())}updateConfig(r,o){if(this._config=r,r||o)if(o)for(const u in o){let f,m;const g=d.dh(o[u].default,o[u]);if(g.result==="success"&&(f=g.value.expression),r&&r[u]!==void 0){const P=d.dh(r[u],o[u]);P.result==="success"&&(m=P.value.expression)}const{minValue:x,maxValue:w,stepValue:E,type:I,values:R}=o[u];if(f){const P=d.m(u,this.scope);this.options.set(P,{default:f,value:m,minValue:x,maxValue:w,stepValue:E,type:I,values:R})}else this.fire(new d.f(new Error(`No schema defined for config option "${u}".`)))}else this.fire(new d.f(new Error("Attempting to set config for a style without schema.")))}_updateLayers(r){for(const o of r){const u=this.getLayer(o);u&&(u.possiblyEvaluateVisibility(),this._updateLayer(u),this._changes.setDirty())}}_dependentLayerIds(r){const o=[];for(const[u,f]of this._layerExpressionDependencies)r(f)&&o.push(u);return o}updateConfigDependencies(r){this._updateLayers(this._dependentLayerIds(o=>r?o.hasConfigDependency(r):o.isConfigDependent)),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=>{const u=o._styleColorTheme.colorThemeOverride?o._styleColorTheme.colorThemeOverride:o._styleColorTheme.colorTheme;if(u){const f=o._evaluateColorThemeData(u);(!o._styleColorTheme.lut&&f!==""||o._styleColorTheme.lut&&f!==o._styleColorTheme.lut.data)&&o.setColorTheme(u)}}),this._updateIndoorEnabled(),this._changes.setDirty()}addLayer(r,o,u={}){this._checkLoaded();const f=r.id;if(this._layers[f])return void this.fire(new d.f(new Error(`Layer with id "${f}" already exists on this map`)));let m;if(r.type==="custom"){if(hl(this,d.di(r)))return;m=d.dj(r,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof r.source=="object"&&(this.addSource(f,r.source),r=d.dd(r),r=Object.assign(r,{source:f})),this._validate(tl,`layers.${f}`,r,{arrayIndex:-1},u))return;m=d.dj(r,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(m),m.setEventedParent(this,{layer:{id:f}})}this._layerExpressionDependencies.set(m.fqid,new Bs(m));let g=this._order.length;if(o){const I=this._order.indexOf(o);if(I===-1)return void this.fire(new d.f(new Error(`Layer with id "${o}" does not exist on this map.`)));m.slot&&m.slot!==this._layers[o].slot?d.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`):g=I}this._order.splice(g,0,f),this._handleLayerOrderChange(),this._layers[f]=m;const x=this.getOwnLayerSourceCache(m),w=!!this.directionalLight&&this.directionalLight.shadowsEnabled();x&&m.canCastShadows()&&w&&(x.castsShadows=!0);const E=this._changes.getRemovedLayer(m);if(E&&m.source&&x&&m.type!=="custom"){this._changes.discardLayerRemoval(m);const I=d.m(m.source,m.scope);E.type!==m.type?this._changes.updateSourceCache(I,"clear"):(this._changes.updateSourceCache(I,"reload"),x.pause())}this._updateLayer(m),m.onAdd&&m.onAdd(this.map),m.scope=this.scope,this.mergeLayers()}moveLayer(r,o){this._checkLoaded();const u=this._checkLayer(r);if(!u||r===o)return;const f=this._order.indexOf(r);this._order.splice(f,1);let m=this._order.length;if(o){const g=this._order.indexOf(o);if(g===-1)return void this.fire(new d.f(new Error(`Layer with id "${o}" does not exist on this map.`)));u.slot&&u.slot!==this._layers[o].slot?d.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`):m=g}this._order.splice(m,0,r),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(r){this._checkLoaded();const o=this._checkLayer(r);if(!o)return;o.setEventedParent(null);const u=this._order.indexOf(r);this._order.splice(u,1),delete this._layers[r],this._changes.setDirty(),this._handleLayerOrderChange(),this._layerExpressionDependencies.delete(o.fqid),this._changes.removeLayer(o);const f=this.getOwnLayerSourceCache(o);if(f&&f.castsShadows){let m=!1;for(const g in this._layers)if(this._layers[g].source===o.source&&this._layers[g].canCastShadows()){m=!0;break}f.castsShadows=m}o.onRemove&&o.onRemove(this.map),this.mergeLayers()}getOwnLayer(r){return this._layers[r]}hasLayer(r){return r in this._mergedLayers}hasLayerType(r){for(const o in this._layers)if(this._layers[o].type===r)return!0;return!1}setLayerZoomRange(r,o,u){this._checkLoaded();const f=this._checkLayer(r);f&&(f.minzoom===o&&f.maxzoom===u||(o!=null&&(f.minzoom=o),u!=null&&(f.maxzoom=u),this._updateLayer(f)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(r,o){this._checkLoaded();const u=this._checkLayer(r);u&&u.slot!==o&&(u.slot=o,this._updateLayer(u))}setFilter(r,o,u={}){this._checkLoaded();const f=this._checkLayer(r);if(!f||d.O(f.filter,o))return;const m=this._layerExpressionDependencies.get(f.fqid);if(o==null)return f.filter=void 0,m&&m.invalidateFilter(),void this._updateLayer(f);this._validate(Z,`layers.${f.id}.filter`,o,{layerType:f.type},u)||(f.filter=d.dd(o),m&&m.invalidateFilter(),this._updateLayer(f))}getFilter(r){const o=this._checkLayer(r);if(o)return d.dd(o.filter)}setLayoutProperty(r,o,u,f={}){this._checkLoaded();const m=this._checkLayer(r);if(m&&!d.O(m.getLayoutProperty(o),u)){if(u!=null&&(!f||f.validate!==!1)&&hl(m,k.call(io,{key:`layers.${r}.layout.${o}`,layerType:m.type,objectKey:o,value:u,styleSpec:d.s,style:{glyphs:!0,sprite:!0}})))return;m.setLayoutProperty(o,u),this._updateLayer(m)}}getLayerProperty(r,o){const u=this._checkLayer(r);if(u){switch(o){case"minzoom":return u.minzoom;case"maxzoom":return u.maxzoom;case"filter":return this.getFilter(r);case"slot":return u.slot;case"appearances":return u.getAppearances().map(f=>f.serialize())}return u.isPaintProperty(o)?this.getPaintProperty(r,o):this.getLayoutProperty(r,o)}}setLayerProperty(r,o,u,f={}){this._checkLoaded();const m=this._checkLayer(r);if(m){switch(o){case"appearances":return m.setAppearances(u),void this._updateLayer(m);case"minzoom":return this.setLayerZoomRange(r,u);case"maxzoom":return this.setLayerZoomRange(r,null,u);case"filter":return this.setFilter(r,u,f);case"slot":return this.setSlot(r,u)}m.isPaintProperty(o)?this.setPaintProperty(r,o,u,f):this.setLayoutProperty(r,o,u,f)}}getLayoutProperty(r,o){const u=this._checkLayer(r);if(u)return u.getLayoutProperty(o)}setPaintProperty(r,o,u,f={}){this._checkLoaded();const m=this._checkLayer(r);m&&(d.O(m.getPaintProperty(o),u)||(u==null||f&&f.validate===!1||!hl(m,M.call(io,{key:`layers.${r}.paint.${o}`,layerType:m.type,objectKey:o,value:u,styleSpec:d.s})))&&(m.setPaintProperty(o,u)&&this._updateLayer(m),this._changes.updatePaintProperties(m)))}getPaintProperty(r,o){const u=this._checkLayer(r);if(u)return u.getPaintProperty(o)}setFeatureState(r,o){if(this._checkLoaded(),"target"in r){if("featuresetId"in r.target){const{featuresetId:w,importId:E}=r.target,I=this.getFragmentStyle(E),R=I.getFeaturesetLayers(w);for(const{source:P,sourceLayer:B}of R)I.setFeatureState({id:r.id,source:P,sourceLayer:B},o)}else if("layerId"in r.target){const w=this._resolveLayerFragment(r.target.layerId);w==null||w.fragment.setFeatureState({id:r.id,source:w.layer.source,sourceLayer:w.layer.sourceLayer},o)}return}const u=r.source,f=r.sourceLayer,m=this._checkSource(u);if(!m)return;const g=m.type;if(g==="geojson"&&f)return void this.fire(new d.f(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(g==="vector"&&!f)return void this.fire(new d.f(new Error("The sourceLayer parameter must be provided for vector source types.")));r.id===void 0&&this.fire(new d.f(new Error("The feature id parameter must be provided.")));const x=this.getOwnSourceCaches(u);for(const w of x)w.setFeatureState(f,r.id,o)}removeFeatureState(r,o){if(this._checkLoaded(),"target"in r){if("featuresetId"in r.target){const{featuresetId:w,importId:E}=r.target,I=this.getFragmentStyle(E),R=I.getFeaturesetLayers(w);for(const{source:P,sourceLayer:B}of R)I.removeFeatureState({id:r.id,source:P,sourceLayer:B},o)}else if("layerId"in r.target){const w=this._resolveLayerFragment(r.target.layerId);w==null||w.fragment.removeFeatureState({id:r.id,source:w.layer.source,sourceLayer:w.layer.sourceLayer},o)}return}const u=r.source,f=this._checkSource(u);if(!f)return;const m=f.type,g=m==="vector"?r.sourceLayer:void 0;if(m==="vector"&&!g)return void this.fire(new d.f(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&typeof r.id!="string"&&typeof r.id!="number")return void this.fire(new d.f(new Error("A feature id is required to remove its specific state property.")));const x=this.getOwnSourceCaches(u);for(const w of x)w.removeFeatureState(g,r.id,o)}getFeatureState(r){if(this._checkLoaded(),"target"in r){let m;if("featuresetId"in r.target){const{featuresetId:g,importId:x}=r.target,w=this.getFragmentStyle(x),E=w.getFeaturesetLayers(g);for(const{source:I,sourceLayer:R}of E){const P=w.getFeatureState({id:r.id,source:I,sourceLayer:R});if(P&&!m)m=P;else if(!d.O(m,P))return void this.fire(new d.f(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 r.target){const g=this._resolveLayerFragment(r.target.layerId);m=g==null?void 0:g.fragment.getFeatureState({id:r.id,source:g.layer.source,sourceLayer:g.layer.sourceLayer})}return m}const o=r.source,u=r.sourceLayer,f=this._checkSource(o);if(f){if(f.type!=="vector"||u)return r.id===void 0&&this.fire(new d.f(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(o)[0].getFeatureState(u,r.id);this.fire(new d.f(new Error("The sourceLayer parameter must be provided for vector source types.")))}}resetFeatureStates(r){if(this._checkLoaded(),"featuresetId"in r){const{featuresetId:o,importId:u}=r,f=this.getFragmentStyle(u);if(!f)return;const m=f.getFeaturesetLayers(o);for(const{source:g,sourceLayer:x}of m)f.removeFeatureState({source:g,sourceLayer:x})}else{const o=this._resolveLayerFragment(r.layerId);o==null||o.fragment.removeFeatureState({source:o.layer.source,sourceLayer:o.layer.sourceLayer})}}setTransition(r){return this.stylesheet.transition={...this.stylesheet.transition,...r},this.transition=this.stylesheet.transition,this}getTransition(){return{...this.stylesheet.transition}}setWorldview(r){r!==this._worldview&&(this._worldview=r,this.dispatcher.broadcast("upsertRenderParams",{worldview:this._worldview}),this.reloadSources())}serialize(){this._checkLoaded();const r=this.getTerrain(),o=r&&this.terrain&&this.terrain.scope===this.scope?r:this.stylesheet.terrain;return d.dk({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)},u=>u!==void 0)}_updateFilteredLayers(r){for(const o of Object.values(this._mergedLayers))r(o)&&this._updateLayer(o)}_updateLayer(r){this._changes.updateLayer(r);const o=this.getLayerSourceCache(r),u=d.m(r.source,r.scope),f=this._changes.getUpdatedSourceCaches();r.source&&!f[u]&&o&&o.getSource().type!=="raster"&&(this._changes.updateSourceCache(u,"reload"),o.pause()),r.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(r){const o=x=>this._mergedLayers[x].is3D(!!this.terrain),u=this.order,f={},m=[];for(let x=u.length-1;x>=0;x--){const w=u[x];if(o(w)){f[w]=x;for(const E of r){const I=E[w];if(I)for(const R of I)m.push(R)}}}m.sort((x,w)=>w.intersectionZ-x.intersectionZ);const g=[];for(let x=u.length-1;x>=0;x--){const w=u[x];if(o(w))for(let E=m.length-1;E>=0;E--){const I=m[E].feature;if(I.layer&&f[I.layer.id]<x)break;g.push(I),m.pop()}else for(const E of r){const I=E[w];if(I)for(const R of I)g.push(R.feature)}}return g}queryRasterValue(r,o,u){const f=this.getOwnSource(r);return f?f.type!=="raster-array"?(this.fire(new d.f(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):f.queryRasterArrayValue(o,u):(this.fire(new d.f(new Error(`Source with id "${r}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(r,o,u){let f;o&&!Array.isArray(o)&&o.filter&&(this._validate(Z,"queryRenderedFeatures.filter",o.filter,null,o),f=d.bv(o.filter));const m={},g=I=>{if(dl.has(I.type))return;const R=this.getOwnLayerSourceCache(I),P=m[R.id]=m[R.id]||{sourceCache:R,layers:{},has3DLayers:!1};I.is3D(!!this.terrain)&&(P.has3DLayers=!0),P.layers[I.fqid]=P.layers[I.fqid]||{styleLayer:I,targets:[]},P.layers[I.fqid].targets.push({filter:f})};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new d.f(new Error("parameters.layers must be an Array."))),[];for(const I of o.layers){const R=this._layers[I];if(!R)return this.fire(new d.f(new Error(`The layer '${I}' does not exist in the map's style and cannot be queried for features.`))),[];g(R)}}else for(const I in this._layers)g(this._layers[I]);const x=this._queryRenderedFeatures(r,m,u),w=this._flattenAndSortRenderedFeatures(x),E=[];for(const I of w)d.bW(I.layer.id)===this.scope&&E.push(I);return E}queryRenderedFeatureset(r,o,u){let f;o&&!Array.isArray(o)&&o.filter&&(this._validate(Z,"queryRenderedFeatures.filter",o.filter,null,o),f=d.bv(o.filter));const m="mock",g=[];if(o&&o.target)g.push({...o,targetId:m,filter:f});else{const I=this.getFeaturesetDescriptors();for(const R of I)g.push({targetId:m,filter:f,target:R});for(const{style:R}of this.fragments){const P=R.getFeaturesetDescriptors();for(const B of P)g.push({targetId:m,filter:f,target:B})}}const x=this.queryRenderedTargets(r,g,u),w=[],E=new Set;for(const I of x)for(const R of I.variants[m])Lf(R,I,E)||w.push(new d.dl(I,R));return w}queryRenderedTargets(r,o,u){const f={},m=(x,w,E,I)=>{const R=f[w.id]=f[w.id]||{sourceCache:w,layers:{},has3DLayers:!1};if(R.layers[x.fqid]=R.layers[x.fqid]||{styleLayer:x,targets:[]},x.is3D(!!this.terrain)&&(R.has3DLayers=!0),!I)return E.uniqueFeatureID=!1,void R.layers[x.fqid].targets.push(E);R.layers[x.fqid].targets.push({...E,namespace:I.namespace,properties:I.properties,uniqueFeatureID:I.uniqueFeatureID})};for(const x of o)if("featuresetId"in x.target){const{featuresetId:w,importId:E}=x.target,I=this.getFragmentStyle(E);if(!I||!I._featuresetSelectors)continue;const R=I._featuresetSelectors[w];if(!R){this.fire(new d.f(new Error(`The featureset '${w}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const P of R){const B=I.getOwnLayer(P.layerId);B&&!dl.has(B.type)&&m(B,I.getOwnLayerSourceCache(B),x,P)}}else if("layerId"in x.target){const{layerId:w}=x.target,E=this.getLayer(w);if(!E||dl.has(E.type))continue;m(E,this.getLayerSourceCache(E),x)}const g=this._queryRenderedFeatures(r,f,u);return this._flattenAndSortRenderedFeatures(g)}_queryRenderedFeatures(r,o,u){const f=[],m=!!this.map._showQueryGeometry,g=_a.createFromScreenPoints(r,u);for(const x in o){const w=zf(g,o[x],this._availableImages,u,m,this.getActualScope());Object.keys(w).length&&f.push(w)}if(this.placement)for(const x in o){if(o[x].sourceCache._renderSourceType!==d.bR.Symbol)continue;const w=f_(g.screenGeometry,o[x],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(w).length&&f.push(w)}return f}querySourceFeatures(r,o){const u=o&&o.filter;u&&this._validate(Z,"querySourceFeatures.filter",u,null,o);let f=[];const m=this.getOwnSourceCaches(r);for(const g of m)f=f.concat(Kh(g,o));return f}getFlatLight(){return this.light.getLight()}setFlatLight(r,o,u={}){this._checkLoaded();const f=this.light.getLight();let m=!1;for(const x in r)if(!d.O(r[x],f[x])){m=!0;break}if(!m)return;const g=this._getTransitionParameters();this.light.setLight(r,o,u),this.light.updateTransitions(g)}hasTerrain(){return!!this.terrain&&this.terrain.drapeRenderMode===1}getTerrain(){return this.hasTerrain()?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=d.e.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&d.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(r,o=1){if(this._checkLoaded(),!r)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),o===0&&delete this.terrain,r===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let u=r;const f=!("source"in r)||r.source==null;if(o===1){if(this.disableElevatedTerrain)return;if("source"in u&&typeof u.source=="object"){const x="terrain-dem-src";this.addSource(x,u.source),u=d.dd(u),u=Object.assign(u,{source:x})}const m={...u},g={};if(this.terrain&&f){m.source=this.terrain.get().source;const x=this.terrain?this.getFragmentStyle(this.terrain.scope):null;x&&(g.style=x.serialize())}if(this._validate(Hu,"terrain",m,g))return}if(!this.terrain||this.terrain.scope!==this.scope&&!f||this.terrain&&o!==this.terrain.drapeRenderMode){if(!u)return;this._createTerrain(u,o),this.fire(new d.h("data",{dataType:"style"}))}else{const m=this.terrain,g=m.get();for(const x of Object.keys(d.s.terrain))!Object.hasOwn(u,x)&&d.s.terrain[x].default&&(u[x]=d.s.terrain[x].default);for(const x in r)if(!d.O(r[x],g[x])){m.set(r,this.options),this.stylesheet.terrain=r;const w=this._getTransitionParameters({duration:0});m.updateTransitions(w),this.fire(new d.h("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(r){const o=this.fog=new Ee(r,this.map.transform,this.scope,this.options);this.stylesheet.fog=o.get();const u=this._getTransitionParameters({duration:0});o.updateTransitions(u)}_createSnow(r){const o=this.snow=new Ge(r,this.map.transform,this.scope,this.options);this.stylesheet.snow=o.get();const u=this._getTransitionParameters({duration:0});o.updateTransitions(u)}_createRain(r){const o=this.rain=new ut(r,this.map.transform,this.scope,this.options);this.stylesheet.rain=o.get();const u=this._getTransitionParameters({duration:0});o.updateTransitions(u)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const r of this.map._markers)r._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),r)if(this.fog){const o=this.fog;if(!d.O(o.get(),r)){o.set(r,this.options),this.stylesheet.fog=o.get();const u=this._getTransitionParameters({duration:0});o.updateTransitions(u)}}else this._createFog(r);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(r){if(this._checkLoaded(),!r)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const o=this.snow;if(!d.O(o.get(),r)){o.set(r,this.options),this.stylesheet.snow=o.get();const u=this._getTransitionParameters({duration:0});o.updateTransitions(u)}}else this._createSnow(r);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(r){if(this._checkLoaded(),!r)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const o=this.rain;if(!d.O(o.get(),r)){o.set(r,this.options),this.stylesheet.rain=o.get();const u=this._getTransitionParameters({duration:0});o.updateTransitions(u)}}else this._createRain(r);this._markersNeedUpdate=!0}_reloadColorTheme(){const r=()=>{for(const f in this._layers)this._layers[f].lut=this._styleColorTheme.lut;for(const f in this._sourceCaches)this._sourceCaches[f].clearTiles()},o=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!o)return this._styleColorTheme.lut=null,void r();const u=this._evaluateColorThemeData(o);this._loadColorTheme(u).then(()=>{this.fire(new d.h("colorthemeset")),r()}).catch(f=>{d.w(`Couldn't set color theme: ${f}`)})}setColorTheme(r){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&d.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=r,this._reloadColorTheme()}setImportColorTheme(r,o){const u=this.getFragmentStyle(r);u&&(u._styleColorTheme.colorThemeOverride=o,u._reloadColorTheme())}_getTransitionParameters(r){return{now:d.e.now(),transition:Object.assign(this.transition,r)}}updateDrapeFirstLayers(){if(!this.terrain)return;const r=[],o=[];for(const u of this._mergedOrder)this.isLayerDraped(this._mergedLayers[u])?r.push(u):o.push(u);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...r),this._drapedFirstOrder.push(...o)}_createTerrain(r,o){const u=this.terrain=new ne(r,o,this.scope,this.options,this.map.getWorldview());o===1&&(this.stylesheet.terrain=r),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const f=this._getTransitionParameters({duration:0});u.updateTransitions(f)}_force3DLayerUpdate(){for(const r in this._layers){const o=this._layers[r];o.type==="fill-extrusion"&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(const r in this._layers){const o=this._layers[r];o.type==="symbol"&&this._updateLayer(o)}}_validate(r,o,u,f,m={}){if(m&&m.validate===!1)return!1;const g={...this.serialize()};return hl(this,r.call(io,{key:o,style:g,value:u,styleSpec:d.s,...f}))}_remove(){this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),d.dm.off("pluginStateChange",this._rtlTextPluginCallback);for(const r in this._mergedLayers)this._mergedLayers[r].setEventedParent(null);for(const r in this._mergedSourceCaches){const o=this._mergedSourceCaches[r];o.clearTiles(),o.setEventedParent(null);const u=o.getSource();u&&u.onRemove&&u.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&&this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(r){const o=this.getSourceCaches(r);for(const u of o)u.clearTiles()}clearSources(){for(const r in this._mergedSourceCaches)this._mergedSourceCaches[r].clearTiles()}clearLayers(){for(const r in this._mergedLayers){const o=this._mergedLayers[r];o._clear&&o._clear()}}reloadSource(r){const o=this.getSourceCaches(r);for(const u of o)u.resume(),u.reload()}reloadSources(){for(const r of this.getSources())r.reload&&r.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(r=>{r.modelManager.reloadModels(r.scope)})}updateSources(r){let o;this.directionalLight&&(o=d.dn(this.directionalLight));const u=new Set,f=new Set,m=new Set;for(const g in this._mergedLayers){const x=this._mergedLayers[g];x.type==="building"?u.add(x.source):x.type!=="raster"||!x.paint||x.paint.get("raster-elevation-reference")!=="ground"&&x.paint.get("raster-allow-draping")!==!1||m.add(x.source),x.hasElevation()&&!f.has(x.source)&&f.add(x.source)}this.updateFrcCoverageFadeRange();for(const g in this._mergedSourceCaches){const x=this._mergedSourceCaches[g],w=f.has(x._source.id);x._isRasterElevatedOverTerrain=m.has(x._source.id),u.has(x._source.id)&&(x._source.reparseOverscaled=!1),x.update(r,void 0,void 0,o,w)}this.updateFrcCoverage(),this.updateElevationCoverage(),Tt.markElevationIngestSourceCachesUsed&&Tt.markElevationIngestSourceCachesUsed(this)}_reloadSources(){for(const r in this._sourceCaches){const o=this._sourceCaches[r];o.resume(),o.reload()}}updateFrcCoverageFadeRange(){this.map.painter&&Tt.updateFrcCoverageFadeRange&&Tt.updateFrcCoverageFadeRange(this,this.map.painter)}updateFrcCoverage(){this._hdCoverage&&Tt.updateFrcCoverage&&Tt.updateFrcCoverage(this,this._hdCoverage)}updateElevationCoverage(){this.isRootStyle()&&Tt.setupAndUpdateElevationCoverage&&Tt.setupAndUpdateElevationCoverage(this)}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new d.h("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new td),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(r,o,u,f,m,g){this.pauseablePlacement||(this.pauseablePlacement=new td);let x=!1,w=!1;const E={},I={};for(const G of this._mergedOrder){const $=this._mergedLayers[G];if($.type!=="symbol")continue;const Y=d.m($.source,$.scope);let re=E[Y];if(!re){const pe=this.getLayerSourceCache($);if(!pe)continue;const ce=pe.getRenderableIds(!0).map(_e=>pe.getTileByID(_e));I[Y]=ce.slice(),re=E[Y]=ce.sort((_e,ue)=>ue.tileID.overscaledZ-_e.tileID.overscaledZ||(_e.tileID.isLessThan(ue.tileID)?-1:1))}const oe=this.crossTileSymbolIndex.addLayer($,re,r.center.lng,r.projection);x=x||oe}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const R=!!(this.placement&&!r.equals(this.placement.transform)),P=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!m||this.placement.lastReplacementSourceUpdateTime!==m.updateTime)),B=R||P||x,V=(B||this.pauseablePlacement.isStale())&&u===0,U=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(d.e.now(),r.zoom)&&u!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||V||U)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(r,this._mergedOrder,o,u,f,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null,this._buildingIndex,g),this.map.painter)){const G=this.map.painter.maxFrontCutoffRawStart;if(G>0){const $=180*r.pitch/Math.PI;if($>=15){const Y=Math.min(1,Math.max(0,($-15)/5)),re=Y*Y*(3-2*Y);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-re)+G*re}}}if(this.pauseablePlacement.isDone()?B&&u!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,E,I,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(d.e.now()),w=!0),x&&this.pauseablePlacement.setStale()),w||x){this._buildingIndex.onNewFrame(r.zoom);for(let G=0;G<this._mergedOrder.length;G++){const $=this._mergedLayers[this._mergedOrder[G]];if($.type!=="symbol"||$.visibility==="none")continue;const Y=this.isLayerClipped($);this.placement.updateLayerOpacities($,E[d.m($.source,$.scope)],G,Y?m:null,o,this.map.painter.scaleFactor)}}return!this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(d.e.now())}_releaseSymbolFadeTiles(){for(const r in this._sourceCaches)this._sourceCaches[r].releaseSymbolFadeTiles()}addImport(r,o){if(this._checkLoaded(),new Set(["__proto__","constructor","prototype"]).has(r.id))return void this.fire(new d.f(new Error(`Import id can't be "${r.id}".`)));const u=this.stylesheet.imports=this.stylesheet.imports||[];if(u.findIndex(({id:m})=>m===r.id)!==-1)return void this.fire(new d.f(new Error(`Import with id '${r.id}' already exists in the map's style.`)));if(!o)return u.push(r),this._loadImports([r],!0);const f=u.findIndex(({id:m})=>m===o);return f===-1&&this.fire(new d.f(new Error(`Import with id "${o}" does not exist on this map.`))),this.stylesheet.imports=u.slice(0,f).concat(r).concat(u.slice(f)),this._loadImports([r],!0,o)}updateImport(r,o){this._checkLoaded();const u=this.stylesheet.imports||[],f=this.getImportIndex(r);return f===-1?this:typeof o=="string"?(this.setImportUrl(r,o),this):(o.url&&o.url!==u[f].url&&this.setImportUrl(r,o.url),d.O(o.config,u[f].config)||this.setImportConfig(r,o.config,o.data.schema),d.O(o.data,u[f].data)||this.setImportData(r,o.data),this)}moveImport(r,o){this._checkLoaded();let u=this.stylesheet.imports||[];const f=this.getImportIndex(r);if(f===-1)return this;const m=this.getImportIndex(o);if(m===-1)return this;const g=u[f],x=this.fragments[f];return u=u.filter(({id:w})=>w!==r),this.fragments=this.fragments.filter(({id:w})=>w!==r),this.stylesheet.imports=u.slice(0,m).concat(g).concat(u.slice(m)),this.fragments=this.fragments.slice(0,m).concat(x).concat(this.fragments.slice(m)),this.mergeLayers(),this}setImportUrl(r,o){this._checkLoaded();const u=this.stylesheet.imports||[],f=this.getImportIndex(r);if(f===-1)return this;u[f].url=o;const m=this.fragments[f];return m.style=this._createFragmentStyle(u[f]),m.style.on("style.import.load",()=>this.mergeAll()),m.style.loadURL(o),this}setImportData(r,o){this._checkLoaded();const u=this.getImportIndex(r),f=this.stylesheet.imports||[];return u===-1?this:o?(this.fragments[u].style.setState(o),this._reloadImports(),this):(delete f[u].data,this.setImportUrl(r,f[u].url))}setImportConfig(r,o,u){this._checkLoaded();const f=this.getImportIndex(r),m=this.stylesheet.imports||[];if(f===-1)return this;o?m[f].config=o:delete m[f].config;const g=this.fragments[f];u&&g.style.stylesheet&&(g.style.stylesheet.schema=u);const x=g.style.stylesheet&&g.style.stylesheet.schema;return g.config=o,g.style.updateConfig(o,x),this.updateConfigDependencies(),this}removeImport(r){this._checkLoaded();const o=this.stylesheet.imports||[],u=this.getImportIndex(r);u!==-1&&(o.splice(u,1),this.fragments[u].style._remove(),this.fragments.splice(u,1),this._reloadImports())}getImportIndex(r){const o=(this.stylesheet.imports||[]).findIndex(u=>u.id===r);return o===-1&&this.fire(new d.f(new Error(`Import '${r}' does not exist in the map's style and cannot be updated.`))),o}getLayer(r){return this._mergedLayers[r]}getSources(){const r=[];for(const o in this._mergedOtherSourceCaches){const u=this._mergedOtherSourceCaches[o];u&&r.push(u.getSource())}return r}getSource(r,o){const u=this.getSourceCache(r,o);return u&&u.getSource()}getLayerSource(r){const o=this.getLayerSourceCache(r);return o&&o.getSource()}getSourceCache(r,o){const u=d.m(r,o);return this._mergedOtherSourceCaches[u]}getLayerSourceCache(r){const o=d.m(r.source,r.scope);return r.type==="symbol"?this._mergedSymbolSourceCaches[o]:r.type==="fill-extrusion"?this._mergedFillExtrusionSourceCaches[o]||this._mergedOtherSourceCaches[o]:r.type==="fill"&&r.sourceLayer===d.bU&&this._mergedHdRoadCoverageSourceCaches[o]?this._mergedHdRoadCoverageSourceCaches[o]:this._mergedOtherSourceCaches[o]}getSourceCaches(r){return r==null?Object.values(this._mergedSourceCaches):[this._mergedOtherSourceCaches[r],this._mergedSymbolSourceCaches[r],this._mergedFillExtrusionSourceCaches[r],this._mergedHdRoadCoverageSourceCaches[r],this._mergedHdRoadElevationSourceCaches[r]].filter(Boolean)}updateSourceCaches(){const r=this._changes.getUpdatedSourceCaches();for(const o in r){const u=r[o];u==="reload"?this.reloadSource(o):u==="clear"&&this.clearSource(o)}}updateLayers(r){const o=this._changes.getUpdatedPaintProperties();for(const u of o){const f=this.getLayer(u);f&&f.updateTransitions(r)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(r){this.stylesheet.glyphs=r,this.glyphManager.setURL(r)}getOwnSourceCache(r){return this._otherSourceCaches[r]}getOwnLayerSourceCache(r){return r.type==="symbol"?this._symbolSourceCaches[r.source]:r.type==="fill-extrusion"&&this._fillExtrusionSourceCaches[r.source]||this._otherSourceCaches[r.source]}getOwnSourceCaches(r){return[this._otherSourceCaches[r],this._symbolSourceCaches[r],this._fillExtrusionSourceCaches[r],this._hdCoverage&&this._hdCoverage.coverageSourceCaches[r],this._hdElevation&&this._hdElevation.elevationSourceCaches[d.m(r,this.scope)]].filter(Boolean)}_updateHdCoverageSourceCache(r){return Tt.HdCoverageState&&Tt.updateHdCoverageSourceCache?(this._hdCoverage||(this._hdCoverage=new Tt.HdCoverageState),Tt.updateHdCoverageSourceCache(this,this._hdCoverage,r),!1):r.type==="fill"&&r.sourceLayer===d.bU}_isSourceCacheLoaded(r){const o=this.getOwnSourceCaches(r);return o.length===0?(this.fire(new d.f(new Error(`There is no source with ID '${r}'`))),!1):o.every(u=>u.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(r,o){if(!this._clipLayerPresent&&r.type!=="fill-extrusion"&&r.type!=="building")return!1;const u=r.type==="fill-extrusion"&&(r.sourceLayer==="building"||r.sourceLayer==="procedural_buildings"),f=r.type==="building";if(r.is3D(!!this.terrain)){if(u||f||o&&o.type==="batched-model"||r.type==="model")return!0}else if(r.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(r=>{r.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}async getImages(r,o){const u=new Promise((w,E)=>{this.imageManager.getImages(o.icons.concat(o.patterns),o.scope,(I,R)=>{I?E(I):w(R)})});this._updateTilesForChangedImages();const f=o.icons.map(w=>d.I.toString(w)),m=o.patterns.map(w=>d.I.toString(w)),g=w=>{w&&(w.setDependencies(o.tileID.key,"icons",f),w.setDependencies(o.tileID.key,"patterns",m))},x=d.m(o.source,o.scope);return g(this._mergedOtherSourceCaches[x]),g(this._mergedSymbolSourceCaches[x]),(o.icons.some(w=>w.iconsetId)||o.patterns.some(w=>w.iconsetId))&&this.fire(new d.h("data",{dataType:"style"})),u}async rasterizeImages(r,o){return new Promise((u,f)=>{this.imageManager.rasterizeImages(o,(m,g)=>{m?f(m):u(g)})})}async checkAtlasCache(r,o){const u=this.imageManager.imageAtlasCache.findCachedAtlas(o.descriptor);return u&&u.contentDescriptor?{iconPositions:u.iconPositions,patternPositions:u.patternPositions,sourceHash:u.contentDescriptor.hash}:null}async getGlyphs(r,o){return new Promise((u,f)=>{this.glyphManager.getGlyphs(o.stacks,(m,g)=>{m?f(m):u(g)})})}}fl.registerForPluginStateChange=d.d6;class Gf{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(r,o,u,f,m,g,x,w){this.context=r;let E=this.boundPaintVertexBuffers.length!==f.length;for(let R=0;!E&&R<f.length;R++)this.boundPaintVertexBuffers[R]!==f[R]&&(E=!0);let I=this.boundDynamicVertexBuffers.length!==x.length;for(let R=0;!I&&R<x.length;R++)this.boundDynamicVertexBuffers[R]!==x[R]&&(I=!0);if(!this.vao||this.boundProgram!==o||this.boundLayoutVertexBuffer!==u||E||I||this.boundIndexBuffer!==m||this.boundVertexOffset!==g)this.freshBind(o,u,f,m,g,x,w);else{r.bindVertexArrayOES.set(this.vao);for(const R of x)R&&(R.bind(),w&&R.instanceCount&&R.setVertexAttribDivisor(r.gl,o,w));m&&m.dynamicDraw&&m.bind()}}freshBind(r,o,u,f,m,g,x){const w=this.context,E=w.gl;this.vao&&this.destroy(),this.vao=w.gl.createVertexArray(),w.bindVertexArrayOES.set(this.vao),this.boundProgram=r,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=u,this.boundIndexBuffer=f,this.boundVertexOffset=m,this.boundDynamicVertexBuffers=g,o.enableAttributes(E,r),o.bind(),o.setVertexAttribPointers(E,r,m);for(const I of u)I.enableAttributes(E,r),I.bind(),I.setVertexAttribPointers(E,r,m);for(const I of g)I&&(I.enableAttributes(E,r),I.bind(),I.setVertexAttribPointers(E,r,m),x&&I.instanceCount&&I.setVertexAttribDivisor(E,r,x));f&&f.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function od(a,r){const o=Math.pow(2,r.canonical.z),u=r.canonical.y;return[new d.bS(0,u/o).toLngLat().lat,new d.bS(0,(u+1)/o).toLngLat().lat]}function th(a,r,o,u,f,m,g){const x=a.context,w=x.gl,E=o.hillshadeFBO;if(!E)return;a.prepareDrawTile();const I=a.isTileAffectedByFog(r),R=[];a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&R.push("USE_MRT1");const P=a.getOrCreateProgram("hillshade",{overrideFog:I,defines:R});x.activeTexture.set(w.TEXTURE0),w.bindTexture(w.TEXTURE_2D,E.colorAttachment0.get());const B=(($,Y,re,oe)=>{const pe=re.paint.get("hillshade-shadow-color"),ce=re.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",_e=re.paint.get("hillshade-highlight-color"),ue=re.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",me=re.paint.get("hillshade-accent-color"),Ie=re.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",we=re.paint.get("hillshade-emissive-strength");let ve=d.au(re.paint.get("hillshade-illumination-direction"));if(re.paint.get("hillshade-illumination-anchor")==="viewport")ve-=$.transform.angle;else if($.style&&$.style.enable3dLights()&&$.style.directionalLight){const Re=$.style.directionalLight.properties.get("direction"),Ue=d.de(Re.x,Re.y,Re.z);ve=d.au(Ue[1])}const Se=!$.options.moving;return{u_matrix:oe||$.transform.calculateProjMatrix(Y.tileID.toUnwrapped(),Se),u_image:0,u_latrange:od(0,Y.tileID),u_light:[re.paint.get("hillshade-exaggeration"),ve],u_shadow:pe.toPremultipliedRenderColor(ce?null:re.lut),u_highlight:_e.toPremultipliedRenderColor(ue?null:re.lut),u_emissive_strength:we,u_accent:me.toPremultipliedRenderColor(Ie?null:re.lut)}})(a,o,u,a.terrain?r.projMatrix:null);a.uploadCommonUniforms(x,P,r.toUnwrapped());const{tileBoundsBuffer:V,tileBoundsIndexBuffer:U,tileBoundsSegments:G}=a.getTileBoundsBuffers(o);P.draw(a,w.TRIANGLES,f,m,g,d.$.disabled,B,u.id,V,U,G)}function pl(a,r,o){if(!r.needsDEMTextureUpload)return;const u=a.context,f=u.gl;u.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||a.getTileTexture(o.stride);const m=o.getPixels();r.demTexture?r.demTexture.update(m,{premultiply:!1}):r.demTexture=new d.T(u,m,f.R32F,{premultiply:!1}),r.needsDEMTextureUpload=!1}function Hf(a,r,o){const u=a.context,f=u.gl;if(!r.dem)return;const m=r.dem;if(u.activeTexture.set(f.TEXTURE1),pl(a,r,m),!r.demTexture)return;r.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE);const g=m.dim;u.activeTexture.set(f.TEXTURE0);let x=r.hillshadeFBO;if(!x){const P=new d.T(u,{width:g,height:g,data:null},f.RGBA8);P.bind(f.LINEAR,f.CLAMP_TO_EDGE),x=r.hillshadeFBO=u.createFramebuffer(g,g,1,"renderbuffer"),x.colorAttachment0.set(P.texture)}u.bindFramebuffer.set(x.framebuffer),u.viewport.set([0,0,g,g]);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:E,tileBoundsSegments:I}=a.getMercatorTileBoundsBuffers(),R=[];a.linearFloatFilteringSupported()&&R.push("TERRAIN_DEM_FLOAT_FORMAT"),a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&R.push("USE_MRT1"),a.getOrCreateProgram("hillshadePrepare",{defines:R}).draw(a,f.TRIANGLES,d.Z.disabled,d._.disabled,d.a1.unblended,d.$.disabled,((P,B)=>{const V=B.stride,U=d.Y();return d.dr(U,0,d.a2,-d.a2,0,0,1),d.bM(U,U,[0,-d.a2,0]),{u_matrix:U,u_image:1,u_dimension:[V,V],u_zoom:P.overscaledZ}})(r.tileID,m),o.id,w,E,I),r.needsHillshadePrepare=!1}class Gi{constructor(r){this.gl=r.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(r){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Zf extends Gi{getDefault(){return d.C.transparent.toNonPremultipliedRenderColor(null)}set(r){const o=this.current;(r.r!==o.r||r.g!==o.g||r.b!==o.b||r.a!==o.a||this.dirty)&&(this.gl.clearColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class ac extends Gi{getDefault(){return 1}set(r){(r!==this.current||this.dirty)&&(this.gl.clearDepth(r),this.current=r,this.dirty=!1)}}class $f extends Gi{getDefault(){return 0}set(r){(r!==this.current||this.dirty)&&(this.gl.clearStencil(r),this.current=r,this.dirty=!1)}}class w_ extends Gi{getDefault(){return[!0,!0,!0,!0]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.colorMask(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class T_ extends Gi{getDefault(){return!0}set(r){(r!==this.current||this.dirty)&&(this.gl.depthMask(r),this.current=r,this.dirty=!1)}}class E_ extends Gi{getDefault(){return 255}set(r){(r!==this.current||this.dirty)&&(this.gl.stencilMask(r),this.current=r,this.dirty=!1)}}class sd extends Gi{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(r){const o=this.current;(r.func!==o.func||r.ref!==o.ref||r.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(r.func,r.ref,r.mask),this.current=r,this.dirty=!1)}}class ad extends Gi{getDefault(){const r=this.gl;return[r.KEEP,r.KEEP,r.KEEP]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(r[0],r[1],r[2]),this.current=r,this.dirty=!1)}}class ld extends Gi{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=r,this.dirty=!1}}class cd extends Gi{getDefault(){return[0,1]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||this.dirty)&&(this.gl.depthRange(r[0],r[1]),this.current=r,this.dirty=!1)}}class qf extends Gi{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=r,this.dirty=!1}}class Wf extends Gi{getDefault(){return this.gl.LESS}set(r){(r!==this.current||this.dirty)&&(this.gl.depthFunc(r),this.current=r,this.dirty=!1)}}class S_ extends Gi{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.BLEND):o.disable(o.BLEND),this.current=r,this.dirty=!1}}class Kc extends Gi{getDefault(){const r=this.gl;return[r.ONE,r.ZERO,r.ONE,r.ZERO]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.blendFuncSeparate(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class Jc extends Gi{getDefault(){return d.C.transparent.toNonPremultipliedRenderColor(null)}set(r){const o=this.current;(r.r!==o.r||r.g!==o.g||r.b!==o.b||r.a!==o.a||this.dirty)&&(this.gl.blendColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class Xf extends Gi{getDefault(){return this.gl.FUNC_ADD}set(r){(r!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(r,r),this.current=r,this.dirty=!1)}}class zo extends Gi{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=r,this.dirty=!1}}class ud extends Gi{getDefault(){return this.gl.BACK}set(r){(r!==this.current||this.dirty)&&(this.gl.cullFace(r),this.current=r,this.dirty=!1)}}class ih extends Gi{getDefault(){return this.gl.CCW}set(r){(r!==this.current||this.dirty)&&(this.gl.frontFace(r),this.current=r,this.dirty=!1)}}let I_=class extends Gi{getDefault(){return null}set(a){(a!==this.current||this.dirty)&&(this.gl.useProgram(a),this.current=a,this.dirty=!1)}};class rh extends Gi{getDefault(){return this.gl.TEXTURE0}set(r){(r!==this.current||this.dirty)&&(this.gl.activeTexture(r),this.current=r,this.dirty=!1)}}class hd extends Gi{getDefault(){const r=this.gl;return[0,0,r.drawingBufferWidth,r.drawingBufferHeight]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.viewport(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class dd extends Gi{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,r),this.current=r,this.dirty=!1}}class fd extends Gi{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class pd extends Gi{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindTexture(o.TEXTURE_2D,r),this.current=r,this.dirty=!1}}class nh extends Gi{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class Yf extends Gi{getDefault(){return null}set(r){const o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class Kf extends Gi{getDefault(){return null}set(r){this.gl&&(r!==this.current||this.dirty)&&(this.gl.bindVertexArray(r),this.current=r,this.dirty=!1)}}class lc extends Gi{getDefault(){return 4}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,r),this.current=r,this.dirty=!1}}class A_ extends Gi{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),this.current=r,this.dirty=!1}}class C_ extends Gi{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,r),this.current=r,this.dirty=!1}}class md extends Gi{constructor(r,o){super(r),this.context=r,this.parent=o}getDefault(){return null}}class oh extends md{constructor(r,o,u=0){super(r,o),this.attachmentPoint=r.gl.COLOR_ATTACHMENT0+u}setDirty(){this.dirty=!0}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachmentPoint,o.TEXTURE_2D,r,0),this.current=r,this.dirty=!1}}class Jf extends md{attachment(){return this.gl.DEPTH_ATTACHMENT}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class M_ extends md{attachment(){return this.gl.DEPTH_ATTACHMENT}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachment(),o.TEXTURE_2D,r,0),this.current=r,this.dirty=!1}}class _d extends Jf{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const gd=(a,r,o,u)=>({u_matrix:a,u_image0:0,u_image1:1,u_skirt_height:r,u_ground_shadow_factor:o,u_emissive_texture_available:u}),sh=(a,r,o,u,f,m,g,x,w,E,I,R,P,B,V,U,G)=>({u_proj_matrix:Float32Array.from(a),u_globe_matrix:r,u_normalize_matrix:Float32Array.from(u),u_merc_matrix:o,u_zoom_transition:f,u_merc_center:m,u_image0:0,u_image1:1,u_frustum_tl:g,u_frustum_tr:x,u_frustum_br:w,u_frustum_bl:E,u_globe_pos:I,u_globe_radius:R,u_viewport:P,u_grid_matrix:G?Float32Array.from(G):new Float32Array(9),u_skirt_height:B,u_far_z_cutoff:V,u_emissive_texture_available:U});function ml(a,r){return a!=null&&r!=null&&!(!a.hasData()||!r.hasData())&&a.demTexture!=null&&r.demTexture!=null&&a.tileID.key!==r.tileID.key}const _l=new class{constructor(){this.operations={}}newMorphing(a,r,o,u,f){if(a in this.operations){const m=this.operations[a];m.to.tileID.key!==o.tileID.key&&(m.queued=o)}else this.operations[a]={startTime:u,phase:0,duration:f,from:r,to:o,queued:null}}getMorphValuesForProxy(a){if(!(a in this.operations))return null;const r=this.operations[a];return{from:r.from,to:r.to,phase:r.phase}}update(a){for(const r in this.operations){const o=this.operations[r];for(o.phase=(a-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,a)){delete this.operations[r];break}}}_nextOp(a,r){return!!a.queued&&(a.from=a.to,a.to=a.queued,a.queued=null,a.phase=0,a.startTime=r,!0)}_validOp(a){return a.from.hasData()&&a.to.hasData()}};function yd(a,r,o){if(r===0)return 0;const u=r<1&&o===514?.25/r:1;return 6*Math.pow(1.5,22-a)*Math.max(r,1)*u}function Qf(a,r){const o=1<<a.z;return!r&&(a.x===0||a.x===o-1)||a.y===0||a.y===o-1}function Qc(a,r){if(!a.style||!a.style.enable3dLights())return;const o=a.context,u=o.gl;o.activeTexture.set(u.TEXTURE1),r?r.bind(u.LINEAR,u.CLAMP_TO_EDGE):a.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE)}class wa extends Tn{constructor(r){const o={type:"raster-dem",maxzoom:Math.ceil(r.transform.maxZoom)},u=Xu("mock-dem",o,r.style.dispatcher,r.style);super("mock-dem",u,null),u.setEventedParent(this),this._sourceLoaded=!0}_loadTile(r,o){r.state="loaded",o(null)}}class xd extends Tn{constructor(r){const o=Xu("proxy",{type:"geojson",maxzoom:Math.ceil(r.transform.maxZoom)},r.style.dispatcher,r.style);super("proxy",o,null),o.setEventedParent(this),this.map=this.getSource().map=r,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(r,o,u){if(r.freezeTileCoverage)return;this.transform=r;const f=r.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((m,g)=>{if(m[g.key]="",!this._tiles[g.key]){const x=new Ms(g,this._source.tileSize*g.overscaleFactor(),r.tileZoom,void 0,void 0,this._source.worldview);x.state="loaded",this._tiles[g.key]=x}return m},{});for(const m in this._tiles)m in f||(this.freeFBO(m),this._tiles[m].unloadVectorData(),delete this._tiles[m])}freeFBO(r){const o=this.proxyCachedFBO[r];if(o!==void 0){const u=Object.values(o);this.renderCachePool.push(...u),delete this.proxyCachedFBO[r]}}deallocRenderCache(){this.renderCache.forEach(r=>r.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class eu extends d.bP{constructor(r,o,u){super(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y),this.proxyTileKey=o,this.projMatrix=u}}class tu extends d.cW{constructor(r,o){super(),this.painter=r,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[u,f,m]=function(){const w=new d.bC,E=new d.ad,I=131;w.reserve(17161),E.reserve(33800);const R=d.a2/128,P=d.a2+R/2,B=P+R;for(let U=-R;U<B;U+=R)for(let G=-R;G<B;G+=R){const $=G<0||G>P||U<0||U>P?24575:0,Y=d.b0(Math.round(G),0,d.a2),re=d.b0(Math.round(U),0,d.a2);w.emplaceBack(Y+$,re)}const V=(U,G)=>{const $=G*I+U;E.emplaceBack($+1,$,$+I),E.emplaceBack($+I,$+I+1,$+1)};for(let U=1;U<129;U++)for(let G=1;G<129;G++)V(G,U);return[0,129].forEach(U=>{for(let G=0;G<130;G++)V(G,U),V(U,G)}),[w,E,32768]}(),g=r.context;this.gridBuffer=g.createVertexBuffer(u,d.bE.members),this.gridIndexBuffer=g.createIndexBuffer(f),this.gridSegments=d.ac.simpleSegment(0,0,u.length,f.length),this.gridNoSkirtSegments=d.ac.simpleSegment(0,0,u.length,m),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new xd(o.map),this.orthoMatrix=d.Y(),d.dr(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,d.a2,0,d.a2,0,1);const x=g.gl;this._overlapStencilMode=new d._({func:x.GEQUAL,mask:255},0,255,x.KEEP,x.KEEP,x.REPLACE),this._previousZoom=r.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new wa(o.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null}set style(r){r.on("data",this._onStyleDataEvent.bind(this)),this._style=r,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(r,o,u){if(r&&r.terrain){this._style!==r&&(this.style=r,this._evaluationZoom=void 0);const f=r.terrain.properties,m=r.terrain.drapeRenderMode===0,g=r.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=d.e.now();const x=r.terrain&&r.terrain.scope,w=f.get("source"),E=m?this._mockSourceCache:r.getSourceCache(w,x);if(!E)return void d.w(`Couldn't find terrain source "${w}".`);if(this.sourceCache=E,this._attenuationRange=r.terrain.getAttenuationRange(),this._exaggeration=g?this.calculateExaggeration(o):f.get("exaggeration"),!o.projection.requiresDraping&&g&&this._exaggeration===0)return void this._disable();this.enabled=!0;const I=()=>{this.sourceCache.used&&d.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
3411This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const R=this.getScaledDemTileSize();this.sourceCache.update(o,R,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,I(),this._initializing=!0),I(),o.updateElevation(!0,u),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0,this._previousZoom=o.zoom}else this._disable()}calculateExaggeration(r){if(this._attenuationRange&&r.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(r.zoom);const o=this._previousCameraAltitude,u=r.getFreeCameraOptions().position.z/r.pixelsPerMeter*r.worldSize;this._previousCameraAltitude=u;const f=o!=null?u-o:Number.MAX_VALUE;if(Math.abs(f)<2)return this._exaggeration;const m=r.zoom,g=this._style.terrain;if(!this._previousUpdateTimestamp)return g.getExaggeration(m);let x=m-this._previousZoom;const w=this._previousUpdateTimestamp;let E=m;this._evaluationZoom!=null&&(E=this._evaluationZoom,Math.abs(m-E)>.5&&(x=.5*(m-E+x)),x*f<0&&(E+=x)),this._evaluationZoom=E;const I=g.getExaggeration(E),R=I===g.getExaggeration(Math.max(0,E-.1));if(R&&Math.abs(I-this._exaggeration)<.01)return I;let P=Math.min(.1,.00375*(this._updateTimestamp-w));return(R||I<.1||Math.abs(x)<1e-4)&&(P=Math.min(.2,4*P)),d.al(this._exaggeration,I,P)}resetTileLookupCache(r){this._findCoveringTileCache[r]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(r){r.dataType==="source"&&r.coord?this._clearRenderCacheForTile(r.sourceCacheId,r.coord):r.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(const r in this._style._mergedSourceCaches)this._style._mergedSourceCaches[r].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(r=>r.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(){const r=2*this.proxySourceCache.getSource().tileSize;return[r,r]}set useVertexMorphing(r){this._useVertexMorphing=r}updateTileBinding(r){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const o=this.proxySourceCache,u=this.painter.transform;this._initializing&&(this._initializing=u._centerAltitude===0&&this.getAtPointOrZero(d.bS.fromLngLat(u.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const f=this.proxyCoords=o.getIds().map(w=>{const E=o.getTileByID(w).tileID;return E.projMatrix=u.calculateProjMatrix(E.toUnwrapped()),E});(function(w,E){const I=E.transform.pointCoordinate(E.transform.getCameraPoint()),R=new d.P(I.x,I.y);w.sort((P,B)=>{if(B.overscaledZ-P.overscaledZ)return B.overscaledZ-P.overscaledZ;const V=new d.P(P.canonical.x+(1<<P.canonical.z)*P.wrap,P.canonical.y),U=new d.P(B.canonical.x+(1<<B.canonical.z)*B.wrap,B.canonical.y),G=R.mult(1<<P.canonical.z);return G.x-=.5,G.y-=.5,G.distSqr(V)-G.distSqr(U)})})(f,this.painter);const m=this.proxyToSource||{};this.proxyToSource={},f.forEach(w=>{this.proxyToSource[w.key]={}}),this.terrainTileForTile={};const g=this._style._mergedSourceCaches;for(const w in g){const E=g[w];if(!E.used||!E.transform||(E!==this.sourceCache&&this.resetTileLookupCache(E.id),this._setupProxiedCoordsForOrtho(E,r[w],m),E.usedForTerrain))continue;const I=r[w];(E.getSource().reparseOverscaled||E._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(I)}this.proxiedCoords[o.id]=f.map(w=>new eu(w,w.key,this.orthoMatrix)),this._assignTerrainTiles(f),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(m),this.renderingToTexture=!1;const x={};this._visibleDemTiles=[];for(const w of this.proxyCoords){const E=this.terrainTileForTile[w.key];if(!E)continue;const I=E.tileID.key;I in x||(this._visibleDemTiles.push(E),x[I]=I)}}_assignTerrainTiles(r){this._initializing||r.forEach(o=>{if(this.terrainTileForTile[o.key])return;const u=this._findTileCoveringTileID(o,this.sourceCache);u&&(this.terrainTileForTile[o.key]=u)})}_prepareDEMTextures(){const r=this.painter.context,o=r.gl;for(const u in this.terrainTileForTile){const f=this.terrainTileForTile[u],m=f.dem;!m||f.demTexture&&!f.needsDEMTextureUpload||(r.activeTexture.set(o.TEXTURE1),pl(this.painter,f,m))}}_prepareDemTileUniforms(r,o,u,f){if(!o||o.demTexture==null)return!1;const m=r.tileID.canonical,g=Math.pow(2,o.tileID.canonical.z-m.z),x=f||"";return u[`u_dem_tl${x}`]=[m.x*g%1,m.y*g%1],u[`u_dem_scale${x}`]=g,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let r=0;const o=this._visibleDemTiles.reduce((u,f)=>{if(!f.dem)return u;const m=f.dem.tree.minimums[0];return m>0&&r++,u+m},0);return r?o/r:0}_updateEmptyDEMTexture(){const r=this.painter.context,o=r.gl;r.activeTexture.set(o.TEXTURE2);const u=this._getLoadedAreaMinimum(),f=new d.dv({width:1,height:1},new Float32Array([u]));this._emptyDEMTextureDirty=!1;let m=this._emptyDEMTexture;return m?m.update(f,{premultiply:!1}):m=this._emptyDEMTexture=new d.T(r,f,o.R32F,{premultiply:!1}),m}setupElevationDraw(r,o,u){const f=this.painter.context,m=f.gl,g={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};g.u_exaggeration=this.exaggeration();let x=null,w=null,E=1;if(u&&u.morphing&&this._useVertexMorphing){const B=u.morphing.srcDemTile,V=u.morphing.dstDemTile;E=u.morphing.phase,B&&V&&(this._prepareDemTileUniforms(r,B,g,"_prev")&&(w=B),this._prepareDemTileUniforms(r,V,g)&&(x=V))}const I=B=>B&&B.demTexture&&this.painter.linearFloatFilteringSupported()?m.LINEAR:m.NEAREST;let R=null;var P;if(this.enabled?w&&x?(R=x.demTexture,f.activeTexture.set(m.TEXTURE4),w.demTexture.bind(I(w),m.CLAMP_TO_EDGE),g.u_dem_lerp=E):(x=this.terrainTileForTile[r.tileID.key],R=this._prepareDemTileUniforms(r,x,g)?x.demTexture:this.emptyDEMTexture):R=this.emptyDEMTexture,f.activeTexture.set(m.TEXTURE2),R&&(g.u_dem_size=(P=R).size[0]===1?1:P.size[0]-2,R.bind(I(x),m.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(u&&u.useDepthForOcclusion,o,g),u&&u.useMeterToDem&&x){const B=(1<<x.tileID.canonical.z)*d.dw(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;g.u_meter_to_dem=B}if(u&&u.labelPlaneMatrixInv&&(g.u_label_plane_matrix_inv=u.labelPlaneMatrixInv),o.setTerrainUniformValues(f,g),this.painter.transform.projection.name==="globe"){const B=this.globeUniformValues(this.painter.transform,r.tileID.canonical,u&&u.useDenormalizedUpVectorScale);o.setGlobeUniformValues(f,B)}}globeUniformValues(r,o,u){const f=r.projection;return{u_tile_tl_up:f.upVector(o,0,0),u_tile_tr_up:f.upVector(o,d.a2,0),u_tile_br_up:f.upVector(o,d.a2,d.a2),u_tile_bl_up:f.upVector(o,0,d.a2),u_tile_up_scale:u?d.dx(1):f.upVectorScale(o,r.center.lat,r.worldSize).metersToTile}}renderToBackBuffer(r){const o=this.painter,u=this.painter.context;r.length!==0&&(u.bindFramebuffer.set(null),u.viewport.set([0,0,o.width,o.height]),o.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(f,m,g,x,w){if(f.transform.projection.name==="globe")(function(E,I,R,P,B){const V=E.context,U=V.gl;let G,$;const Y=E.transform,re=d.dt(E,V,Y),oe=(Se,Re)=>{if($===Re)return;const Ue=[];Re===1&&Ue.push("TERRAIN_VERTEX_MORPHING"),Ue.push("PROJECTION_GLOBE_VIEW"),re&&Ue.push("CUSTOM_ANTIALIASING");const Pe=E.isTileAffectedByFog(Se);G=E.getOrCreateProgram("globeRaster",{defines:Ue,overrideFog:Pe}),$=Re},pe=E.colorModeForRenderPass(),ce=new d.Z(U.LEQUAL,d.Z.ReadWrite,E.depthRangeFor3D);_l.update(B);const _e=d.b6(Y),ue=[d.a7(Y.center.lng),d.a8(Y.center.lat)],me=E.globeSharedBuffers,Ie=[Y.width*d.e.devicePixelRatio,Y.height*d.e.devicePixelRatio],we=Float32Array.from(Y.globeMatrix),ve={useDenormalizedUpVectorScale:!0};{const Se=E.transform,Re=yd(Se.zoom,I.exaggeration(),I.sourceCache._source.tileSize);$=-1;const Ue=U.TRIANGLES;for(const Pe of P){const Oe=R.getTile(Pe),Xe=d._.disabled,ot=I.prevTerrainTileForTile[Pe.key],tt=I.terrainTileForTile[Pe.key];ml(ot,tt)&&_l.newMorphing(Pe.key,ot,tt,B,250),Qc(E,Oe.emissiveTexture),V.activeTexture.set(U.TEXTURE0),Oe.texture&&Oe.texture.bind(U.LINEAR,U.CLAMP_TO_EDGE);const Ye=_l.getMorphValuesForProxy(Pe.key),mt=Ye?1:0;Ye&&Object.assign(ve,{morphing:{srcDemTile:Ye.from,dstDemTile:Ye.to,phase:d.ds(Ye.phase)}});const We=d.b2(Pe.canonical),je=d.b3(We.getCenter().lat),Je=d.b7(Pe.canonical,We,je,Se.worldSize/Se._pixelsPerMercatorPixel),ft=d.b4(d.b5(Pe.canonical)),rt=E.emissiveMode==="mrt-fallback"?1:0,ct=sh(Se.expandedFarZProjMatrix,we,_e,ft,d.S(Se.zoom),ue,Se.frustumCorners.TL,Se.frustumCorners.TR,Se.frustumCorners.BR,Se.frustumCorners.BL,Se.globeCenterInViewSpace,Se.globeRadius,Ie,Re,Se._farZ,rt,Je);if(oe(Pe,mt),G&&(I.setupElevationDraw(Oe,G,ve),E.uploadCommonUniforms(V,G,Pe.toUnwrapped()),me)){const[xt,Rt,Mt]=me.getGridBuffers(je,Re!==0);G.draw(E,Ue,ce,Xe,pe,d.$.backCCW,ct,"globe_raster",xt,Rt,Mt)}}}if(me&&(E.renderDefaultNorthPole||E.renderDefaultSouthPole)){const Se=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];re&&Se.push("CUSTOM_ANTIALIASING"),G=E.getOrCreateProgram("globeRaster",{defines:Se});for(const Re of P){const{x:Ue,y:Pe,z:Oe}=Re.canonical,Xe=Pe===0,ot=Pe===(1<<Oe)-1,[tt,Ye,mt,We]=me.getPoleBuffers(Oe,!1);if(We&&(Xe||ot)){const je=R.getTile(Re);Qc(E,je.emissiveTexture),V.activeTexture.set(U.TEXTURE0),je.texture&&je.texture.bind(U.LINEAR,U.CLAMP_TO_EDGE);let Je=d.du(Oe,Ue,Y);const ft=d.b4(d.b5(Re.canonical)),rt=E.emissiveMode==="mrt-fallback"?1:0,ct=(xt,Rt)=>xt.draw(E,U.TRIANGLES,ce,d._.disabled,pe,d.$.disabled,sh(Y.expandedFarZProjMatrix,Je,Je,ft,0,ue,Y.frustumCorners.TL,Y.frustumCorners.TR,Y.frustumCorners.BR,Y.frustumCorners.BL,Y.globeCenterInViewSpace,Y.globeRadius,Ie,0,Y._farZ,rt),"globe_pole_raster",Rt,mt,We);I.setupElevationDraw(je,G,ve),E.uploadCommonUniforms(V,G,Re.toUnwrapped()),Xe&&E.renderDefaultNorthPole&&ct(G,tt),ot&&E.renderDefaultSouthPole&&(Je=d.aN(d.Y(),Je,[1,-1,1]),ct(G,Ye))}}}})(f,m,g,x,w);else{const E=f.context,I=E.gl;let R,P;const B=f.shadowRenderer,V=d.aE(f,f.longestCutoffRange),U=pe=>{if(P===pe)return;const ce=[];pe===1&&ce.push("TERRAIN_VERTEX_MORPHING"),V.shouldRenderCutoff&&ce.push("RENDER_CUTOFF"),B&&(ce.push("RENDER_SHADOWS"),B.useNormalOffset&&ce.push("NORMAL_OFFSET")),R=f.getOrCreateProgram("terrainRaster",{defines:ce}),P=pe},G=f.colorModeForRenderPass(),$=new d.Z(I.LEQUAL,d.Z.ReadWrite,f.depthRangeFor3D);_l.update(w);const Y=f.transform,re=yd(Y.zoom,m.exaggeration(),m.sourceCache._source.tileSize);let oe=[0,0,0];if(B){const pe=f.style.directionalLight,ce=f.style.ambientLight;pe&&ce&&(oe=d.aF(f.style,pe,ce))}{P=-1;const pe=I.TRIANGLES,[ce,_e]=[m.gridIndexBuffer,m.gridSegments];for(const ue of x){const me=g.getTile(ue),Ie=d._.disabled,we=m.prevTerrainTileForTile[ue.key],ve=m.terrainTileForTile[ue.key];ml(we,ve)&&_l.newMorphing(ue.key,we,ve,w,250),Qc(f,me.emissiveTexture),E.activeTexture.set(I.TEXTURE0),me.texture&&me.texture.bind(I.LINEAR,I.CLAMP_TO_EDGE);const Se=_l.getMorphValuesForProxy(ue.key),Re=Se?1:0;let Ue;Se&&(Ue={morphing:{srcDemTile:Se.from,dstDemTile:Se.to,phase:d.ds(Se.phase)}});const Pe=f.emissiveMode==="mrt-fallback"?1:0,Oe=gd(ue.projMatrix,Qf(ue.canonical,Y.renderWorldCopies)?re/10:re,oe,Pe);if(U(Re),!R)continue;m.setupElevationDraw(me,R,Ue);const Xe=ue.toUnwrapped();B&&B.setupShadows(Xe,R),f.uploadCommonUniforms(E,R,Xe,null,V),R.draw(f,pe,$,Ie,G,d.$.backCCW,Oe,"terrain_raster",m.gridBuffer,ce,_e)}}}}(o,this,this.proxySourceCache,r,this._updateTimestamp),this.renderingToTexture=!0,o.gpuTimingDeferredRenderEnd(),r.splice(0,r.length))}renderBatch(r){if(this._drapedRenderBatches.length===0)return r+1;this.renderingToTexture=!0;const o=this.painter,u=this.painter.context,f=this.proxySourceCache,m=this.proxiedCoords[f.id],g=this._drapedRenderBatches.shift(),x=o.style.order,w=[];this._updateFBOs(o.emissiveMode==="mrt-fallback");let E=0;for(const I of m){const R=f.getTileByID(I.proxyTileKey),P=f.proxyCachedFBO[I.key]?f.proxyCachedFBO[I.key][r]:void 0,B=P!==void 0?f.renderCache[P]:this.pool[E++],V=P!==void 0;if(R.texture=B.tex,R.emissiveTexture=B.emissiveTex,V&&!B.dirty){w.push(R.tileID);continue}u.bindFramebuffer.set(B.fb.framebuffer);const U=u.gl;let G;U.drawBuffers(o.emissiveMode==="mrt-fallback"?[U.COLOR_ATTACHMENT0,U.COLOR_ATTACHMENT1]:[U.COLOR_ATTACHMENT0]),this.renderedToTile=!1,B.dirty&&(u.clear({color:d.C.transparent,stencil:0}),B.dirty=!1);for(let $=g.start;$<=g.end;++$){const Y=o.style._mergedLayers[x[$]];if(Y.isHidden(o.transform.zoom))continue;const re=o.style.getLayerSourceCache(Y),oe=re?this.proxyToSource[I.key][re.id]:[I];if(!oe)continue;const pe=oe;u.viewport.set([0,0,B.fb.width,B.fb.height]),G!==(re?re.id:null)&&(this._setupStencil(B,oe,Y,re),G=re?re.id:null),o.renderLayer(o,re,Y,pe)}if(U.drawBuffers([U.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const $ of this._pendingGroundEffectLayers){const Y=o.style._mergedLayers[x[$]];if(Y.isHidden(o.transform.zoom))continue;const re=o.style.getLayerSourceCache(Y),oe=re?this.proxyToSource[I.key][re.id]:[I];if(!oe)continue;const pe=oe;u.viewport.set([0,0,B.fb.width,B.fb.height]),G!==(re?re.id:null)&&(this._setupStencil(B,oe,Y,re),G=re?re.id:null),o.renderLayer(o,re,Y,pe)}this.renderedToTile?(B.dirty=!0,w.push(R.tileID)):V||--E,E===5&&(E=0,this.renderToBackBuffer(w))}return this.renderToBackBuffer(w),this.renderingToTexture=!1,u.bindFramebuffer.set(null),u.viewport.set([0,0,o.width,o.height]),g.end+1}postRender(){}isLayerOrderingCorrect(r){const o=r.order.length;let u=-1,f=o;for(let m=0;m<o;++m)this._style.isLayerDraped(r._mergedLayers[r.order[m]])?u=Math.max(u,m):f=Math.min(f,m);return f>u}getMinElevationBelowMSL(){let r=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{r=Math.min(r,o.dem.tree.minimums[0])}),r===0?r:(r-30)*this._exaggeration}raycast(r,o,u){if(!this._visibleDemTiles)return null;const f=this._visibleDemTiles.filter(m=>m.dem).map(m=>{const g=m.tileID,x=1<<g.overscaledZ,{x:w,y:E}=g.canonical,I=w/x,R=(w+1)/x,P=E/x,B=(E+1)/x;return{minx:I,miny:P,maxx:R,maxy:B,t:m.dem.tree.raycastRoot(I,P,R,B,r,o,u),tile:m}});f.sort((m,g)=>(m.t!==null?m.t:Number.MAX_VALUE)-(g.t!==null?g.t:Number.MAX_VALUE));for(const m of f){if(m.t==null)return null;const g=m.tile.dem.tree.raycast(m.minx,m.miny,m.maxx,m.maxy,r,o,u);if(g!=null)return g}return null}_createFBO(){const r=this.painter.context,o=r.gl,u=this.drapeBufferSize;r.activeTexture.set(o.TEXTURE0);const f=new d.T(r,{width:u[0],height:u[1],data:null},o.RGBA8);f.bind(o.LINEAR,o.CLAMP_TO_EDGE);const m=r.createFramebuffer(u[0],u[1],1,null);let g;return m.colorAttachment0.set(f.texture),this._emissiveTexture&&(g=new d.T(r,{width:u[0],height:u[1],data:null},o.R8),g.bind(o.LINEAR,o.CLAMP_TO_EDGE),m.createColorAttachment(r,1),m.colorAttachment1.set(g.texture)),m.depthAttachment=new _d(r,m.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=r.createRenderbuffer(r.gl.DEPTH_STENCIL,u[0],u[1]),this._stencilRef=0,m.depthAttachment.set(this._sharedDepthStencil),r.clear({stencil:0})):m.depthAttachment.set(this._sharedDepthStencil),r.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax),{fb:m,tex:f,emissiveTex:g,dirty:!1}}_updateFBOs(r){if(this._emissiveTexture!==r){for(const o of this.pool)this._updateFBO(o,r);for(const o of this.proxySourceCache.renderCache)this._updateFBO(o,r);this._emissiveTexture=r}}_updateFBO(r,o){const u=r.fb,f=this.painter.context,m=f.gl,g=this.drapeBufferSize;if(o){const x=new d.T(f,{width:g[0],height:g[1],data:null},m.R8);x.bind(m.LINEAR,m.CLAMP_TO_EDGE),r.emissiveTex=x,u.createColorAttachment(f,1),u.colorAttachment1.set(x.texture)}else r.emissiveTex=void 0,u.removeColorAttachment(f,1);r.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(const r in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[r].hasTransition())return!0;return this._style.order.some(r=>{const o=this._style._mergedLayers[r],u=o.isHidden(this.painter.transform.zoom);return o.type==="hillshade"||o.type==="custom"?!u&&o.shouldRedrape():!u&&o.hasTransition()})}_clearLineLayersFromRenderCache(){let r=!1;for(const u of this._style.getSources())if(u instanceof ya){r=!0;break}if(!r)return;const o={};for(let u=0;u<this._style.order.length;++u){const f=this._style._mergedLayers[this._style.order[u]],m=this._style.getLayerSourceCache(f);if(!m||o[m.id]||f.isHidden(this.painter.transform.zoom)||f.type!=="line")continue;const g=f.widthExpression(),x=f.emissiveStrengthExpression();if(g instanceof d.aj||x instanceof d.aj){o[m.id]=!0;for(const w of this.proxyCoords){const E=this.proxyToSource[w.key][m.id];if(E)for(const I of E)this._clearRenderCacheForTile(m.id,I)}}}}_clearRasterLayersFromRenderCache(){let r=!1;for(const u in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[u]._source instanceof jc){r=!0;break}if(!r)return;const o={};for(let u=0;u<this._style.order.length;++u){const f=this._style._mergedLayers[this._style.order[u]],m=this._style.getLayerSourceCache(f);if(!m||o[m.id]||f.isHidden(this.painter.transform.zoom)||f.type!=="raster")continue;const g=f.paint.get("raster-fade-duration");for(const x of this.proxyCoords){const w=this.proxyToSource[x.key][m.id];if(w)for(const E of w){const I=Or(m.getTile(E),m.findLoadedParent(E,0),m,this.painter.transform,g);(I.opacity!==1||I.mix!==0)&&this._clearRenderCacheForTile(m.id,E)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();const r=this._style.order,o=r.length;if(o===0)return;const u=[];this._pendingGroundEffectLayers=[];let f,m=0,g=this._style._mergedLayers[r[m]];for(;!this._style.isLayerDraped(g)&&g.isHidden(this.painter.transform.zoom)&&++m<o;)g=this._style._mergedLayers[r[m]];for(;m<o;++m){const x=this._style._mergedLayers[r[m]];x.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(x)?f===void 0&&(f=m):(x.type==="fill-extrusion"&&this._pendingGroundEffectLayers.push(m),f!==void 0&&(u.push({start:f,end:m-1}),f=void 0)))}if(f!==void 0&&u.push({start:f,end:m-1}),u.length!==0){const x=u.at(-1);this._pendingGroundEffectLayers.every(w=>w>x.end)||d.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=u}_setupRenderCache(r){const o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){const g=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let x=0;x<g.length;++x){const w=Object.values(g[x]);o.renderCachePool.push(...w)}}return}this._clearRasterLayersFromRenderCache();const u=this.proxyCoords,f=this._tilesDirty;for(let g=u.length-1;g>=0;g--){const x=u[g];if(o.getTileByID(x.key),o.proxyCachedFBO[x.key]!==void 0){const w=r[x.key],E=this.proxyToSource[x.key];let I=0;for(const R in E){const P=E[R],B=w[R];if(!B||B.length!==P.length||P.some((V,U)=>V!==B[U]||f[R]&&Object.hasOwn(f[R],V.key))){I=-1;break}++I}for(const R in o.proxyCachedFBO[x.key])o.renderCache[o.proxyCachedFBO[x.key][R]].dirty=I<0||I!==Object.values(w).length}}const m=[...this._drapedRenderBatches];m.sort((g,x)=>x.end-x.start-(g.end-g.start));for(const g of m)for(const x of u){if(o.proxyCachedFBO[x.key])continue;let w=o.renderCachePool.pop();w===void 0&&o.renderCache.length<50&&(w=o.renderCache.length,o.renderCache.push(this._createFBO())),w!==void 0&&(o.proxyCachedFBO[x.key]={},o.proxyCachedFBO[x.key][g.start]=w,o.renderCache[w].dirty=!0)}this._tilesDirty={}}_setupStencil(r,o,u,f){if(!f||!this._sourceTilesOverlap[f.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const m=this.painter.context,g=m.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let x;if(u.isTileClipped())x=o.length,this._overlapStencilMode.test={func:g.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(o[0].overscaledZ>o.at(-1).overscaledZ))return void(this._overlapStencilType=!1);x=1,this._overlapStencilMode.test={func:g.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+x>255&&(m.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=x,this._overlapStencilMode.ref=this._stencilRef,u.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(r){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[r.key]),this._overlapStencilMode):d._.disabled}_renderTileClippingMasks(r,o){const u=this.painter,f=this.painter.context,m=f.gl;u._tileClippingMaskIDs={},f.setColorMode(d.a1.disabled),f.setDepthMode(d.Z.disabled);const g=u.getOrCreateProgram("clippingMask");for(const x of r){const w=u._tileClippingMaskIDs[x.key]=--o;g.draw(u,m.TRIANGLES,d.Z.disabled,new d._({func:m.ALWAYS,mask:0},w,255,m.KEEP,m.KEEP,m.REPLACE),d.a1.disabled,d.$.disabled,Sr(x.projMatrix),"$clipping",u.tileExtentBuffer,u.quadTriangleIndexBuffer,u.tileExtentSegments)}}pointCoordinate(r){const o=this.painter.transform;if(r.x<0||r.x>o.width||r.y<0||r.y>o.height)return null;const u=[r.x,r.y,1,1];d.c7(u,u,o.pixelMatrixInverse),d.dy(u,u,1/u[3]),u[0]/=o.worldSize,u[1]/=o.worldSize;const f=o._camera.position,m=d.dw(1,o.center.lat),g=[f[0],f[1],f[2]/m,0],x=d.dz([],u.slice(0,3),g);d.c3(x,x);const w=this.raycast(g,x,this._exaggeration);return w!==null&&w?(d.dA(g,g,x,w),g[3]=g[2],g[2]*=m,g):null}_setupProxiedCoordsForOrtho(r,o,u){if(r.getSource()instanceof ho)return this._setupProxiedCoordsForImageSource(r,o,u);this._findCoveringTileCache[r.id]=this._findCoveringTileCache[r.id]||{};const f=this.proxiedCoords[r.id]=[],m=this.proxyCoords;for(let w=0;w<m.length;w++){const E=m[w],I=this._findTileCoveringTileID(E,r);if(I){const R=this._createProxiedId(E,I,u[E.key]&&u[E.key][r.id]);f.push(R),this.proxyToSource[E.key][r.id]=[R]}}let g=!1;const x=new Set;for(let w=0;w<o.length;w++){const E=r.getTile(o[w]);if(!E||!E.hasData())continue;const I=this._findTileCoveringTileID(E.tileID,this.proxySourceCache);if(I&&I.tileID.canonical.z!==E.tileID.canonical.z){const R=this.proxyToSource[I.tileID.key][r.id],P=this._createProxiedId(I.tileID,E,u[I.tileID.key]&&u[I.tileID.key][r.id]);R?R.splice(R.length-1,0,P):this.proxyToSource[I.tileID.key][r.id]=[P];const B=this.proxyToSource[I.tileID.key][r.id];x.has(B)||x.add(B),f.push(P),g=!0}}if(this._sourceTilesOverlap[r.id]=g,g)for(const w of x)w.sort((E,I)=>I.overscaledZ-E.overscaledZ)}_setupProxiedCoordsForImageSource(r,o,u){if(!r.getSource().loaded())return;const f=this.proxiedCoords[r.id]=[],m=this.proxyCoords,g=r.getSource(),x=g.tileID;if(!x)return;const w=new d.P(x.x,x.y)._div(1<<x.z),E=g.coordinates.map(d.bS.fromLngLat).reduce((R,P)=>(R.min.x=Math.min(R.min.x,P.x-w.x),R.min.y=Math.min(R.min.y,P.y-w.y),R.max.x=Math.max(R.max.x,P.x-w.x),R.max.y=Math.max(R.max.y,P.y-w.y),R),{min:new d.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new d.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),I=(R,P)=>{const B=R.wrap+R.canonical.x/(1<<R.canonical.z),V=R.canonical.y/(1<<R.canonical.z),U=d.a2/(1<<R.canonical.z),G=P.wrap+P.canonical.x/(1<<P.canonical.z),$=P.canonical.y/(1<<P.canonical.z);return B+U<G+E.min.x||B>G+E.max.x||V+U<$+E.min.y||V>$+E.max.y};for(let R=0;R<m.length;R++){const P=m[R];for(let B=0;B<o.length;B++){const V=r.getTile(o[B]);if(!V||!V.hasData()||I(P,V.tileID))continue;const U=this._createProxiedId(P,V,u[P.key]&&u[P.key][r.id]),G=this.proxyToSource[P.key][r.id];G?G.push(U):this.proxyToSource[P.key][r.id]=[U],f.push(U)}}}_createProxiedId(r,o,u){let f=this.orthoMatrix;if(u){const m=u.find(g=>g.key===o.tileID.key);if(m)return m}if(o.tileID.key!==r.key){const m=r.canonical.z-o.tileID.canonical.z;let g,x,w;f=d.Y();const E=o.tileID.wrap-r.wrap<<r.overscaledZ;m>0?(g=d.a2>>m,x=g*((o.tileID.canonical.x<<m)-r.canonical.x+E),w=g*((o.tileID.canonical.y<<m)-r.canonical.y)):(g=d.a2<<-m,x=d.a2*(o.tileID.canonical.x-(r.canonical.x+E<<-m)),w=d.a2*(o.tileID.canonical.y-(r.canonical.y<<-m))),d.dr(f,0,g,0,g,0,1),d.bM(f,f,[x,w,0])}return new eu(o.tileID,r.key,f)}_findTileCoveringTileID(r,o){let u=o.getTile(r);if(u&&u.hasData())return u;const f=this._findCoveringTileCache[o.id],m=f[r.key];if(u=m?o.getTileByID(m):null,u&&u.hasData()||m===null)return u;let g=u?u.tileID:r,x=g.overscaledZ;const w=o.getSource().minzoom,E=[];if(!m){const R=o.getSource().maxzoom;if(r.canonical.z>=R){const P=r.canonical.z-R;o.getSource().reparseOverscaled?(x=Math.max(r.canonical.z+2,o.transform.tileZoom),g=new d.bP(x,r.wrap,R,r.canonical.x>>P,r.canonical.y>>P)):P!==0&&(x=R,g=new d.bP(x,r.wrap,R,r.canonical.x>>P,r.canonical.y>>P))}g.key!==r.key&&(E.push(g.key),u=o.getTile(g))}const I=R=>{E.forEach(P=>{f[P]=R}),E.length=0};for(x-=1;x>=w&&(!u||!u.hasData());x--){u&&I(u.tileID.key);const R=g.calculateScaledKey(x);if(u=o.getTileByID(R),u&&u.hasData())break;const P=f[R];if(P===null)break;P===void 0?E.push(R):u=o.getTileByID(P)}return I(u?u.tileID.key:null),u&&u.hasData()?u:null}findDEMTileFor(r){return this.enabled?this._findTileCoveringTileID(r,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(r,o){let u=this._tilesDirty[r];u||(u=this._tilesDirty[r]={}),u[o.key]=!0}}function ep(a,r,o){const u=function(x,w,E){const I=d.dF(w,x),R=d.dF(E,[.2126,.7152,.0722]),P=1-.3*Math.min(R,1),B=d.al(P,1,Math.min(I+1,1));return d.al(.92,1,Math.asin(d.b0(w[2],-1,1))/Math.PI+.5)*B}(a,[0,0,1],r),f=[0,0,0];d.dC(f,o.slice(0,3),u);const m=[0,0,0];d.dC(m,r.slice(0,3),a[2]);const g=[0,0,0];return d.dD(g,f,m),d.dE(g)}const Ta=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],vd=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class iu{static cacheKey(r,o,u,f){const m=[o];f&&m.push(f.cacheKey);for(const g of u)(typeof g=="string"&&g.includes(" ")||r.usedDefines.has(g))&&m.push(g);return m.join("/")}constructor(r,o,u,f,m,g,x=!1){const w=r.gl;this.program=w.createProgram(),this._context=r,this._fixedUniformsFn=m,this._pending=!0,this._precompiled=x,this.attributes={},this.configuration=f,this.name=o,this.fixedDefines=[...g],x?r._compileStats.precompiled++:r._compileStats.onDemand++;const E=`#version 300 es
3412${(f?f.defines():[]).concat(g.map(G=>`#define ${G}`)).join(`
3413`)}`,I=[E,d.dG];for(const G of u.fragmentIncludes)I.push(d.ba[G]);I.push(u.fragmentSource);const R=I.join(`
3414`),P=[E,d.dH];for(const G of u.vertexIncludes)P.push(d.ba[G]);this.forceManualRenderingForInstanceIDShaders=r.forceManualRenderingForInstanceIDShaders&&u.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&P.push("uniform int u_instanceID;"),P.push(u.vertexSource);let B=P.join(`
3415`);this.forceManualRenderingForInstanceIDShaders&&(B=B.replaceAll("gl_InstanceID","u_instanceID"));const V=w.createShader(w.FRAGMENT_SHADER);if(w.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);w.shaderSource(V,R),w.compileShader(V),w.attachShader(this.program,V);const U=w.createShader(w.VERTEX_SHADER);if(w.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);w.shaderSource(U,B),w.compileShader(U),w.attachShader(this.program,U),w.linkProgram(this.program),this._fragmentShader=V,this._vertexShader=U,r.extParallelShaderCompile?r._pendingPrograms.add(this):this._finalize()}_finalize(){if(!this._pending)return;this._pending=!1;const r=this._context,o=r.gl;r._pendingPrograms.delete(this);const u=d.e.now(),f=o.getProgramParameter(this.program,o.LINK_STATUS),m=d.e.now()-u,g=r._compileStats;if(g.totalStallMs+=m,m>g.maxStallMs&&(g.maxStallMs=m),m>1){g.framesMissed+=Math.floor(60*m/1e3);const E=this.fixedDefines.join(",");g.stalls.push({name:`${this.name}${E?"/":""}${E}`,ms:m,timestamp:u})}if(this._fragmentShader&&(f||d.w(`Fragment shader '${this.name}': ${o.getShaderInfoLog(this._fragmentShader)}`),o.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(f||d.w(`Vertex shader '${this.name}': ${o.getShaderInfoLog(this._vertexShader)}`),o.deleteShader(this._vertexShader),this._vertexShader=null),!f)return d.w(`Failed to link program '${this.name}': ${o.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(r),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(r):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(E=>({u_instanceID:new d.aX(E)}))(r));const x=this.fixedDefines,w=this.name;(x.includes("TERRAIN")||x.includes("ELEVATED")||w.includes("symbol")||w.includes("circle"))&&(this.terrainUniforms=(E=>({u_dem:new d.aX(E),u_dem_prev:new d.aX(E),u_dem_tl:new d.a3(E),u_dem_scale:new d.a4(E),u_dem_tl_prev:new d.a3(E),u_dem_scale_prev:new d.a4(E),u_dem_size:new d.a4(E),u_dem_lerp:new d.a4(E),u_exaggeration:new d.a4(E),u_depth:new d.aX(E),u_depth_size_inv:new d.a3(E),u_depth_range_unpack:new d.a3(E),u_occluder_half_size:new d.a4(E),u_occlusion_depth_offset:new d.a4(E),u_meter_to_dem:new d.a4(E),u_label_plane_matrix_inv:new d.a5(E)}))(r)),x.includes("GLOBE")&&(this.globeUniforms=(E=>({u_tile_tl_up:new d.a6(E),u_tile_tr_up:new d.a6(E),u_tile_br_up:new d.a6(E),u_tile_bl_up:new d.a6(E),u_tile_up_scale:new d.a4(E)}))(r)),x.includes("FOG")&&(this.fogUniforms=(E=>({u_fog_matrix:new d.a5(E),u_fog_range:new d.a3(E),u_fog_color:new d.aY(E),u_fog_horizon_blend:new d.a4(E),u_fog_vertical_limit:new d.a3(E),u_fog_temporal_offset:new d.a4(E),u_frustum_tl:new d.a6(E),u_frustum_tr:new d.a6(E),u_frustum_br:new d.a6(E),u_frustum_bl:new d.a6(E),u_globe_pos:new d.a6(E),u_globe_radius:new d.a4(E),u_globe_transition:new d.a4(E),u_is_globe:new d.aX(E),u_viewport:new d.a3(E)}))(r)),x.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=d.dI(r)),x.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(E=>({u_lighting_ambient_color:new d.a6(E),u_lighting_directional_dir:new d.a6(E),u_lighting_directional_color:new d.a6(E),u_ground_radiance:new d.a6(E)}))(r)),x.includes("RENDER_SHADOWS")&&(this.shadowUniforms=d.dJ(r))}maybeFinalize(){if(!this._pending)return;const r=this._context.extParallelShaderCompile;r&&!this._context.gl.getProgramParameter(this.program,r.COMPLETION_STATUS_KHR)||this._finalize()}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms())}getAttributeLocation(r,o){this._ensureReady();let u=this.attributes[o];return u===void 0&&(u=this.attributes[o]=r.getAttribLocation(this.program,o)),u}_setUniformGroup(r,o,u){this._ensureReady();const f=this[o];if(!this.failedToCreate&&f){r.program.set(this.program);for(const m in u){const g=f[m];g&&g.set(this.program,m,u[m])}}}setTerrainUniformValues(r,o){this._setUniformGroup(r,"terrainUniforms",o)}setGlobeUniformValues(r,o){this._setUniformGroup(r,"globeUniforms",o)}setFogUniformValues(r,o){this._setUniformGroup(r,"fogUniforms",o)}setCutoffUniformValues(r,o){this._setUniformGroup(r,"cutoffUniforms",o)}setLightsUniformValues(r,o){this._setUniformGroup(r,"lightsUniforms",o)}setShadowUniformValues(r,o){this._setUniformGroup(r,"shadowUniforms",o)}_drawDebugWireframe(r,o,u,f,m,g,x,w,E,I){const R=r.options.wireframe;if(R.terrain===!1&&R.layers2D===!1&&R.layers3D===!1)return;const P=r.context;if(!(!(!R.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!R.layers2D||r._terrain&&r._terrain.renderingToTexture||!Ta.includes(this.name))||!(!R.layers3D||!vd.includes(this.name))))return;const B=P.gl,V=r.wireframeDebugCache.getLinesFromTrianglesBuffer(r.frameCounter,m,P);if(!V)return;const U=[...this.fixedDefines,"DEBUG_WIREFRAME"],G=r.getOrCreateProgram(this.name,{config:this.configuration,defines:U});G._ensureReady(),P.program.set(G.program);const $=(oe,pe,ce)=>{if(pe[oe]&&ce[oe])for(const _e in pe[oe])ce[oe][_e]&&ce[oe][_e].set(ce.program,_e,pe[oe][_e].current)};E&&E.setUniforms(G.program,P,G.binderUniforms,x,{zoom:w}),$("fixedUniforms",this,G),$("terrainUniforms",this,G),$("globeUniforms",this,G),$("fogUniforms",this,G),$("lightsUniforms",this,G),$("shadowUniforms",this,G),V.bind(),P.setColorMode(new d.a1([B.ONE,B.ONE_MINUS_SRC_ALPHA,B.ZERO,B.ONE],d.C.transparent,[!0,!0,!0,!1])),P.setDepthMode(new d.Z(o.func===B.LESS?B.LEQUAL:o.func,d.Z.ReadOnly,o.range)),P.setStencilMode(d._.disabled);const Y=3*g.primitiveLength*2,re=3*g.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const oe=I||1;for(let pe=0;pe<oe;++pe)G.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",pe),B.drawElements(B.LINES,Y,B.UNSIGNED_SHORT,re)}else I&&I>1?B.drawElementsInstanced(B.LINES,Y,B.UNSIGNED_SHORT,re,I):B.drawElements(B.LINES,Y,B.UNSIGNED_SHORT,re);m.bind(),P.program.set(this.program),P.setDepthMode(o),P.setStencilMode(u),P.setColorMode(f)}checkUniforms(r,o,u){if(this.fixedDefines.includes(o)){for(const f of Object.keys(u))if(!u[f].initialized)throw new Error(`Program '${this.name}', from draw '${r}': uniform ${f} not set but required by ${o} being defined`)}}draw(r,o,u,f,m,g,x,w,E,I,R,P,B,V,U,G){const $=r.context,Y=$.gl;if(this._ensureReady(),this.failedToCreate)return;$.program.set(this.program),$.setDepthMode(u),$.setStencilMode(f),$.setColorMode(m),$.setCullFace(g);for(const[ue,me]of this.fixedUniformsEntries)me.set(this.program,ue,x[ue]);V&&V.setUniforms(this.program,$,this.binderUniforms,P,{zoom:B});const re={[Y.POINTS]:1,[Y.LINES]:2,[Y.TRIANGLES]:3,[Y.LINE_STRIP]:1}[o];this.checkUniforms(w,"RENDER_SHADOWS",this.shadowUniforms);const oe=U||[],pe=V?V.getPaintVertexBuffers():[],ce=o===Y.TRIANGLES&&I,_e=G&&G>0?1:void 0;for(const ue of R.get()){const me=ue.vaos||(ue.vaos={});if((me[w]||(me[w]=new Gf)).bind($,this,E,pe,I,ue.vertexOffset,oe,_e),this.forceManualRenderingForInstanceIDShaders){const Ie=G||1;for(let we=0;we<Ie;++we)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",we),I?Y.drawElements(o,ue.primitiveLength*re,Y.UNSIGNED_SHORT,ue.primitiveOffset*re*2):Y.drawArrays(o,ue.vertexOffset,ue.vertexLength)}else G&&G>1?Y.drawElementsInstanced(o,ue.primitiveLength*re,Y.UNSIGNED_SHORT,ue.primitiveOffset*re*2,G):I?Y.drawElements(o,ue.primitiveLength*re,Y.UNSIGNED_SHORT,ue.primitiveOffset*re*2):Y.drawArrays(o,ue.vertexOffset,ue.vertexLength);ce&&this._drawDebugWireframe(r,u,f,m,I,ue,P,B,V,G)}}}const bd=(a,r,o)=>({u_matrix:a,u_emissive_strength:r,u_ground_shadow_factor:o,u_opacity_multiplier:1}),wd=(a,r,o,u,f,m=0)=>Object.assign(bd(a,r,f),d.dK(o,u,m)),Td=(a,r,o,u)=>({u_matrix:a,u_world:o,u_emissive_strength:r,u_ground_shadow_factor:u,u_opacity_multiplier:1}),Ed=(a,r,o,u,f,m,g=0)=>Object.assign(wd(a,r,o,u,m,g),{u_world:f}),R_=(a,r,o)=>({u_image:a,u_texel_size:r,u_first_pass:o?1:0}),tp=d.Y(),ru=(a,r,o,u,f,m,g)=>{const x=a.transform,w=x.projection.name==="globe",E=w?d.dL(x.zoom,r.canonical)*x._pixelsPerMercatorPixel:d.c5(o,1,m),I={u_matrix:r.projMatrix,u_extrude_scale:E,u_intensity:g,u_inv_rot_matrix:tp,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(w){I.u_inv_rot_matrix=u,I.u_merc_center=f,I.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],I.u_zoom_transition=d.S(x.zoom);const R=f[0]*d.a2,P=f[1]*d.a2;I.u_up_dir=x.projection.upVector(new d.bX(0,0,0),R,P)}return I};function P_(a){const r=a.terrain?a.terrain.exaggeration():1;return(a.transform.pitch<15?d.al(.07,.7,d.b0((14-a.transform.zoom)/5,0,1)):.07)*r}const ip=(a,r,o,u,f,m,g,x,w,E,I,R,P,B,V,U,G,$,Y,re,oe,pe)=>({u_matrix:r,u_normalize_matrix:o,u_globe_matrix:u,u_merc_matrix:f,u_grid_matrix:m,u_tl_parent:g,u_scale_parent:I,u_fade_t:R.mix,u_opacity:R.opacity*P.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:P.paint.get("raster-brightness-min"),u_brightness_high:P.paint.get("raster-brightness-max"),u_saturation_factor:d.dO(P.paint.get("raster-saturation")),u_contrast_factor:d.dN(P.paint.get("raster-contrast")),u_spin_weights:rp(P.paint.get("raster-hue-rotate")),u_perspective_transform:B,u_raster_elevation:V,u_zoom_transition:x,u_merc_center:w,u_cutoff_params:E,u_colorization_mix:Yr(d.dM,G,Y),u_colorization_offset:wr(d.dM,$,Y),u_color_ramp:U,u_color_ramp_size:d.dM,u_texture_offset:[oe/(re+2*oe),re/(re+2*oe)],u_texture_res:[re+2*oe,re+2*oe],u_emissive_strength:pe,u_zbias_factor:P_(a)});function rp(a){a*=Math.PI/180;const r=Math.sin(a),o=Math.cos(a);return[(2*o+1)/3,(-Math.sqrt(3)*r-o+1)/3,(Math.sqrt(3)*r-o+1)/3]}const np=d.Y(),ah=(a,r,o,u,f,m,g,x,w,E,I,R,P,B,V,U,G,$,Y,re,oe,pe,ce,_e,ue)=>{const me=f.transform,Ie={u_is_size_zoom_constant:+(a==="constant"||a==="source"),u_is_size_feature_constant:+(a==="constant"||a==="camera"),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:me.getCameraToCenterDistance(re),u_rotate_symbol:+o,u_aspect_ratio:me.width/me.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_matrix:m,u_label_plane_matrix:g,u_coord_matrix:x,u_is_text:+E,u_is_sdf:+I,u_elevation_from_sea:w?1:0,u_pitch_with_map:+u,u_texsize:R,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:np,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:np,u_up_vector:[0,-1,0],u_color_adj_mat:ce,u_icon_transition:_e||0,u_gamma_scale:I?u?f.transform.getCameraToCenterDistance(re)*Math.cos(f.terrain?0:f.transform._pitch):1:0,u_device_pixel_ratio:d.e.devicePixelRatio,u_is_halo:1,u_scale_factor:ue||1,u_ground_shadow_factor:oe,u_inv_matrix:d.aO(d.Y(),g),u_normal_scale:pe,u_lutTexture:d.dQ.LUT,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],u_spp_zoom_fraction:0,u_opacity_multiplier:1};return re.name==="globe"&&(Ie.u_tile_id=[V.canonical.x,V.canonical.y,1<<V.canonical.z],Ie.u_zoom_transition=U,Ie.u_inv_rot_matrix=$,Ie.u_merc_center=G,Ie.u_camera_forward=me._camera.forward(),Ie.u_ecef_origin=d.dP(me.globeMatrix,V.toUnwrapped()),Ie.u_tile_matrix=me.globeMatrix,Ie.u_up_vector=Y),Ie},nu=(a,r,o,u)=>({u_matrix:a,u_emissive_strength:r,u_opacity:o,u_color:u}),Ea=(a,r,o,u,f,m,g,x,w)=>Object.assign(d.dR(f,m,g,u,x,w),{u_matrix:a,u_emissive_strength:r,u_opacity:o}),lh={fillExtrusion:d.dX,fillExtrusionPattern:d.dW,fill:a=>({u_matrix:new d.a5(a),u_emissive_strength:new d.a4(a),u_ground_shadow_factor:new d.a6(a),u_opacity_multiplier:new d.a4(a)}),fillPattern:a=>({u_matrix:new d.a5(a),u_emissive_strength:new d.a4(a),u_image:new d.aX(a),u_texsize:new d.a3(a),u_pixel_coord_upper:new d.a3(a),u_pixel_coord_lower:new d.a3(a),u_tile_units_to_pixels:new d.a4(a),u_ground_shadow_factor:new d.a6(a),u_pattern_transition:new d.a4(a),u_opacity_multiplier:new d.a4(a)}),fillOutline:a=>({u_matrix:new d.a5(a),u_emissive_strength:new d.a4(a),u_world:new d.a3(a),u_ground_shadow_factor:new d.a6(a),u_opacity_multiplier:new d.a4(a)}),fillOutlinePattern:a=>({u_matrix:new d.a5(a),u_emissive_strength:new d.a4(a),u_world:new d.a3(a),u_image:new d.aX(a),u_texsize:new d.a3(a),u_pixel_coord_upper:new d.a3(a),u_pixel_coord_lower:new d.a3(a),u_tile_units_to_pixels:new d.a4(a),u_ground_shadow_factor:new d.a6(a),u_pattern_transition:new d.a4(a),u_opacity_multiplier:new d.a4(a)}),lineBlendComposite:a=>({u_image:new d.aX(a),u_opacity:new d.a4(a),u_blend_mode:new d.aX(a),u_max_density:new d.a4(a)}),lineBlendReduce:a=>({u_image:new d.aX(a),u_texel_size:new d.a3(a),u_first_pass:new d.aX(a)}),circle:d.dV,collisionBox:a=>({u_matrix:new d.a5(a),u_inv_rot_matrix:new d.a5(a),u_camera_to_center_distance:new d.a4(a),u_extrude_scale:new d.a3(a),u_zoom_transition:new d.a4(a),u_merc_center:new d.a3(a),u_tile_id:new d.a6(a)}),collisionCircle:a=>({u_matrix:new d.a5(a),u_inv_matrix:new d.a5(a),u_camera_to_center_distance:new d.a4(a),u_viewport_size:new d.a3(a)}),debug:d.dU,clippingMask:a=>({u_matrix:new d.a5(a)}),heatmap:a=>({u_extrude_scale:new d.a4(a),u_intensity:new d.a4(a),u_matrix:new d.a5(a),u_inv_rot_matrix:new d.a5(a),u_merc_center:new d.a3(a),u_tile_id:new d.a6(a),u_zoom_transition:new d.a4(a),u_up_dir:new d.a6(a)}),heatmapTexture:a=>({u_image:new d.aX(a),u_color_ramp:new d.aX(a),u_opacity:new d.a4(a)}),hillshade:a=>({u_matrix:new d.a5(a),u_image:new d.aX(a),u_latrange:new d.a3(a),u_light:new d.a3(a),u_shadow:new d.dq(a),u_highlight:new d.dq(a),u_emissive_strength:new d.a4(a),u_accent:new d.dq(a)}),hillshadePrepare:a=>({u_matrix:new d.a5(a),u_image:new d.aX(a),u_dimension:new d.a3(a),u_zoom:new d.a4(a)}),line:d.dT,linePattern:d.dS,raster:a=>({u_matrix:new d.a5(a),u_normalize_matrix:new d.a5(a),u_globe_matrix:new d.a5(a),u_merc_matrix:new d.a5(a),u_grid_matrix:new d.aZ(a),u_tl_parent:new d.a3(a),u_scale_parent:new d.a4(a),u_fade_t:new d.a4(a),u_opacity:new d.a4(a),u_image0:new d.aX(a),u_image1:new d.aX(a),u_brightness_low:new d.a4(a),u_brightness_high:new d.a4(a),u_saturation_factor:new d.a4(a),u_contrast_factor:new d.a4(a),u_spin_weights:new d.a6(a),u_perspective_transform:new d.a3(a),u_raster_elevation:new d.a4(a),u_zoom_transition:new d.a4(a),u_merc_center:new d.a3(a),u_cutoff_params:new d.aY(a),u_colorization_mix:new d.aY(a),u_colorization_offset:new d.a4(a),u_color_ramp:new d.aX(a),u_color_ramp_size:new d.a4(a),u_texture_offset:new d.a3(a),u_texture_res:new d.a3(a),u_emissive_strength:new d.a4(a),u_zbias_factor:new d.a4(a)}),symbol:a=>({u_is_size_zoom_constant:new d.aX(a),u_is_size_feature_constant:new d.aX(a),u_size_t:new d.a4(a),u_size:new d.a4(a),u_camera_to_center_distance:new d.a4(a),u_rotate_symbol:new d.aX(a),u_aspect_ratio:new d.a4(a),u_fade_change:new d.a4(a),u_matrix:new d.a5(a),u_label_plane_matrix:new d.a5(a),u_coord_matrix:new d.a5(a),u_is_text:new d.aX(a),u_is_sdf:new d.aX(a),u_elevation_from_sea:new d.aX(a),u_pitch_with_map:new d.aX(a),u_texsize:new d.a3(a),u_texsize_icon:new d.a3(a),u_texture:new d.aX(a),u_texture_icon:new d.aX(a),u_gamma_scale:new d.a4(a),u_device_pixel_ratio:new d.a4(a),u_tile_id:new d.a6(a),u_zoom_transition:new d.a4(a),u_inv_rot_matrix:new d.a5(a),u_merc_center:new d.a3(a),u_camera_forward:new d.a6(a),u_tile_matrix:new d.a5(a),u_up_vector:new d.a6(a),u_ecef_origin:new d.a6(a),u_is_halo:new d.aX(a),u_icon_transition:new d.a4(a),u_color_adj_mat:new d.a5(a),u_scale_factor:new d.a4(a),u_ground_shadow_factor:new d.a6(a),u_inv_matrix:new d.a5(a),u_normal_scale:new d.a4(a),u_lutTexture:new d.aX(a),u_spp_fill_np_color:new d.aY(a),u_spp_halo_np_color:new d.aY(a),u_spp_opacity:new d.a4(a),u_spp_halo_width:new d.a4(a),u_spp_halo_blur:new d.a4(a),u_spp_emissive_strength:new d.a4(a),u_spp_occlusion_opacity:new d.a4(a),u_spp_z_offset:new d.a4(a),u_spp_translate_rotation:new d.a3(a),u_spp_zoom_fraction:new d.a4(a),u_opacity_multiplier:new d.a4(a)}),background:a=>({u_matrix:new d.a5(a),u_emissive_strength:new d.a4(a),u_opacity:new d.a4(a),u_color:new d.dq(a)}),backgroundPattern:a=>({u_matrix:new d.a5(a),u_emissive_strength:new d.a4(a),u_opacity:new d.a4(a),u_image:new d.aX(a),u_pattern_tl:new d.a3(a),u_pattern_br:new d.a3(a),u_texsize:new d.a3(a),u_pattern_size:new d.a3(a),u_pixel_coord_upper:new d.a3(a),u_pixel_coord_lower:new d.a3(a),u_pattern_units_to_pixels:new d.a3(a)}),terrainRaster:a=>({u_matrix:new d.a5(a),u_image0:new d.aX(a),u_image1:new d.aX(a),u_skirt_height:new d.a4(a),u_ground_shadow_factor:new d.a6(a),u_emissive_texture_available:new d.a4(a)}),skybox:a=>({u_matrix:new d.a5(a),u_sun_direction:new d.a6(a),u_cubemap:new d.aX(a),u_opacity:new d.a4(a),u_temporal_offset:new d.a4(a)}),skyboxGradient:a=>({u_matrix:new d.a5(a),u_color_ramp:new d.aX(a),u_center_direction:new d.a6(a),u_radius:new d.a4(a),u_opacity:new d.a4(a),u_temporal_offset:new d.a4(a)}),skyboxCapture:a=>({u_matrix_3f:new d.aZ(a),u_sun_direction:new d.a6(a),u_sun_intensity:new d.a4(a),u_color_tint_r:new d.aY(a),u_color_tint_m:new d.aY(a),u_luminance:new d.a4(a)}),globeRaster:a=>({u_proj_matrix:new d.a5(a),u_globe_matrix:new d.a5(a),u_normalize_matrix:new d.a5(a),u_merc_matrix:new d.a5(a),u_zoom_transition:new d.a4(a),u_merc_center:new d.a3(a),u_image0:new d.aX(a),u_image1:new d.aX(a),u_grid_matrix:new d.aZ(a),u_skirt_height:new d.a4(a),u_far_z_cutoff:new d.a4(a),u_frustum_tl:new d.a6(a),u_frustum_tr:new d.a6(a),u_frustum_br:new d.a6(a),u_frustum_bl:new d.a6(a),u_globe_pos:new d.a6(a),u_globe_radius:new d.a4(a),u_viewport:new d.a3(a),u_emissive_texture_available:new d.a4(a)}),globeAtmosphere:a=>({u_frustum_tl:new d.a6(a),u_frustum_tr:new d.a6(a),u_frustum_br:new d.a6(a),u_frustum_bl:new d.a6(a),u_horizon:new d.a4(a),u_transition:new d.a4(a),u_fadeout_range:new d.a4(a),u_atmosphere_fog_color:new d.aY(a),u_high_color:new d.aY(a),u_space_color:new d.aY(a),u_temporal_offset:new d.a4(a),u_horizon_angle:new d.a4(a)}),stars:a=>({u_matrix:new d.a5(a),u_up:new d.a6(a),u_right:new d.a6(a),u_intensity_multiplier:new d.a4(a)}),occlusion:a=>({u_matrix:new d.a5(a),u_anchorPos:new d.a6(a),u_screenSizePx:new d.a3(a),u_occluderSizePx:new d.a3(a),u_color:new d.aY(a)})};class Fo{constructor(r,o,u,f){this.id=Fo.uniqueIdxCounter,Fo.uniqueIdxCounter++,this.context=r;const m=r.gl;this.buffer=m.createBuffer(),this.dynamicDraw=!!u,this.context.unbindVAO(),r.bindElementBuffer.set(this.buffer),m.bufferData(m.ELEMENT_ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.STATIC_DRAW),this.dynamicDraw||f||o.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(r){this.id=Fo.uniqueIdxCounter,Fo.uniqueIdxCounter++;const o=this.context.gl;this.context.unbindVAO(),this.bind(),o.bufferSubData(o.ELEMENT_ARRAY_BUFFER,0,r.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Fo.uniqueIdxCounter=0;const op={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class ch{constructor(r,o,u,f,m,g){this.length=o.length,this.attributes=u,this.itemSize=o.bytesPerElement,this.dynamicDraw=f,this.instanceCount=g,this.context=r;const x=r.gl;this.buffer=x.createBuffer(),r.bindVertexBuffer.set(this.buffer),x.bufferData(x.ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?x.DYNAMIC_DRAW:x.STATIC_DRAW),this.dynamicDraw||m||o.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(r){const o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,r.arrayBuffer)}enableAttributes(r,o){for(const u of this.attributes){const f=o.getAttributeLocation(r,u.name);f!==-1&&r.enableVertexAttribArray(f)}}setVertexAttribPointers(r,o,u){for(const f of this.attributes){const m=o.getAttributeLocation(r,f.name);if(m!==-1){const g=f.offset+this.itemSize*(u||0);f.type==="Float32"?r.vertexAttribPointer(m,f.components,r.FLOAT,!1,this.itemSize,g):r.vertexAttribIPointer(m,f.components,r[op[f.type]],this.itemSize,g)}}}setVertexAttribDivisor(r,o,u){for(let f=0;f<this.attributes.length;f++){const m=o.getAttributeLocation(r,this.attributes[f].name);m!==-1&&this.instanceCount&&this.instanceCount>0&&r.vertexAttribDivisor(m,u)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Js{constructor(r,o,u,f,m){this.context=r,this.width=o,this.height=u;const g=this.framebuffer=r.gl.createFramebuffer();f>0&&(this.colorAttachment0=new oh(r,g,0)),f>1&&(this.colorAttachment1=new oh(r,g,1)),m&&(this.depthAttachmentType=m,this.depthAttachment=m==="renderbuffer"?new Jf(r,g):new M_(r,g))}static createWithTexture(r,o,u,f,m){const g=r.gl;if(r.activeTexture.set(g.TEXTURE1),r.viewport.set([0,0,u,f]),o&&o.width===u&&o.height===f)return g.bindTexture(g.TEXTURE_2D,o.colorAttachment0.get()),r.bindFramebuffer.set(o.framebuffer),o;o&&o.destroy();const x=r.extRenderToTextureHalfFloat||r.extColorBufferFloat?r.gl.RGBA16F:r.gl.RGBA8,w=new d.T(r,{width:u,height:f,data:null},x);w.bind(g.LINEAR,g.CLAMP_TO_EDGE);const E=r.createFramebuffer(u,f,1,null);if(E.format=x,E.colorAttachment0.set(w.texture),m){const I=r.createRenderbuffer(g.DEPTH24_STENCIL8,u,f);r.bindFramebuffer.set(E.framebuffer),g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,I),E._stencilRbo=I}return E}createColorAttachment(r,o){o===0?this.colorAttachment0=new oh(r,this.framebuffer,0):o===1&&(this.colorAttachment1=new oh(r,this.framebuffer,1))}removeColorAttachment(r,o){const u=this.context.gl;let f;o===0?(f=this.colorAttachment0.get(),this.colorAttachment0=void 0):o===1&&(f=this.colorAttachment1.get(),this.colorAttachment1=void 0),f&&u.deleteTexture(f)}destroy(){const r=this.context.gl;if(this.colorAttachment0){const o=this.colorAttachment0.get();o&&r.deleteTexture(o)}if(this.colorAttachment1){const o=this.colorAttachment1.get();o&&r.deleteTexture(o)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const o=this.depthAttachment.get();o&&r.deleteRenderbuffer(o)}else{const o=this.depthAttachment.get();o&&r.deleteTexture(o)}this._stencilRbo&&(r.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),r.deleteFramebuffer(this.framebuffer)}}class ou{constructor(r,o){this.gl=r,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new Zf(this),this.clearDepth=new ac(this),this.clearStencil=new $f(this),this.colorMask=new w_(this),this.depthMask=new T_(this),this.stencilMask=new E_(this),this.stencilFunc=new sd(this),this.stencilOp=new ad(this),this.stencilTest=new ld(this),this.depthRange=new cd(this),this.depthTest=new qf(this),this.depthFunc=new Wf(this),this.blend=new S_(this),this.blendFunc=new Kc(this),this.blendColor=new Jc(this),this.blendEquation=new Xf(this),this.cullFace=new zo(this),this.cullFaceSide=new ud(this),this.frontFace=new ih(this),this.program=new I_(this),this.activeTexture=new rh(this),this.viewport=new hd(this),this.bindFramebuffer=new dd(this),this.bindRenderbuffer=new fd(this),this.bindTexture=new pd(this),this.bindVertexBuffer=new nh(this),this.bindElementBuffer=new Yf(this),this.bindVertexArrayOES=new Kf(this),this.pixelStoreUnpack=new lc(this),this.pixelStoreUnpackPremultiplyAlpha=new A_(this),this.pixelStoreUnpackFlipY=new C_(this),this.options=o?{...o}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=r.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=r.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=r.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=r.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=o&&!!o.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=r.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=r.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=r.getExtension("EXT_color_buffer_float"),this.extTimerQuery=r.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=r.getParameter(r.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(r.getParameter(r.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=r.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=r.getExtension("KHR_parallel_shader_compile")}sweepPendingPrograms(){if(this._pendingPrograms.size!==0)for(const r of this._pendingPrograms)r.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(r,o,u){return new Fo(this,r,o,u)}createVertexBuffer(r,o,u,f,m){return new ch(this,r,o,u,f,m)}createRenderbuffer(r,o,u){const f=this.gl,m=f.createRenderbuffer();return this.bindRenderbuffer.set(m),f.renderbufferStorage(f.RENDERBUFFER,r,o,u),this.bindRenderbuffer.set(null),m}createFramebuffer(r,o,u,f){return new Js(this,r,o,u,f)}clear({color:r,depth:o,stencil:u,colorMask:f}){const m=this.gl;let g=0;r&&(g|=m.COLOR_BUFFER_BIT,this.clearColor.set(r.toNonPremultipliedRenderColor(null)),this.colorMask.set(f||[!0,!0,!0,!0])),o!==void 0&&(g|=m.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(o),this.depthMask.set(!0)),u!==void 0&&(g|=m.STENCIL_BUFFER_BIT,this.clearStencil.set(u),this.stencilMask.set(255)),m.clear(g)}setCullFace(r){r.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(r.mode),this.frontFace.set(r.frontFace))}setDepthMode(r){r.func!==this.gl.ALWAYS||r.mask?(this.depthTest.set(!0),this.depthFunc.set(r.func),this.depthMask.set(r.mask),this.depthRange.set(r.range)):this.depthTest.set(!1)}setStencilMode(r){r.test.func!==this.gl.ALWAYS||r.mask?(this.stencilTest.set(!0),this.stencilMask.set(r.mask),this.stencilOp.set([r.fail,r.depthFail,r.pass]),this.stencilFunc.set({func:r.test.func,ref:r.ref,mask:r.test.mask})):this.stencilTest.set(!1)}setColorMode(r){d.O(r.blendFunction,d.a1.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(r.blendFunction),this.blendColor.set(r.blendColor),r.blendEquation?this.blendEquation.set(r.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(r.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}const gl=d.Y();function et(a){const r=a._camera.getWorldToCamera(a.worldSize,1),o=d.X([],r,a.globeMatrix);d.aO(o,o);const u=[0,0,0],f=[0,1,0,0];return d.c7(f,f,o),u[0]=f[0],u[1]=f[1],u[2]=f[2],d.c3(u,u),u}function sp({width:a,height:r,anchor:o,textOffset:u,textScale:f},m){const{horizontalAlign:g,verticalAlign:x}=d.cM(o),w=-(g-.5)*a,E=-(x-.5)*r,I=d.cN(o,u);return new d.P((w/f+I[0])*m,(E/f+I[1])*m)}function ap(a,r,o,u,f,m,g,x,w,E){const I=a.text.placedSymbolArray,R=a.text.dynamicLayoutVertexArray,P=a.icon.dynamicLayoutVertexArray,B={},V=a.getProjection(),U=el(g,V,f),G=f.elevation,$=V.upVectorScale(g.canonical,f.center.lat,f.worldSize).metersToTile;R.clear();for(let Y=0;Y<I.length;Y++){const re=I.get(Y),{tileAnchorX:oe,tileAnchorY:pe,numGlyphs:ce}=re,_e=re.hidden||!re.crossTileID||a.allowVerticalPlacement&&!re.placedOrientation?null:u[re.crossTileID];if(_e){let ue=0,me=0,Ie=0;const we=a.elevationType==="road";if(G||we){const tt=new d.P(oe,pe);let Ye=0;if(we&&a.hdExt){const Je=a.symbolInstances.get(a.text.symbolInstanceIndices[Y]);if(a.hdExt.isCrossTileRoadElevation(Je.elevationFeatureIndex,g.canonical)){const ft=a.hdExt.getRoadFeatureHeightForPlacedSymbol(a,a.text,Y,tt,g.canonical);Ye=ft!==null?ft:0}else{const ft=a.hdExt.getElevationFeatureForPlacedSymbol(a,a.text,Y);Ye=d.cW.getAtTileOffset(g,tt,G,ft!==void 0?ft:null)}}else Ye=d.cW.getAtTileOffset(g,tt,G,null);const[mt,We,je]=V.upVector(g.canonical,oe,pe);ue=Ye*mt*$,me=Ye*We*$,Ie=Ye*je*$}let[ve,Se,Re,Ue]=d.cX(re.projectedAnchorX+ue,re.projectedAnchorY+me,re.projectedAnchorZ+Ie,o?U:m);const Pe=d.d_(f.getCameraToCenterDistance(V),Ue);let Oe=d.d4(a.textSizeData,w,re)*Pe/d.d1;o&&(Oe*=a.tilePixelRatio/x);const Xe=sp(_e,Oe);o?({x:ve,y:Se,z:Re}=V.projectTilePoint(oe+Xe.x,pe+Xe.y,g.canonical),[ve,Se,Re]=d.cX(ve+ue,Se+me,Re+Ie,m)):(r&&Xe._rotate(-f.angle),ve+=Xe.x,Se+=Xe.y,Re=0);const ot=a.allowVerticalPlacement&&re.placedOrientation===d.cL.vertical?Math.PI/2:0;for(let tt=0;tt<ce;tt++)d.d$(R,ve,Se,Re,ot);E&&re.associatedIconIndex>=0&&(B[re.associatedIconIndex]={x:ve,y:Se,z:Re,angle:ot})}else d.dZ(ce,R)}if(E){P.clear();const Y=a.icon.placedSymbolArray;for(let re=0;re<Y.length;re++){const oe=Y.get(re),{numGlyphs:pe}=oe,ce=B[re];if(oe.hidden||!ce)d.dZ(pe,P);else{const{x:_e,y:ue,z:me,angle:Ie}=ce;for(let we=0;we<pe;we++)d.d$(P,_e,ue,me,Ie)}}a.icon.dynamicLayoutVertexBuffer.updateData(P)}a.text.dynamicLayoutVertexBuffer.updateData(R)}function uh(a,r,o,u,f,m,g={}){const x=o.paint.get("icon-translate"),w=o.paint.get("text-translate"),E=o.paint.get("icon-translate-anchor"),I=o.paint.get("text-translate-anchor"),R=o.layout.get("icon-rotation-alignment"),P=o.layout.get("text-rotation-alignment"),B=o.layout.get("icon-pitch-alignment"),V=o.layout.get("text-pitch-alignment"),U=o.layout.get("icon-keep-upright"),G=o.layout.get("text-keep-upright"),$=o.paint.get("icon-color-saturation"),Y=o.paint.get("icon-color-contrast"),re=o.paint.get("icon-color-brightness-min"),oe=o.paint.get("icon-color-brightness-max"),pe=o.layout.get("symbol-elevation-reference")==="sea",ce=o.layout.get("icon-image-use-theme")==="none",_e=a.context,ue=_e.gl,me=a.transform,Ie=R==="map",we=P==="map",ve=B==="map",Se=V==="map",Re=o.layout.get("symbol-sort-key").constantOr(1)!==void 0;let Ue=!1;const Pe=a.depthModeForSublayer(0,d.Z.ReadOnly),Oe=new d.Z(a.context.gl.LEQUAL,d.Z.ReadOnly,a.depthRangeFor3D),Xe=[d.a7(me.center.lng),d.a8(me.center.lat)],ot=o.layout.get("text-variable-anchor"),tt=me.projection.name==="globe",Ye=[],mt=[0,-1,0];for(const We of u){const je=r.getTile(We),Je=je.getBucket(o);if(!Je||Je.projection.name==="mercator"&&tt||Je.fullyClipped)continue;const ft=Je.projection.name==="globe",rt=ft?d.S(me.zoom):0,ct=el(We,Je.getProjection(),me),xt=me.calculatePixelsToTileUnitsMatrix(je),Rt=ot&&Je.hasTextData(),Mt=Je.hasIconTextFit()&&Rt&&Je.hasIconData(),Ft=Je.getProjection().createInversionMatrix(me,We.canonical),bi=(1<<je.tileID.canonical.z)*d.a2/a.transform.worldSize,yi=ni=>{let ii=[0,0,0];if(ni){const Ni=a.style.directionalLight,Ar=a.style.ambientLight;Ni&&Ar&&(ii=d.aF(a.style,Ni,Ar))}return ii},kt=ni=>{const ii=Math.floor(a.context.maxUniformBlockSize/4),Ni=Math.floor(ii/4);ni.push(`MAX_UBO_SIZE_VEC4 ${Ni}u`)},_t=ni=>{me.depthOcclusionForSymbolsAndCircles&&(o.hasOcclusionOpacityProperties||a.terrain)&&(ni.push("DEPTH_D24"),ni.push("DEPTH_OCCLUSION"))},wi=ni=>{o.lut&&!ce&&(o.lut.texture||(o.lut.texture=new d.e1(a.context,o.lut.image,[o.lut.image.height,o.lut.image.height,o.lut.image.height],_e.gl.RGBA8)),_e.activeTexture.set(_e.gl.TEXTURE0+d.dQ.LUT),o.lut.texture&&o.lut.texture.bind(_e.gl.LINEAR,_e.gl.CLAMP_TO_EDGE),ni.push("APPLY_LUT_ON_GPU"))},sr=()=>{const ni=Ie&&o.layout.get("symbol-placement")!=="point",ii=[];_t(ii),wi(ii);const Ni=ni||Mt,Ar=Je.elevationType==="road",go=a.shadowRenderer,In=Ar&&ve&&!!go&&go.enabled,_s=yi(In),Fi=Ar&&ve&&!a.terrain?Oe:Pe,mi=o.paint.get("icon-image-cross-fade");a.terrainRenderModeElevated()&&ve&&ii.push("PITCH_WITH_MAP_TERRAIN"),ft&&(ii.push("PROJECTION_GLOBE_VIEW"),Ni&&ii.push("PROJECTED_POS_ON_VIEWPORT")),mi>0&&Je.hasAnySecondaryIcon&&ii.push("ICON_TRANSITION"),!Je.icon.zOffsetVertexBuffer||Ar&&a.terrain||ii.push("Z_OFFSET"),$===0&&Y===0&&re===0&&oe===1||ii.push("COLOR_ADJUSTMENT"),In&&ii.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ar&&ve&&!a.terrain&&Je.icon.orientationVertexBuffer&&ii.push("ELEVATED_ROADS"),kt(ii);const oi=a.getOrCreateProgram("symbol",{defines:ii}),ir=je.imageAtlasTexture?je.imageAtlasTexture.size:[0,0],qr=Je.iconSizeData,Vi=d.cG(qr,me.zoom),Kt=ve||!me.isOrthographic,Cr=d.dY(ct,je.tileID.canonical,ve,Ie,me,Je.getProjection(),xt),Vr=d.cF(ct,je.tileID.canonical,ve,Ie,me,Je.getProjection(),xt),Qo=Je.icon.uboBinder&&Je.icon.uboBinder.hasPerFeatureTranslate()?[0,0]:x,es=a.translatePosMatrix(Vr,je,Qo,E,!0),Ls=a.translatePosMatrix(ct,je,Qo,E),ko=Ni?gl:Cr,Ra=Ie&&!ve&&!ni;let gs=mt;!tt&&!me.mercatorFromTransition||Ie||(gs=et(me));const li=ft?gs:mt,Pa=o.getColorAdjustmentMatrix($,Y,re,oe),Eh=ah(qr.kind,Vi,Ra,ve,a,Ls,ko,es,pe,!1,Je.sdfIcons,ir,[0,0],0,We,rt,Xe,Ft,li,Je.getProjection(),_s,bi,Pa,mi,null),Zd=je.imageAtlasTexture?je.imageAtlasTexture:null,$d=o.layout.get("icon-size").constantOr(0)!==1||Je.iconsNeedLinear,Tl=Je.sdfIcons||a.options.rotating||a.options.zooming||$d||Kt?ue.LINEAR:ue.NEAREST,Sh=Je.sdfIcons&&o.paint.get("icon-halo-width").constantOr(1)!==0,vu=a.terrain&&ve&&ni?d.aO(d.Y(),Cr):gl;if(ni&&Je.icon){const fc=d.cW.getAtTileOffsetFunc(We,me.center.lat,me.worldSize,Je.getProjection()),ts=d.cE(ct,je.tileID.canonical,ve,Ie,me,Je.getProjection(),xt),pr=o.layout.get("icon-size-scale-range"),Et=d.b0(a.scaleFactor,pr[0],pr[1]);d.e0(Je,ct,a,!1,ts,Vr,ve,U,fc,We,Et)}return{program:oi,buffers:Je.icon,uniformValues:Eh,atlasTexture:Zd,atlasTextureIcon:null,atlasInterpolation:Tl,atlasInterpolationIcon:null,isSDF:Je.sdfIcons,hasHalo:Sh,depthMode:Fi,tile:je,renderWithShadows:In,labelPlaneMatrixInv:vu}},qi=()=>{const ni=we&&o.layout.get("symbol-placement")!=="point",ii=[],Ni=ni||ot||Mt,Ar=Je.elevationType==="road",go=a.shadowRenderer,In=Ar&&Se&&!!go&&go.enabled,_s=yi(In),Fi=Ar&&Se&&!a.terrain?Oe:Pe;a.terrainRenderModeElevated()&&Se&&ii.push("PITCH_WITH_MAP_TERRAIN"),ft&&(ii.push("PROJECTION_GLOBE_VIEW"),Ni&&ii.push("PROJECTED_POS_ON_VIEWPORT")),!Je.text.zOffsetVertexBuffer||Ar&&a.terrain||ii.push("Z_OFFSET"),Je.iconsInText&&ii.push("RENDER_TEXT_AND_SYMBOL"),In&&ii.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ar&&Se&&!a.terrain&&Je.text.orientationVertexBuffer&&ii.push("ELEVATED_ROADS"),_t(ii),kt(ii);const mi=a.getOrCreateProgram("symbol",{defines:ii});let oi,ir=[0,0],qr=null;const Vi=Je.textSizeData;Je.iconsInText&&(ir=je.imageAtlasTexture?je.imageAtlasTexture.size:[0,0],qr=je.imageAtlasTexture?je.imageAtlasTexture:null,oi=Se||!me.isOrthographic||a.options.rotating||a.options.zooming||Vi.kind==="composite"||Vi.kind==="camera"?ue.LINEAR:ue.NEAREST);const Kt=je.glyphAtlasTexture?je.glyphAtlasTexture.size:[0,0],Cr=o.layout.get("text-size-scale-range"),Vr=d.b0(a.scaleFactor,Cr[0],Cr[1]),Qo=d.cG(Vi,me.zoom,Vr),es=d.dY(ct,je.tileID.canonical,Se,we,me,Je.getProjection(),xt),Ls=d.cF(ct,je.tileID.canonical,Se,we,me,Je.getProjection(),xt),ko=Je.text.uboBinder&&Je.text.uboBinder.hasPerFeatureTranslate()?[0,0]:w,Ra=a.translatePosMatrix(Ls,je,ko,I,!0),gs=a.translatePosMatrix(ct,je,ko,I),li=Ni?gl:es,Pa=we&&!Se&&!ni;let Eh=mt;!tt&&!me.mercatorFromTransition||we||(Eh=et(me));const Zd=ah(Vi.kind,Qo,Pa,Se,a,gs,li,Ra,pe,!0,!0,Kt,ir,0,We,rt,Xe,Ft,ft?Eh:mt,Je.getProjection(),_s,bi,null,null,Vr),$d=je.glyphAtlasTexture?je.glyphAtlasTexture:null,Tl=ue.LINEAR,Sh=o.paint.get("text-halo-width").constantOr(1)!==0,vu=a.terrain&&Se&&ni?d.aO(d.Y(),es):gl;if(ni&&Je.text){const fc=d.cW.getAtTileOffsetFunc(We,me.center.lat,me.worldSize,Je.getProjection()),ts=d.cE(ct,je.tileID.canonical,Se,we,me,Je.getProjection(),xt);d.e0(Je,ct,a,!0,ts,Ls,Se,G,fc,We,Vr)}return{program:mi,buffers:Je.text,uniformValues:Zd,atlasTexture:$d,atlasTextureIcon:qr,atlasInterpolation:Tl,atlasInterpolationIcon:oi,isSDF:!0,hasHalo:Sh,depthMode:Fi,tile:je,renderWithShadows:In,labelPlaneMatrixInv:vu}},Yt=Je.icon.segments.get().length,Wi=Je.text.segments.get().length,Mi=Yt&&!g.onlyText?sr():null,Wt=Wi&&!g.onlyIcons?qi():null,Ti=o.paint.get("icon-opacity").constantOr(1),tr=o.paint.get("text-opacity").constantOr(1);if(Re&&Je.canOverlap){Ue=!0;const ni=Ti&&!g.onlyText?Je.icon.segments.get():[],ii=tr&&!g.onlyIcons?Je.text.segments.get():[];for(const Ni of ni)Ye.push({segments:new d.ac([Ni]),sortKey:Ni.sortKey,state:Mi});for(const Ni of ii)Ye.push({segments:new d.ac([Ni]),sortKey:Ni.sortKey,state:Wt})}else g.onlyText||Ye.push({segments:Ti?Je.icon.segments:new d.ac([]),sortKey:0,state:Mi}),g.onlyIcons||Ye.push({segments:tr?Je.text.segments:new d.ac([]),sortKey:0,state:Wt})}Ue&&Ye.sort((We,je)=>We.sortKey-je.sortKey);for(const We of Ye){const je=We.state;if(je)if(a.terrain?a.terrain.setupElevationDraw(je.tile,je.program,{useDepthForOcclusion:me.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:je.labelPlaneMatrixInv}):a.setupDepthForOcclusion(me.depthOcclusionForSymbolsAndCircles,je.program),_e.activeTexture.set(ue.TEXTURE0),je.atlasTexture&&je.atlasTexture.bind(je.atlasInterpolation,ue.CLAMP_TO_EDGE,!0),je.atlasTextureIcon&&(_e.activeTexture.set(ue.TEXTURE1),je.atlasTextureIcon&&je.atlasTextureIcon.bind(je.atlasInterpolationIcon,ue.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){const Je=je.uniformValues;Je.u_is_halo=1,po(je.buffers,We.segments,o,a,je.program,je.depthMode,f,m,Je,2),Je.u_is_halo=0}else{if(je.isSDF){const Je=je.uniformValues;je.hasHalo&&(Je.u_is_halo=1,po(je.buffers,We.segments,o,a,je.program,je.depthMode,f,m,Je,1)),Je.u_is_halo=0}po(je.buffers,We.segments,o,a,je.program,je.depthMode,f,m,je.uniformValues,1)}}}function po(a,r,o,u,f,m,g,x,w,E){const I=u.context,R=I.gl,P=[a.dynamicLayoutVertexBuffer,a.opacityVertexBuffer,a.iconTransitioningVertexBuffer,a.globeExtVertexBuffer,a.zOffsetVertexBuffer,a.orientationVertexBuffer];a.featureIdBuffer&&P.push(a.featureIdBuffer);const B=a.uboBinder?null:a.programConfigurations.get(o.id);if(a.uboBinder){a.uboBinder.layer=o;const G=u.transform.zoom,$=u.style.getBrightness?u.style.getBrightness():null,Y=a.uboBinder.getConstantUniformValues(G,$);w.u_spp_fill_np_color=Y.fill_np_color,w.u_spp_halo_np_color=Y.halo_np_color,w.u_spp_opacity=Y.opacity,w.u_spp_halo_width=Y.halo_width,w.u_spp_halo_blur=Y.halo_blur,w.u_spp_emissive_strength=Y.emissive_strength,w.u_spp_occlusion_opacity=Y.occlusion_opacity,w.u_spp_z_offset=Y.z_offset,w.u_spp_zoom_fraction=G-a.uboBinder._floorZoom;const re=o.paint.get(a.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),oe=a.uboBinder.hasPerFeatureTranslate()&&re==="map"?u.transform.angle:0;w.u_spp_translate_rotation=[Math.cos(oe),Math.sin(oe)]}const{batchIndices:V,batchSegments:U}=a.getBatchGrouping(r);for(const G of V){const $=U.get(G);a.uboBinder&&a.uboBinder.bind(I,f.program,G),f.draw(u,R.TRIANGLES,m,g,x,d.$.disabled,w,o.id,a.layoutVertexBuffer,a.indexBuffer,$,o.paint,u.transform.zoom,B,P,E)}}function Oo(a,r,o,u,f,m){const g=o.paint.get("line-width"),x=o.paint.get("line-emissive-strength").isConstant(),w=o.paint.get("line-emissive-strength").constantOr(0),E=o.paint.get("line-occlusion-opacity"),I=o.layout.get("line-elevation-reference"),R=o.layout.get("line-width-unit")==="meters",P=I==="sea",B=!(!a.terrain||!a.terrain.enabled),V=a.context,U=V.gl;if(o.hasElevatedBuckets&&a.transform.projection.name==="globe")return;const G=o.layout.get("line-cross-slope"),$=G!==void 0,Y=G<1,re=f||a.colorModeForDrapableLayerRenderPass(x?w:null),oe=a.terrain&&a.terrain.renderingToTexture||m,pe=oe?1:d.e.devicePixelRatio,ce=o.paint.get("line-dasharray"),_e=ce.constantOr(1),ue=o.layout.get("line-cap"),me=ce.constantOr(null),Ie=ue.constantOr(null),we=o.paint.get("line-pattern"),ve=we.constantOr(1),Se=o.paint.get("line-pattern-cross-fade"),Re=we.constantOr(null),Ue=o.paint.get("line-opacity").constantOr(1);let Pe=!ve&&Ue!==1||a.depthOcclusion&&E>0&&E<1;const Oe=o.paint.get("line-gradient"),Xe=o.paint.get("line-border-width").constantOr(1)!==0?o.paint.get("line-border-gradient"):null,ot=ve?"linePattern":"line",tt=d.e4(o);let Ye;if(oe&&a.terrain&&a.terrain.clipOrMaskOverlapStencilType()&&(Pe=!1),E!==0&&a.depthOcclusion){const ct=o.paint._values["line-opacity"];ct&&ct.value&&ct.value.kind==="constant"?Ye=ct.value:d.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`)}g.value.kind!=="constant"&&g.value.isLineProgressConstant===!1&&tt.push("VARIABLE_LINE_WIDTH");const mt=o.paint.get("line-emissive-strength");ve||mt.value.kind==="constant"||mt.value.isLineProgressConstant!==!1||tt.push("VARIABLE_LINE_EMISSIVE_STRENGTH"),a._debugParams.showElevationIdDebug&&tt.push("DEBUG_ELEVATION_ID"),oe&&(a.emissiveMode!=="dual-source-blending"||x?a.emissiveMode==="mrt-fallback"&&tt.push("USE_MRT1"):tt.push("DUAL_SOURCE_BLENDING"));const We={},je=[],Je=(ct,xt,Rt,Mt,Ft,bi)=>{for(const yi of ct){const kt=r.getTile(yi);if(ve&&!kt.patternsLoaded())continue;const _t=kt.getBucket(o);if(!_t||_t.elevationType!=="none"&&!Ft||_t.elevationType==="none"&&Ft)continue;a.prepareDrawTile();const wi=[...xt],sr=_t.elevationType==="road",qi=a.shadowRenderer,Yt=sr&&!!qi&&qi.enabled;let Wi=[0,0,0];if(Yt){const Kt=a.style.directionalLight,Cr=a.style.ambientLight;Kt&&Cr&&(Wi=d.aF(a.style,Kt,Cr)),wi.push("RENDER_SHADOWS","NORMAL_OFFSET")}const Mi=_t.programConfigurations.get(o.id);let Wt=!1;if(Re&&kt.imageAtlas){const Kt=d.aG.from(Re),Cr=Kt.getPrimary().scaleSelf(pe).toString(),Vr=kt.imageAtlas.patternPositions.get(Cr),Qo=Kt.getSecondary(),es=Qo?kt.imageAtlas.patternPositions.get(Qo.scaleSelf(pe).toString()):null;Wt=!!Vr&&!!es,Vr&&Mi.setConstantPatternPositions(Vr,es)}Se>0&&(Wt||Mi.getPatternTransitionVertexBuffer("line-pattern"))&&wi.push("LINE_PATTERN_TRANSITION"),_t.elevationGroundScaleVertexBuffer&&wi.push("ELEVATION_GROUND_SCALE");const Ti=a.isTileAffectedByFog(yi),tr=a.getOrCreateProgram(ot,{config:Mi,defines:wi,overrideFog:Ti});if(!ve&&me&&Ie&&kt.lineAtlas){const Kt=kt.lineAtlas.getDash(me,Ie);Kt&&Mi.setConstantPatternPositions(Kt)}Yt&&qi.setupShadows(kt.tileID.toUnwrapped(),tr,"vector-tile");let[ni,ii]=o.paint.get("line-trim-offset");(Ie==="round"||Ie==="square")&&ni!==ii&&(ni===0&&(ni-=1),ii===1&&(ii+=1));const Ni=oe?yi.projMatrix:null,Ar=R?1/_t.tileToMeter/d.c5(kt,1,a.transform.zoom):1,go=R?1/_t.tileToMeter/d.c5(kt,1,Math.floor(a.transform.zoom)):1,In=_e?o.paint._values["line-floorwidth"]:null;let _s;const Fi=kt.dashIdealZ;if(In&&In.value.kind==="constant"&&Fi!==kt.tileID.overscaledZ){const Kt=_t.zoom;Kt in We||(We[Kt]=Math.max(.01,o.widthExpression().evaluate({zoom:Kt}))),_s=In.value.value,In.value.value=We[Kt]*Math.pow(2,Fi-Kt)}const mi=ve?d.e5(a,kt,o,Ni,pe,Ar,go,[ni,ii],Wi,Se):d.e6(a,kt,o,Ni,_t.lineClipsArray.length,pe,Ar,go,[ni,ii],Wi),oi=(Kt,Cr,Vr,Qo,es,Ls)=>{let ko=Kt.texture;if(Cr!==Kt.version){let Ra=256;if(Vr){const gs=r.getSource().maxzoom,li=yi.canonical.z===gs?Math.ceil(1<<a.transform.maxZoom-yi.canonical.z):1;Ra=d.b0(d.e7(_t.maxLineLength/d.a2*1024*li),256,V.maxTextureSize)}Kt.gradient=d.e8({expression:Qo,evaluationKey:"lineProgress",resolution:Ra,image:Kt.gradient||void 0,clips:_t.lineClipsArray,lut:es?null:o.lut}),Kt.texture?Kt.texture.update(Kt.gradient):Kt.texture=new d.T(V,Kt.gradient,U.RGBA8),Kt.version=Cr,ko=Kt.texture}V.activeTexture.set(Ls),ko.bind(Vr?U.NEAREST:U.LINEAR,U.CLAMP_TO_EDGE)};Oe&&oi(_t.gradients[o.id],o.gradientVersion,o.stepInterpolant,o.gradientExpression(),o.paint.get("line-gradient-use-theme").constantOr("default")==="none",U.TEXTURE1),Xe&&oi(_t.borderGradients[o.id],o.borderGradientVersion,o.borderStepInterpolant,o.borderGradientExpression(),o.paint.get("line-border-gradient-use-theme").constantOr("default")==="none",U.TEXTURE2),_e&&(V.activeTexture.set(U.TEXTURE0),kt.lineAtlasTexture&&kt.lineAtlasTexture.bind(U.LINEAR,U.REPEAT),Mi.updatePaintBuffers()),ve&&(V.activeTexture.set(U.TEXTURE0),kt.imageAtlasTexture&&kt.imageAtlasTexture.bind(U.LINEAR,U.CLAMP_TO_EDGE),Mi.updatePaintBuffers()),Ft&&!sr&&a.terrain.setupElevationDraw(kt,tr),a.uploadCommonUniforms(V,tr,yi.toUnwrapped());const ir=Tt.drawLineFrcCoverageDetect?Tt.drawLineFrcCoverageDetect(a,_t,yi,Ft,mi,Mi,tr,Rt,re,je):null,qr=(Kt,Cr,Vr)=>{Cr&&Cr.get().length!==0&&(Ye!=null&&(Ye.value=Ue*E),Vr!==void 0&&(mi.u_opacity_multiplier=Vr),tr.draw(a,U.TRIANGLES,Rt,Kt,re,d.$.disabled,mi,o.id,_t.layoutVertexBuffer,_t.indexBuffer,Cr,o.paint,a.transform.zoom,Mi,[_t.layoutVertexBuffer2,_t.patternVertexBuffer,_t.zOffsetVertexBuffer,_t.elevationIdColVertexBuffer,_t.elevationGroundScaleVertexBuffer]),Vr!==void 0&&(mi.u_opacity_multiplier=1),Ye!=null&&(Ye.value=Ue))},Vi=Kt=>{ir&&ir.active&&Tt.drawLineFrcRenderLine?Tt.drawLineFrcRenderLine(_t,ir,Kt,qr):qr(Kt,_t.segments)};if(Pe&&!Ft){const Kt=a.stencilModeForClipping(yi).ref;Kt===0&&oe&&V.clear({stencil:0});const Cr={func:U.EQUAL,mask:255};mi.u_alpha_discard_threshold=.8,Vi(new d._(Cr,Kt,255,U.KEEP,U.KEEP,U.INVERT)),mi.u_alpha_discard_threshold=0,Vi(new d._(Cr,Kt,255,U.KEEP,U.KEEP,U.KEEP))}else mi.u_alpha_discard_threshold=Pe&&Ft&&bi?.8:0,Vi(Ft?Mt:a.stencilModeForClipping(yi));ir&&Tt.drawLineFrcFadePass&&Tt.drawLineFrcFadePass(a,_t,yi,ir,Ft,Mt,qr),_s!==void 0&&(In.value.value=_s)}};let ft=a.depthModeForSublayer(0,d.Z.ReadOnly);const rt=new d.Z(a.depthOcclusion?U.GREATER:U.LEQUAL,d.Z.ReadOnly,a.depthRangeFor3D);if(o.hasNonElevatedBuckets){const ct=!oe&&a.terrain;E!==0&&ct?d.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`):ct?d.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${o.id}.`):Je(u,tt,ft,d._.disabled,!1,!0)}if(o.hasElevatedBuckets){I==="hd-road-markup"?B||(ft=rt,tt.push("ELEVATED_ROADS")):(tt.push("ELEVATED"),ft=rt,$&&tt.push(Y?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),P&&tt.push("ELEVATION_REFERENCE_SEA"));const ct=Pe?a.stencilModeFor3D():d._.disabled;I!=="hd-road-markup"&&(a.forceTerrainMode=!0),Je(u,tt,ft,ct,!0,!0),Pe&&Je(u,tt,ft,ct,!0,!1),I!=="hd-road-markup"&&(a.forceTerrainMode=!1)}Tt.drawLineFrcCoverageSecondPass&&Tt.drawLineFrcCoverageSecondPass(a,o,je),Pe&&(a.resetStencilClippingMasks(),oe&&V.clear({stencil:0})),E===0||a.depthOcclusion||oe||a.layersWithOcclusionOpacity.push(a.currentLayer)}class Sd{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null)}}class lp{constructor(r){this.pbo=r.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0}destroy(r){this.sync&&(r.deleteSync(this.sync),this.sync=null),r.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null)}}const su={additive:{clearColor:new d.C(0,0,0,0),colorMode:d.a1.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new d.C(1,1,1,1),colorMode:d.a1.multiply,compositeUniformValue:0}};function au(a){return!(!a.extRenderToTextureHalfFloat&&!a.extColorBufferFloat)}function hh(a,r){return a==="additive"&&au(r)?d.a1.additiveAlphaWeightedUnboundedAlpha:su[a].colorMode}function Id(a,r,o){const u=a.context,f=u.gl;let m=o.width,g=o.height,x=o.colorAttachment0.get();r.lineBlendDensityReadback||(r.lineBlendDensityReadback=new lp(f));const w=r.lineBlendDensityReadback;let E=0,I=!0;for(;m>1||g>1;){const B=Math.max(1,Math.floor(m/2)),V=Math.max(1,Math.floor(g/2)),U=E===0?"fboA":"fboB";w[U]=Js.createWithTexture(u,w[U],B,V,!1);const G=w[U];u.bindFramebuffer.set(G.framebuffer),u.viewport.set([0,0,B,V]),u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,x),a.getOrCreateProgram("lineBlendReduce").draw(a,f.TRIANGLES,d.Z.disabled,d._.disabled,d.a1.unblended,d.$.disabled,R_(0,[1/m,1/g],I),r.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments,r.paint,a.transform.zoom),m=B,g=V,x=G.colorAttachment0.get(),E=1-E,I=!1}const R=au(u),P=R?16:4;w.sync&&(f.deleteSync(w.sync),w.sync=null),f.bindBuffer(f.PIXEL_PACK_BUFFER,w.pbo),f.bufferData(f.PIXEL_PACK_BUFFER,P,f.STREAM_READ),f.readPixels(0,0,1,1,f.RGBA,R?f.FLOAT:f.UNSIGNED_BYTE,0),f.bindBuffer(f.PIXEL_PACK_BUFFER,null),w.sync=f.fenceSync(f.SYNC_GPU_COMMANDS_COMPLETE,0),u.viewport.set([0,0,a.width,a.height])}function lu(a,r,o){if(!au(a.context))return;const u=r.lineBlendDensityReadback;u&&u.sync?(function(f,m,g){if(f.sync&&m.getSyncParameter(f.sync,m.SYNC_STATUS)===m.SIGNALED){if(m.deleteSync(f.sync),f.sync=null,m.bindBuffer(m.PIXEL_PACK_BUFFER,f.pbo),au(g)){const x=new Float32Array(4);m.getBufferSubData(m.PIXEL_PACK_BUFFER,0,x);const w=x[1];f.maxDensity=Math.max(2*(w>0?x[0]/w:0),1)}else f.maxDensity=1;m.bindBuffer(m.PIXEL_PACK_BUFFER,null)}}(u,a.context.gl,a.context),u.sync||(Id(a,r,o),a.style.map.triggerRepaint())):(Id(a,r,o),a.style.map.triggerRepaint())}function dh(a,r,o,u,f,m){const g=a.context,x=g.gl,w=o==="additive"?1:r.paint.get("line-opacity").constantOr(1),E=o==="additive"?function(R,P){const B=P.paint.get("line-blend-additive-clamp");if(B>0)return B;const V=P.lineBlendDensityReadback;return V&&V.maxDensity!==0?V.maxDensity:null}(0,r):1;if(E===null)return;g.bindFramebuffer.set(f),m&&g.viewport.set([0,0,m[0],m[1]]),g.activeTexture.set(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,u.colorAttachment0.get());const I=hh(o,a.context);a.getOrCreateProgram("lineBlendComposite").draw(a,x.TRIANGLES,d.Z.disabled,d._.disabled,I,d.$.disabled,((R,P,B,V)=>({u_image:0,u_opacity:P,u_blend_mode:B,u_max_density:V}))(0,w,su[o].compositeUniformValue,E),r.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments,r.paint,a.transform.zoom)}function cc(a,r,o,u){const{painter:f,sourceCache:m,layer:g,coords:x,colorMode:w,elevationType:E,terrainEnabled:I,pass:R}=a,P=f.context.gl,B=g.paint.get("fill-pattern"),V=g.paint.get("fill-pattern-cross-fade"),U=B.constantOr(null);let G=E;E!=="road"||r&&!I||(G="none");const $=G==="road",Y=a.painter.shadowRenderer,re=$&&!!Y&&Y.enabled,oe=new d.Z(f.context.gl.LEQUAL,d.Z.ReadOnly,f.depthRangeFor3D);let pe=[0,0,0];if(re){const me=f.style.directionalLight,Ie=f.style.ambientLight;me&&Ie&&(pe=d.aF(f.style,me,Ie))}const ce=B&&B.constantOr(1),_e=f.terrain&&f.terrain.renderingToTexture,ue=(me,Ie)=>{let we,ve,Se,Re,Ue;Ie?(we=ce&&!g.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",Se=P.LINES):(we=ce?"fillPattern":"fill",Se=P.TRIANGLES);const Pe=[];for(const Oe of x){const Xe=m.getTile(Oe);if(ce&&!Xe.patternsLoaded())continue;const ot=Xe.getBucket(g);if(!ot)continue;const tt=r?ot.hdExt&&ot.hdExt.elevationBufferData:ot.bufferData;if(!tt||tt.isEmpty())continue;f.prepareDrawTile();const Ye=tt.programConfigurations.get(g.id),mt=f.isTileAffectedByFog(Oe),We=[],je=[];$&&(We.push("ELEVATED_ROADS"),je.push(tt.elevatedLayoutVertexBuffer)),re&&We.push("RENDER_SHADOWS","NORMAL_OFFSET"),_e&&o&&We.push("USE_MRT1"),ce&&(f.context.activeTexture.set(P.TEXTURE0),Xe.imageAtlasTexture&&Xe.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),Ye.updatePaintBuffers());let Je=!1;if(U&&Xe.imageAtlas){const Ft=Xe.imageAtlas,bi=d.aG.from(U),yi=bi.getPrimary().scaleSelf(d.e.devicePixelRatio).toString(),kt=bi.getSecondary(),_t=Ft.patternPositions.get(yi),wi=kt?Ft.patternPositions.get(kt.scaleSelf(d.e.devicePixelRatio).toString()):null;Je=!!_t&&!!wi,_t&&Ye.setConstantPatternPositions(_t,wi)}V>0&&(Je||Ye.getPatternTransitionVertexBuffer("fill-pattern"))&&We.push("FILL_PATTERN_TRANSITION");const ft=f.getOrCreateProgram(we,{config:Ye,overrideFog:mt,defines:We}),rt=f.translatePosMatrix(Oe.projMatrix,Xe,g.paint.get("fill-translate"),g.paint.get("fill-translate-anchor"));re&&Y.setupShadows(Xe.tileID.toUnwrapped(),ft,"vector-tile");const ct=g.paint.get("fill-emissive-strength");if(Ie){Re=tt.lineIndexBuffer,Ue=tt.lineSegments;const Ft=f.terrain&&f.terrain.renderingToTexture?f.terrain.drapeBufferSize:[P.drawingBufferWidth,P.drawingBufferHeight];ve=we==="fillOutlinePattern"&&ce?Ed(rt,ct,f,Xe,Ft,pe,V):Td(rt,ct,Ft,pe)}else Re=tt.indexBuffer,Ue=tt.triangleSegments,ve=ce?wd(rt,ct,f,Xe,pe,V):bd(rt,ct,pe);f.uploadCommonUniforms(f.context,ft,Oe.toUnwrapped());let xt=me;if((E==="road"&&!I||E==="offset")&&(xt=oe),!Ue||Ue.get&&Ue.get().length===0)continue;const Rt=u||f.stencilModeForClipping(Oe);let Mt="fallthrough";!Ie&&Tt.drawFillFrcCoverageFirstPass&&(Mt=Tt.drawFillFrcCoverageFirstPass({painter:f,layer:g,bucket:ot,coord:Oe,elevatedGeometry:r,program:ft,programConfiguration:Ye,uniformValues:ve,drawMode:Se,depthMode:xt,stencilMode:Rt,colorMode:w,bufferData:tt,indexBuffer:Re,segments:Ue,dynamicBuffers:je,polygonCoverageTiles:Pe})),Mt==="fallthrough"&&ft.draw(f,Se,xt,Rt,w,d.$.disabled,ve,g.id,tt.layoutVertexBuffer,Re,Ue,g.paint,f.transform.zoom,Ye,je)}!Ie&&Tt.drawFillFrcCoverageSecondPass&&Tt.drawFillFrcCoverageSecondPass(f,g,Pe,Se,w)};f.renderPass===R&&ue(f.depthModeForSublayer(1,f.renderPass==="opaque"?d.Z.ReadWrite:d.Z.ReadOnly),!1),G==="none"&&f.renderPass==="translucent"&&g.paint.get("fill-antialias")&&ue(f.depthModeForSublayer(g.getPaintProperty("fill-outline-color")?2:0,d.Z.ReadOnly),!0)}function Ad(a){return[a[0]*d.ea,a[1]*d.ea,a[2]*d.ea,0]}function fh(a,r,o,u,f,m,g,x,w,E){const I=f.getSource(),R=u.globeSharedBuffers;if(!R)return;let P,B,V;if(o&&(P=f.getTile(o)),I instanceof ho?(B=I.texture,V=d.du(0,0,u.transform)):P&&o&&(B=P.texture,V=d.du(o.canonical.z,o.canonical.x,u.transform)),!B||!V)return;r||(V=d.aN(d.Y(),V,[1,-1,1]));const U=u.context,G=U.gl,$=m.paint.get("raster-resampling")==="nearest"?G.NEAREST:G.LINEAR,Y=u.colorModeForDrapableLayerRenderPass(g),re=x.defines;re.push("GLOBE_POLES");const oe=new d.Z(G.LEQUAL,d.Z.ReadWrite,u.depthRangeFor3D),pe=u.transform.expandedFarZProjMatrix,ce=Float32Array.from(d.b4(d.b5(new d.bX(0,0,0))));u.terrain&&u.terrain.prepareDrawTile(),U.activeTexture.set(G.TEXTURE0),B.bind($,G.CLAMP_TO_EDGE),U.activeTexture.set(G.TEXTURE1),B.bind($,G.CLAMP_TO_EDGE),"useMipmap"in B&&U.extTextureFilterAnisotropic&&u.transform.pitch>20&&G.texParameterf(G.TEXTURE_2D,U.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,U.extTextureFilterAnisotropicMax);const[_e,ue,me,Ie]=o?R.getPoleBuffers(o.canonical.z,!1):R.getPoleBuffers(0,!0),we=a;let ve;r?(ve=_e,u.renderDefaultNorthPole=we!==0):(ve=ue,u.renderDefaultSouthPole=we!==0);const Se=Ad(x.mix),Re=((Pe,Oe,Xe,ot,tt,Ye,mt,We,je,Je,ft,rt,ct,xt)=>ip(Pe,Oe,Xe,ot,new Float32Array(16),new Float32Array(9),[0,0],tt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},mt,[0,0],je,2,ft,rt,ct,1,0,xt))(u,pe,ce,V,d.S(u.transform.zoom),0,m,0,we,0,Se,x.offset,x.range,g),Ue=u.getOrCreateProgram("raster",{defines:re});u.uploadCommonUniforms(U,Ue,null),Ue.draw(u,G.TRIANGLES,oe,E,Y,w,Re,m.id,ve,me,Ie)}function cp(a){if(a.isOrthographic)return[0,0,0,0];const r=a._nearZ,o=a.projection.farthestPixelDistance(a),u=o-r,f=.2*a.height,m=r+f;return[r,o,(m-f-r)/u,(m-r)/u]}function up(a,r,o,u){if(a)return r.type==="raster-array"?r.getTextureDescriptor(a,o,!0):{texture:a.texture,mix:Ad(u.mix),offset:u.offset,buffer:0,tileSize:1}}const hp=d.d0(new Float32Array(16)),dp=d.a_([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Cd}=dp;function Ds(a,r,o,u){a.emplaceBack(r,o,u)}class Md{constructor(r){this.vertexArray=new d.eb,this.indices=new d.ad,Ds(this.vertexArray,-1,-1,1),Ds(this.vertexArray,1,-1,1),Ds(this.vertexArray,-1,1,1),Ds(this.vertexArray,1,1,1),Ds(this.vertexArray,-1,-1,-1),Ds(this.vertexArray,1,-1,-1),Ds(this.vertexArray,-1,1,-1),Ds(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=r.createVertexBuffer(this.vertexArray,Cd),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=d.ac.simpleSegment(0,0,36,12)}}function yl(a,r,o,u,f,m){const g=a.context.gl,x=r.paint.get("sky-atmosphere-color"),w=r.paint.get("sky-atmosphere-halo-color"),E=r.paint.get("sky-atmosphere-sun-intensity"),I=((R,P,B,V,U)=>({u_matrix_3f:R,u_sun_direction:P,u_sun_intensity:B,u_color_tint_r:[V.r,V.g,V.b,V.a],u_color_tint_m:[U.r,U.g,U.b,U.a],u_luminance:5e-5}))(d.ee(d.ef(),u),f,E,x.toPremultipliedRenderColor(null),w.toPremultipliedRenderColor(null));g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_CUBE_MAP_POSITIVE_X+m,r.skyboxTexture,0),o.draw(a,g.TRIANGLES,d.Z.disabled,d._.disabled,d.a1.unblended,d.$.frontCW,I,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}const fp=d.a_([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class pp{constructor(r){const o=new d.eg;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);const u=new d.ad;u.emplaceBack(0,1,2),u.emplaceBack(2,3,0),this.vertexBuffer=r.createVertexBuffer(o,fp.members),this.indexBuffer=r.createIndexBuffer(u),this.segments=d.ac.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Rd=d.a_([{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 mp{constructor(){this.colorModeAlphaBlendedWriteRGB=new d.a1([d.eh,d.ei,d.eh,d.ei],d.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new d.a1([d.eh,d.ej,d.eh,d.ej],d.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(r){this._painter=r;const o=r.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new pp(o);let u=this.params;const f=u.sizeRange,m=u.intensityRange,g=function(R){const P=d.bi(30),B=[];for(let V=0;V<R;++V){const U=2*Math.PI*P(),G=Math.acos(1-2*P())-.5*Math.PI;B.push(d.bh(Math.cos(G)*Math.cos(U),Math.cos(G)*Math.sin(U),Math.sin(G)))}return B}(u.starsCount),x=d.bi(300),w=new d.ek,E=new d.ad;let I=0;for(let R=0;R<g.length;++R){const P=d.dC([],g[R],200),B=Math.max(0,1+.01*f*(1*x()-.5)),V=Math.max(0,1+.01*m*(1*x()-.5));w.emplaceBack(P[0],P[1],P[2],-1,-1,B,V),w.emplaceBack(P[0],P[1],P[2],1,-1,B,V),w.emplaceBack(P[0],P[1],P[2],1,1,B,V),w.emplaceBack(P[0],P[1],P[2],-1,1,B,V),E.emplaceBack(I+0,I+1,I+2),E.emplaceBack(I+0,I+2,I+3),I+=4}this.starsVx=o.createVertexBuffer(w,Rd.members),this.starsIdx=o.createIndexBuffer(E),this.starsSegments=d.ac.simpleSegment(0,0,w.length,E.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy(),this._painter=null}drawAtmosphereGlow(r,o){const u=r.context,f=u.gl,m=r.transform,g=new d.Z(f.LEQUAL,d.Z.ReadOnly,[0,1]),x=d.S(m.zoom),w=r.style.getLut(o.scope),E=o.properties.get("color-use-theme")==="none",I=o.properties.get("color").toNonPremultipliedRenderColor(E?null:w),R=o.properties.get("high-color-use-theme")==="none",P=o.properties.get("high-color").toNonPremultipliedRenderColor(R?null:w),B=o.properties.get("space-color-use-theme")==="none",V=o.properties.get("space-color").toNonPremultipliedRenderColor(B?null:w),U=5e-4,G=d.el(o.properties.get("horizon-blend"),0,1,U,.25),$=d.dt(r,u,m)&&G===U?m.worldSize/(2*Math.PI*1.025)-1:m.globeRadius,Y=r.frameCounter/1e3%1,re=d.em(m.globeCenterInViewSpace),oe=Math.sqrt(Math.pow(re,2)-Math.pow($,2)),pe=Math.acos(oe/re),ce=_e=>{const ue=m.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];_e&&ue.push("ALPHA_PASS");const me=r.getOrCreateProgram("globeAtmosphere",{defines:ue}),Ie=((ve,Se,Re,Ue,Pe,Oe,Xe,ot,tt,Ye,mt,We)=>({u_frustum_tl:ve,u_frustum_tr:Se,u_frustum_br:Re,u_frustum_bl:Ue,u_horizon:Pe,u_transition:Oe,u_fadeout_range:Xe,u_atmosphere_fog_color:ot.toArray01(),u_high_color:tt.toArray01(),u_space_color:Ye.toArray01(),u_temporal_offset:mt,u_horizon_angle:We}))(m.frustumCorners.TL,m.frustumCorners.TR,m.frustumCorners.BR,m.frustumCorners.BL,m.frustumCorners.horizon,x,G,I,P,V,Y,pe);r.uploadCommonUniforms(u,me);const we=this.atmosphereBuffer;we&&me.draw(r,f.TRIANGLES,g,d._.disabled,_e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,d.$.backCW,Ie,_e?"atmosphere_glow_alpha":"atmosphere_glow",we.vertexBuffer,we.indexBuffer,we.segments)};ce(!1),ce(!0)}drawStars(r,o){const u=d.b0(o.properties.get("star-intensity"),0,1);if(u===0)return;const f=r.context,m=f.gl,g=r.transform,x=r.getOrCreateProgram("stars"),w=d.bd([]);d.be(w,w,-g._pitch),d.bf(w,w,-g.angle),d.be(w,w,d.au(g._center.lat)),d.en(w,w,-d.au(g._center.lng));const E=d.bg(new Float32Array(16),w),I=d.X([],g.starsProjMatrix,E),R=d.ee([],E),P=d.eo([],R);let B=this.params.sizeMultiplier;const V=[0,1,0];d.ct(V,V,P),d.dC(V,V,B);const U=[1,0,0];d.ct(U,U,P),d.dC(U,U,B);const G=($=V,Y=U,re=u,{u_matrix:Float32Array.from(I),u_up:$,u_right:Y,u_intensity_multiplier:re});var $,Y,re;r.uploadCommonUniforms(f,x),this.starsVx&&this.starsIdx&&x.draw(r,m.TRIANGLES,d.Z.disabled,d._.disabled,this.colorModeAlphaBlendedWriteRGB,d.$.disabled,G,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class Pd{}class _p{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(r,o,u){{const R=this._storage.get(o.id);if(R)return R.lastUsedFrameIdx=r,R.buf}const f=u.gl,m=f.getBufferParameter(f.ELEMENT_ARRAY_BUFFER,f.BUFFER_SIZE),g=new ArrayBuffer(m),x=new Int16Array(g);f.getBufferSubData(f.ELEMENT_ARRAY_BUFFER,0,new Int16Array(g));const w=new d.ep;for(let R=0;R<m/2;R+=3){const P=x[R],B=x[R+1],V=x[R+2];w.emplaceBack(P,B),w.emplaceBack(B,V),w.emplaceBack(V,P)}const E=u.bindVertexArrayOES.current,I=new Pd;return I.buf=new Fo(u,w),I.lastUsedFrameIdx=r,this._storage.set(o.id,I),u.bindVertexArrayOES.set(E),I.buf}update(r){for(const[o,u]of this._storage)r-u.lastUsedFrameIdx>30&&(u.buf.destroy(),this._storage.delete(o))}destroy(){for(const[r,o]of this._storage)o.buf.destroy(),this._storage.delete(r)}}class Dd{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const xl={symbol:function(a,r,o,u,f){if(a.renderPass!=="translucent")return;const m=d._.disabled,g=a.colorModeForRenderPass(),x=o.layout.get("text-variable-anchor"),w=o.layout.get("text-size-scale-range"),E=d.b0(a.scaleFactor,w[0],w[1]);x&&function(P,B,V,U,G,$,Y,re){const oe=B.transform,pe=G==="map",ce=$==="map";for(const _e of P){const ue=U.getTile(_e),me=ue.getBucket(V);if(!me||!me.text||!me.text.segments.get().length)continue;const Ie=d.cG(me.textSizeData,oe.zoom,re),we=el(_e,me.getProjection(),oe),ve=oe.calculatePixelsToTileUnitsMatrix(ue),Se=d.dY(we,ue.tileID.canonical,ce,pe,oe,me.getProjection(),ve),Re=me.hasIconTextFit()&&me.hasIconData();Ie&&ap(me,pe,ce,Y,oe,Se,_e,Math.pow(2,oe.zoom-ue.tileID.overscaledZ),Ie,Re)}}(u,a,o,r,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),f,E);const I=o.paint.get("icon-opacity").constantOr(1)!==0,R=o.paint.get("text-opacity").constantOr(1)!==0;o.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(I||R)?uh(a,r,o,u,m,g):(I&&uh(a,r,o,u,m,g,{onlyIcons:!0}),R&&uh(a,r,o,u,m,g,{onlyText:!0})),r.map.showCollisionBoxes&&Gn.drawCollisionDebug&&(Gn.drawCollisionDebug(a,r,o,u,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),Gn.drawCollisionDebug(a,r,o,u,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(a,r,o,u){if(a.renderPass!=="translucent")return;const f=o.paint.get("circle-opacity"),m=o.paint.get("circle-stroke-width"),g=o.paint.get("circle-stroke-opacity"),x=o.layout.get("circle-sort-key").constantOr(1)!==void 0,w=o.paint.get("circle-emissive-strength");if(f.constantOr(1)===0&&(m.constantOr(1)===0||g.constantOr(1)===0))return;const E=a.context,I=E.gl,R=a.transform,P=!(!a.terrain||!a.terrain.enabled),B=o.layout.get("circle-elevation-reference"),V=a.depthModeForSublayer(0,d.Z.ReadOnly),U=new d.Z(a.context.gl.LEQUAL,d.Z.ReadOnly,a.depthRangeFor3D),G=B==="none"||P?V:U,$=d._.disabled,Y=a.colorModeForDrapableLayerRenderPass(w),re=R.projection.name==="globe",oe=[d.a7(R.center.lng),d.a8(R.center.lat)],pe=[];for(let _e=0;_e<u.length;_e++){const ue=u[_e],me=r.getTile(ue),Ie=me.getBucket(o);if(!Ie||Ie.projection.name!==R.projection.name)continue;const we=Ie.programConfigurations.get(o.id),ve=Ie.layoutVertexBuffer,Se=Ie.globeExtVertexBuffer,Re=Ie.indexBuffer,Ue=d.e2(o),Pe=[Se],Oe=a.isTileAffectedByFog(ue);re&&Ue.push("PROJECTION_GLOBE_VIEW"),Ue.push("DEPTH_D24"),a.terrain&&R.depthOcclusionForSymbolsAndCircles&&Ue.push("DEPTH_OCCLUSION"),Ie.hdExt&&Ie.hdExt.hasElevation&&!a.terrain&&(Ue.push("ELEVATED_ROADS"),Pe.push(Ie.hdExt.elevatedLayoutVertexBuffer));const Xe=a.getOrCreateProgram("circle",{config:we,defines:Ue,overrideFog:Oe}),ot=R.projection.createInversionMatrix(R,ue.canonical),tt={programConfiguration:we,program:Xe,layoutVertexBuffer:ve,dynamicBuffers:Pe,indexBuffer:Re,uniformValues:d.e3(a,ue,me,ot,oe,o),tile:me};if(x){const Ye=Ie.segments.get();for(const mt of Ye)pe.push({segments:new d.ac([mt]),sortKey:mt.sortKey,state:tt})}else pe.push({segments:Ie.segments,sortKey:0,state:tt})}x&&pe.sort((_e,ue)=>_e.sortKey-ue.sortKey);const ce={useDepthForOcclusion:R.depthOcclusionForSymbolsAndCircles};for(const _e of pe){const{programConfiguration:ue,program:me,layoutVertexBuffer:Ie,dynamicBuffers:we,indexBuffer:ve,uniformValues:Se,tile:Re}=_e.state,Ue=_e.segments;a.terrain&&a.terrain.setupElevationDraw(Re,me,ce),a.uploadCommonUniforms(E,me,Re.tileID.toUnwrapped()),me.draw(a,I.TRIANGLES,G,$,Y,d.$.disabled,Se,o.id,Ie,ve,Ue,o.paint,R.zoom,ue,we)}},heatmap:function(a,r,o,u){if(o.paint.get("heatmap-opacity")!==0)if(a.renderPass==="offscreen"){const f=a.context,m=f.gl,g=d._.disabled,x=new d.a1([m.ONE,m.ONE,m.ONE,m.ONE],d.C.transparent,[!0,!0,!0,!0]),w=a.transform.projection.name==="globe"?.5:.25;o.heatmapFbo=Js.createWithTexture(f,o.heatmapFbo,a.width*w,a.height*w),f.clear({color:d.C.transparent});const E=a.transform,I=E.projection.name==="globe",R=I?["PROJECTION_GLOBE_VIEW"]:[],P=I?d.$.frontCCW:d.$.disabled,B=[d.a7(E.center.lng),d.a8(E.center.lat)];for(let V=0;V<u.length;V++){const U=u[V];if(r.hasRenderableParent(U))continue;const G=r.getTile(U),$=G.getBucket(o);if(!$||$.projection.name!==E.projection.name)continue;const Y=a.isTileAffectedByFog(U),re=$.programConfigurations.get(o.id),oe=a.getOrCreateProgram("heatmap",{config:re,defines:R,overrideFog:Y}),{zoom:pe}=a.transform;a.terrain&&a.terrain.setupElevationDraw(G,oe),a.uploadCommonUniforms(f,oe,U.toUnwrapped());const ce=E.projection.createInversionMatrix(E,U.canonical);oe.draw(a,m.TRIANGLES,d.Z.disabled,g,x,P,ru(a,U,G,ce,B,pe,o.paint.get("heatmap-intensity")),o.id,$.layoutVertexBuffer,$.indexBuffer,$.segments,o.paint,a.transform.zoom,re,I?[$.globeExtVertexBuffer]:null)}f.viewport.set([0,0,a.width,a.height])}else a.renderPass==="translucent"&&(a.context.setColorMode(a.colorModeForRenderPass()),function(f,m){const g=f.context,x=g.gl,w=m.heatmapFbo;if(!w)return;g.activeTexture.set(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,w.colorAttachment0.get()),g.activeTexture.set(x.TEXTURE1);let E=m.colorRampTexture;E||(E=m.colorRampTexture=new d.T(g,m.colorRamp,x.RGBA8)),E.bind(x.LINEAR,x.CLAMP_TO_EDGE),f.getOrCreateProgram("heatmapTexture").draw(f,x.TRIANGLES,d.Z.disabled,d._.disabled,f.colorModeForRenderPass(),d.$.disabled,((I,R)=>({u_image:0,u_color_ramp:1,u_opacity:R.paint.get("heatmap-opacity")}))(0,m),m.id,f.viewportBuffer,f.quadTriangleIndexBuffer,f.viewportSegments,m.paint,f.transform.zoom)}(a,o))},line:function(a,r,o,u){const f=o.paint.get("line-opacity"),m=o.paint.get("line-width");if(f.constantOr(1)===0||m.constantOr(1)===0)return;const g=o.paint.get("line-blend-mode"),x=a.terrain&&a.terrain.renderingToTexture;if(g==="default"||a.transform.projection.name==="globe")a.renderPass==="translucent"&&Oo(a,r,o,u);else{if(x)return void function(w,E,I,R,P){if(w.renderPass!=="translucent")return;const B=w.context,V=B.gl,U=w.terrain;if(!U)return;const G=B.bindFramebuffer.current,$=w.emissiveMode==="mrt-fallback",Y=U.drapeBufferSize[0],re=U.drapeBufferSize[1];I.lineBlendFbos||(I.lineBlendFbos=new Sd),I.lineBlendFbos.drapeFbo=Js.createWithTexture(B,I.lineBlendFbos.drapeFbo,Y,re,!0),$&&V.drawBuffers([V.COLOR_ATTACHMENT0]),B.clear({color:su[P].clearColor,depth:1,stencil:0});const oe=w.currentStencilSource,pe=w._tileClippingMaskIDs,ce=w.nextStencilID;w.currentStencilSource=void 0,w._tileClippingMaskIDs={},w.nextStencilID=1;const _e=w._terrain;w._terrain=null,w._renderTileClippingMasks(I,E,R),Oo(w,E,I,R,hh(P,w.context),!0),w._terrain=_e,w.currentStencilSource=oe,w._tileClippingMaskIDs=pe,w.nextStencilID=ce,$&&V.drawBuffers([V.COLOR_ATTACHMENT0,V.COLOR_ATTACHMENT1]);const ue=U.drapeBufferSize,me=I.lineBlendFbos&&I.lineBlendFbos.drapeFbo;me&&(P==="additive"&&lu(w,I,me),dh(w,I,P,me,G,ue))}(a,r,o,u,g);if(a.renderPass==="offscreen")return void function(w,E,I,R,P){const B=w.context,V=Math.ceil(w.width),U=Math.ceil(w.height);I.lineBlendFbos||(I.lineBlendFbos=new Sd),I.lineBlendFbos.fbo=Js.createWithTexture(B,I.lineBlendFbos.fbo,V,U,!0),B.clear({color:su[P].clearColor,depth:1,stencil:0});const G=w.currentStencilSource,$=w._tileClippingMaskIDs,Y=w.nextStencilID;w.currentStencilSource=void 0,w._tileClippingMaskIDs={},w.nextStencilID=1,w._renderTileClippingMasks(I,E,R);const re=w.renderPass;w.renderPass="translucent",Oo(w,E,I,R,hh(P,w.context)),w.renderPass=re,w.currentStencilSource=G,w._tileClippingMaskIDs=$,w.nextStencilID=Y,B.viewport.set([0,0,w.width,w.height]),P==="additive"&&lu(w,I,I.lineBlendFbos.fbo)}(a,r,o,u,g);if(a.renderPass==="translucent"){const w=o.lineBlendFbos&&o.lineBlendFbos.fbo;return void(w&&dh(a,o,g,w,null))}}},fill:function(a,r,o,u){const f=o.paint.get("fill-color"),m=o.paint.get("fill-opacity");if(m.constantOr(1)===0)return;const g=o.paint.get("fill-emissive-strength"),x=a.colorModeForDrapableLayerRenderPass(g),w=o.paint.get("fill-pattern"),E=a.opaquePassEnabledForLayer()&&!w.constantOr(1)&&f.constantOr(d.C.transparent).a===1&&m.constantOr(0)===1?"opaque":"translucent";let I="none";o.layout.get("fill-elevation-reference")!=="none"?I="road":o.paint.get("fill-z-offset").constantOr(1)!==0&&(I="offset");const R=!(!a.terrain||!a.terrain.enabled),P={painter:a,sourceCache:r,layer:o,coords:u,colorMode:x,elevationType:I,terrainEnabled:R,pass:E};if(a.renderPass==="shadow")return void(a.shadowRenderer&&I==="road"&&!R&&Tt.drawElevatedFillShadows&&Tt.drawElevatedFillShadows(P));const B=a.emissiveMode==="mrt-fallback";if(I!=="offset"){if(cc(P,!1,B),I==="road"){const V=!R&&a.renderPass==="translucent";V&&Tt.drawDepthPrepass&&Tt.drawDepthPrepass(a,r,o,u,"geometry"),cc(P,!0,B,d._.disabled),V&&Tt.drawElevatedStructures&&Tt.drawElevatedStructures(P)}}else cc(P,!1,B,a.stencilModeFor3D())},"fill-extrusion":function(a,r,o,u){const f=o.paint.get("fill-extrusion-opacity"),m=a.context,g=m.gl,x=a.terrain,w=x&&x.renderingToTexture;if(f===0)return;const E=a.emissiveMode==="mrt-fallback",I=a.conflationActive&&a.style.isLayerClipped(o,r.getSource()),R=a.style.order.indexOf(o.fqid);if(I&&function(P,B,V,U,G){for(const $ of U){const Y=B.getTile($).getBucket(V);Y&&(Y.updateReplacement($,P.replacementSource,G),Y.uploadCentroid(P.context))}}(a,r,o,u,R),x||I)for(const P of u){const B=r.getTile(P).getBucket(o);B&&yr(a.context,r,P,B,o,x,I)}if(a.renderPass==="shadow"&&a.shadowRenderer){if(x&&f<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof d.aj)return;const P=a.shadowRenderer.getShadowPassDepthMode();pi(a,r,o,u,P,d._.disabled,d.a1.disabled,I)}else if(a.renderPass==="translucent"){const P=!o.paint.get("fill-extrusion-pattern").constantOr(1),B=o.paint.get("fill-extrusion-color").constantOr(d.C.white);if(!w&&B.a!==0){const U=new d.Z(a.context.gl.LEQUAL,d.Z.ReadWrite,a.depthRangeFor3D);f===1&&P?pi(a,r,o,u,U,d._.disabled,d.a1.unblended,I):(pi(a,r,o,u,U,d._.disabled,d.a1.disabled,I),pi(a,r,o,u,U,a.stencilModeFor3D(),a.colorModeForRenderPass(),I),a.resetStencilClippingMasks())}const V=a.style.enable3dLights()&&P&&(!x&&a.transform.projection.name!=="globe"||w);if(V&&!Ct.drawGroundEffect&&Zt(),V&&Ct.drawGroundEffect){const U=o.paint.get("fill-extrusion-opacity"),G=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),$=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Y=o.paint.get("fill-extrusion-flood-light-intensity"),re=o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",oe=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(re?null:o.lut).toArray01().slice(0,3),pe=G>0&&$>0,ce=Y>0,_e=new zt;_e.translate=o.paint.get("fill-extrusion-translate"),_e.translateAnchor=o.paint.get("fill-extrusion-translate-anchor"),_e.edgeRadius=o.layout.get("fill-extrusion-edge-radius"),_e.cutoffFadeRange=o.paint.get("fill-extrusion-cutoff-fade-range");const ue=me=>{const Ie=a.depthModeForSublayer(1,d.Z.ReadOnly,g.LEQUAL,!0),we=o.paint.get(me?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),ve=d.al(.1,3,we),Se=a._showOverdrawInspector;if(!Se){const Re=new d._({func:g.ALWAYS,mask:255},255,255,g.KEEP,g.KEEP,g.REPLACE),Ue=new d.a1([g.ONE,g.ONE,g.ONE,g.ONE],d.C.transparent,[!1,!1,!1,!0],g.MIN);Ct.drawGroundEffect(_e,a,r,o,u,Ie,Re,Ue,d.$.disabled,me,"sdf",U,G,$,Y,oe,ve,I,!1)}{const Re=Se?d._.disabled:new d._({func:g.EQUAL,mask:255},255,255,g.KEEP,g.DECR,g.DECR),Ue=Se?a.colorModeForRenderPass():new d.a1([g.ONE_MINUS_DST_ALPHA,g.DST_ALPHA,g.ONE,g.ONE],d.C.transparent,[!0,!0,!0,!0]);Ct.drawGroundEffect(_e,a,r,o,u,Ie,Re,Ue,d.$.disabled,me,"color",U,G,$,Y,oe,ve,I,!1)}};if(w){const me=()=>{const we=x.drapeBufferSize[0],ve=x.drapeBufferSize[1];let Se=x.framebufferCopyTexture;return Se&&(!Se||Se.size[0]===we&&Se.size[1]===ve)||(Se&&Se.destroy(),Se=x.framebufferCopyTexture=new d.T(m,new d.b({width:we,height:ve}),g.RGBA8)),Se.bind(g.LINEAR,g.CLAMP_TO_EDGE),g.copyTexSubImage2D(g.TEXTURE_2D,0,0,0,0,0,we,ve),Se},Ie=(we,ve,Se)=>{const Re=a.depthModeForSublayer(1,d.Z.ReadOnly,g.LEQUAL,!1),Ue=o.paint.get(we?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Pe=d.al(.1,3,Ue);{const Oe=new d.a1([g.ONE,g.ONE,g.ONE,g.ONE],d.C.transparent,[!1,!1,!1,!0]);Ct.drawGroundEffect(_e,a,r,o,u,Re,d._.disabled,Oe,d.$.disabled,we,"clear",U,G,$,Y,oe,Pe,I,ve)}{const Oe=new d._({func:g.ALWAYS,mask:255},255,255,g.KEEP,g.KEEP,g.REPLACE),Xe=new d.a1([g.ONE,g.ONE,g.ONE,g.ONE],d.C.transparent,[!1,!1,!1,!0],g.MIN);Ct.drawGroundEffect(_e,a,r,o,u,Re,Oe,Xe,d.$.disabled,we,"sdf",U,G,$,Y,oe,Pe,I,ve)}E&&!we&&(Se=me());{const Oe=we?g.ZERO:g.ONE_MINUS_DST_ALPHA,Xe=new d._({func:g.EQUAL,mask:255},255,255,g.KEEP,g.DECR,g.DECR),ot=new d.a1([Oe,g.DST_ALPHA,g.ONE_MINUS_DST_ALPHA,g.ZERO],d.C.transparent,[!0,!0,!0,!0]);Ct.drawGroundEffect(_e,a,r,o,u,Re,Xe,ot,d.$.disabled,we,"color",U,G,$,Y,oe,Pe,I,ve)}if(!E||we){const Oe=new d.a1([g.ONE,g.ONE,g.ONE,we?g.ZERO:g.ONE],d.C.transparent,[!1,!1,!1,!0],we?g.FUNC_ADD:g.MAX);Ct.drawGroundEffect(_e,a,r,o,u,Re,d._.disabled,Oe,d.$.disabled,we,"clear",U,G,$,Y,oe,Pe,I,ve,Se)}else{g.drawBuffers([g.NONE,g.COLOR_ATTACHMENT1]);const Oe=new d._({func:g.EQUAL,mask:255},254,255,g.KEEP,g.DECR,g.DECR),Xe=new d.a1([g.ONE,g.ONE,g.ONE,g.ONE],d.C.transparent,[!0,!1,!1,!1],g.MAX);Ct.drawGroundEffect(_e,a,r,o,u,Re,Oe,Xe,d.$.disabled,we,"emissive",U,G,$,Y,oe,Pe,I,ve,Se),g.drawBuffers([g.COLOR_ATTACHMENT0])}};if(pe||ce){let we;a.prepareDrawTile(),E&&!pe||(we=me()),pe&&Ie(!0,!1,we),ce&&Ie(!1,!0,we)}}else pe&&ue(!0),ce&&ue(!1),(pe||ce)&&a.resetStencilClippingMasks()}}},hillshade:function(a,r,o,u){if(a.renderPass!=="offscreen"&&a.renderPass!=="translucent"||a.style.disableElevatedTerrain)return;const f=a.context,m=a.terrain&&a.terrain.renderingToTexture,[g,x]=a.renderPass!=="translucent"||m?[{},u]:a.stencilConfigForOverlap(u);for(const w of x){const E=r.getTile(w);if(E.needsHillshadePrepare&&a.renderPass==="offscreen")Hf(a,E,o);else if(a.renderPass==="translucent"){const I=a.depthModeForSublayer(0,d.Z.ReadOnly),R=o.paint.get("hillshade-emissive-strength"),P=a.colorModeForDrapableLayerRenderPass(R),B=m&&a.terrain?a.terrain.stencilModeForRTTOverlap(w):g[w.overscaledZ];th(a,w,E,o,I,B,P)}}f.viewport.set([0,0,a.width,a.height]),a.resetStencilClippingMasks()},raster:function(a,r,o,u,f,m){if(a.renderPass!=="translucent")return;const g=o.paint.get("raster-opacity");if(g===0)return;const x=o.paint.get("raster-allow-draping"),w=a.transform.projection.name==="globe";let E=o.paint.get("raster-elevation"),I=o.paint.get("raster-elevation-reference")==="ground";x||E!==0||(E=.001,I=!0);const R=E>0,P=a.terrain&&a.terrain.exaggeration()>0&&R&&I,B=R&&w,V=!w&&P;if(a.renderElevatedRasterBackface&&!B)return;const U=a.context,G=U.gl,$=r.getSource(),Y=function(ve,Se,Re,Ue,Pe){const Oe=Se.paint.get("raster-color"),Xe=ve.type==="raster-array",ot=[],tt=Se.paint.get("raster-resampling"),Ye=Se.paint.get("raster-color-mix");let mt=Se.paint.get("raster-color-range");const We=[Ye[0],Ye[1],Ye[2],0],je=Ye[3];let Je=tt==="nearest"?Ue.NEAREST:Ue.LINEAR;if(Xe&&(ot.push("RASTER_ARRAY"),Oe||ot.push("RASTER_COLOR"),tt==="linear"&&ot.push("RASTER_ARRAY_LINEAR"),Je=Ue.NEAREST,Oe&&Se.paint.get("raster-color-scale")==="log"&&ot.push("RASTER_COLOR_SCALE_LOG"),!mt&&ve.rasterLayers)){const ft=ve.rasterLayers.find(({id:rt})=>rt===Se.sourceLayer);ft&&ft.fields&&ft.fields.range&&(mt=ft.fields.range)}if(mt=mt||[0,1],Oe){ot.push("RASTER_COLOR"),Re.activeTexture.set(Ue.TEXTURE2),Se.updateColorRamp(mt);let ft=Se.colorRampTexture;ft||(ft=Se.colorRampTexture=new d.T(Re,Se.colorRamp,Ue.RGBA8)),ft.bind(Je,Ue.CLAMP_TO_EDGE)}return Pe&&ot.push("USE_MRT1"),{mix:We,range:mt,offset:je,defines:ot,resampling:Je}}($,o,U,G,a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback");if($ instanceof ho&&!u.length&&!w)return;const re=o.paint.get("raster-emissive-strength"),oe=a.colorModeForDrapableLayerRenderPass(re),pe=a.terrain&&a.terrain.renderingToTexture,ce=!a.options.moving,_e=o.paint.get("raster-resampling")==="nearest"?G.NEAREST:G.LINEAR;if($ instanceof ho&&!u.length&&($.onNorthPole||$.onSouthPole)){const ve=R?a.stencilModeFor3D():d._.disabled;return void fh(E,!!$.onNorthPole,null,a,r,o,re,Y,d.$.disabled,ve)}if(!u.length)return;const[ue,me]=$ instanceof ho||pe?[{},u]:a.stencilConfigForOverlap(u),Ie=me.at(-1).overscaledZ;B&&Y.defines.push("PROJECTION_GLOBE_VIEW"),R&&Y.defines.push("RENDER_CUTOFF","ELEVATED"),P&&Y.defines.push("ELEVATION_REFERENCE_GROUND");const we=(ve,Se,Re)=>{for(const Ue of ve){const Pe=Ue.toUnwrapped(),Oe=r.getTile(Ue);if(pe&&(!Oe||!Oe.hasData()))continue;U.activeTexture.set(G.TEXTURE0);const Xe=up(Oe,$,o,Y);if(!Xe||!Xe.texture)continue;const{texture:ot,mix:tt,offset:Ye,tileSize:mt,buffer:We}=Xe;let je,Je;pe?(je=d.Z.disabled,Je=Ue.projMatrix):R?(je=new d.Z(G.LEQUAL,d.Z.ReadWrite,a.depthRangeFor3D),Je=w?a.transform.expandedFarZProjMatrix:a.transform.calculateProjMatrix(Pe,ce)):(je=a.depthModeForSublayer(Ue.overscaledZ-Ie,g===1?d.Z.ReadWrite:d.Z.ReadOnly,G.LESS),Je=a.transform.calculateProjMatrix(Pe,ce));const ft=a.terrain&&pe?a.terrain.stencilModeForRTTOverlap(Ue):ue[Ue.overscaledZ],rt=m?0:o.paint.get("raster-fade-duration");Oe.registerFadeDuration(rt);const ct=r.findLoadedParent(Ue,0),xt=Or(Oe,ct,r,a.transform,rt);let Rt,Mt;!xt.isFading&&Oe.refreshedUponExpiration&&(Oe.refreshedUponExpiration=!1),a.terrain&&a.terrain.prepareDrawTile(),U.activeTexture.set(G.TEXTURE0),ot.bind(_e,G.CLAMP_TO_EDGE),U.activeTexture.set(G.TEXTURE1),ct?(ct.texture&&ct.texture.bind(_e,G.CLAMP_TO_EDGE),Rt=Math.pow(2,ct.tileID.overscaledZ-Oe.tileID.overscaledZ),Mt=[Oe.tileID.canonical.x*Rt%1,Oe.tileID.canonical.y*Rt%1]):ot.bind(_e,G.CLAMP_TO_EDGE),"useMipmap"in ot&&U.extTextureFilterAnisotropic&&a.transform.pitch>20&&G.texParameterf(G.TEXTURE_2D,U.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,U.extTextureFilterAnisotropicMax);const Ft=a.transform;let bi;const yi=R?cp(Ft):[0,0,0,0];let kt,_t,wi,sr,qi,Yt=0;if(B&&$ instanceof ho&&$.coordinates.length>3)kt=Float32Array.from(d.b4(d.b5(new d.bX(0,0,0)))),_t=Float32Array.from(Ft.globeMatrix),wi=Float32Array.from(d.b6(Ft)),sr=[d.a7(Ft.center.lng),d.a8(Ft.center.lat)],bi=$.elevatedGlobePerspectiveTransform,qi=$.elevatedGlobeGridMatrix||new Float32Array(9);else if(B){const Ti=d.b2(Ue.canonical);Yt=d.b3(Ti.getCenter().lat),kt=Float32Array.from(d.b4(d.b5(Ue.canonical))),_t=Float32Array.from(Ft.globeMatrix),wi=Float32Array.from(d.b6(Ft)),sr=[d.a7(Ft.center.lng),d.a8(Ft.center.lat)],bi=[0,0],qi=Float32Array.from(d.b7(Ue.canonical,Ti,Yt,Ft.worldSize/Ft._pixelsPerMercatorPixel))}else bi=$ instanceof ho?$.perspectiveTransform:[0,0],kt=new Float32Array(16),_t=new Float32Array(9),wi=new Float32Array(16),sr=[0,0],qi=new Float32Array(9);const Wi=ip(a,Je,kt,_t,wi,qi,Mt||[0,0],d.S(a.transform.zoom),sr,yi,Rt||1,xt,o,bi,E,2,tt,Ye,Y.range,mt,We,re),Mi=a.isTileAffectedByFog(Ue),Wt=a.getOrCreateProgram("raster",{defines:Y.defines,overrideFog:Mi});if(a.uploadCommonUniforms(U,Wt,Pe),$ instanceof ho){const Ti=$.elevatedGlobeVertexBuffer,tr=$.elevatedGlobeIndexBuffer;if(pe||!w)$.boundsBuffer&&$.boundsSegments&&Wt.draw(a,G.TRIANGLES,je,d._.disabled,oe,d.$.disabled,Wi,o.id,$.boundsBuffer,a.quadTriangleIndexBuffer,$.boundsSegments);else if(Ti&&tr){const ni=Ft.zoom<=d.e9?$.elevatedGlobeSegments:$.getSegmentsForLongitude(Ft.center.lng);ni&&Wt.draw(a,G.TRIANGLES,je,d._.disabled,oe,Se,Wi,o.id,Ti,tr,ni)}}else if(B){je=new d.Z(G.LEQUAL,d.Z.ReadOnly,a.depthRangeFor3D);const Ti=a.globeSharedBuffers;if(Ti){P&&(a.terrain.setupElevationDraw(Oe,Wt),a.uploadCommonUniforms(U,Wt,Oe.tileID.toUnwrapped()));const[tr,ni,ii]=Ti.getGridBuffers(Yt,!1),Ni=Wt.getAttributeLocation(G,"a_texture_pos");Ni!==-1&&G.vertexAttribI4ui(Ni,0,0,0,0),Wt.draw(a,G.TRIANGLES,je,Re||ft,a.colorModeForRenderPass(),Se,Wi,o.id,tr,ni,ii)}}else if(V)je=new d.Z(G.LEQUAL,d.Z.ReadOnly,a.depthRangeFor3D),a.terrain.setupElevationDraw(Oe,Wt),a.uploadCommonUniforms(U,Wt,Oe.tileID.toUnwrapped()),Ft.pitch>20&&Wt.draw(a,G.TRIANGLES,je,d._.disabled,d.a1.disabled,d.$.frontCCW,Wi,o.id,a.terrain.gridBuffer,a.terrain.gridIndexBuffer,a.terrain.gridSegments),Wt.draw(a,G.TRIANGLES,je,ft,oe,d.$.backCCW,Wi,o.id,a.terrain.gridBuffer,a.terrain.gridIndexBuffer,a.terrain.gridSegments);else{const{tileBoundsBuffer:Ti,tileBoundsIndexBuffer:tr,tileBoundsSegments:ni}=a.getTileBoundsBuffers(Oe);Wt.draw(a,G.TRIANGLES,je,ft,oe,d.$.disabled,Wi,o.id,Ti,tr,ni)}}if(!($ instanceof ho)&&B)for(const Ue of ve){const Pe=Ue.canonical.y===(1<<Ue.canonical.z)-1;Ue.canonical.y===0&&fh(E,!0,Ue,a,r,o,re,Y,Se,Re||d._.disabled),Pe&&fh(E,!1,Ue,a,r,o,re,Y,Se===d.$.frontCW?d.$.backCW:d.$.frontCW,Re||d._.disabled)}};B?we(me,a.renderElevatedRasterBackface?d.$.backCW:d.$.frontCW,a.stencilModeFor3D()):we(me,d.$.disabled,void 0),a.resetStencilClippingMasks()},background:function(a,r,o,u){const f=o.paint.get("background-color"),m=o.paint.get("background-color-use-theme").constantOr("default")==="none",g=o.paint.get("background-opacity"),x=o.paint.get("background-emissive-strength"),w=o.paint.get("background-pitch-alignment")==="viewport";if(g===0)return;const E=a.context,I=E.gl,R=a.transform,P=R.tileSize,B=o.paint.get("background-pattern");let V;if(B!==void 0&&(B===null||(V=a.imageManager.getPattern(d.I.from(B.toString()),o.scope,a.style.getLut(o.scope)),!V)))return;const U=!B&&f.a===1&&g===1&&a.opaquePassEnabledForLayer()?"opaque":"translucent";if(a.renderPass!==U)return;const G=d._.disabled,$=a.depthModeForSublayer(0,U==="opaque"?d.Z.ReadWrite:d.Z.ReadOnly),Y=a.colorModeForDrapableLayerRenderPass(x),re=B?"backgroundPattern":"background";let oe,pe=u;pe||(oe=a.getBackgroundTiles(),pe=Object.values(oe).map(_e=>_e.tileID)),B&&(E.activeTexture.set(I.TEXTURE0),a.imageManager.bind(a.context,o.scope));const ce=[];if(a.terrain&&a.terrain.renderingToTexture&&a.emissiveMode==="mrt-fallback"&&ce.push("USE_MRT1"),w){const _e=a.getOrCreateProgram(re,{overrideFog:!1,overrideRtt:!0,defines:ce}),ue=hp,me=new d.bP(0,0,0,0,0),Ie=B?Ea(ue,x,g,a,B,o.scope,V,w,{tileID:me,tileSize:P}):nu(ue,x,g,f.toPremultipliedRenderColor(m?null:o.lut));return void _e.draw(a,I.TRIANGLES,$,G,Y,d.$.disabled,Ie,o.id,a.viewportBuffer,a.quadTriangleIndexBuffer,a.viewportSegments)}for(const _e of pe){const ue=a.isTileAffectedByFog(_e),me=a.getOrCreateProgram(re,{overrideFog:ue,defines:ce}),Ie=_e.toUnwrapped(),we=u?_e.projMatrix:a.transform.calculateProjMatrix(Ie);a.prepareDrawTile();const ve=r?r.getTile(_e):oe?oe[_e.key]:new Ms(_e,P,R.zoom,a),Se=B?Ea(we,x,g,a,B,o.scope,V,w,{tileID:_e,tileSize:P}):nu(we,x,g,f.toPremultipliedRenderColor(m?null:o.lut));a.uploadCommonUniforms(E,me,Ie);const{tileBoundsBuffer:Re,tileBoundsIndexBuffer:Ue,tileBoundsSegments:Pe}=a.getTileBoundsBuffers(ve);me.draw(a,I.TRIANGLES,$,G,Y,d.$.disabled,Se,o.id,Re,Ue,Pe)}},sky:function(a,r,o){const u=a._atmosphere?d.S(a.transform.zoom):1,f=o.paint.get("sky-opacity")*u;if(f===0)return;const m=a.context,g=o.paint.get("sky-type"),x=new d.Z(m.gl.LEQUAL,d.Z.ReadOnly,[0,1]),w=a.frameCounter/1e3%1;g==="atmosphere"?a.renderPass==="offscreen"?o.needsSkyboxCapture(a)&&(function(E,I){const R=E.context,P=R.gl;let B=I.skyboxFbo;if(!B){B=I.skyboxFbo=R.createFramebuffer(32,32,1,null),I.skyboxGeometry=new Md(R),I.skyboxTexture=R.gl.createTexture(),P.bindTexture(P.TEXTURE_CUBE_MAP,I.skyboxTexture),P.texParameteri(P.TEXTURE_CUBE_MAP,P.TEXTURE_WRAP_S,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_CUBE_MAP,P.TEXTURE_WRAP_T,P.CLAMP_TO_EDGE),P.texParameteri(P.TEXTURE_CUBE_MAP,P.TEXTURE_MIN_FILTER,P.LINEAR),P.texParameteri(P.TEXTURE_CUBE_MAP,P.TEXTURE_MAG_FILTER,P.LINEAR);for(let $=0;$<6;++$)P.texImage2D(P.TEXTURE_CUBE_MAP_POSITIVE_X+$,0,P.RGBA,32,32,0,P.RGBA,P.UNSIGNED_BYTE,null)}R.bindFramebuffer.set(B.framebuffer),R.viewport.set([0,0,32,32]);const V=I.getCenter(E,!0),U=E.getOrCreateProgram("skyboxCapture"),G=new Float64Array(16);d.ec(G,.5*-Math.PI),yl(E,I,U,G,V,0),d.ec(G,.5*Math.PI),yl(E,I,U,G,V,1),d.ed(G,.5*-Math.PI),yl(E,I,U,G,V,2),d.ed(G,.5*Math.PI),yl(E,I,U,G,V,3),d.d0(G),yl(E,I,U,G,V,4),d.ec(G,Math.PI),yl(E,I,U,G,V,5),R.viewport.set([0,0,E.width,E.height])}(a,o),o.markSkyboxValid(a)):a.renderPass==="sky"&&function(E,I,R,P,B){const V=E.context,U=V.gl,G=E.transform,$=E.getOrCreateProgram("skybox");V.activeTexture.set(U.TEXTURE0),U.bindTexture(U.TEXTURE_CUBE_MAP,I.skyboxTexture);const Y=((re,oe,pe,ce,_e)=>({u_matrix:re,u_sun_direction:oe,u_cubemap:0,u_opacity:ce,u_temporal_offset:_e}))(G.skyboxMatrix,I.getCenter(E,!1),0,P,B);E.uploadCommonUniforms(V,$),$.draw(E,U.TRIANGLES,R,d._.disabled,E.colorModeForRenderPass(),d.$.backCW,Y,"skybox",I.skyboxGeometry.vertexBuffer,I.skyboxGeometry.indexBuffer,I.skyboxGeometry.segment)}(a,o,x,f,w):g==="gradient"&&a.renderPass==="sky"&&function(E,I,R,P,B){const V=E.context,U=V.gl,G=E.transform,$=E.getOrCreateProgram("skyboxGradient");I.skyboxGeometry||(I.skyboxGeometry=new Md(V)),V.activeTexture.set(U.TEXTURE0);let Y=I.colorRampTexture;Y||(Y=I.colorRampTexture=new d.T(V,I.colorRamp,U.RGBA8)),Y.bind(U.LINEAR,U.CLAMP_TO_EDGE);const re=((oe,pe,ce,_e,ue)=>({u_matrix:oe,u_color_ramp:0,u_center_direction:pe,u_radius:d.au(ce),u_opacity:_e,u_temporal_offset:ue}))(G.skyboxMatrix,I.getCenter(E,!1),I.paint.get("sky-gradient-radius"),P,B);E.uploadCommonUniforms(V,$),$.draw(E,U.TRIANGLES,R,d._.disabled,E.colorModeForRenderPass(),d.$.backCW,re,"skyboxGradient",I.skyboxGeometry.vertexBuffer,I.skyboxGeometry.indexBuffer,I.skyboxGeometry.segment)}(a,o,x,f,w)},custom:function(a,r,o,u){const f=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(r)){if(a.renderPass==="offscreen"){const g=m.prerender;if(g){if(a.setCustomLayerDefaults(),f.setColorMode(a.colorModeForRenderPass()),a.transform.projection.name==="globe"){const x=a.transform.pointMerc;g.call(m,f.gl,a.transform.customLayerMatrix(),a.transform.getProjection(),a.transform.globeToMercatorMatrix(),d.S(a.transform.zoom),[x.x,x.y],a.transform.pixelsPerMeterRatio)}else g.call(m,f.gl,a.transform.customLayerMatrix());f.setDirty(),a.setBaseState()}}else if(a.renderPass==="translucent"){if(a.terrain&&a.terrain.renderingToTexture){const x=m.renderToTile;if(x){const w=u[0].canonical,E={x:w.x+u[0].wrap*(m.wrapTileId?0:1<<w.z),y:w.y,z:w.z};f.setDepthMode(d.Z.disabled),f.setStencilMode(d._.disabled),f.setColorMode(a.colorModeForRenderPass()),a.setCustomLayerDefaults();const I=f.gl;a.emissiveMode==="mrt-fallback"&&I.drawBuffers([I.COLOR_ATTACHMENT0]),x.call(m,f.gl,E),a.emissiveMode==="mrt-fallback"&&I.drawBuffers([I.COLOR_ATTACHMENT0,I.COLOR_ATTACHMENT1]),f.setDirty(),a.setBaseState()}return}a.setCustomLayerDefaults(),f.setColorMode(a.colorModeForRenderPass()),f.setStencilMode(d._.disabled);const g=m.renderingMode==="3d"?new d.Z(a.context.gl.LEQUAL,d.Z.ReadWrite,a.depthRangeFor3D):a.depthModeForSublayer(0,d.Z.ReadOnly);if(f.setDepthMode(g),a.transform.projection.name==="globe"){const x=a.transform.pointMerc;m.render(f.gl,a.transform.customLayerMatrix(),a.transform.getProjection(),a.transform.globeToMercatorMatrix(),d.S(a.transform.zoom),[x.x,x.y],a.transform.pixelsPerMeterRatio)}else m.render(f.gl,a.transform.customLayerMatrix());f.setDirty(),a.setBaseState(),f.bindFramebuffer.set(null)}}else d.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")}},cu={line:function(a,r,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(r){const u=r.getVisibleCoordinates();for(const f of u){const m=r.getTile(f).getBucket(a);if(m&&(m.elevationType!=="none"?a.hasElevatedBuckets=!0:a.hasNonElevatedBuckets=!0,a.hasElevatedBuckets&&a.hasNonElevatedBuckets))break}}}else a.hasNonElevatedBuckets=!0},raster:function(a,r,o){const u=r.getSource();if(u.type!=="raster-array"||!u.loaded())return;const f=a.sourceLayer||u.rasterLayerIds&&u.rasterLayerIds[0];if(!f)return;const m=a.paint.get("raster-array-band")||u.getInitialBand(f);if(m==null)return;const g=r.getIds().map(x=>r.getTileByID(x));for(const x of g)x.updateNeeded(a.id,m)&&u.prepareTile(x,f,a.id,m)}};async function gp(a){if(await Zt(),Object.assign(xl,{model:Ct.drawModels}),Object.assign(cu,{model:Ct.prepare}),a&&!a._destroyed&&!a._shadowRenderer){const r=Ct.ShadowRenderer;r&&(a._shadowRenderer=new r(a))}}class Ld{constructor(r,o,u,f,m){this.context=new ou(r,o),this.transform=u,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.frcCoverageSnapshot=null,this.elevationCoverageSnapshot=null,this.elevationProvidersReady=void 0,this.frcCoverageFadeRange=null,this.frcCoverageSourceLayers=[],this.frcCoverageRenderer=Tt.FrcCoverageRenderer?new Tt.FrcCoverageRenderer:null,this._debugParams={averageFPS:0,fpsHistory:[],fpsWindow:30,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,snowVignetteParamsOverride:null,overrideRainParams:!1,rainParamsOverride:null,rainRevealParamsOverride:null,rainVignetteParamsOverride:null,overrideStarsParams:!1,starsParamsOverride:null,show3DModelFootprints:!1,showElevationIdDebug:!1,lodSwitchDistance:-1,lodSwitchFadeDuration:.5},this.occlusionParams=new Dd,this.setup(),this.numSublayers=Tn.maxUnderzooming+Tn.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this.frameTimeDelta=0,this.lastPaintStartTimeStamp=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new d.eq,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._wireframeDebugCache=new _p,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const g=new d.b({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new d.T(this.context,g,r.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=f,this.maxFrontCutoffRawStart=0,this.worldview=m,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(r,o){const u=!!r&&!!r.terrain&&this.transform.projection.supportsTerrain;if(!(u||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new tu(this,r));const f=this._terrain;this.transform.elevation=u?f:null,f.update(r,this.transform,o),this.transform.elevation&&!f.enabled&&(this.transform.elevation=null)}_updateFog(r){const o=r.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);const[u,f]=o.getRangeForProjection();if(u>f)return void(this.transform.fogCullDistSq=null);const m=u+.78*(f-u);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(r){r&&!this._terrain&&(this._terrain=new tu(this,this.style)),this._forceTerrainMode=r}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(r,o){if(this.width=r*d.e.devicePixelRatio,this.height=o*d.e.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const u of this.style.order)this.style._mergedLayers[u].resize()}setup(){const r=this.context,o=new d.bC;o.emplaceBack(0,0),o.emplaceBack(d.a2,0),o.emplaceBack(0,d.a2),o.emplaceBack(d.a2,d.a2),this.tileExtentBuffer=r.createVertexBuffer(o,d.bE.members),this.tileExtentSegments=d.ac.simpleSegment(0,0,4,2);const u=new d.bC;u.emplaceBack(0,0),u.emplaceBack(d.a2,0),u.emplaceBack(0,d.a2),u.emplaceBack(d.a2,d.a2),this.debugBuffer=r.createVertexBuffer(u,d.bE.members),this.debugSegments=d.ac.simpleSegment(0,0,4,5);const f=new d.bC;f.emplaceBack(-1,-1),f.emplaceBack(1,-1),f.emplaceBack(-1,1),f.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(f,d.bE.members),this.viewportSegments=d.ac.simpleSegment(0,0,4,2);const m=new d.bs;m.emplaceBack(0,0,0,0),m.emplaceBack(d.a2,0,d.a2,0),m.emplaceBack(0,d.a2,0,d.a2),m.emplaceBack(d.a2,d.a2,d.a2,d.a2),this.mercatorBoundsBuffer=r.createVertexBuffer(m,Cs.members),this.mercatorBoundsSegments=d.ac.simpleSegment(0,0,4,2);const g=new d.ad;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(g);const x=new d.bD;for(const E of[0,1,3,2,0])x.emplaceBack(E);this.debugIndexBuffer=r.createIndexBuffer(x),this.emptyTexture=new d.T(r,new d.b({width:1,height:1},Uint8Array.of(0,0,0,0)),r.gl.RGBA8),this.identityMat=d.Y();const w=this.context.gl;this.stencilClearMode=new d._({func:w.ALWAYS,mask:0},0,255,w.ZERO,w.ZERO,w.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(r){return r._makeTileBoundsBuffers(this.context,this.transform.projection),r._tileBoundsBuffer?{tileBoundsBuffer:r._tileBoundsBuffer,tileBoundsIndexBuffer:r._tileBoundsIndexBuffer,tileBoundsSegments:r._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const r=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,r.TRIANGLES,d.Z.disabled,this.stencilClearMode,d.a1.disabled,d.$.disabled,Sr(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(r,o,u){if(!o||this.currentStencilSource===o.id||!r.isTileClipped()||!u||u.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let x=!1;for(const w of u)if(this._tileClippingMaskIDs[w.key]===void 0){x=!0;break}if(!x)return}this.currentStencilSource=o.id;const f=this.context,m=f.gl;this.nextStencilID+u.length>256&&this.clearStencil(),f.setColorMode(d.a1.disabled),f.setDepthMode(d.Z.disabled);const g=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const x of u){const w=o.getTile(x),E=this._tileClippingMaskIDs[x.key]=this.nextStencilID++,{tileBoundsBuffer:I,tileBoundsIndexBuffer:R,tileBoundsSegments:P}=this.getTileBoundsBuffers(w);g.draw(this,m.TRIANGLES,d.Z.disabled,new d._({func:m.ALWAYS,mask:0},E,255,m.KEEP,m.KEEP,m.REPLACE),d.a1.disabled,d.$.disabled,Sr(x.projMatrix),"$clipping",I,R,P)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,o=this.context.gl;return new d._({func:o.NOTEQUAL,mask:255},r,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(r){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(r);const o=this.context.gl;return new d._({func:o.EQUAL,mask:255},this._tileClippingMaskIDs[r.key],0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(r){const o=this.context.gl,u=r.sort((g,x)=>x.overscaledZ-g.overscaledZ),f=u.at(-1).overscaledZ,m=u[0].overscaledZ-f+1;if(m>1){this.currentStencilSource=void 0,this.nextStencilID+m>256&&this.clearStencil();const g={};for(let x=0;x<m;x++)g[x+f]=new d._({func:o.GEQUAL,mask:255},x+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=m,[g,u]}return[{[f]:d._.disabled},u]}colorModeForRenderPass(){const r=this.context.gl;return this._showOverdrawInspector?new d.a1([r.CONSTANT_COLOR,r.ONE,r.CONSTANT_COLOR,r.ONE],new d.C(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?d.a1.unblended:d.a1.alphaBlended}colorModeForDrapableLayerRenderPass(r){const o=this.context.gl;return this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture&&this.renderPass==="translucent"?r!=null&&this.emissiveMode!=="mrt-fallback"||this.emissiveMode==="constant"?new d.a1([o.ONE,o.ONE_MINUS_SRC_ALPHA,o.CONSTANT_ALPHA,o.ONE_MINUS_SRC_ALPHA],new d.C(0,0,0,r??0),[!0,!0,!0,!0]):this.emissiveMode==="dual-source-blending"?new d.a1([o.ONE,o.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,o.ONE_MINUS_SRC_ALPHA],d.C.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(r,o,u,f=!1){if(this.depthOcclusion)return new d.Z(this.context.gl.GREATER,d.Z.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!f)return d.Z.disabled;const m=1-((1+this.currentLayer)*this.numSublayers+r)*this.depthEpsilon;return new d.Z(u||this.context.gl.LEQUAL,o,[m,m])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const r=this.context.gl,o=Math.ceil(this.width),u=Math.ceil(this.height),f=this.context.bindFramebuffer.get(),m=r.getParameter(r.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===o&&this.depthFBO.height===u||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),o!==0&&u!==0&&(this.depthFBO=new Js(this.context,o,u,0,"texture"),this.depthTexture=new d.T(this.context,{width:o,height:u,data:null},r.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(f),r.bindTexture(r.TEXTURE_2D,m),this.depthFBO&&(r.bindFramebuffer(r.READ_FRAMEBUFFER,null),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),r.blitFramebuffer(0,0,o,u,0,0,o,u,r.DEPTH_BUFFER_BIT,r.NEAREST),r.bindFramebuffer(r.FRAMEBUFFER,this.context.bindFramebuffer.current))}render(r,o){this.context.sweepPendingPrograms(),this.frameTimeDelta=this.lastPaintStartTimeStamp===0?0:o.paintStartTimeStamp-this.lastPaintStartTimeStamp,this.lastPaintStartTimeStamp=o.paintStartTimeStamp,this._wireframeDebugCache.update(this.frameCounter),this.style=r,this.options=o,this.frcCoverageSnapshot&&!this.frcCoverageSnapshot.empty()&&(!this.frcCoverageRenderer&&Tt.FrcCoverageRenderer&&(this.frcCoverageRenderer=new Tt.FrcCoverageRenderer),this.frcCoverageRenderer&&this.frcCoverageRenderer.update(this.context,this.frcCoverageSnapshot.tiles));const u=this.style._mergedLayers,f=!(!this.terrain||!this.terrain.enabled),m=()=>this.style._getOrder(f);let g=m(),x=!1,w=!1,E=null,I=0,R=!1;for(const Pe of g){const Oe=u[Pe];Oe.visibility!=="none"&&(Oe.type==="circle"?x=!0:Oe.type==="building"?(E=Oe,++I):Oe.type==="symbol"&&(Oe.hasOcclusionOpacityProperties?w=!0:x=!0))}this.updateEmissiveMode();let P=g.map(Pe=>u[Pe]);const B=this.style._mergedSourceCaches;this.imageManager=r.imageManager,this.modelManager=r.modelManager,this.symbolFadeChange=r.placement.symbolFadeChange(d.e.now()),this.imageManager.beginFrame();for(const Pe in B){const Oe=B[Pe];Oe.used&&(Oe.prepare(this.context),Oe.getSource().usedInConflation&&++I)}let V=!1;for(const Pe of P)Pe.isHidden(this.transform.zoom)||(Pe.type==="clip"&&(V=!0),this.prepareLayer(Pe));const U={},G={},$={},Y={},re={};for(const Pe in B){const Oe=B[Pe];U[Pe]=Oe.getVisibleCoordinates(),G[Pe]=U[Pe].slice().reverse(),$[Pe]=Oe.getVisibleCoordinates(!0).reverse(),Y[Pe]=Oe.getShadowCasterCoordinates(),re[Pe]=Oe.sortCoordinatesByDistance(U[Pe])}const oe=Pe=>{const Oe=this.style.getLayerSourceCache(Pe);return Oe&&Oe.used?Oe.getSource():null};if(I||V||this._clippingActiveLastFrame){const Pe=[],Oe=[];let Xe=0;for(const ot of P)this.isSourceForClippingOrConflation(ot,oe(ot))&&(Pe.push(ot),Oe.push(Xe)),Xe++;if(Pe&&(V||Pe.length>1)||this._clippingActiveLastFrame){V=!1;const ot=[];for(let tt=0;tt<Pe.length;tt++){const Ye=Pe[tt],mt=Oe[tt],We=this.style.getLayerSourceCache(Ye);if(!We||!We.used||!We.getSource().usedInConflation&&Ye.type!=="clip"&&Ye.type!=="building")continue;let je=d.er,Je=d.cI.None;const ft=[];let rt=!0;if(Ye.type==="building")je=d.ev;else if(Ye.type==="clip")if(je=mt,Ye.isHidden(this.transform.zoom))rt=!1;else{if(!Ye.layout){rt=!1;continue}for(const ct of Ye.layout.get("clip-layer-types"))Je|=ct==="model"?d.cI.Model:ct==="symbol"?d.cI.Symbol:d.cI.FillExtrusion;for(const ct of Ye.layout.get("clip-layer-scope"))ft.push(d.m(ct,Ye.scope));V=!0}rt&&ot.push({layer:Ye.fqid,cache:We,order:je,clipMask:Je,clipScope:ft})}this.replacementSource.setSources(ot),R=!0}}this._clippingActiveLastFrame=V,R||this.replacementSource.clear(),this.conflationActive=R,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let Pe=0;Pe<P.length;Pe++){const Oe=P[Pe];if(Oe.visibility==="none")continue;const Xe=Oe.cutoffRange();if(this.longestCutoffRange=Math.max(Xe,this.longestCutoffRange),Xe>0){const ot=oe(Oe);ot&&(this.minCutoffZoom=Math.max(ot.minzoom,this.minCutoffZoom)),Oe.minzoom&&(this.minCutoffZoom=Math.max(Oe.minzoom,this.minCutoffZoom))}Oe.is3D(f)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Pe),this._lastOcclusionLayer=Pe)}const pe=this.style&&this.style.fog;pe?(this._fogVisible=pe.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=pe.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding($),this.opaquePassCutoff=0,g=m(),P=g.map(Pe=>u[Pe])),this.style.enable3dLights()&&!this._shadowRenderer&&gp(this);const ce=this._shadowRenderer;if(ce){ce.updateShadowParameters(this.transform,this.style.directionalLight);for(const Pe in B)for(const Oe of U[Pe]){let Xe={min:0,max:0};this.terrain&&(Xe=this.terrain.getMinMaxForTile(Oe)||Xe),ce.addShadowReceiver(Oe.toUnwrapped(),Xe.min,Xe.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new d.es(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new mp),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let _e=!(!this.style||!this.style.snow),ue=!(!this.style||!this.style.rain);if(_e&&!this._snow&&Tt.Snow&&(this._snow=new Tt.Snow),!_e&&this._snow&&(this._snow.destroy(),delete this._snow),ue&&!this._rain&&Tt.Rain&&(this._rain=new Tt.Rain),!ue&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),E&&(!this.buildingTileBorderManager&&Tt.BuildingTileBorderManager&&(this.buildingTileBorderManager=new Tt.BuildingTileBorderManager),this.buildingTileBorderManager)){const Pe=this.style.getLayerSourceCache(E);this.buildingTileBorderManager.updateBorders(Pe,E)}if(!d.et(this.context.gl))return;this.renderPass="offscreen";for(const Pe of P){const Oe=r.getLayerSourceCache(Pe);if(!Pe.hasOffscreenPass()||Pe.isHidden(this.transform.zoom))continue;const Xe=Oe?G[Oe.id]:void 0;(Pe.type==="custom"||Pe.type==="raster"||Pe.type==="raster-particle"||Pe.isSky()||Xe&&Xe.length)&&this.renderLayer(this,Oe,Pe,Xe)}this.depthRangeFor3D=[0,1-(P.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,Y)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const me=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ie=(()=>{if(o.showOverdrawInspector)return d.C.black;const Pe=this.style.fog;if(Pe&&this.transform.projection.supportsFog){const Oe=this.style.getLut(Pe.scope);if(!me){const Xe=Pe.properties.get("color-use-theme")==="none",ot=Pe.properties.get("color").toNonPremultipliedRenderColor(Xe?null:Oe).toArray01();return new d.C(...ot)}if(me){const Xe=Pe.properties.get("space-color-use-theme")==="none",ot=Pe.properties.get("space-color").toNonPremultipliedRenderColor(Xe?null:Oe).toArray01();return new d.C(...ot)}}return d.C.transparent})();if(this.context.clear({color:Ie,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&me&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=g.length-1;this.currentLayer>=0;this.currentLayer--){const Pe=P[this.currentLayer],Oe=r.getLayerSourceCache(Pe);if(Pe.isSky())continue;const Xe=Oe?(Pe.is3D(f)?re:G)[Oe.id]:void 0;this._renderTileClippingMasks(Pe,Oe,Xe),this.renderLayer(this,Oe,Pe,Xe)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&me&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||d.S(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<g.length;this.currentLayer++){const Pe=P[this.currentLayer],Oe=r.getLayerSourceCache(Pe);Pe.isSky()&&this.renderLayer(this,Oe,Pe,Oe?G[Oe.id]:void 0)}function we(Pe,Oe){let Xe;return Oe&&(Xe=(Pe.type==="symbol"?$:Pe.is3D(f)?re:G)[Oe.id]),Xe}if(this.renderPass="translucent",this.transform.projection.name==="globe"){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<g.length;){const Pe=P[this.currentLayer];if(Pe.type==="raster"||Pe.type==="raster-particle"){const Oe=r.getLayerSourceCache(Pe);this.renderLayer(this,Oe,Pe,we(Pe,Oe))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;const ve=ce?ce.getGroundShadowLayerIndex():-1;let Se=!1,Re=-1;for(let Pe=0;Pe<g.length;++Pe){const Oe=P[Pe];Oe.isHidden(this.transform.zoom)||Oe.is3D(f)&&(Re=Pe)}w&&Re===-1&&(x=!0);let Ue=!1;for(;this.currentLayer<g.length;){const Pe=P[this.currentLayer],Oe=r.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(!Ue&&Pe.is3D(f)&&!f){const Xe=this.currentLayer,ot=tt=>{for(this.currentLayer=0;this.currentLayer<P.length;this.currentLayer++){const Ye=P[this.currentLayer];if(Ye.type==="fill"&&Tt.drawDepthPrepass){const mt=this.style.getLayerSourceCache(Ye);Tt.drawDepthPrepass(this,mt,Ye,we(Ye,mt),tt)}}};ot("initialize"),ot("reset"),this.currentLayer=Xe,Ue=!0}if(x&&!Se&&this.terrain&&!this.transform.isOrthographic&&(Se=!0,this.blitDepth()),w&&Re!==-1&&this.currentLayer===Re+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(Pe,Oe,Oe?U[Oe.id]:void 0),this.renderLayer(this,Oe,Pe,we(Pe,Oe)),!this.terrain&&ce&&this.currentLayer===ve){{this.clearStencil(),this.resetStencilClippingMasks();const Xe=this.currentLayer;for(this.currentLayer=0;this.currentLayer<P.length;this.currentLayer++){const ot=P[this.currentLayer];if(ot.type==="fill"&&Tt.drawGroundShadowMask){const tt=this.style.getLayerSourceCache(ot);Tt.drawGroundShadowMask(this,tt,ot,we(ot,tt))}}this.currentLayer=Xe}if(ce.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){const Xe=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=Xe;this.currentLayer++){const ot=P[this.currentLayer];if(!ot.hasLightBeamPass())continue;const tt=r.getLayerSourceCache(ot);this.renderLayer(this,tt,ot,tt?G[tt.id]:void 0)}this.currentLayer=Xe,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const Xe=this.currentLayer;this.depthOcclusion=!0;for(const ot of this.layersWithOcclusionOpacity){this.currentLayer=ot;const tt=P[this.currentLayer],Ye=r.getLayerSourceCache(tt),mt=Ye?G[Ye.id]:void 0;this.terrain||this._renderTileClippingMasks(tt,Ye,Ye?U[Ye.id]:void 0),this.renderLayer(this,Ye,tt,mt)}this.depthOcclusion=!1,this.currentLayer=Xe,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;P.forEach(Oe=>{const Xe=r.getLayerSourceCache(Oe);Xe&&!Oe.isHidden(this.transform.zoom)&&Xe.getVisibleCoordinates().length&&(!Pe||Pe.getSource().maxzoom<Xe.getSource().maxzoom)&&(Pe=Xe)}),Pe&&this.options.showTileBoundaries&&Gn.drawDebug&&Gn.drawDebug(this,Pe,Pe.getVisibleCoordinates(),d.C.red,!1,this.options.showParseStatus)}this.options.showPadding&&Gn.drawDebugPadding&&Gn.drawDebugPadding(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),R||(this.conflationActive=!1)}prepareLayer(r){this.gpuTimingStart(r);const{unsupportedLayers:o}=this.transform.projection,u=!o||!o.includes(r.type);if(cu[r.type]&&(u||this.terrain&&r.type==="custom")){const f=this.style.getLayerSourceCache(r);cu[r.type](r,f,this)}this.gpuTimingEnd()}renderLayer(r,o,u,f){u.isHidden(this.transform.zoom)||(u.type==="background"||u.type==="sky"||u.type==="custom"||u.type==="model"||u.type==="raster"||u.type==="raster-particle"||f&&f.length)&&(this.id=u.id,this.gpuTimingStart(u),(!r.transform.projection.unsupportedLayers||!r.transform.projection.unsupportedLayers.includes(u.type)||r.terrain&&u.type==="custom")&&u.type!=="clip"&&u.type!=="slot"&&xl[u.type]&&xl[u.type](r,o,u,f,this.style.placement.variableOffsets,this.options.isInitialLoad),xl[u.type]||(u.mayUse("HD")&&async function(){await Zn(),Object.assign(xl,{building:Tt.drawBuilding,"raster-particle":Tt.drawRasterParticle}),Object.assign(cu,{"raster-particle":Tt.prepareRasterParticle})}(),u.mayUse("Standard")&&gp(r)),this.gpuTimingEnd())}gpuTimingStart(r){if(!this.options.gpuTiming)return;const o=this.context.extTimerQuery,u=this.context.gl;let f=this.gpuTimers[r.id];f||(f=this.gpuTimers[r.id]={calls:0,cpuTime:0,query:u.createQuery()}),f.calls++,u.beginQuery(o.TIME_ELAPSED_EXT,f.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const r=this.context.extTimerQuery,o=this.context.gl,u=o.createQuery();this.deferredRenderGpuTimeQueries.push(u),o.beginQuery(r.TIME_ELAPSED_EXT,u)}}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(){const r=this.gpuTimers;return this.gpuTimers={},r}collectDeferredRenderGpuQueries(){const r=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],r}queryGpuTimers(r){const o={};for(const u in r){const f=r[u],m=this.context.extTimerQuery,g=m.getQueryParameter(f.query,this.context.gl.QUERY_RESULT)/1e6;m.deleteQueryEXT(f.query),o[u]=g}return o}queryGpuTimeDeferredRender(r){if(!this.options.gpuTimingDeferredRender)return 0;const o=this.context.gl;let u=0;for(const f of r)u+=o.getQueryParameter(f,o.QUERY_RESULT)/1e6,o.deleteQuery(f);return u}translatePosMatrix(r,o,u,f,m){if(!u[0]&&!u[1])return r;const g=m?f==="map"?this.transform.angle:0:f==="viewport"?-this.transform.angle:0;if(g){const E=Math.sin(g),I=Math.cos(g);u=[u[0]*I-u[1]*E,u[0]*E+u[1]*I]}const x=[m?u[0]:d.c5(o,u[0],this.transform.zoom),m?u[1]:d.c5(o,u[1],this.transform.zoom),0],w=new Float32Array(16);return d.bM(w,r,x),w}saveTileTexture(r){if(r.context!==this.context)return;const o=r.size[0],u=this._tileTextures[o];u?u.push(r):this._tileTextures[o]=[r]}getTileTexture(r){const o=this._tileTextures[r];return o&&o.length>0?o.pop():null}terrainRenderModeElevated(){return this.style&&this.style.hasTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(r,o,u,f,m){const g=u===void 0?this.terrain&&this.terrain.renderingToTexture:u,x=f===void 0?this.terrainRenderModeElevated():f,w=m===void 0?this.transform.projection.name==="globe":m,E=[];return this.style&&this.style.enable3dLights()&&(r==="globeRaster"||r==="terrainRaster"?(E.push("LIGHTING_3D_MODE"),E.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):g||E.push("LIGHTING_3D_MODE")),x&&(E.push("TERRAIN"),this.linearFloatFilteringSupported()&&E.push("TERRAIN_DEM_FLOAT_FORMAT")),w&&E.push("GLOBE"),!this._fogVisible||g||o!==void 0&&!o||E.push("FOG"),g&&E.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&E.push("OVERDRAW_INSPECTOR"),E}getOrCreateProgram(r,o){this.cache=this.cache||{};const{defines:u,config:f,overrideFog:m,overrideRtt:g,overrideTerrain:x,overrideGlobe:w,precompiled:E}=o||{},I=this.currentGlobalDefines(r,m,g,x,w).concat(u||[]),R=this.getShaderSource(r),P=Tt.programUniforms,B=Ct.programUniforms,V=lh[r]||P&&P[r]||B&&B[r],U=iu.cacheKey(R,r,I,f);return this.cache[U]||(this.cache[U]=new iu(this.context,r,R,f,V,I,E)),this.cache[U]}getShaderSource(r){const o=Tt.shaders,u=Ct.shaders;return d.eu[r]||o&&o[r]||u&&u[r]}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(){const r=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(r.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new d.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(),this._destroyed=!0}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(r,o,u){if(this.style.enable3dLights()){const f=this.style.directionalLight,m=this.style.ambientLight;if(f&&m){const g=((x,w,E,I)=>{const R=x.properties.get("direction"),P=x.properties.get("color-use-theme")==="none",B=x.properties.get("color").toNonPremultipliedRenderColor(P?null:E.getLut(x.scope)).toArray01();let V=x.properties.get("intensity");const U=w.properties.get("color-use-theme")==="none",G=w.properties.get("color").toNonPremultipliedRenderColor(U?null:E.getLut(w.scope)).toArray01();let $=w.properties.get("intensity");const Y=[R.x,R.y,R.z];I&&(I.ambientIntensity!==void 0&&($=I.ambientIntensity),I.directionalIntensity!==void 0&&(V=I.directionalIntensity),I.ambientColor!==void 0&&(G[0]=I.ambientColor[0],G[1]=I.ambientColor[1],G[2]=I.ambientColor[2]),I.directionalColor!==void 0&&(B[0]=I.directionalColor[0],B[1]=I.directionalColor[1],B[2]=I.directionalColor[2]));const re=d.dB(G,$),oe=d.dB(B,V);return{u_lighting_ambient_color:re,u_lighting_directional_dir:Y,u_lighting_directional_color:oe,u_ground_radiance:ep(Y,oe,re)}})(f,m,this.style,u);o.setLightsUniformValues(r,g)}}}uploadCommonUniforms(r,o,u,f,m,g){if(this.uploadCommonLightUniforms(r,o,g),this.terrain&&this.terrain.renderingToTexture)return;const x=this.style.fog;if(x){const w=x.getOpacity(this.transform.pitch),E=((I,R,P,B,V,U,G,$,Y,re,oe,pe)=>{const ce=I.transform,_e=R.properties.get("color-use-theme")==="none",ue=R.properties.get("color").toNonPremultipliedRenderColor(_e?null:I.style.getLut(R.scope)).toArray01();ue[3]=B;const me=I.frameCounter/1e3%1,[Ie,we]=R.properties.get("vertical-range");return{u_fog_matrix:P?ce.calculateFogTileMatrix(P):pe||I.identityMat,u_fog_range:R.getRangeForProjection(),u_fog_color:ue,u_fog_horizon_blend:R.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(Ie,we),we],u_fog_temporal_offset:me,u_frustum_tl:V,u_frustum_tr:U,u_frustum_br:G,u_frustum_bl:$,u_globe_pos:Y,u_globe_radius:re,u_viewport:oe,u_globe_transition:d.S(ce.zoom),u_is_globe:+(ce.projection.name==="globe")}})(this,x,u,w,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*d.e.devicePixelRatio,this.transform.height*d.e.devicePixelRatio],f);o.setFogUniformValues(r,E)}m&&o.setCutoffUniformValues(r,m.uniformValues)}setTileLoadedFlag(r){this.tileLoaded=r}saveCanvasCopy(){const r=this.canvasCopy();r&&(this.frameCopies.push(r),this.tileLoaded=!1)}canvasCopy(){const r=this.context.gl,o=r.createTexture();return r.bindTexture(r.TEXTURE_2D,o),r.copyTexImage2D(r.TEXTURE_2D,0,r.RGBA,0,0,r.drawingBufferWidth,r.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const r=this.style&&this.style.fog;return!!r&&r.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const r=this._backgroundTiles,o=this._backgroundTiles={},u=this.transform.coveringTiles({tileSize:512});for(const f of u)o[f.key]=r[f.key]||new Ms(f,512,this.transform.tileZoom,this,void 0,this.worldview);return o}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(r,o){return!(!r.is3D(!(!this.terrain||!this.terrain.enabled))||r.type!=="clip"&&r.type!=="building"&&(r.minzoom&&r.minzoom>this.transform.zoom||(this.style._clipLayerPresent||r.sourceLayer!=="building"&&r.sourceLayer!=="procedural_buildings")&&(!o||o.type!=="batched-model")))}isTileAffectedByFog(r){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let o=this._cachedTileFogOpacities[r.key];return o||(this._cachedTileFogOpacities[r.key]=o=this.style.fog.getOpacityForTile(r)),o[0]>=d.at||o[1]>=d.at}setupDepthForOcclusion(r,o,u){const f=this.context,m=f.gl,g=!!u;var x;u||(u={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}),f.activeTexture.set(m.TEXTURE3),r&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(m.NEAREST,m.CLAMP_TO_EDGE),u.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],u.u_depth_range_unpack=[2/((x=this.depthRangeFor3D)[1]-x[0]),-1-2*x[0]/(x[1]-x[0])],u.u_occluder_half_size=.5*this.occlusionParams.occluderSize,u.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(m.NEAREST,m.CLAMP_TO_EDGE),f.activeTexture.set(m.TEXTURE0),g||o.setTerrainUniformValues(f,u)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const r=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=r?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function zd(a,r){let o=!1,u=null;const f=()=>{u=null,o&&(a(),u=setTimeout(f,r),o=!1)};return()=>(o=!0,u||f(),u)}const yp=/(#.+)?$/;class D_{constructor(r){this._hashName=r&&encodeURIComponent(r),d.aV(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=zd(this._updateHashUnthrottled.bind(this),300)}addTo(r){return this._map=r,window.addEventListener("hashchange",this._onHashChange,!1),r.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(){const r=this._map;if(!r)return"";const o=xp(r);if(this._hashName){const u=this._hashName;let f=!1;const m=location.hash.slice(1).split("&").map(g=>{const x=g.split("=")[0];return x===u?(f=!0,`${x}=${o}`):g}).filter(g=>g);return f||m.push(`${u}=${o}`),`#${m.join("&")}`}return`#${o}`}_getCurrentHash(){const r=location.hash.replace("#","");if(this._hashName){let o;return r.split("&").map(u=>u.split("=")).forEach(u=>{u[0]===this._hashName&&(o=u)}),(o&&o[1]||"").split("/")}return r.split("/")}_onHashChange(){const r=this._map;if(!r)return!1;const o=this._getCurrentHash();if(o.length>=3&&!o.some(u=>isNaN(Number(u)))){const u=r.dragRotate.isEnabled()&&r.touchZoomRotate.isEnabled()?+(o[3]||0):r.getBearing();return r.jumpTo({center:[+o[2],+o[1]],zoom:+o[0],bearing:u,pitch:+(o[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(yp,this.getHashString()))}}function xp(a,r){const o=a.getCenter(),u=Math.round(100*a.getZoom())/100,f=Math.ceil((u*Math.LN2+Math.log(512/360/.5))/Math.LN10),m=Math.pow(10,f),g=Math.round(o.lng*m)/m,x=Math.round(o.lat*m)/m,w=a.getBearing(),E=a.getPitch();let I=r?`/${g}/${x}/${u}`:`${u}/${x}/${g}`;return(w||E)&&(I+="/"+Math.round(10*w)/10),E&&(I+=`/${Math.round(E)}`),I}const Sn={linearity:.3,easing:d.ew(0,0,.3,1)},Fd={deceleration:2500,maxSpeed:1400,...Sn},zn={deceleration:20,maxSpeed:1400,...Sn},Sa={deceleration:1e3,maxSpeed:360,...Sn},vp={deceleration:1e3,maxSpeed:90,...Sn};class Od{constructor(r){this._map=r,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:d.e.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,o=d.e.now();for(;r.length>0&&o-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const o={zoom:0,bearing:0,pitch:0,pan:new d.P(0,0),pinchAround:void 0,around:void 0};for(const{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);const u=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,f={};if(o.pan.mag()){const m=hc(o.pan.mag(),u,{...Fd,...r||{}});f.offset=o.pan.mult(m.amount/o.pan.mag()),f.center=this._map.transform.center,uc(f,m)}if(o.zoom){const m=hc(o.zoom,u,zn);f.zoom=this._map.transform.zoom+m.amount,uc(f,m)}if(o.bearing){const m=hc(o.bearing,u,Sa);f.bearing=this._map.transform.bearing+d.b0(m.amount,-179,179),uc(f,m)}if(o.pitch){const m=hc(o.pitch,u,vp);f.pitch=this._map.transform.pitch+m.amount,uc(f,m)}if(f.zoom||f.bearing){const m=o.pinchAround===void 0?o.around:o.pinchAround;f.around=m?this._map.unproject(m):this._map.getCenter()}return this.clear(),f.noMoveStart=!0,f}}function uc(a,r){(!a.duration||a.duration<r.duration)&&(a.duration=r.duration,a.easing=r.easing)}function hc(a,r,o){const{maxSpeed:u,linearity:f,deceleration:m}=o,g=d.b0(a*f/(r/1e3),-u,u),x=Math.abs(g)/(m*f);return{easing:o.easing,duration:1e3*x,amount:g*(x/2)}}class mo extends d.h{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,u,f={}){const m=Yi(o.getCanvasContainer(),u);super(r,{point:m,lngLat:o.unproject(m),originalEvent:u,...f}),this._defaultPrevented=!1,this.target=o}}class ps extends d.h{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,u){const f=r==="touchend"?u.changedTouches:u.touches,m=hr(o.getCanvasContainer(),f),g=m.map(w=>o.unproject(w)),x=m.reduce((w,E,I,R)=>w.add(E.div(R.length)),new d.P(0,0));super(r,{points:m,point:x,lngLats:g,lngLat:o.unproject(x),originalEvent:u}),this._defaultPrevented=!1}}class zi extends d.h{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o){super("wheel",{originalEvent:o}),this._defaultPrevented=!1}}class ph{constructor(r,o){this._map=r,this._clickTolerance=o.clickTolerance}reset(){this._mousedownPos=void 0}wheel(r){return this._firePreventable(new zi(this._map,r))}mousedown(r,o){return this._mousedownPos=o,this._firePreventable(new mo(r.type,this._map,r))}mouseup(r){this._map.fire(new mo(r.type,this._map,r))}preclick(r){const o=new MouseEvent("preclick",r);this._map.fire(new mo(o.type,this._map,o))}click(r,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(r),this._map.fire(new mo(r.type,this._map,r)))}dblclick(r){return this._firePreventable(new mo(r.type,this._map,r))}mouseover(r){this._map.fire(new mo(r.type,this._map,r))}mouseout(r){this._map.fire(new mo(r.type,this._map,r))}touchstart(r){return this._firePreventable(new ps(r.type,this._map,r))}touchmove(r){this._map.fire(new ps(r.type,this._map,r))}touchend(r){this._map.fire(new ps(r.type,this._map,r))}touchcancel(r){this._map.fire(new ps(r.type,this._map,r))}_firePreventable(r){if(this._map.fire(r),r.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bd{constructor(r){this._map=r}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(r){this._map.fire(new mo(r.type,this._map,r))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new mo("c
3415ontextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(r){this._delayContextMenu?this._contextMenuEvent=r:this._map.fire(new mo(r.type,this._map,r)),this._map.listens("contextmenu")&&r.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class bp{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._container=r.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(r,o){this.isEnabled()&&r.shiftKey&&r.button===0&&(rr(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(r,o){if(!this._active)return;const u=o,f=this._startPos,m=this._lastPos;if(!f||!m||m.equals(u)||!this._box&&u.dist(f)<this._clickTolerance)return;this._lastPos=u,this._box||(this._box=ai("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",r));const g=Math.min(f.x,u.x),x=Math.max(f.x,u.x),w=Math.min(f.y,u.y),E=Math.max(f.y,u.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${g}px,${w}px)`,this._box.style.width=x-g+"px",this._box.style.height=E-w+"px")})}mouseupWindow(r,o){if(!this._active)return;const u=this._startPos,f=o;if(u&&r.button===0){if(this.reset(),Dt(),u.x!==f.x||u.y!==f.y)return this._map.fire(new d.h("boxzoomend",{originalEvent:r})),{cameraAnimation:m=>m.fitScreenCoordinates(u,f,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",r)}}keydown(r){this._active&&r.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",r))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),kl(),delete this._startPos,delete this._lastPos}_fireEvent(r,o){return this._map.fire(new d.h(r,{originalEvent:o}))}}function mh(a,r){const o={};for(let u=0;u<a.length;u++)o[a[u].identifier]=r[u];return o}class wp{constructor(r){this.reset(),this.numTouches=r.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(r,o,u){(this.centroid||u.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=r.timeStamp),u.length===this.numTouches&&(this.centroid=function(f){const m=new d.P(0,0);for(const g of f)m._add(g);return m.div(f.length)}(o),this.touches=mh(u,o)))}touchmove(r,o,u){if(this.aborted||!this.centroid)return;const f=mh(u,o);for(const m in this.touches){const g=f[m];(!g||g.dist(this.touches[m])>30)&&(this.aborted=!0)}}touchend(r,o,u){if((!this.centroid||r.timeStamp-this.startTime>500)&&(this.aborted=!0),u.length===0){const f=!this.aborted&&this.centroid;if(this.reset(),f)return f}}}class uu{constructor(r){this.singleTap=new wp(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(r,o,u){this.singleTap.touchstart(r,o,u)}touchmove(r,o,u){this.singleTap.touchmove(r,o,u)}touchend(r,o,u){const f=this.singleTap.touchend(r,o,u);if(f){const m=r.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(f)<30;if(m&&g||this.reset(),this.count++,this.lastTime=r.timeStamp,this.lastTap=f,this.count===this.numTaps)return this.reset(),f}}}class Qs{constructor(){this._zoomIn=new uu({numTouches:1,numTaps:2}),this._zoomOut=new uu({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(r,o,u){this._zoomIn.touchstart(r,o,u),this._zoomOut.touchstart(r,o,u)}touchmove(r,o,u){this._zoomIn.touchmove(r,o,u),this._zoomOut.touchmove(r,o,u)}touchend(r,o,u){const f=this._zoomIn.touchend(r,o,u),m=this._zoomOut.touchend(r,o,u);return f?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:g.getZoom()+1,around:g.unproject(f)},{originalEvent:r})}):m?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:g.getZoom()-1,around:g.unproject(m)},{originalEvent:r})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Ia=0,He=2,Ze={[Ia]:1,[He]:2},Aa={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class ki{constructor(r){this.reset(),this._clickTolerance=r.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(r,o){return!1}_move(r,o){return{}}mousedown(r,o){if(this._lastPoint)return;const u=Es(r);this._correctButton(r,u)&&(this._lastPoint=o,this._eventButton=u)}mousemoveWindow(r,o){const u=this._lastPoint;if(u){if(r.preventDefault(),this._eventButton!=null&&function(f,m){const g=Ze[m];return f.buttons===void 0||(f.buttons&g)!==g}(r,this._eventButton))this.reset();else if(this._moved||!(o.dist(u)<this._clickTolerance))return this._moved=!0,this._lastPoint=o,this._move(u,o)}}mouseupWindow(r){this._lastPoint&&Es(r)===this._eventButton&&(this._moved&&Dt(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class de extends ki{mousedown(r,o){super.mousedown(r,o),this._lastPoint&&(this._active=!0)}_correctButton(r,o){return o===0&&!r.ctrlKey}_move(r,o){return{around:o,panDelta:o.sub(r)}}}class kd extends ki{constructor(r){super(r),this._pitchRotateKey=r.pitchRotateKey?Aa[r.pitchRotateKey]:void 0}_correctButton(r,o){return this._pitchRotateKey?o===0&&r[this._pitchRotateKey]:o===0&&r.ctrlKey||o===2}_move(r,o){const u=.8*(o.x-r.x);if(u)return this._active=!0,{bearingDelta:u}}contextmenu(r){this._pitchRotateKey||r.preventDefault()}}class hu extends ki{constructor(r){super(r),this._pitchRotateKey=r.pitchRotateKey?Aa[r.pitchRotateKey]:void 0}_correctButton(r,o){return this._pitchRotateKey?o===0&&r[this._pitchRotateKey]:o===0&&r.ctrlKey||o===2}_move(r,o){const u=-.5*(o.y-r.y);if(u)return this._active=!0,{pitchDelta:u}}contextmenu(r){this._pitchRotateKey||r.preventDefault()}}class Nd{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),d.aV(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new d.P(0,0)}touchstart(r,o,u){return this._calculateTransform(r,o,u)}touchmove(r,o,u){if(this._active&&!(u.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(u.length===1&&!d.ex())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return r.cancelable&&r.preventDefault(),this._calculateTransform(r,o,u)}}touchend(r,o,u){this._calculateTransform(r,o,u),this._active&&u.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(r,o,u){u.length>0&&(this._active=!0);const f=mh(u,o),m=new d.P(0,0),g=new d.P(0,0);let x=0;for(const E in f){const I=f[E],R=this._touches[E];R&&(m._add(I),g._add(I.sub(R)),x++,f[E]=I)}if(this._touches=f,x<this._minTouches||!g.mag())return;
vendor: 77,379 bytes, lines 3415-3420
3415const w=g.div(x);return this._sum._add(w),this._sum.mag()<this._clickTolerance?void 0:{around:m.div(x),panDelta:w}}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=ai("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 du{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(r){}_move(r,o,u){return{}}touchstart(r,o,u){this._firstTwoTouches||u.length<2||(this._firstTwoTouches=[u[0].identifier,u[1].identifier],this._start([o[0],o[1]]))}touchmove(r,o,u){const f=this._firstTwoTouches;if(!f)return;r.preventDefault();const[m,g]=f,x=fu(u,o,m),w=fu(u,o,g);if(!x||!w)return;const E=this._aroundCenter?null:x.add(w).div(2);return this._move([x,w],E,r)}touchend(r,o,u){if(!this._firstTwoTouches)return;const[f,m]=this._firstTwoTouches,g=fu(u,o,f),x=fu(u,o,m);g&&x||(this._active&&Dt(),this.reset())}touchcancel(){this.reset()}enable(r){this._enabled=!0,this._aroundCenter=!!r&&r.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function fu(a,r,o){for(let u=0;u<a.length;u++)if(a[u].identifier===o)return r[u]}function Vd(a,r){return Math.log2(a/r)}class dc extends du{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(r){this._startDistance=this._distance=r[0].dist(r[1])}_move(r,o){const u=this._distance;if(this._distance=r[0].dist(r[1]),this._active||!(Math.abs(Vd(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Vd(this._distance,u),pinchAround:o}}}function Tp(a,r){return 180*a.angleWith(r)/Math.PI}class L_ extends du{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(r){this._startVector=this._vector=r[0].sub(r[1]),this._minDiameter=r[0].dist(r[1])}_move(r,o){const u=this._vector;if(this._vector=r[0].sub(r[1]),u&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Tp(this._vector,u),pinchAround:o}}_isBelowThreshold(r){this._minDiameter=Math.min(this._minDiameter,r.mag());const o=25/(Math.PI*this._minDiameter)*360,u=this._startVector;if(!u)return!1;const f=Tp(r,u);return Math.abs(f)<o}}function _h(a){return Math.abs(a.y)>Math.abs(a.x)}class gh extends du{constructor(r){super(),this._map=r}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(r){this._lastPoints=r,_h(r[0].sub(r[1]))&&(this._valid=!1)}_move(r,o,u){const f=this._lastPoints;if(!f)return;const m=r[0].sub(f[0]),g=r[1].sub(f[1]);return this._map._cooperativeGestures&&!d.ex()&&u.touches.length<3||(this._valid=this.gestureBeginsVertically(m,g,u.timeStamp),!this._valid)?void 0:(this._lastPoints=r,this._active=!0,{pitchDelta:(m.y+g.y)/2*-.5})}gestureBeginsVertically(r,o,u){if(this._valid!==void 0)return this._valid;const f=r.mag()>=2,m=o.mag()>=2;if(!f&&!m)return;if(!f||!m)return this._firstMove??(this._firstMove=u),u-this._firstMove<100&&void 0;const g=r.y>0==o.y>0;return _h(r)&&_h(o)&&g}}const Ud={panStep:100,bearingStep:15,pitchStep:10};class Ep{constructor(){const r=Ud;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._bearingDisabled=!1,this._pitchDisabled=!1,this._panDisabled=!1,this._zoomDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(r){if(r.altKey||r.ctrlKey||r.metaKey||!this.isEnabled())return;let o=0,u=0,f=0,m=0,g=0;switch(r.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:r.shiftKey?u=-1:(r.preventDefault(),m=-1);break;case 39:r.shiftKey?u=1:(r.preventDefault(),m=1);break;case 38:r.shiftKey?f=1:(r.preventDefault(),g=-1);break;case 40:r.shiftKey?f=-1:(r.preventDefault(),g=1);break;default:return}return this._bearingDisabled&&(u=0),this._pitchDisabled&&(f=0),this._panDisabled&&(m=0,g=0),this._zoomDisabled&&(o=0),{cameraAnimation:x=>{const w=x.getZoom();x.easeTo({duration:300,easeId:"keyboardHandler",easing:Sp,zoom:o?Math.round(w)+o*(r.shiftKey?2:1):w,bearing:x.getBearing()+u*this._bearingStep,pitch:x.getPitch()+f*this._pitchStep,offset:[-m*this._panStep,-g*this._panStep],center:x.getCenter()},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled&&!(this._bearingDisabled&&this._pitchDisabled&&this._panDisabled&&this._zoomDisabled)}isActive(){return this._active}disableRotation(){this._pitchDisabled=!0,this._bearingDisabled=!0}enableRotation(){this._pitchDisabled=!1,this._bearingDisabled=!1}isRotationEnabled(){return!this._pitchDisabled&&!this._bearingDisabled}disablePan(){this._panDisabled=!0}enablePan(){this._panDisabled=!1}isPanEnabled(){return!this._panDisabled}disableZoom(){this._zoomDisabled=!0}enableZoom(){this._zoomDisabled=!1}isZoomEnabled(){return!this._zoomDisabled}disablePitch(){this._pitchDisabled=!0}enablePitch(){this._pitchDisabled=!1}isPitchEnabled(){return!this._pitchDisabled}disableBearing(){this._bearingDisabled=!0}enableBearing(){this._bearingDisabled=!1}isBearingEnabled(){return!this._bearingDisabled}}function Sp(a){return a*(2-a)}const pu=4.000244140625,mu=1/450,yh=/(Mac|iPad)/i;class Ip{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._handler=o,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=mu,d.aV(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(r){this._defaultZoomRate=r}setWheelZoomRate(r){this._wheelZoomRate=r}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(r){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!r&&r.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(r){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(r.ctrlKey||r.metaKey||this.isZooming()||d.ex()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=r.deltaMode===WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const u=d.e.now(),f=u-(this._lastWheelEventTime||0);this._lastWheelEventTime=u,o!==0&&o%pu===0?this._type="wheel":o!==0&&Math.abs(o)<4?this._type="trackpad":f>400?(this._type=null,this._lastValue=o,this._timeout=window.setTimeout(this._onTimeout,40,r)):this._type||(this._type=Math.abs(f*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),r.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=r,this._delta-=o,this._active||this._start(r)),r.preventDefault()}_onTimeout(r){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)}_start(r){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const o=Yi(this._el,r);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._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const r=this._map.transform;this._type==="wheel"&&r.projection.wrap&&(r._center.lng>=180||r._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const o=()=>r._terrainEnabled()&&this._aroundCoord?r.computeZoomRelativeTo(this._aroundCoord):r.zoom;if(this._delta!==0){const E=this._type==="wheel"&&Math.abs(this._delta)>pu?this._wheelZoomRate:this._defaultZoomRate;let I=2/(1+Math.exp(-Math.abs(this._delta*E)));this._delta<0&&I!==0&&(I=1/I);const R=o(),P=Math.pow(2,R),B=typeof this._targetZoom=="number"?r.zoomScale(this._targetZoom):P;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(B*I))),this._type==="wheel"&&(this._startZoom=R,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const u=typeof this._targetZoom=="number"?this._targetZoom:o(),f=this._startZoom,m=this._easing;let g,x=!1;if(this._type==="wheel"&&f&&m){const E=Math.min((d.e.now()-this._lastWheelEventTime)/200,1),I=m(E);g=d.al(f,u,I),E<1?this._frameId||(this._frameId=!0):x=!0}else g=u,x=!0;this._active=!0,x&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let w=g-o();return w*this._lastDelta<0&&(w=0),{noInertia:!0,needsRenderFrame:!x,zoomDelta:w,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let o=d.ey;if(this._prevEase){const u=this._prevEase,f=(d.e.now()-u.start)/u.duration,m=u.easing(f+.01)-u.easing(f),g=.27/Math.sqrt(m*m+1e-4)*.01,x=Math.sqrt(.0729-g*g);o=d.ew(g,x,.25,1)}return this._prevEase={start:d.e.now(),duration:r,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=ai("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=yh.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 Ap{constructor(r,o){this._clickZoom=r,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 Cp{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(r,o){return r.preventDefault(),{cameraAnimation:u=>{u.easeTo({duration:300,zoom:u.getZoom()+(r.shiftKey?-1:1),around:u.unproject(o)},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Mp{constructor(){this._tap=new uu({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(r,o,u){this._swipePoint||(this._tapTime&&r.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?u.length>0&&(this._swipePoint=o[0],this._swipeTouch=u[0].identifier):this._tap.touchstart(r,o,u))}touchmove(r,o,u){if(this._tapTime){if(this._swipePoint){if(u[0].identifier!==this._swipeTouch)return;const f=o[0],m=f.y-this._swipePoint.y;return this._swipePoint=f,r.preventDefault(),this._active=!0,{zoomDelta:m/128}}}else this._tap.touchmove(r,o,u)}touchend(r,o,u){this._tapTime?this._swipePoint&&u.length===0&&this.reset():this._tap.touchend(r,o,u)&&(this._tapTime=r.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Rp{constructor(r,o,u){this._el=r,this._mousePan=o,this._touchPan=u}enable(r){this._inertiaOptions=r||{},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 z_{constructor(r,o,u){this._pitchWithRotate=r.pitchWithRotate,this._mouseRotate=o,this._mousePitch=u,this._pitchDisabled=!1,this._rotationDisabled=!1}enable(){this._rotationDisabled||this._mouseRotate.enable(),this._pitchWithRotate&&!this._pitchDisabled&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._pitchWithRotate?!this._rotationDisabled&&this._mouseRotate.isEnabled()||!this._pitchDisabled&&this._mousePitch.isEnabled():!this._rotationDisabled&&this._mouseRotate.isEnabled()}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}disablePitch(){this._pitchDisabled=!0,this._mousePitch.disable()}enablePitch(){this._pitchDisabled=!1,this._pitchWithRotate&&this._mouseRotate.isEnabled()&&this._mousePitch.enable()}isPitchEnabled(){return!this._pitchDisabled&&this._mousePitch.isEnabled()}disableRotation(){this._rotationDisabled=!0,this._mouseRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._mouseRotate.enable()}isRotationEnabled(){return!this._rotationDisabled&&this._mouseRotate.isEnabled()}}class Pp{constructor(r,o,u,f){this._el=r,this._touchZoom=o,this._touchRotate=u,this._tapDragZoom=f,this._rotationDisabled=!1,this._tapDragZoomDisabled=!1,this._enabled=!0}enable(r){this._touchZoom.enable(r),this._rotationDisabled||this._touchRotate.enable(r),this._tapDragZoomDisabled||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._tapDragZoomDisabled&&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()}isRotationEnabled(){return!this._rotationDisabled}disableTapDragZoom(){this._tapDragZoomDisabled=!0,this._tapDragZoom.disable()}enableTapDragZoom(){this._tapDragZoomDisabled=!1,this._touchZoom.isEnabled()&&this._tapDragZoom.enable()}isTapDragZoomEnabled(){return!this._tapDragZoomDisabled}}const xh=a=>a.zoom||a.drag||a.pitch||a.rotate;class Fn extends d.h{}class vh{constructor(){this.constants=[1,1,.01],this.radius=0}setup(r,o){const u=d.c2([],o,r);this.radius=d.em(u[2]<0?d.eA([],u,this.constants):[u[0],u[1],0])}projectRay(r){d.eA(r,r,this.constants),d.c3(r,r),d.eB(r,r,this.constants);const o=d.dC([],r,this.radius);if(o[2]>0){const u=d.dC([],[0,0,1],d.dF(o,[0,0,1])),f=d.dC([],d.c3([],[o[0],o[1],0]),this.radius),m=d.dD([],o,d.dC([],d.c2([],d.dD([],f,u),o),2));o[0]=m[0],o[1]=m[1]}return o}}function ea(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}class Dp{constructor(r,o){this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Od(r),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new vh,this._dragOrigin=null,this._mouseBeingPressed=!1,this._activeTouchCount=0,this._eventsInProgress={},this._addDefaultHandlers(o),d.aV(["handleEvent","handleWindowEvent"],this);const u=this._el;this._listeners=[[u,"touchstart",{passive:!0}],[u,"touchmove",{passive:!1}],[u,"touchend",void 0],[u,"touchcancel",void 0],[u,"mousedown",void 0],[u,"mousemove",void 0],[u,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[u,"mouseover",void 0],[u,"mouseout",void 0],[u,"dblclick",void 0],[u,"click",void 0],[u,"keydown",{capture:!1}],[u,"keyup",void 0],[u,"wheel",{passive:!1}],[u,"contextmenu",void 0],[window,"blur",void 0]];for(const[f,m,g]of this._listeners){const x=f===document?this.handleWindowEvent:this.handleEvent;f.addEventListener(m,x,g)}}destroy(){for(const[r,o,u]of this._listeners){const f=r===document?this.handleWindowEvent:this.handleEvent;r.removeEventListener(o,f,u)}}_addDefaultHandlers(r){const o=this._map,u=o.getCanvasContainer();this._add("mapEvent",new ph(o,r));const f=o.boxZoom=new bp(o,r);this._add("boxZoom",f);const m=new Qs,g=new Cp;o.doubleClickZoom=new Ap(g,m),this._add("tapZoom",m),this._add("clickZoom",g);const x=new Mp;this._add("tapDragZoom",x);const w=o.touchPitch=new gh(o);this._add("touchPitch",w);const E=new kd(r),I=new hu(r);o.dragRotate=new z_(r,E,I),this._add("mouseRotate",E,["mousePitch"]),this._add("mousePitch",I,["mouseRotate"]);const R=new de(r),P=new Nd(o,r);o.dragPan=new Rp(u,R,P),this._add("mousePan",R),this._add("touchPan",P,["touchZoom","touchRotate"]);const B=new L_,V=new dc;o.touchZoomRotate=new Pp(u,V,B,x),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",V,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Bd(o));const U=o.scrollZoom=new Ip(o,this);this._add("scrollZoom",U,["mousePan"]);const G=o.keyboard=new Ep;this._add("keyboard",G);for(const $ of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])r.interactive&&r[$]&&o[$].enable(r[$])}_add(r,o,u){this._handlers.push({handlerName:r,handler:o,allowed:u}),this._handlersById[r]=o}stop(r="never"){if(!this._updatingCamera&&!(r==="always"||r==="ifPointerDown"&&this._isPointerDown())){for(const{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},!1),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:r}of this._handlers)if(r.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!xh(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(r,o,u){for(const f in r)if(!(f===u||o&&o.includes(f)))return!0;return!1}handleWindowEvent(r){this.handleEvent(r,`${r.type}Window`)}_getMapTouches(r){const o=[];for(const u of r)this._el.contains(u.target)&&o.push(u);return o}_updatePointerLiveness(r){switch(r.type){case"mousedown":this._mouseBeingPressed=!0;break;case"mousemove":r.buttons===0&&(this._mouseBeingPressed=!1);break;case"mouseup":this._mouseBeingPressed=!1;break;case"touchstart":case"touchmove":case"touchend":case"touchcancel":this._activeTouchCount=r.touches?r.touches.length:0;break;case"blur":this._mouseBeingPressed=!1,this._activeTouchCount=0}}_isPointerDown(){return this._mouseBeingPressed||this._activeTouchCount>0}handleEvent(r,o){this._updatePointerLiveness(r),this._updatingCamera=!0;const u=r.type==="renderFrame",f=u?void 0:r,m={needsRenderFrame:!1},g={},x={},w=r.touches?this._getMapTouches(r.touches):void 0,E=w?hr(this._el,w):u?void 0:Yi(this._el,r);for(const{handlerName:P,handler:B,allowed:V}of this._handlers){if(!B.isEnabled())continue;let U;this._blockedByActive(x,V,P)?B.reset():B[o||r.type]&&(U=B[o||r.type](r,E,w),this.mergeHandlerResult(m,g,U,P,f),U&&U.needsRenderFrame&&this._triggerRenderFrame()),(U||B.isActive())&&(x[P]=B)}const I={};for(const P in this._previousActiveHandlers)x[P]||(I[P]=f);this._previousActiveHandlers=x,(Object.keys(I).length||ea(m))&&(this._changes.push([m,g,I]),this._triggerRenderFrame()),(Object.keys(x).length||ea(m))&&this._map._stop({keepGesture:"always"}),this._updatingCamera=!1;const{cameraAnimation:R}=m;R&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],R(this._map))}mergeHandlerResult(r,o,u,f,m){if(!u)return;Object.assign(r,u);const g={handlerName:f,originalEvent:u.originalEvent||m};u.zoomDelta!==void 0&&(o.zoom=g),u.panDelta!==void 0&&(o.drag=g),u.pitchDelta!==void 0&&(o.pitch=g),u.bearingDelta!==void 0&&(o.rotate=g)}_applyChanges(){const r={},o={},u={};for(const[f,m,g]of this._changes)f.panDelta&&(r.panDelta=(r.panDelta||new d.P(0,0))._add(f.panDelta)),f.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+f.pitchDelta),f.around!==void 0&&(r.around=f.around),f.aroundCoord!==void 0&&(r.aroundCoord=f.aroundCoord),f.pinchAround!==void 0&&(r.pinchAround=f.pinchAround),f.noInertia&&(r.noInertia=f.noInertia),Object.assign(o,m),Object.assign(u,g);this._updateMapTransform(r,o,u),this._changes=[]}_updateMapTransform(r,o,u){const f=this._map,m=f.transform,g=Y=>[Y.x,Y.y,Y.z];if((()=>{const Y=this._eventsInProgress.drag;return Y&&!this._handlersById[Y.handlerName].isActive()})()&&!ea(r)){const Y=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"),Y!==m.zoom&&this._map._update(!0)}if(m._isCameraConstrained&&f._stop({keepGesture:"always"}),!ea(r))return void this._fireEvents(o,u,!0);let{panDelta:x,zoomDelta:w,bearingDelta:E,pitchDelta:I,around:R,aroundCoord:P,pinchAround:B}=r;m._isCameraConstrained&&(w>0&&(w=0),m._isCameraConstrained=!1),B!==void 0&&(R=B),(w||(Y=>o[Y]&&!this._eventsInProgress[Y])("drag"))&&R&&(this._dragOrigin=g(m.pointCoordinate3D(R)),this._originalZoom=m.zoom,this._trackingEllipsoid.setup(m._camera.position,this._dragOrigin)),m.cameraElevationReference="sea",f._stop({keepGesture:"always"}),R=R||f.transform.centerPoint,E&&(m.bearing+=E),I&&(m.pitch+=I),m._updateCameraState();const V=[0,0,0];if(x)if(m.projection.name==="mercator"){const Y=this._trackingEllipsoid.projectRay(m.screenPointToMercatorRay(R).dir),re=this._trackingEllipsoid.projectRay(m.screenPointToMercatorRay(R.sub(x)).dir);V[0]=re[0]-Y[0],V[1]=re[1]-Y[1]}else{const Y=m.pointCoordinate(R);if(m.projection.name==="globe"){x=x.rotate(-m.angle);const re=m._pixelsPerMercatorPixel/m.worldSize;V[0]=-x.x*d.ez(d.br(Y.y))*re,V[1]=-x.y*d.ez(m.center.lat)*re}else{const re=m.pointCoordinate(R.sub(x));Y&&re&&(V[0]=re.x-Y.x,V[1]=re.y-Y.y)}}const U=m.zoom,G=[0,0,0];if(w){const Y=g(P||m.pointCoordinate3D(R)),re={dir:d.c3([],d.c2([],Y,m._camera.position))};if(re.dir[2]<0){const oe=m.zoomDeltaToMovement(Y,w);d.dC(G,re.dir,oe)}}const $=d.dD(V,V,G);m._translateCameraConstrained($),w&&Math.abs(m.zoom-U)>1e-4&&m.recenterOnTerrain(),m.cameraElevationReference="ground",this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(o,u,!0)}_fireEvents(r,o,u){const f=xh(this._eventsInProgress),m=xh(r),g={};for(const I in r){const{originalEvent:R}=r[I];this._eventsInProgress[I]||(g[`${I}start`]=R),this._eventsInProgress[I]=r[I]}!f&&m&&this._fireEvent("movestart",m.originalEvent);for(const I in g)this._fireEvent(I,g[I]);m&&this._fireEvent("move",m.originalEvent);for(const I in r){const{originalEvent:R}=r[I];this._fireEvent(I,R)}const x={};let w;for(const I in this._eventsInProgress){const{handlerName:R,originalEvent:P}=this._eventsInProgress[I];this._handlersById[R].isActive()||(delete this._eventsInProgress[I],w=o[R]||P,x[`${I}end`]=w)}for(const I in x)this._fireEvent(I,x[I]);const E=xh(this._eventsInProgress);if(u&&(f||m)&&!E){this._updatingCamera=!0;const I=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),R=P=>P!==0&&-this._bearingSnap<P&&P<this._bearingSnap;I?(R(I.bearing||this._map.getBearing())&&(I.bearing=0),this._map.easeTo(I,{originalEvent:w})):(this._map.fire(new d.h("moveend",{originalEvent:w})),R(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(r,o){this._map.fire(new d.h(r,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(r=>{this._frameId=void 0,this.handleEvent(new Fn("renderFrame",{timeStamp:r})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Ca="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class _u extends d.E{constructor(r,o){super(),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=o.bearingSnap,this._respectPrefersReducedMotion=o.respectPrefersReducedMotion!==!1,d.aV(["_renderFrameCallback"],this)}getCenter(){return new d.cz(this.transform.center.lng,this.transform.center.lat)}setCenter(r,o){return this.jumpTo({center:r},o)}panBy(r,o,u){return r=d.P.convert(r).mult(-1),this.panTo(this.transform.center,{offset:r,...o},u)}panTo(r,o,u){return this.easeTo({center:r,...o},u)}getZoom(){return this.transform.zoom}setZoom(r,o){return this.jumpTo({zoom:r},o),this}zoomTo(r,o,u){return this.easeTo({zoom:r,...o},u)}zoomIn(r,o){return this.zoomTo(this.getZoom()+1,r,o),this}zoomOut(r,o){return this.zoomTo(this.getZoom()-1,r,o),this}getBearing(){return this.transform.bearing}setBearing(r,o){return this.jumpTo({bearing:r},o),this}getPadding(){return this.transform.padding}setPadding(r,o){return this.jumpTo({padding:r},o),this}rotateTo(r,o,u){return this.easeTo({bearing:r,...o},u)}resetNorth(r,o){return this.rotateTo(0,{duration:1e3,...r},o),this}resetNorthPitch(r,o){return this.easeTo({bearing:0,pitch:0,duration:1e3,...r},o),this}snapToNorth(r,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(r,o):this}getPitch(){return this.transform.pitch}setPitch(r,o){return this.jumpTo({pitch:r},o),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(r,o){return this.jumpTo({fov:r},o)}getHorizontalFieldOfView(){return this.transform.horizontalFov}cameraForBounds(r,o){r=d.eC.convert(r);const u=o&&o.bearing||0,f=o&&o.pitch||0,m=r.getNorthWest(),g=r.getSouthEast();return this._cameraForBounds(this.transform,m,g,u,f,o)}_extendPadding(r){const o={top:0,right:0,bottom:0,left:0};return r==null?{...o,...this.transform.padding}:typeof r=="number"?{top:r,bottom:r,right:r,left:r}:{...o,...r}}_extendCameraOptions(r){return(r={offset:[0,0],maxZoom:this.transform.maxZoom,...r}).padding=this._extendPadding(r.padding),r}_minimumAABBFrustumDistance(r,o){const u=o.max[0]-o.min[0],f=o.max[1]-o.min[1];return u/f>r.aspect?u/(2*Math.tan(.5*r.fovX)*r.aspect):f/(2*Math.tan(.5*r.fovY)*r.aspect)}_cameraForBoundsOnGlobe(r,o,u,f,m,g){const x=r.clone(),w=this._extendCameraOptions(g);x.bearing=f,x.pitch=m;const E=d.cz.convert(o),I=d.cz.convert(u),R=.5*(E.lat+I.lat),P=.5*(E.lng+I.lng),B=d.eD(R,P),V=d.c3([],B),U=d.c3([],d.eE([],V,[0,1,0])),G=d.eE([],U,V),$=[U[0],U[1],U[2],0,G[0],G[1],G[2],0,V[0],V[1],V[2],0,0,0,0,1],Y=[B,d.eD(E.lat,E.lng),d.eD(I.lat,E.lng),d.eD(I.lat,I.lng),d.eD(E.lat,I.lng),d.eD(R,E.lng),d.eD(R,I.lng),d.eD(E.lat,P),d.eD(I.lat,P)];let re=d.eF.fromPoints(Y.map(tt=>[d.dF(U,tt),d.dF(G,tt),d.dF(V,tt)]));const oe=d.bH([],re.center,$);d.eG(oe)===0&&d.eH(oe,0,0,1),d.c3(oe,oe),d.dC(oe,oe,d.c8),x.center=d.eI(oe);const pe=x.getWorldToCameraMatrix(),ce=d.aO(new Float64Array(16),pe);re=d.eF.applyTransform(re,d.X([],pe,$));const _e=this._extendAABB(re,x,w,f);if(!_e)return void d.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");re=_e,d.bH(oe,oe,pe);const ue=.5*(re.max[2]-re.min[2]),me=this._minimumAABBFrustumDistance(x,re),Ie=d.dC([],[0,0,1],ue),we=d.dD(Ie,oe,Ie),ve=me+(x.pitch===0?0:d.eJ(oe,we)),Se=x.globeCenterInViewSpace,Re=d.c2([],oe,[Se[0],Se[1],Se[2]]);d.c3(Re,Re),d.dC(Re,Re,ve);const Ue=d.dD([],oe,Re);d.bH(Ue,Ue,ce);const Pe=d.bj/d.c8,Oe=d.em(Ue),Xe=d.dw(Math.max(Oe*Pe-d.bj,Number.EPSILON),0),ot=Math.min(x.zoomFromMercatorZAdjusted(Xe),w.maxZoom);return ot>.5*(d.e9+d.b1)?(x.setProjection({name:"mercator"}),x.zoom=ot,this._cameraForBounds(x,o,u,f,m,g)):{center:x.center,zoom:ot,bearing:f,pitch:m}}_extendAABB(r,o,u,f){const m=.5*((u.padding.left||0)+(u.padding.right||0)),g=.5*((u.padding.top||0)+(u.padding.bottom||0)),x=g,w=m,E=m,I=g,R=o.width-(w+E),P=o.height-(x+I),B=d.c2([],r.max,r.min),V=Math.min(R/B[0],P/B[1]),U=Math.min(o.scaleZoom(o.scale*V),u.maxZoom);if(isNaN(U))return null;const G=o.scale/o.zoomScale(U),$=new d.eF([r.min[0]-w*G,r.min[1]-I*G,r.min[2]],[r.max[0]+E*G,r.max[1]+x*G,r.max[2]]),Y=(typeof u.offset.x=="number"&&typeof u.offset.y=="number"?new d.P(u.offset.x,u.offset.y):d.P.convert(u.offset)).rotate(-d.au(f));return $.center[0]-=Y.x*G,$.center[1]+=Y.y*G,$}queryTerrainElevation(r,o){const u=this.transform.elevation;return u?(o={exaggerated:!0,...o},u.getAtPoint(d.bS.fromLngLat(r),null,o.exaggerated)):null}_cameraForBounds(r,o,u,f,m,g){if(r.projection.name==="globe")return this._cameraForBoundsOnGlobe(r,o,u,f,m,g);const x=r.clone(),w=this._extendCameraOptions(g);x.bearing=f,x.pitch=m;const E=d.cz.convert(o),I=d.cz.convert(u),R=new d.cz(E.lng,I.lat),P=new d.cz(I.lng,E.lat),B=x.project(E),V=x.project(I),U=this.queryTerrainElevation(E),G=this.queryTerrainElevation(I),$=this.queryTerrainElevation(R),Y=this.queryTerrainElevation(P),re=[[B.x,B.y,Math.min(U||0,G||0,$||0,Y||0)],[V.x,V.y,Math.max(U||0,G||0,$||0,Y||0)]];let oe=d.eF.fromPoints(re);const pe=x.getWorldToCameraMatrix(),ce=d.aO(new Float64Array(16),pe);oe=d.eF.applyTransform(oe,pe);const _e=this._extendAABB(oe,x,w,f);if(!_e)return void d.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");oe=_e;const ue=.5*d.c2([],oe.max,oe.min)[2],me=this._minimumAABBFrustumDistance(x,oe),Ie=[0,0,1,0];d.c7(Ie,Ie,pe),d.eK(Ie,Ie);const we=d.dC([],Ie,me+ue),ve=d.dD([],oe.center,we);d.bH(oe.center,oe.center,ce),d.bH(ve,ve,ce);const Se=x.unproject(new d.P(oe.center[0],oe.center[1])),Re=d.eL(x.projection,Se),Ue=Math.pow(2,Re),Pe=Math.min(x._zoomFromMercatorZ(ve[2]*x.pixelsPerMeter*Ue/x.worldSize),w.maxZoom);return x.mercatorFromTransition&&Pe<.5*(d.e9+d.b1)?(x.setProjection({name:"globe"}),x.zoom=Pe,this._cameraForBounds(x,o,u,f,m,g)):{center:Se,zoom:Pe,bearing:f,pitch:m}}fitBounds(r,o,u){const f=this.cameraForBounds(r,o);return this._fitInternal(f,o,u)}fitScreenCoordinates(r,o,u,f,m){const g=d.P.convert(r),x=d.P.convert(o),w=new d.P(Math.min(g.x,x.x),Math.min(g.y,x.y)),E=new d.P(Math.max(g.x,x.x),Math.max(g.y,x.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(g,x))return this;const I=this.transform.pointLocation3D(w),R=this.transform.pointLocation3D(E),P=this.transform.pointLocation3D(new d.P(w.x,E.y)),B=this.transform.pointLocation3D(new d.P(E.x,w.y)),V=[Math.min(I.lng,R.lng,P.lng,B.lng),Math.min(I.lat,R.lat,P.lat,B.lat)],U=[Math.max(I.lng,R.lng,P.lng,B.lng),Math.max(I.lat,R.lat,P.lat,B.lat)],G=f&&f.pitch?f.pitch:this.getPitch(),$=this._cameraForBounds(this.transform,V,U,u,G,f);return this._fitInternal($,f,m)}_fitInternal(r,o,u){return r?(o=Object.assign(r,o)).linear?this.easeTo(o,u):this.flyTo(o,u):this}jumpTo(r,o){this._stop({keepGesture:"ifPointerDown"});const u=r.preloadOnly?this.transform.clone():this.transform;let f=!1,m=!1,g=!1;"zoom"in r&&u.zoom!==+r.zoom&&(f=!0,u.zoom=+r.zoom),r.center!==void 0&&(u.center=d.cz.convert(r.center)),"bearing"in r&&u.bearing!==+r.bearing&&(m=!0,u.bearing=+r.bearing),"pitch"in r&&u.pitch!==+r.pitch&&(g=!0,u.pitch=+r.pitch),"fov"in r&&(u.fov=+r.fov);const x=typeof r.padding=="number"?this._extendPadding(r.padding):r.padding;if(r.padding!=null&&!u.isPaddingEqual(x))if(r.retainPadding===!1){const w=u.clone();w.padding=x,u.setLocationAtPoint(u.center,w.centerPoint)}else u.padding=x;return r.preloadOnly?(this._preloadTiles(u),this):(this.fire(new d.h("movestart",o)).fire(new d.h("move",o)),f&&this.fire(new d.h("zoomstart",o)).fire(new d.h("zoom",o)).fire(new d.h("zoomend",o)),m&&this.fire(new d.h("rotatestart",o)).fire(new d.h("rotate",o)).fire(new d.h("rotateend",o)),g&&this.fire(new d.h("pitchstart",o)).fire(new d.h("pitch",o)).fire(new d.h("pitchend",o)),this.fire(new d.h("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||d.w(Ca),this.transform.getFreeCameraOptions()}setFreeCameraOptions(r,o){const u=this.transform;if(!u.projection.supportsFreeCamera)return d.w(Ca),this;this.stop();const f=u.zoom,m=u.pitch,g=u.bearing;u.setFreeCameraOptions(r);const x=f!==u.zoom,w=m!==u.pitch,E=g!==u.bearing;return this.fire(new d.h("movestart",o)).fire(new d.h("move",o)),x&&this.fire(new d.h("zoomstart",o)).fire(new d.h("zoom",o)).fire(new d.h("zoomend",o)),E&&this.fire(new d.h("rotatestart",o)).fire(new d.h("rotate",o)).fire(new d.h("rotateend",o)),w&&this.fire(new d.h("pitchstart",o)).fire(new d.h("pitch",o)).fire(new d.h("pitchend",o)),this.fire(new d.h("moveend",o)),this}easeTo(r,o){this._stop({easeId:r.easeId}),((r={offset:[0,0],duration:500,easing:d.ey,...r}).animate===!1||this._prefersReducedMotion(r))&&(r.duration=0);const u=this.transform,f=this.getZoom(),m=this.getBearing(),g=this.getPitch(),x=this.getPadding(),w=this.getVerticalFieldOfView(),E="zoom"in r?+r.zoom:f,I="bearing"in r?this._normalizeBearing(r.bearing,m):m,R="pitch"in r?+r.pitch:g,P="fov"in r?+r.fov:w,B=this._extendPadding(r.padding),V=d.P.convert(r.offset);let U,G,$;if(u.projection.name==="globe"){const Se=d.bS.fromLngLat(u.center),Re=V.rotate(-u.angle);Se.x+=Re.x/u.worldSize,Se.y+=Re.y/u.worldSize;const Ue=Se.toLngLat(),Pe=d.cz.convert(r.center||Ue);this._normalizeCenter(Pe),U=u.centerPoint.add(Re),G=new d.P(Se.x,Se.y).mult(u.worldSize),$=new d.P(d.a7(Pe.lng),d.a8(Pe.lat)).mult(u.worldSize).sub(G)}else{U=u.centerPoint.add(V);const Se=u.pointLocation(U),Re=d.cz.convert(r.center||Se);this._normalizeCenter(Re),G=u.project(Se),$=u.project(Re).sub(G)}const Y=u.zoomScale(E-f);let re,oe;r.around&&(re=d.cz.convert(r.around),oe=u.locationPoint(re));const pe=this._zooming||E!==f,ce=this._rotating||m!==I,_e=this._pitching||R!==g,ue=P!==w,me=!u.isPaddingEqual(B),Ie=r.retainPadding===!1?u.clone():u,we=Se=>Re=>{if(pe&&(Se.zoom=d.al(f,E,Re)),ce&&(Se.bearing=d.al(m,I,Re)),_e&&(Se.pitch=d.al(g,R,Re)),ue&&(Se.fov=d.al(w,P,Re)),me&&(Ie.interpolatePadding(x,B,Re),U=Ie.centerPoint.add(V)),re)Se.setLocationAtPoint(re,oe);else{const Ue=Se.zoomScale(Se.zoom-f),Pe=E>f?Math.min(2,Y):Math.max(.5,Y),Oe=Math.pow(Pe,1-Re),Xe=Se.unproject(G.add($.mult(Re*Oe)).mult(Ue));Se.setLocationAtPoint(Se.renderWorldCopies?Xe.wrap():Xe,U)}return r.preloadOnly||this._fireMoveEvents(o),Se};if(r.preloadOnly){const Se=this._emulate(we,r.duration,u);return this._preloadTiles(Se),this}const ve={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=pe,this._rotating=ce,this._pitching=_e,this._padding=me,this._easeId=r.easeId,this._prepareEase(o,r.noMoveStart,ve),this._ease(we(u),Se=>{u.cameraElevationReference==="sea"&&u.recenterOnTerrain(),this._afterEase(o,Se)},r),this}_prepareEase(r,o,u={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),o||u.moving||this.fire(new d.h("movestart",r)),this._zooming&&!u.zooming&&this.fire(new d.h("zoomstart",r)),this._rotating&&!u.rotating&&this.fire(new d.h("rotatestart",r)),this._pitching&&!u.pitching&&this.fire(new d.h("pitchstart",r))}_fireMoveEvents(r){this.fire(new d.h("move",r)),this._zooming&&this.fire(new d.h("zoom",r)),this._rotating&&this.fire(new d.h("rotate",r)),this._pitching&&this.fire(new d.h("pitch",r))}_afterEase(r,o){if(this._easeId&&o&&this._easeId===o)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const u=this._zooming,f=this._rotating,m=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,u&&this.fire(new d.h("zoomend",r)),f&&this.fire(new d.h("rotateend",r)),m&&this.fire(new d.h("pitchend",r)),this.fire(new d.h("moveend",r))}flyTo(r,o){if(this._prefersReducedMotion(r)){const We=d.cb(r,["center","zoom","bearing","pitch","fov","around","padding","retainPadding"]);return this.jumpTo(We,o)}this.stop(),r={offset:[0,0],speed:1.2,curve:1.42,easing:d.ey,...r};const u=this.transform,f=this.getZoom(),m=this.getBearing(),g=this.getPitch(),x=this.getPadding(),w=this.getVerticalFieldOfView(),E="zoom"in r?d.b0(+r.zoom,u.minZoom,u.maxZoom):f,I="bearing"in r?this._normalizeBearing(r.bearing,m):m,R="pitch"in r?+r.pitch:g,P="fov"in r?+r.fov:w,B=P!==w,V=this._extendPadding(r.padding),U=u.zoomScale(E-f),G=d.P.convert(r.offset);let $=u.centerPoint.add(G);const Y=u.pointLocation($),re=d.cz.convert(r.center||Y);this._normalizeCenter(re);const oe=u.project(Y),pe=u.project(re).sub(oe);let ce=r.curve;const _e=Math.max(u.width,u.height),ue=_e/U,me=pe.mag();if("minZoom"in r){const We=d.b0(Math.min(r.minZoom,f,E),u.minZoom,u.maxZoom),je=_e/u.zoomScale(We-f);ce=Math.sqrt(je/me*2)}const Ie=ce*ce;function we(We){const je=(ue*ue-_e*_e+(We?-1:1)*Ie*Ie*me*me)/(2*(We?ue:_e)*Ie*me);return Math.log(Math.sqrt(je*je+1)-je)}function ve(We){return(Math.exp(We)-Math.exp(-We))/2}function Se(We){return(Math.exp(We)+Math.exp(-We))/2}const Re=we(0);let Ue=function(We){return Se(Re)/Se(Re+ce*We)},Pe=function(We){return _e*((Se(Re)*(ve(je=Re+ce*We)/Se(je))-ve(Re))/Ie)/me;var je},Oe=(we(1)-Re)/ce;if(Math.abs(me)<1e-6||!isFinite(Oe)){if(Math.abs(_e-ue)<1e-6)return this.easeTo(r,o);const We=ue<_e?-1:1;Oe=Math.abs(Math.log(ue/_e))/ce,Pe=function(){return 0},Ue=function(je){return Math.exp(We*ce*je)}}r.duration="duration"in r?+r.duration:1e3*Oe/("screenSpeed"in r?+r.screenSpeed/ce:+r.speed),r.maxDuration&&r.duration>r.maxDuration&&(r.duration=0);const Xe=m!==I,ot=R!==g,tt=!u.isPaddingEqual(V),Ye=r.retainPadding===!1?u.clone():u,mt=We=>je=>{const Je=je*Oe,ft=1/Ue(Je);We.zoom=je===1?E:f+We.scaleZoom(ft),Xe&&(We.bearing=d.al(m,I,je)),ot&&(We.pitch=d.al(g,R,je)),B&&(We.fov=d.al(w,P,je)),tt&&(Ye.interpolatePadding(x,V,je),$=Ye.centerPoint.add(G));const rt=je===1?re:We.unproject(oe.add(pe.mult(Pe(Je))).mult(ft));return We.setLocationAtPoint(We.renderWorldCopies?rt.wrap():rt,$),We._updateCameraOnTerrain(),r.preloadOnly||this._fireMoveEvents(o),We};if(r.preloadOnly){const We=this._emulate(mt,r.duration,u);return this._preloadTiles(We),this}return this._zooming=!0,this._rotating=Xe,this._pitching=ot,this._padding=tt,this._prepareEase(o,!1),this._ease(mt(u),()=>this._afterEase(o),r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(r){}_cancelRenderFrame(r){}_stop({easeId:r,keepGesture:o}={}){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const f=this._onEaseEnd;this._onEaseEnd=void 0,f.call(this,r)}const u=this.handlers;return u&&u.stop(o),this}_ease(r,o,u){u.animate===!1||u.duration===0?(r(1),o()):(this._easeStart=d.e.now(),this._easeOptions=u,this._onEaseFrame=r,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const r=Math.min((d.e.now()-this._easeStart)/this._easeOptions.duration,1),o=this._onEaseFrame;o&&o(this._easeOptions.easing(r)),r<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(r,o){r=d.cU(r,-180,180);const u=Math.abs(r-o);return Math.abs(r-360-o)<u&&(r-=360),Math.abs(r+360-o)<u&&(r+=360),r}_normalizeCenter(r){const o=this.transform;if(o.maxBounds||o.projection.name!=="globe"&&!o.renderWorldCopies)return;const u=r.lng-o.center.lng;r.lng+=u>180?-360:u<-180?360:0}_prefersReducedMotion(r){return this._respectPrefersReducedMotion&&d.e.prefersReducedMotion&&!(r&&r.essential)}_emulate(r,o,u){const f=Math.ceil(15*o/1e3),m=[],g=r(u.clone());for(let x=0;x<=f;x++){const w=g(x/f);m.push(w.clone())}return m}_preloadTiles(r,o){}}const F_=/^(https?:|mailto:)/i;class Lp{constructor(r={}){this.options=r,d.aV(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(r){const o=this.options&&this.options.compact,u=r._getUIString("AttributionControl.ToggleAttribution");this._map=r,this._container=ai("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=ai("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",u);const f=ai("span","mapboxgl-ctrl-icon",this._compactButton);return f.setAttribute("aria-hidden","true"),f.setAttribute("title",u),this._innerContainer=ai("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 r=this._editLink;r||(r=this._editLink=this._container.querySelector(".mapbox-improve-map"));const o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||d.eM.ACCESS_TOKEN}];if(r){const u=o.reduce((f,m,g)=>(m.value&&(f+=`${m.key}=${m.value}${g<o.length-1?"&":""}`),f),"?");r.href=`${d.eM.FEEDBACK_URL}/${u}#${xp(this._map,!0)}`,r.rel="noopener nofollow"}}_updateData(r){!r||(r.dataType!=="source"||r.sourceDataType!=="metadata"&&r.sourceDataType!=="visibility")&&r.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let r=[];if(this._map.style.stylesheet){const f=this._map.style.stylesheet;this.styleOwner=f.owner,this.styleId=f.id}const o=this._map.style._mergedSourceCaches;for(const f in o){const m=o[f];if(m.used){const g=m.getSource();g.attribution&&!r.includes(g.attribution)&&r.push(g.attribution)}}r.sort((f,m)=>f.length-m.length),r=r.filter((f,m)=>{for(let g=m+1;g<r.length;g++)if(r[g].includes(f))return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?r=[...this.options.customAttribution,...r]:r.unshift(this.options.customAttribution));const u=r.map(f=>function(m){const g=new DOMParser().parseFromString(m,"text/html");return Array.from(g.body.querySelectorAll("*")).reverse().forEach(x=>{const w=x.textContent||"";if(x.tagName!=="A")return void x.replaceWith(...x.childNodes);const E=x.getAttribute("href");if(!E||!F_.test(E))return void x.replaceWith(g.createTextNode(w));const I=g.createElement("a");I.href=E,I.textContent=w,I.rel="noopener nofollow";const R=x.getAttribute("class");R&&(I.className=R),x.replaceWith(I)}),g.body.innerHTML}(f)).join(" | ");u!==this._attribHTML&&(this._attribHTML=u,r.length?(this._innerContainer.innerHTML=u,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 zp{constructor(){d.aV(["_updateLogo","_updateCompact"],this)}onAdd(r){this._map=r,this._container=ai("div","mapboxgl-ctrl");const o=ai("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(r){r&&r.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const r=this._map.style._sourceCaches;if(Object.entries(r).length===0)return!0;for(const o in r){const u=r[o].getSource();if(Object.hasOwn(u,"mapbox_logo")&&!u.mapbox_logo)return!1}return!0}_updateCompact(){const r=this._container.children;if(r.length){const o=r[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class Fp{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(r){const o=++this._id;return this._queue.push({callback:r,id:o,cancelled:!1}),o}remove(r){const o=this._currentlyRunning,u=o?this._queue.concat(o):this._queue;for(const f of u)if(f.id===r)return void(f.cancelled=!0)}run(r=0){const o=this._currentlyRunning=this._queue;this._queue=[];for(const u of o)if(!u.cancelled&&(u.callback(r),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class O_{constructor(r){this.jumpTo(r)}getValue(r){if(r<=this._startTime)return this._start;if(r>=this._endTime)return this._end;const o=d.ds((r-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(r){return r>=this._startTime&&r<=this._endTime}jumpTo(r){this._startTime=-1/0,this._endTime=-1/0,this._start=r,this._end=r}easeTo(r,o,u){this._start=this.getValue(o),this._end=r,this._startTime=o,this._endTime=o+u}}const B_={"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 ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class Op extends d.h{constructor(r,o,u,f){const{point:m,lngLat:g,originalEvent:x,target:w}=r;super(r.type,{point:m,lngLat:g,originalEvent:x,target:w}),this.preventDefault=()=>{r.preventDefault()},this.id=o,this.interaction=u,this.feature=f}}class jd{constructor(r){this.map=r,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(r,o){if(this.typeById.has(r))throw new Error(`Interaction id "${r}" already exists.`);const u=o.filter;let f=o.type;u&&this.filters.set(r,d.bv(u)),f==="mouseover"&&(f="mouseenter"),f==="mouseout"&&(f="mouseleave");const m=this.interactionsByType.get(f)||new Map;f==="mouseenter"||f==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(r,o)):m.size===0&&this.map.on(f,this.handleType),m.size===0&&this.interactionsByType.set(f,m),m.set(r,o),this.typeById.set(r,f)}get(r){const o=this.typeById.get(r);if(!o)return;const u=this.interactionsByType.get(o);return u?u.get(r):void 0}remove(r){const o=this.typeById.get(r);if(!o)return;this.typeById.delete(r),this.filters.delete(r);const u=this.interactionsByType.get(o);u&&(u.delete(r),o==="mouseenter"||o==="mouseleave"?(this.delegatedInteractions.delete(r),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):u.size===0&&this.map.off(o,this.handleType))}queryTargets(r,o){const u=[];for(const[f,m]of o)m.target&&u.push({targetId:f,target:m.target,filter:this.filters.get(f)});return this.map.style.queryRenderedTargets(r,u,this.map.transform)}handleMove(r){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const o=this.queryTargets(r.point,Array.from(this.delegatedInteractions).reverse());o.length&&(r.type="mouseenter",this.handleType(r,o));const u=new Map;for(const[f,{feature:m}]of this.prevHoveredFeatures)this.hoveredFeatures.has(f)||u.set(m.id,m);u.size&&(r.type="mouseleave",this.handleType(r,Array.from(u.values())))}handleOut(r){const o=Array.from(this.hoveredFeatures.values()).map(({feature:u})=>u);o.length&&(r.type="mouseleave",this.handleType(r,o)),this.hoveredFeatures.clear()}handleType(r,o){const u=r.type==="mouseenter";if(u&&!this.interactionsByType.has(r.type))return void d.w("mouseenter interaction required for mouseleave to work.");const f=Array.from(this.interactionsByType.get(r.type)).reverse(),m=!!o;o=o||this.queryTargets(r.point,f);let g=!1;const x=new Set;for(const w of o){for(const[E,I]of f){if(!I.target)continue;const R=w.variants?w.variants[E]:null;if(R){for(const P of R){if(Lf(P,w,x,E))continue;const B=new d.dl(w,P),V=Df(P,w,E);m&&B.id!==void 0&&(B.state=this.map.getFeatureState(B));const U=u?this.prevHoveredFeatures.get(V):null,G=new Op(r,E,I,B),$=U?U.stop:I.handler(G);if(u&&this.hoveredFeatures.set(V,{feature:w,stop:$}),$!==!1){g=!0;break}}if(g)break}}if(g)break}if(!g)for(const[w,E]of f){const{handler:I,target:R}=E;if(!R&&I(new Op(r,w,E,null))!==!1)break}}}function k_(a,r){if(Array.isArray(a)&&Array.isArray(r)){const o=new Set(a),u=new Set(r);return o.size===u.size&&a.every(f=>u.has(f))}return d.O(a,r)}const Bp=/matrix.*\((.+)\)/,gu={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},N_={showCompass:!0,showZoom:!0,visualizePitch:!1};class Ir{constructor(r,o,u=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new kd({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,u&&(this.mousePitch=new hu({clickTolerance:r.dragRotate._mousePitch._clickTolerance})),d.aV(["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(r,o){this.mouseRotate.mousedown(r,o),this.mousePitch&&this.mousePitch.mousedown(r,o),rr()}move(r,o){const u=this.map,f=this.mouseRotate.mousemoveWindow(r,o),m=f&&f.bearingDelta;if(m&&u.setBearing(u.getBearing()+m),this.mousePitch){const g=this.mousePitch.mousemoveWindow(r,o),x=g&&g.pitchDelta;x&&u.setPitch(u.getPitch()+x)}}off(){const r=this.element;r.removeEventListener("mousedown",this.mousedown),r.removeEventListener("touchstart",this.touchstart),r.removeEventListener("touchmove",this.touchmove),r.removeEventListener("touchend",this.touchend),r.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){kl(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(r){this.down({...r,button:r.button,type:r.type,ctrlKey:!0,preventDefault:()=>r.preventDefault()},Yi(this.element,r)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(r){this.move(r,Yi(this.element,r))}mouseup(r){this.mouseRotate.mouseupWindow(r),this.mousePitch&&this.mousePitch.mouseupWindow(r),this.offTemp()}touchstart(r){r.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=hr(this.element,r.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>r.preventDefault()},this._startPos))}touchmove(r){r.targetTouches.length!==1?this.reset():(this._lastPos=hr(this.element,r.targetTouches)[0],this.move({buttons:1,preventDefault:()=>r.preventDefault()},this._lastPos))}touchend(r){r.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 vl(a,r,o){if(a=new d.cz(a.lng,a.lat),r){const u=new d.cz(a.lng-360,a.lat),f=new d.cz(a.lng+360,a.lat),m=360*Math.ceil(Math.abs(a.lng-o.center.lng)/360),g=o.locationPoint3D(a).distSqr(r),x=r.x<0||r.y<0||r.x>o.width||r.y>o.height;o.locationPoint3D(u).distSqr(r)<g&&(x||Math.abs(u.lng-o.center.lng)<m)?a=u:o.locationPoint3D(f).distSqr(r)<g&&(x||Math.abs(f.lng-o.center.lng)<m)&&(a=f)}for(;Math.abs(a.lng-o.center.lng)>180;){const u=o.locationPoint3D(a);if(u.x>=0&&u.y>=0&&u.x<=o.width&&u.y<=o.height)break;a.lng>o.center.lng?a.lng-=360:a.lng+=360}return a}const bh={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%)"},wh=/\s+/,Bo={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class bl extends d.E{constructor(r,o){super(),(r instanceof HTMLElement||o)&&(r={element:r,...o}),d.aV(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:u="center",color:f="#3FB1CE",scale:m=1,draggable:g=!1,clickTolerance:x=0,rotation:w=Bo.rotation,rotationAlignment:E=Bo.rotationAlignment,pitchAlignment:I=Bo.pitchAlignment,occludedOpacity:R=Bo.occludedOpacity,altitude:P=Bo.altitude}=r||{};this._anchor=u,this._color=f,this._scale=m,this._draggable=g,this._clickTolerance=x,this._rotation=w,this._rotationAlignment=E,this._pitchAlignment=I,this._occludedOpacity=R,this._altitude=P,this._state="inactive",this._isDragging=!1,this._pointerEvents=null,this._updateMoving=()=>this._update(!0),r&&r.element?(this._element=r.element,this._offset=d.P.convert(r&&r.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=d.P.convert(r&&r.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",V=>{V.preventDefault()}),this._element.addEventListener("mousedown",V=>{V.preventDefault()});const B=this._element.classList;for(const V in bh)B.remove(`mapboxgl-marker-anchor-${V}`);B.add(`mapboxgl-marker-anchor-${this._anchor}`),r&&r.className&&B.add(...r.className.trim().split(wh)),this._popup=null}_createDefaultMarker(){const r=ai("div"),o=So("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},r);this._svgElement=o;const u=So("radialGradient",{id:"shadowGradient"},So("defs",{},o));So("stop",{offset:"10%","stop-opacity":.4},u),So("stop",{offset:"100%","stop-opacity":.05},u);const f=So("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"});return this._shadowElement=f,this._altitude===0&&o.insertBefore(f,o.firstChild),So("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),So("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),So("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},o),r}addTo(r){return r===this._map||(this.remove(),this._map=r,r.getCanvasContainer().appendChild(this._element),r.on("move",this._updateMoving),r.on("moveend",this._update),r.on("remove",this._clearFadeTimer),r._addMarker(this),this.setDraggable(this._draggable),this._update(),r.on("click",this._onMapClick)),this}remove(){const r=this._map;return r&&(r.off("click",this._onMapClick),r.off("move",this._updateMoving),r.off("moveend",this._update),r.off("mousedown",this._addDragHandler),r.off("touchstart",this._addDragHandler),r.off("mouseup",this._onUp),r.off("touchend",this._onUp),r.off("mousemove",this._onMove),r.off("touchmove",this._onMove),r.off("remove",this._clearFadeTimer),r._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=d.cz.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(r){if(r===this._altitude)return this;const o=this._altitude;return this._altitude=r||Bo.altitude,this._defaultMarker&&o===0!=(this._altitude===0)&&(this._altitude===0?this._svgElement.insertBefore(this._shadowElement,this._svgElement.firstChild):this._shadowElement.remove()),this._update(),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(r){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")),r){if(!("offset"in r.options)){const f=Math.sqrt(Math.pow(13.5,2)/2);r.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[f,-1*(38.1-13.5+f)],"bottom-right":[-f,-1*(38.1-13.5+f)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=r,r._marker=this,r._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(r){const o=r.code,u=r.charCode||r.keyCode;o!=="Space"&&o!=="Enter"&&u!==32&&u!==13||this.togglePopup()}_onMapClick(r){const o=r.originalEvent.target,u=this._element;this._popup&&(o===u||u.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const r=this._popup;return r?(r.isOpen()?(r.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(r.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const r=this._map,o=this._pos;if(!r||!o)return!1;const u=r.unproject(o,this._altitude),f=r.getFreeCameraOptions();if(!f.position)return!1;const m=f.position.toLngLat();return m.distanceTo(u)<.9*m.distanceTo(this._lngLat)}_evaluateOpacity(){const r=this._map;if(!r)return;const o=this._pos;if(!o||o.x<0||o.x>r.transform.width||o.y<0||o.y>r.transform.height)return void this._clearFadeTimer();const u=r.unproject(o,this._altitude);let f;r._showingGlobe()&&d.f3(r.transform,this._lngLat)?f=0:(f=1-r._queryFogOpacity(u),r.transform._terrainEnabled()&&r.style&&r.style.hasTerrain()&&this._behindTerrain()&&(f*=this._occludedOpacity)),this._element.style.opacity=`${f}`;const m=this._element.style.pointerEvents;(this._pointerEvents===null?m==="":m===this._pointerEvents)&&(this._pointerEvents=f>0?"auto":"none",this._element.style.pointerEvents=this._pointerEvents),this._popup&&this._popup._setOpacity(f),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const r=this._pos;if(!r||!this._map)return;const o=this._offset.mult(this._scale);this._element.style.transform=`
3416            translate(${r.x}px,${r.y}px)
3417            ${bh[this._anchor]}
3418            ${this._calculateXYTransform()} ${this._calculateZTransform()}
3419            translate(${o.x}px,${o.y}px)
3420        `}_calculateXYTransform(){const r=this._pos,o=this._map,u=this.getPitchAlignment();if(!o||!r||u!=="map")return"";if(!o._showingGlobe()){const w=o.getPitch();return w?`rotateX(${w}deg)`:""}const f=d.f4(d.f5(o.transform,this._lngLat)),m=r.sub(d.f6(o.transform)),g=Math.abs(m.x)+Math.abs(m.y);if(g===0)return"";const x=f/g;return`rotateX(${-m.y*x}deg) rotateY(${m.x*x}deg)`}_calculateZTransform(){const r=this._pos,o=this._map;if(!o||!r)return"";let u=0;const f=this.getRotationAlignment();if(f==="map")if(o._showingGlobe()){const m=o.project(new d.cz(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),g=o.project(new d.cz(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(m);u=d.f4(Math.atan2(g.y,g.x))-90}else u=-o.getBearing();else if(f==="horizon"){const m=d.am(4,6,o.getZoom()),g=d.f6(o.transform);g.y+=m*o.transform.height;const x=r.sub(g),w=d.f4(Math.atan2(x.y,x.x));u=(w>90?w-270:w+90)*(1-m)}return u+=this._rotation,u?`rotateZ(${u}deg)`:""}_update(r){cancelAnimationFrame(this._updateFrameId);const o=this._map;o&&(o.transform.renderWorldCopies&&(this._lngLat=vl(this._lngLat,this._pos,o.transform)),this._pos=o.project(this._lngLat,this._altitude),r===!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.style&&o.style.hasTerrain()||o.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(r){return this._offset=d.P.convert(r),this._update(),this}addClassName(r){return this._element.classList.add(r),this}removeClassName(r){return this._element.classList.remove(r),this}toggleClassName(r){return this._element.classList.toggle(r)}_onMove(r){const o=this._map;if(!o)return;const u=this._pointerdownPos,f=this._positionDelta;if(u&&f){if(!this._isDragging){const m=this._clickTolerance||o._clickTolerance;if(r.point.dist(u)<m)return;this._isDragging=!0}this._pos=r.point.sub(f),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 d.h("dragstart"))),this.fire(new d.h("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const r=this._map;r&&(r.off("mousemove",this._onMove),r.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new d.h("dragend")),this._state="inactive"}_addDragHandler(r){const o=this._map,u=this._pos;o&&u&&this._element.contains(r.originalEvent.target)&&(r.preventDefault(),this._positionDelta=r.point.sub(u),this._pointerdownPos=r.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(r){this._draggable=!!r;const o=this._map;return o&&(r?(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(r){return this._rotation=r||Bo.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(r){return this._rotationAlignment=r||Bo.rotationAlignment,this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(r){return this._pitchAlignment=r||Bo.pitchAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(r){return this._occludedOpacity=r||Bo.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const kp={OFF:[],WAITING_ACTIVE:["waiting","active"],ACTIVE_LOCK:["active"],ACTIVE_ERROR:["waiting","active-error"],BACKGROUND:["background"],BACKGROUND_ERROR:["waiting","background-error"]},yu=a=>`mapboxgl-ctrl-geolocate-${a}`,xu=["waiting","active","active-error","background","background-error"].map(yu),Ma={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},Np={maxWidth:100,unit:"metric"},Gd={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},Hd=/\s+/,On={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},wl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Th(a=new d.P(0,0),r="bottom"){if(typeof a=="number"){const o=Math.round(Math.sqrt(.5*Math.pow(a,2)));switch(r){case"top":return new d.P(0,a);case"top-left":return new d.P(o,o);case"top-right":return new d.P(-o,o);case"bottom":return new d.P(0,-a);case"bottom-left":return new d.P(o,-o);case"bottom-right":return new d.P(-o,-o);case"left":return new d.P(a,0);case"right":return new d.P(-a,0)}return new d.P(0,0)}return a instanceof d.P||Array.isArray(a)?d.P.convert(a):d.P.convert(a[r]||[0,0])}const _o=typeof document<"u"?document.currentScript:null;return d.f7(_o&&_o.src&&d.f8(_o.src)?"cdn":"other"),{version:d.f2,supported:function(a){return!function(r){return typeof window<"u"&&typeof document<"u"?Object.hasOwn?function(){const o=document.createElement("canvas");o.width=o.height=1;const u=o.getContext("2d");return!!u&&u.getImageData(0,0,1,1).width===o.width}()?function(o){return o?(Xn===void 0&&(Xn=Lr(!0)),Xn):(Eo===void 0&&(Eo=Lr(!1)),Eo)}(r)?"":"insufficient WebGL2 support":"insufficient Canvas/getImageData support":"Object.hasOwn not supported":"not a browser"}(a)},setRTLTextPlugin:d.fd,getRTLTextPluginStatus:d.fc,setSdkInfo:d.fb,addTileProvider:d.fa,Map:class extends _u{constructor(a){d.eN.mark(d.eO.create);const r=a;if((a={...gu,...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");super(new d.eP(a.minZoom,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._placementAlgorithm=a.placementAlgorithm||"default",this._isInitialLoad=!0,this._crossSourceCollisions=a.crossSourceCollisions,this._collectResourceTiming=a.collectResourceTiming,this._language=this._parseLanguage(a.language),this._worldview=a.worldview,this._renderTaskQueue=new Fp,this._domRenderTaskQueue=new Fp,this._controls=[],this._markers=[],this._popups=[],this._mapId=d.av(),this._locale={...B_,...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 O_(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=a.scaleFactor,this._requestManager=new d.eQ(a.transformRequest,a.accessToken,a.testMode);const o=d.eR(a.accessToken||d.eM.ACCESS_TOKEN);if(o&&"atlas"in o&&typeof o.atlas=="number"&&(this._tokenExpiration=o.atlas),this._silenceAuthErrors=!!a.testMode,this._contextCreateOptions=a.contextCreateOptions?{...a.contextCreateOptions}:{},typeof a.container=="string"){const u=document.getElementById(a.container);if(!u)throw new Error(`Container '${a.container.toString()}' not found.`);this._container=u}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&&d.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",d.aV(["_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 Dp(this,a),this._localFontFamily=a.localFontFamily,this._localIdeographFontFamily=a.localIdeographFontFamily,this._fontstackCompositing=a.fontstackCompositing,(a.style||!a.testMode)&&this.setStyle(a.style||d.eM.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 D_(typeof a.hash=="string"&&a.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){r.center==null&&r.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch});const u=a.bounds;u&&(this.resize(),this.fitBounds(u,{...a.fitBoundsOptions,duration:0}))}this.resize(),a.attributionControl&&this.addControl(new Lp({customAttribution:a.customAttribution})),this._logoControl=new zp,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",u=>{this._update(u.dataType==="style"),this.fire(new d.h(`${u.dataType}data`,u))}),this.on("dataloading",u=>{this.fire(new d.h(`${u.dataType}dataloading`,u))}),this._interactions=new jd(this)}_getMapId(){return this._mapId}addControl(a,r){if(r===void 0&&(r=a.getDefaultPosition?a.getDefaultPosition():"top-right"),!a||!a.onAdd)return this.fire(new d.f(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=a.onAdd(this);this._controls.push(a);const u=this._controlPositions[r];return r.includes("bottom")?u.insertBefore(o,u.firstChild):u.appendChild(o),this}removeControl(a){if(!a||!a.onRemove)return this.fire(new d.f(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(a);return r>-1&&this._controls.splice(r,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));const r=!this._moving;return r&&this.fire(new d.h("movestart",a)).fire(new d.h("move",a)),this.fire(new d.h("resize",a)),r&&this.fire(new d.h("moveend",a)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(a){return this.transform.setMaxBounds(d.eC.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 d.h("zoomstart")).fire(new d.h("zoom")).fire(new d.h("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 d.h("zoomstart")).fire(new d.h("zoom")).fire(new d.h("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 d.h("pitchstart")).fire(new d.h("pitch")).fire(new d.h("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 d.h("pitchstart")).fire(new d.h("pitch")).fire(new d.h("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(r=>r.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(r=>r==="auto"?navigator.language:r):a}setLanguage(a){const r=this._parseLanguage(a);if(!this.style||r===this._language)return this;this._language=r,this.style.reloadSources();for(const 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
3420ing"&&(a={name:a}):a=null,this._useExplicitProjection=!!a,this._prioritizeAndUpdateProjection(a,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const a=this.transform,r=a.projection.name;let o;r==="globe"&&a.zoom>=d.b1?(a.setMercatorFromTransition(),o=!0):r==="mercator"&&a.zoom<d.b1&&(a.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0))}_prioritizeAndUpdateProjection(a,r){return this._updateProjection(a||r||{name:"mercator"})}_updateProjection(a){let r;const o=this.transform.mercatorFromTransition;r=a.name==="globe"&&this.transform.zoom>=d.b1?this.transform.setMercatorFromTransition():this.transform.setProjection(a),this.style.applyProjectionUpdate();const u=this.transform.getProjection().name==="mercator"&&o!==this.transform.mercatorFromTransition;return(r||u)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(a,r){return this.transform.locationPoint3D(d.cz.convert(a),r)}unproject(a,r){return this.transform.pointLocation3D(d.P.convert(a),r)}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,r,o){const u=f=>{let m=[];if(Array.isArray(r)){const g=r.filter(x=>this.getLayer(x));m=g.length?this.queryRenderedFeatures(f,{layers:g}):[]}else m=this.queryRenderedFeatures(f,{target:r});return m};if(a==="mouseenter"||a==="mouseover"){let f=!1;return{listener:o,targets:r,delegates:{mousemove:g=>{const x=u(g.point);x.length?f||(f=!0,o.call(this,new mo(a,this,g.originalEvent,{features:x}))):f=!1},mouseout:()=>{f=!1}}}}if(a==="mouseleave"||a==="mouseout"){let f=!1;return{listener:o,targets:r,delegates:{mousemove:x=>{u(x.point).length?f=!0:f&&(f=!1,o.call(this,new mo(a,this,x.originalEvent)))},mouseout:x=>{f&&(f=!1,o.call(this,new mo(a,this,x.originalEvent)))}}}}{const f=m=>{const g=u(m.point);g.length&&(m.features=g,o.call(this,m),delete m.features)};return{listener:o,targets:r,delegates:{[a]:f}}}}on(a,r,o){if(typeof r=="function"||o===void 0)return super.on(a,r);if(typeof r=="string"&&(r=[r]),!this._areTargetsValid(r))return this;const u=this._createDelegatedListener(a,r,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[a]=this._delegatedListeners[a]||[],this._delegatedListeners[a].push(u);for(const f in u.delegates)this.on(f,u.delegates[f]);return this}once(a,r,o){if(typeof r=="function"||o===void 0)return super.once(a,r);if(typeof r=="string"&&(r=[r]),!this._areTargetsValid(r))return this;const u=this._createDelegatedListener(a,r,o);for(const f in u.delegates)this.once(f,u.delegates[f]);return this}off(a,r,o){if(typeof r=="function"||o===void 0)return super.off(a,r);if(typeof r=="string"&&(r=[r]),!this._areTargetsValid(r))return this;const u=this._delegatedListeners?this._delegatedListeners[a]:void 0;return u&&(f=>{for(let m=0;m<f.length;m++){const g=f[m];if(g.listener===o&&k_(g.targets,r)){for(const x in g.delegates)this.off(x,g.delegates[x]);return f.splice(m,1),this}}})(u),this}queryRenderedFeatures(a,r){if(!this.style)return[];if(a===void 0||a instanceof d.P||Array.isArray(a)||r!==void 0||(r=a,a=void 0),a=a||[[0,0],[this.transform.width,this.transform.height]],!r){const m=this.style.queryRenderedFeatures(a,void 0,this.transform),g=this.style.queryRenderedFeatureset(a,void 0,this.transform);return m.concat(g)}let o=!0;if(r.target&&(o=this._isTargetValid(r.target),o&&!r.layers))return this.style.queryRenderedFeatureset(a,r,this.transform);let u=!0;if(r.layers&&Array.isArray(r.layers)){for(const m of r.layers)if(!this._isValidId(m)){u=!1;break}if(u&&!r.target)return this.style.queryRenderedFeatures(a,r,this.transform)}let f=[];return u&&(f=f.concat(this.style.queryRenderedFeatures(a,r,this.transform))),o&&(f=f.concat(this.style.queryRenderedFeatureset(a,r,this.transform))),f}
vendor: 29,129 bytes, lines 3420-3422
3420querySourceFeatures(a,r){return!a||typeof a=="string"&&!this._isValidId(a)?[]:this.style.querySourceFeatures(a,r)}queryRasterValue(a,r,o){return this._isValidId(a)?this.style.queryRasterValue(a,r,o):Promise.resolve(null)}isPointOnSurface(a){const{name:r}=this.transform.projection;return r!=="globe"&&r!=="mercator"&&d.w(`${r} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(d.P.convert(a))}addInteraction(a,r){return this._interactions.add(a,r),this}removeInteraction(a){return this._interactions.remove(a),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(a){return this._cooperativeGestures=a,this}setStyle(a,r){return r={localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,fontstackCompositing:this._fontstackCompositing,...r},this.style&&a&&r.diff!==!1&&r.localFontFamily===this._localFontFamily&&r.localIdeographFontFamily===this._localIdeographFontFamily&&r.fontstackCompositing===this._fontstackCompositing&&!r.config?(this.style._diffStyle(a,(o,u)=>{if(o){const f=typeof o=="string"?o:o instanceof Error?o.message:o.error;d.w(`Unable to perform style diff: ${f}. Rebuilding the style from scratch.`),this._updateStyle(a,r)}else u&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._fontstackCompositing=r.fontstackCompositing,this._updateStyle(a,r))}_getUIString(a){const r=this._locale[a];if(r==null)throw new Error(`Missing UI string '${a}'`);return r}_updateStyle(a,r){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),a){const o={...r};r&&r.config&&(o.initialConfig=r.config,delete o.config),this.style=new fl(this,o).load(a),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new fl(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():(d.w("There is no style added to the map."),!1)}_isValidId(a){return a==null?(this.fire(new d.f(new Error("IDs can't be empty."))),!1):d.df(a)?(this.fire(new d.f(new Error(`IDs can't contain special symbols: "${a}".`))),!1):a!=="__proto__"&&a!=="constructor"&&a!=="prototype"||(this.fire(new d.f(new Error(`IDs can't be "${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(const r of a)if(!this._isValidId(r))return!1;return!0}return this._isTargetValid(a)}addSource(a,r){return this._isValidId(a)?(this._lazyInitEmptyStyle(),this.style.addSource(a,r),this._update(!0)):this}isSourceLoaded(a){return!!this._isValidId(a)&&!!this.style&&this.style._isSourceCacheLoaded(a)}areTilesLoaded(){return this.style.areTilesLoaded()}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,r,{pixelRatio:o=1,sdf:u=!1,stretchX:f,stretchY:m,content:g}={}){this._lazyInitEmptyStyle();const x=d.I.from(a);if(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap){const{width:w,height:E,data:I}=d.e.getImageData(r);this.style.addImage(x,{data:new d.b({width:w,height:E},I),pixelRatio:o,stretchX:f,stretchY:m,content:g,sdf:u,version:0,usvg:!1})}else if(r.width===void 0||r.height===void 0)this.fire(new d.f(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{const{width:w,height:E}=r,I=r;this.style.addImage(x,{data:new d.b({width:w,height:E},new Uint8Array(I.data)),pixelRatio:o,stretchX:f,stretchY:m,content:g,sdf:u,usvg:!1,version:0,userImage:I}),I.onAdd&&I.onAdd(this,a)}}updateImage(a,r){this._lazyInitEmptyStyle();const o=d.I.from(a),u=this.style.getImage(o);if(!u)return void this.fire(new d.f(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const f=r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap?d.e.getImageData(r):r,{width:m,height:g,data:x}=f;if(m===void 0||g===void 0)return void this.fire(new d.f(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!==(u.usvg?u.icon.usvg_tree.width:u.data.width)||g!==(u.usvg?u.icon.usvg_tree.height:u.data.height))return void this.fire(new d.f(new Error(`The width and height of the updated image (${m}, ${g})
3421                must be that same as the previous version of the image
3422                (${u.data.width}, ${u.data.height})`)));const w=!(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap);let E=!1;u.usvg?(u.data=new d.b({width:m,height:g},new Uint8Array(x)),u.usvg=!1,u.icon=void 0,E=!0):u.data.replace(x,w),this.style.updateImage(o,u,E)}hasImage(a){return a?!!this.style&&!!this.style.getImage(d.I.from(a)):(this.fire(new d.f(new Error("Missing required image id"))),!1)}removeImage(a){this.style.removeImage(d.I.from(a))}loadImage(a,r){(async()=>{const o=await this._requestManager.transformRequest(a,d.R.Image),{data:u}=await d.a(o);return u})().then(o=>r(null,o)).catch(r)}listImages(){return this.style.listImages().map(a=>a.name)}addModel(a,r){this._lazyInitEmptyStyle(),this.style.addModel(a,r)}hasModel(a){return a?this.style.hasModel(a):(this.fire(new d.f(new Error("Missing required model id"))),!1)}removeModel(a){this.style.removeModel(a)}listModels(){return this.style.listModels()}addLayer(a,r){return this._isValidId(a.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(a,r),this._update(!0)):this}getSlot(a){const r=this.getLayer(a);return r&&r.slot||null}setSlot(a,r){return this.style.setSlot(a,r),this.style.mergeLayers(),this._update(!0)}addImport(a,r){return this._isValidId(a.id)?(this.style.addImport(a,r).catch(o=>this.fire(new d.f(new Error("Failed to add import",o)))),this):this}updateImport(a,r){return typeof r!="string"&&r.id!==a?(this.removeImport(a),this.addImport(r)):(this.style.updateImport(a,r),this._update(!0))}removeImport(a){return this.style.removeImport(a),this}moveImport(a,r){return this.style.moveImport(a,r),this._update(!0)}moveLayer(a,r){return this._isValidId(a)?(this.style.moveLayer(a,r),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;const r=this.style.getOwnLayer(a);return r?r.type==="custom"?r.implementation:r.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(a,r,o){return this._isValidId(a)?(this.style.setLayerZoomRange(a,r,o),this._update(!0)):this}setFilter(a,r,o={}){return this._isValidId(a)?(this.style.setFilter(a,r,o),this._update(!0)):this}getFilter(a){return this._isValidId(a)?this.style.getFilter(a):null}setPaintProperty(a,r,o,u={}){return this._isValidId(a)?(this.style.setPaintProperty(a,r,o,u),this._update(!0)):this}getPaintProperty(a,r){return this._isValidId(a)?this.style.getPaintProperty(a,r):null}setLayoutProperty(a,r,o,u={}){return this._isValidId(a)?(this.style.setLayoutProperty(a,r,o,u),this._update(!0)):this}getLayoutProperty(a,r){return this._isValidId(a)?this.style.getLayoutProperty(a,r):null}getLayerProperty(a,r){return this._isValidId(a)?this.style.getLayerProperty(a,r):null}setLayerProperty(a,r,o,u={}){return this._isValidId(a)?(r==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(a,r,o,u),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,r){return this.style.setSchema(a,r),this._update(!0)}getConfig(a){return this.style.getConfig(a)}setConfig(a,r){return this.style.setConfig(a,r),this._update(!0)}getConfigProperty(a,r){return this.style.getConfigProperty(a,r)}setConfigProperty(a,r,o){return this.style.setConfigProperty(a,r,o),this._update(!0)}getFeaturesetDescriptors(a){return this.style.getFeaturesetDescriptors(a)}setLights(a){if(this._lazyInitEmptyStyle(),a&&a.length===1&&a[0].type==="flat"){const r=a[0];r.properties?this.style.setFlatLight(r.properties,r.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(a),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const a=this.style.getLights()||[];return a.length===0&&a.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),a}setLight(a,r={}){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,r){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(a,r),this._update(!0)}setCamera(a){return this.style.setCamera(a),this._triggerCameraUpdate(a)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(a){const r=this.transform.nearClipOffset!==a;return this.transform.nearClipOffset=a,this._update(r)}_triggerCameraUpdate(a){return this._update(this.transform.setOrthographicProjectionAtLowPitch(a["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(a){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(d.cz.convert(a),this.transform):0}setFeatureState(a,r){return a.source&&!this._isValidId(a.source)?this:(this.style.setFeatureState(a,r),this._update())}removeFeatureState(a,r){return a.source&&!this._isValidId(a.source)?this:(this.style.removeFeatureState(a,r),this._update())}getFeatureState(a){return a.source&&!this._isValidId(a.source)?null:this.style.getFeatureState(a)}resetFeatureStates(a){return this.style.resetFeatureStates(a),this._update()}_selectIndoorFloor(a){this.style.indoorManager&&this.style.indoorManager.selectFloor(a)}_setIndoorActiveFloorsVisibility(a){this.style.indoorManager&&this.style.indoorManager.setActiveFloorsVisibility(a)}getIndoorTileOptions(a,r){return this.style&&this.style.isIndoorEnabled()&&this.style.indoorManager?this.style.indoorManager.getIndoorTileOptions(a,r):null}_updateContainerDimensions(){if(!this._container)return;const a=this._container.getBoundingClientRect().width||400,r=this._container.getBoundingClientRect().height||300;let o,u,f,m=this._container;for(;m&&(!u||!f);){const g=window.getComputedStyle(m).transform;g&&g!=="none"&&(o=g.match(Bp)[1].split(", "),o[0]&&o[0]!=="0"&&o[0]!=="1"&&(u=o[0]),o[3]&&o[3]!=="0"&&o[3]!=="1"&&(f=o[3])),m=m.parentElement}this._containerWidth=u?Math.abs(a/u):a,this._containerHeight=f?Math.abs(r/f):r}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&d.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(){const a=this._container;a.classList.add("mapboxgl-map"),(this._missingCSSCanary=ai("div","mapboxgl-canary",a)).style.visibility="hidden",this._detectMissingCSS();const r=this._canvasContainer=ai("div","mapboxgl-canvas-container",a);this._canvas=ai("canvas","mapboxgl-canvas",r),this._interactive&&(r.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);const o=this._controlContainer=ai("div","mapboxgl-control-container",a),u=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(f=>{u[f]=ai("div",`mapboxgl-ctrl-${f}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(a,r){const o=d.e.devicePixelRatio||1;this._canvas.width=o*Math.ceil(a),this._canvas.height=o*Math.ceil(r),this._canvas.style.width=`${a}px`,this._canvas.style.height=`${r}px`}_addMarker(a){this._markers.push(a)}_removeMarker(a){const r=this._markers.indexOf(a);r!==-1&&this._markers.splice(r,1)}_addPopup(a){this._popups.push(a)}_removePopup(a){const r=this._popups.indexOf(a);r!==-1&&this._popups.splice(r,1)}_setupPainter(){const a={...L,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},r=this._canvas.getContext("webgl2",a);r?(d.eS(r,!0),this.painter=new Ld(r,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",o=>{if(o.dataType==="source"){const u=this.transform.elevation?this.transform.elevation._source():null;u&&o.sourceCacheId===u.id&&this.style&&this.style._setLabelPlacementStale(),this.style&&o.sourceCacheId&&this.style._buildingIndex.hasLayerForSourceCache(o.sourceCacheId)&&this.style._requestFullLabelPlacement(),this.painter.setTileLoadedFlag(!0)}})):this.fire(new d.f(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 d.h("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 d.h("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 r;this.fire(new d.h("renderstart")),++this._frameId;const o=this.painter.context.extTimerQuery,u=d.e.now(),f=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=f.createQuery(),f.beginQuery(o.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(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();const m=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const w=this.transform.zoom,E=this.transform.pitch,I=d.e.now(),R=new d.ai(w,{now:I,fadeDuration:m,pitch:E,transition:this._loaded?this.style.transition:{duration:0,delay:0},worldview:this._worldview});this.style.update(R)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let g=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),g=this._updateAverageElevation(u),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):g=this._updateAverageElevation(u),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,m,this._crossSourceCollisions,this.painter.replacementSource,this._placementAlgorithm)),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,paintStartTimeStamp:a}),this.fire(new d.h("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,d.eN.mark(d.eO.load),this.fire(new d.h("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._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const w=d.e.now()-u;f.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{const E=f.getQueryParameter(r,f.QUERY_RESULT)/1e6;f.deleteQuery(r),this.fire(new d.h("gpu-timing-frame",{cpuTime:w,gpuTime:E}))},50)}if(this.listens("gpu-timing-layer")){const w=this.painter.collectGpuTimers();setTimeout(()=>{const E=this.painter.queryGpuTimers(w);this.fire(new d.h("gpu-timing-layer",{layerTimes:E}))},50)}if(this.listens("gpu-timing-deferred-render")){const w=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const E=this.painter.queryGpuTimeDeferredRender(w);this.fire(new d.h("gpu-timing-deferred-render",{gpuTime:E}))},50)}const x=this._sourcesDirty||this._styleDirty||this._placementDirty||g;if(x||this._repaint)this.triggerRepaint();else{const w=this.idle();if(w&&(g=this._updateAverageElevation(u,!0)),g)this.triggerRepaint();else{if(this._triggerFrame(!1),w&&(this.fire(new d.h("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const E=this._calculateSpeedIndex();this.fire(new d.h("speedindexcompleted",{speedIndex:E})),this.speedIndexTiming=!1}w&&this.style&&this.style.handleIdle()}}!this._loaded||this._fullyLoaded||x||(this._fullyLoaded=!0,d.eN.mark(d.eO.fullLoad),this._performanceMetricsCollection&&d.eT(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:this.painter.style.hasTerrain(),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(const r of this._markers)a&&!this.getRenderWorldCopies()&&(r._lngLat=r._lngLat.wrap()),r._update();for(const r of this._popups)!a||this.getRenderWorldCopies()||r._trackPointer||(r._lngLat=r._lngLat.wrap()),r._update()}_updateAverageElevation(a,r=!1){const o=f=>(this.transform.averageElevation=f,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&o(0);const u=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(u||(r||a-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(a)){const f=this.transform.averageElevation;let m=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(m)?m=0:this._averageElevationLastSampledAt=a;const g=Math.abs(f-m);if(g>1){if(this._isInitialLoad||u)return this._averageElevation.jumpTo(m),o(m);this._averageElevation.easeTo(m,a,300)}else if(g>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(){const a=this.painter.context.gl;d.eS(a,!1),this._logoControl instanceof zp&&this._logoControl._updateLogo(),a&&a.clear(a.DEPTH_BUFFER_BIT|a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new d.f(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(){d.eU(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,a=>{a&&(a.message!==d.eV&&a.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),d.eW(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&d.eX(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&d.eY(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){d.eZ(this._requestManager._customAccessToken)}_updateTerrain(){const a=this._isDragging();this.painter.updateTerrain(this.style,a)}_calculateSpeedIndex(){const a=this.painter.canvasCopy(),r=this.painter.getCanvasCopiesAndTimestamps();r.timeStamps.push(performance.now());const o=this.painter.context.gl,u=o.createFramebuffer();function f(m){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,m,0);const g=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,g),g}return o.bindFramebuffer(o.FRAMEBUFFER,u),this._canvasPixelComparison(f(a),r.canvasCopies.map(f),r.timeStamps)}_canvasPixelComparison(a,r,o){let u=o[1]-o[0];const f=a.length/4;for(let m=0;m<r.length;m++){const g=r[m];let x=0;for(let w=0;w<g.length;w+=4)g[w]===a[w]&&g[w+1]===a[w+1]&&g[w+2]===a[w+2]&&g[w+3]===a[w+3]&&(x+=1);u+=(o[m+2]-o[m+1])*(1-x/f)}return u}remove(){if(this._removed)return;this._hash&&this._hash.remove();for(const r of this._controls)r.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);const 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),d.e_(this.painter.context.gl),d.e$.remove(),d.f0.remove(),this._removed=!0,this.fire(new d.h("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(a){this._renderNextFrame=this._renderNextFrame||a,this.style&&!this._frame&&(this._frame=d.e.frame(r=>{const o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(r)}))}_preloadTiles(a){const r=this.style?this.style.getSourceCaches():[];return d.bT(r,(o,u)=>o._preloadTiles(a,u),()=>{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,a&&qo(),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,a&&qo(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(a){this._showCollisionBoxes!==a&&(this._showCollisionBoxes=a,a&&qo(),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,r){d.f1(a,r)}get version(){return d.f2}},NavigationControl:class{constructor(a={}){this.options={...N_,...a},this._container=ai("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",r=>r.preventDefault()),this.options.showZoom&&(d.aV(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",r=>{this._map&&this._map.zoomIn({},{originalEvent:r})}),ai("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",r=>{this._map&&this._map.zoomOut({},{originalEvent:r})}),ai("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(d.aV(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",r=>{const o=this._map;o&&(this.options.visualizePitch?o.resetNorthPitch({},{originalEvent:r}):o.resetNorth({},{originalEvent:r}))}),this._compassIcon=ai("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const a=this._map;if(!a)return;const r=a.getZoom(),o=r===a.getMaxZoom(),u=r===a.getMinZoom();this._zoomInButton.disabled=o,this._zoomOutButton.disabled=u,this._zoomInButton.setAttribute("aria-disabled",o.toString()),this._zoomOutButton.setAttribute("aria-disabled",u.toString())}_rotateCompassArrow(){const a=this._map;if(!a)return;const r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(a.transform.pitch*(Math.PI/180)
3422),.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=r)})}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 Ir(a,this._compass,this.options.visualizePitch)),this._container}onRemove(){const 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,r){const o=ai("button",a,this._container);return o.type="button",o.addEventListener("click",r),o}_setButtonTitle(a,r){if(!this._map)return;const o=this._map._getUIString(`NavigationControl.${r}`);a.setAttribute("aria-label",o),a.firstElementChild&&a.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends d.E{constructor(a={}){super();const r=navigator.geolocation;this.options={geolocation:r,...Ma,...a},d.aV(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=zd(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(a){return this._map=a,this._container=ai("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){const r=(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=>r(o.state!=="denied")).catch(()=>r()):r()}_isOutOfMapMaxBounds(a){const r=this._map.getMaxBounds(),o=a.coords;return!!r&&(o.longitude<r.getWest()||o.longitude>r.getEast()||o.latitude<r.getSouth()||o.latitude>r.getNorth())}_setWatchState(a){this._watchState=a;const r=this._geolocateButton.classList;r.remove(...xu);for(const o of kp[a])r.add(yu(o))}_setButtonTitle(a){const r=this._map._getUIString(a);this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":this._setWatchState("ACTIVE_ERROR");break;case"BACKGROUND":this._setWatchState("BACKGROUND_ERROR")}}_onSuccess(a){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(a))return this._setErrorState(),this.fire(new d.h("outofmaxbounds",a)),this._updateMarker(),void this._finish();if(this._lastKnownPosition=a,this.options.trackUserLocation)switch(this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._setWatchState(this.options.followUserLocation?"ACTIVE_LOCK":"BACKGROUND");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._setWatchState("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 d.h("geolocate",{coords:a.coords,timestamp:a.timestamp,...a.toJSON?{toJSON:a.toJSON.bind(a)}:{}})),this._finish()}}_updateCamera(a){const r=new d.cz(a.coords.longitude,a.coords.latitude),o=a.coords.accuracy,u={bearing:this._map.getBearing(),...this.options.fitBoundsOptions};this._map.fitBounds(r.toBounds(o),u,{geolocateSource:!0})}_updateMarker(a){if(a){const r=new d.cz(a.coords.longitude,a.coords.latitude);this.options.showAccuracyCircle?this._accuracyCircleMarker.setLngLat(r).addTo(this._map):this._accuracyCircleMarker.remove(),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=a.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const a=this._map.transform,r=d.dw(1,a._center.lat)*a.worldSize,o=Math.ceil(2*this._accuracy*r);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(
vendor: 4,295 bytes, line 3422
3422a.code===1)this._setWatchState("OFF"),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable"),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 d.h("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();const 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){this._map!==void 0&&(this._container.addEventListener("contextmenu",r=>r.preventDefault()),this._geolocateButton=ai("button","mapboxgl-ctrl-geolocate",this._container),ai("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",a===!1?(d.w("Geolocation support is not available so the GeolocateControl will be disabled."),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable")):this._setButtonTitle("GeolocateControl.FindMyLocation"),this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._createUserLocationMarkers(),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",r=>{r.geolocateSource||this._watchState!=="ACTIVE_LOCK"||r.originalEvent&&r.originalEvent.type==="resize"||(this._setWatchState("BACKGROUND"),this.fire(new d.h("trackuserlocationend")))}),this.fire(new d.h("ready")))}_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 d.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._setWatchState("WAITING_ACTIVE"),this.fire(new d.h("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._setWatchState("OFF"),this.fire(new d.h("trackuserlocationend"));break;case"BACKGROUND":this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new d.h("trackuserlocationstart"))}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let a;this._geolocateButton.classList.add(yu("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??Ma.followUserLocation,this.options.trackUserLocation&&this._watchState!=="OFF"&&(this.options.followUserLocation?this._watchState!=="BACKGROUND"&&this._watchState!=="BACKGROUND_ERROR"||(this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new d.h("trackuserlocationstart"))):this._watchState!=="ACTIVE_LOCK"&&this._watchState!=="ACTIVE_E
3422RROR"||(this._setWatchState("BACKGROUND"),this.fire(new d.h("trackuserlocationend")))),this}setShowAccuracyCircle(a){if(this.options.showAccuracyCircle=a??Ma.showAccuracyCircle,!this._accuracyCircleMarker)return this;if(this.options.showAccuracyCircle){if(this.options.showUserLocation&&this._lastKnownPosition){const{longitude:r,latitude:o,accuracy:u}=this._lastKnownPosition.coords;this._accuracy=u,this._accuracyCircleMarker.setLngLat(new d.cz(r,o)).addTo(this._map),this._updateCircleRadius()}}else this._accuracyCircleMarker.remove();return this}setShowUserHeading(a){return this.options.showUserHeading=a??Ma.showUserHeading,this._setup?(this.options.showUserHeading?this._geolocationWatchID!==void 0&&this._addDeviceOrientationListener():(this._removeDeviceOrientationListener(),this._heading=void 0,this._userLocationDotMarker&&this._updateMarkerRotation()),this):this}setFitBoundsOptions(a){return this.options.fitBoundsOptions=a??Ma.fitBoundsOptions,this}setShowUserLocation(a){return this.options.showUserLocation=a??Ma.showUserLocation,this._setup?(this.options.showUserLocation?(this._userLocationDotMarker||(this._createUserLocationMarkers(),this._map.on("zoom",this._onZoom)),!this._lastKnownPosition||this._watchState!==void 0&&this._watchState==="OFF"||this._updateMarker(this._lastKnownPosition)):(this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this._accuracyCircleMarker&&this._accuracyCircleMarker.remove()),this):this}_addDeviceOrientationListener(){const a=()=>{const r="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(r,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(r=>{r==="granted"&&a()}).catch(console.error):a()}_removeDeviceOrientationListener(){window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation)}_createUserLocationMarkers(){this._dotElement=ai("div","mapboxgl-user-location"),this._dotElement.appendChild(ai("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(ai("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new bl({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=ai("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new bl({element:this._circleElement,pitchAlignment:"map"})}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),this._removeDeviceOrientationListener(),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(yu("waiting")),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Lp,ScaleControl:class{constructor(a={}){this.options={...Np,...a},d.aV(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const a=this.options.maxWidth||100,r=this._map,o=r._containerHeight/2,u=r._containerWidth/2-a/2,f=r.unproject([u,o]),m=r.unproject([u+a,o]),g=f.distanceTo(m);if(this.options.unit==="imperial"){const x=3.2808*g;x>5280?this._setScale(a,x/5280,"mile"):this._setScale(a,x,"foot")}else this.options.unit==="nautical"?this._setScale(a,g/1852,"nautical-mile"):g>=1e3?this._setScale(a,g/1e3,"kilometer"):this._setScale(a,g,"meter")}_setScale(a,r,o){this._map._requestDomTask(()=>{const u=function(m){const g=Math.pow(10,`${Math.floor(m)}`.length-1);let x=m/g;return x=x>=10?10:x>=5?5:x>=3?3:x>=2?2:x>=1?1:function(w){const E=Math.pow(10,Math.ceil(-Math.log(w)/Math.LN10));return Math.round(w*E)/E}(x),g*x}(r),f=u/r;this._container.innerHTML=o!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:o}).format(u):`${u}&nbsp;${Gd[o]}`,this._container.style.width=a*f+"px"})}onAdd(a){return this._map=a,this._language=a.getLanguage(),this._container=ai("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:d.w("Full screen control 'container' must be a DOM element.")),d.aV(["_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=ai("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",d.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(){const a=this._fullscreenButton=ai("button","mapboxgl-ctrl-fullscreen",this._controlContainer);ai("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(){const 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(){d.aV(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(a){return this._map=a,this._container=ai("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._map.on("idle",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const a=this._map.style.indoorManager;a.off("selector-update",this._onIndoorUpdate),a.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(a.getControlState()),this._map.off("idle",this._onStyleData)}}_createButton(a,r){const o=ai("button",a,this._container);return o.type="button",o.addEventListener("click",r),o}_setButtonTitle(a,r){a.setAttribute("aria-label",r),a.textContent=r}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.off("idle",this._onStyleData),this._map.style&&this._map.style.indoorManager&&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");const r=this._model;this._model=a,this._container.style.display="inline-block";const o=!r||r.floors.length!==a.floors.length||r.floors.some((u,f)=>u.id!==a.floors[f].id);if(o&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),a.selectedFloorId){if(a.selectedFloorId!==this._lastSelectedFloorId||o){const u=a.floors.findIndex(f=>f.id===a.selectedFloorId);if(u!==-1){const f=a.floors.length;let m,g;f<=5?(m=0,g=f-1):this._visibleFloorStart===0?(m=0,g=3):this._visibleFloorStart>=f-3?(m=f-3-1,g=f-1):(m=this._visibleFloorStart,g=this._visibleFloorStart+3-1),u<m?this._visibleFloorStart=u:u>g&&(this._visibleFloorStart=u-2)}}this._lastSelectedFloorId=a.selectedFloorId}this._render()}
vendor: 9,138 bytes, line 3422
3422_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const a=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);ai("span","mapboxgl-ctrl-icon",a).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||a.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(a);const r=this._model.floors,o=r.length;if(o<=5)return void r.forEach(g=>this._createFloorButton(g));const u=this._visibleFloorStart===0,f=this._visibleFloorStart>=o-3;if(u)this._createFloorButton(r[0]);else{const g=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);ai("span","mapboxgl-ctrl-icon",g).setAttribute("aria-hidden","true"),this._container.appendChild(g)}let m=[];if(m=u?r.slice(1,4):f?r.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):r.slice(this._visibleFloorStart,this._visibleFloorStart+3),m.forEach(g=>this._createFloorButton(g)),f)this._createFloorButton(r[o-1]);else{const g=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);ai("span","mapboxgl-ctrl-icon",g).setAttribute("aria-hidden","true"),this._container.appendChild(g)}}_createFloorButton(a){const r=this._createButton("mapboxgl-ctrl-level-button",()=>{const 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(),u=a.zIndex.toString(),f=o?Array.from(o).slice(0,3).join(""):u;this._setButtonTitle(r,f),this._model&&this._model.activeFloorsVisible&&a.id===this._model.selectedFloorId&&r.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(r)}_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);const a=this._model&&this._model.floors||[];if(a.length>3){const r=a.length-3;this._visibleFloorStart===r-1&&(this._visibleFloorStart=r-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){const 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 d.E{constructor(a){super(),this.options=Object.assign(Object.create(On),a),this._altitude=this.options.altitude,d.aV(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(a&&a.className?a.className.trim().split(Hd):[])}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 d.h("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const 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 d.h("close")),this}getLngLat(){return this._lngLat}setLngLat(a){this._lngLat=d.cz.convert(a),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._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();const 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){const r=document.createDocumentFragment(),o=document.createElement("body");let u;for(o.innerHTML=a;u=o.firstChild,u;)r.appendChild(u);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(a){return this.options.maxWidth=a,this._update(),this}setDOMContent(a){let r=this._content;if(r)for(;r.hasChildNodes();)r.firstChild&&r.removeChild(r.firstChild);else r=this._content=ai("div","mapboxgl-popup-content",this._container||void 0);if(r.appendChild(a),this.options.closeButton){const o=this._closeButton=ai("button","mapboxgl-popup-close-button",r);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 r;return this._classList.delete(a)?r=!1:(this._classList.add(a),r=!0),this._updateClassList(),r}_onMouseEvent(a){this._update(a.point)}_getAnchor(a){if(this.options.anchor)return this.options.anchor;const r=this._map,o=this._container,u=this._pos;if(!r||!o||!u)return"bottom";const f=o.offsetWidth,m=o.offsetHeight,g=u.x<f/2,x=u.x>r.transform.width-f/2;if(u.y+a<m)return g?"top-left":x?"top-right":"top";if(u.y>r.transform.height-m){if(g)return"bottom-left";if(x)return"bottom-right"}return g?"left":x?"right":"bottom"}_updateClassList(){const a=this._container;if(!a)return;const r=[...this._classList];r.push("mapboxgl-popup"),this._anchor&&r.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&r.push("mapboxgl-popup-track-pointer"),a.className=r.join(" ")}_update(a){const r=this._map,o=this._content;if(!r||!this._lngLat&&!this._trackPointer||!o)return;let u=this._container;if(u||(u=this._container=ai("div","mapboxgl-popup",r.getContainer()),this._tip=ai("div","mapboxgl-popup-tip",u),u.appendChild(o)),this.options.maxWidth&&u.style.maxWidth!==this.options.maxWidth&&(u.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=vl(this._lngLat,this._pos,r.transform)),!this._trackPointer||a){const f=this._pos=this._trackPointer&&a instanceof d.P?a:r.project(this._lngLat,this._altitude),m=Th(this.options.offset),g=this._anchor=this._getAnchor(m.y),x=Th(this.options.offset,g),w=f.add(x).round();r._requestDomTask(()=>{this._container&&g&&(this._container.style.transform=`${bh[g]} translate(${w.x}px,${w.y}px)`)})}if(!this._marker&&r._showingGlobe()){const f=d.f3(r.transform,this._lngLat)?0:1;this._setOpacity(f)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const a=this._container.querySelector(wl);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:bl,Style:fl,LngLat:d.cz,LngLatBounds:d.eC,Point:d.P,MercatorCoordinate:d.bS,FreeCameraOptions:d.f9,Evented:d.E,config:d.eM,prewarm:function(){Qh().acquire(gt)},clearPrewarmedResources:function(){const a=ic;a&&(a.isPreloaded()&&a.numActive()===1?(a.release(gt),ic=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 d.eM.ACCESS_TOKEN},set accessToken(a){d.fn(a)},get baseApiUrl(){return d.eM.API_URL},set baseApiUrl(a){d.fm(a)},get workerCount(){return at.workerCount},set workerCount(a){(function(r){at.workerCount=r})(a)},get maxParallelImageRequests(){return d.eM.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(a){d.fl(a)},clearStorage(a){d.fk(a)},get workerUrl(){return nt.workerUrl},set workerUrl(a){nt.workerUrl=a},get workerClass(){return nt.workerClass},set workerClass(a){nt.workerClass=a},get dracoUrl(){return d.fj()},set dracoUrl(a){d.fi(a)},get meshoptUrl(){return d.fh()},set meshoptUrl(a){d.fg(a)},get buildingGenUrl(){return d.ff()},set buildingGenUrl(a){d.fe(a)},setNow:d.e.setNow,restoreNow:d.e.restoreNow}});var Db=u_;return Db})})(Mb);var US=Mb.exports;const jS=NS(US),ZS=Object.freeze(Object.defineProperty({__proto__:null,default:jS},Symbol.toStringTag,{value:"Module"}));export{ZS as m};

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.