vendor: 13,537 bytes, line 1
1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3858],{19423:function(t){t.exports=function(){let t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w,T,E,S,I,A,C,M,R,D,P,z,L,O,F,B,k,N,V,U,j,G,H,q,Z,$,W,X,Y,K,Q,J,ee,et={antialias:!1,alpha:!0,stencil:!0,depth:!0};function ei(t){let i,r=document.createElement("canvas"),a=Object.create(et);a.failIfMajorPerformanceCaveat=t;let n=r.getContext("webgl2",a);if(!n)return!1;try{i=n.createShader(n.VERTEX_SHADER)}catch(t){return!1}return!(!i||n.isContextLost())&&(n.shaderSource(i,"void main() {}"),n.compileShader(i),!0===n.getShaderParameter(i,n.COMPILE_STATUS))}var er="3.26.0",ea="undefined"!=typeof Float32Array?Float32Array:Array;function en(t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=r*o-n*a;return s?(t[0]=o*(s=1/s),t[1]=-a*s,t[2]=-n*s,t[3]=r*s,t):null}function eo(){var t=new ea(9);return ea!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function es(t,i){return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[4],t[4]=i[5],t[5]=i[6],t[6]=i[8],t[7]=i[9],t[8]=i[10],t}function el(t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=i[4],l=i[5],h=i[6],u=i[7],c=i[8];return t[0]=s*c-l*u,t[1]=n*u-a*c,t[2]=a*l-n*s,t[3]=l*h-o*c,t[4]=r*c-n*h,t[5]=n*o-r*l,t[6]=o*u-s*h,t[7]=a*h-r*u,t[8]=r*s-a*o,t}function eh(t,i,r){var a=i[0],n=i[1],o=i[2],s=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],p=r[0],f=r[1],_=r[2],m=r[3],g=r[4],y=r[5],x=r[6],v=r[7],b=r[8];return t[0]=p*a+f*s+_*u,t[1]=p*n+f*l+_*c,t[2]=p*o+f*h+_*d,t[3]=m*a+g*s+y*u,t[4]=m*n+g*l+y*c,t[5]=m*o+g*h+y*d,t[6]=x*a+v*s+b*u,t[7]=x*n+v*l+b*c,t[8]=x*o+v*h+b*d,t}function eu(t,i){var r=Math.sin(i),a=Math.cos(i);return t[0]=a,t[1]=r,t[2]=0,t[3]=-r,t[4]=a,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function ec(){var t=new ea(16);return ea!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function ed(t){var i=new ea(16);return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],i}function ep(t,i){return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t}function ef(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function e_(t,i){if(t===i){var r=i[1],a=i[2],n=i[3],o=i[6],s=i[7],l=i[11];t[1]=i[4],t[2]=i[8],t[3]=i[12],t[4]=r,t[6]=i[9],t[7]=i[13],t[8]=a,t[9]=o,t[11]=i[14],t[12]=n,t[13]=s,t[14]=l}else t[0]=i[0],t[1]=i[4],t[2]=i[8],t[3]=i[12],t[4]=i[1],t[5]=i[5],t[6]=i[9],t[7]=i[13],t[8]=i[2],t[9]=i[6],t[10]=i[10],t[11]=i[14],t[12]=i[3],t[13]=i[7],t[14]=i[11],t[15]=i[15];return t}function em(t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=i[4],l=i[5],h=i[6],u=i[7],c=i[8],d=i[9],p=i[10],f=i[11],_=i[12],m=i[13],g=i[14],y=i[15],x=r*l-a*s,v=r*h-n*s,b=r*u-o*s,w=a*h-n*l,T=a*u-o*l,E=n*u-o*h,S=c*m-d*_,I=c*g-p*_,A=c*y-f*_,C=d*g-p*m,M=d*y-f*m,R=p*y-f*g,D=x*R-v*M+b*C+w*A-T*I+E*S;return D?(t[0]=(l*R-h*M+u*C)*(D=1/D),t[1]=(n*M-a*R-o*C)*D,t[2]=(m*E-g*T+y*w)*D,t[3]=(p*T-d*E-f*w)*D,t[4]=(h*A-s*R-u*I)*D,t[5]=(r*R-n*A+o*I)*D,t[6]=(g*b-_*E-y*v)*D,t[7]=(c*E-p*b+f*v)*D,t[8]=(s*M-l*A+u*S)*D,t[9]=(a*A-r*M-o*S)*D,t[10]=(_*T-m*b+y*x)*D,t[11]=(d*b-c*T-f*x)*D,t[12]=(l*I-s*C-h*S)*D,t[13]=(r*C-a*I+n*S)*D,t[14]=(m*v-_*w-g*x)*D,t[15]=(c*w-d*v+p*x)*D,t):null}function eg(t,i,r){var a=i[0],n=i[1],o=i[2],s=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],p=i[9],f=i[10],_=i[11],m=i[12],g=i[13],y=i[14],x=i[15],v=r[0],b=r[1],w=r[2],T=r[3];return t[0]=v*a+b*l+w*d+T*m,t[1]=v*n+b*h+w*p+T*g,t[2]=v*o+b*u+w*f+T*y,t[3]=v*s+b*c+w*_+T*x,t[4]=(v=r[4])*a+(b=r[5])*l+(w=r[6])*d+(T=r[7])*m,t[5]=v*n+b*h+w*p+T*g,t[6]=v*o+b*u+w*f+T*y,t[7]=v*s+b*c+w*_+T*x,t[8]=(v=r[8])*a+(b=r[9])*l+(w=r[10])*d+(T=r[11])*m,t[9]=v*n+b*h+w*p+T*g,t[10]=v*o+b*u+w*f+T*y,t[11]=v*s+b*c+w*_+T*x,t[12]=(v=r[12])*a+(b=r[13])*l+(w=r[14])*d+(T=r[15])*m,t[13]=v*n+b*h+w*p+T*g,t[14]=v*o+b*u+w*f+T*y,t[15]=v*s+b*c+w*_+T*x,t}function ey(t,i,r){var a,n,o,s,l,h,u,c,d,p,f,_,m=r[0],g=r[1],y=r[2];return i===t?(t[12]=i[0]*m+i[4]*g+i[8]*y+i[12],t[13]=i[1]*m+i[5]*g+i[9]*y+i[13],t[14]=i[2]*m+i[6]*g+i[10]*y+i[14],t[15]=i[3]*m+i[7]*g+i[11]*y+i[15]):(n=i[1],o=i[2],s=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],p=i[9],f=i[10],_=i[11],t[0]=a=i[0],t[1]=n,t[2]=o,t[3]=s,t[4]=l,t[5]=h,t[6]=u,t[7]=c,t[8]=d,t[9]=p,t[10]=f,t[11]=_,t[12]=a*m+l*g+d*y+i[12],t[13]=n*m+h*g+p*y+i[13],t[14]=o*m+u*g+f*y+i[14],t[15]=s*m+c*g+_*y+i[15]),t}function ex(t,i,r){var a=r[0],n=r[1],o=r[2];return t[0]=i[0]*a,t[1]=i[1]*a,t[2]=i[2]*a,t[3]=i[3]*a,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=i[7]*n,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=i[11]*o,t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],t}function ev(t,i,r){var a=Math.sin(r),n=Math.cos(r),o=i[4],s=i[5],l=i[6],h=i[7],u=i[8],c=i[9],d=i[10],p=i[11];return i!==t&&(t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15]),t[4]=o*n+u*a,t[5]=s*n+c*a,t[6]=l*n+d*a,t[7]=h*n+p*a,t[8]=u*n-o*a,t[9]=c*n-s*a,t[10]=d*n-l*a,t[11]=p*n-h*a,t}function eb(t,i,r){var a=Math.sin(r),n=Math.cos(r),o=i[0],s=i[1],l=i[2],h=i[3],u=i[8],c=i[9],d=i[10],p=i[11];return i!==t&&(t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15]),t[0]=o*n-u*a,t[1]=s*n-c*a,t[2]=l*n-d*a,t[3]=h*n-p*a,t[8]=o*a+u*n,t[9]=s*a+c*n,t[10]=l*a+d*n,t[11]=h*a+p*n,t}function ew(t,i,r){var a=Math.sin(r),n=Math.cos(r),o=i[0],s=i[1],l=i[2],h=i[3],u=i[4],c=i[5],d=i[6],p=i[7];return i!==t&&(t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15]),t[0]=o*n+u*a,t[1]=s*n+c*a,t[2]=l*n+d*a,t[3]=h*n+p*a,t[4]=u*n-o*a,t[5]=c*n-s*a,t[6]=d*n-l*a,t[7]=p*n-h*a,t}function eT(t,i){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=i[0],t[13]=i[1],t[14]=i[2],t[15]=1,t}function eE(t,i){return t[0]=i[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=i[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function eS(t,i,r){var a,n,o,s=r[0],l=r[1],h=r[2],u=Math.sqrt(s*s+l*l+h*h);return u<1e-6?null:(s*=u=1/u,l*=u,h*=u,a=Math.sin(i),n=Math.cos(i),t[0]=s*s*(o=1-n)+n,t[1]=l*s*o+h*a,t[2]=h*s*o-l*a,t[3]=0,t[4]=s*l*o-h*a,t[5]=l*l*o+n,t[6]=h*l*o+s*a,t[7]=0,t[8]=s*h*o+l*a,t[9]=l*h*o-s*a,t[10]=h*h*o+n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function eI(t,i){var r=Math.sin(i),a=Math.cos(i);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function eA(t,i){var r=Math.sin(i),a=Math.cos(i);return t[0]=a,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function eC(t,i){var r=i[0],a=i[1],n=i[2],o=i[4],s=i[5],l=i[6],h=i[8],u=i[9],c=i[10];return t[0]=Math.sqrt(r*r+a*a+n*n),t[1]=Math.sqrt(o*o+s*s+l*l),t[2]=Math.sqrt(h*h+u*u+c*c),t}function eM(t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=r+r,l=a+a,h=n+n,u=r*s,c=a*s,d=a*l,p=n*s,f=n*l,_=n*h,m=o*s,g=o*l,y=o*h;return t[0]=1-d-_,t[1]=c+y,t[2]=p-g,t[3]=0,t[4]=c-y,t[5]=1-u-_,t[6]=f+m,t[7]=0,t[8]=p+g,t[9]=f-m,t[10]=1-u-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}var eR=function(t,i,r,a,n){var o=1/Math.tan(i/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=n&&n!==1/0){var s=1/(a-n);t[10]=(n+a)*s,t[14]=2*n*a*s}else t[10]=-1,t[14]=-2*a;return t},eD=function(t,i,r,a,n,o,s){var l=1/(i-r),h=1/(a-n),u=1/(o-s);return t[0]=-2*l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(i+r)*l,t[13]=(n+a)*h,t[14]=(s+o)*u,t[15]=1,t};function eP(){var t=new ea(3);return ea!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function ez(t){var i=new ea(3);return i[0]=t[0],i[1]=t[1],i[2]=t[2],i}function eL(t){var i=t[0],r=t[1],a=t[2];return Math.sqrt(i*i+r*r+a*a)}function eO(t,i,r){var a=new ea(3);return a[0]=t,a[1]=i,a[2]=r,a}function eF(t,i,r,a){return t[0]=i,t[1]=r,t[2]=a,t}function eB(t,i,r){return t[0]=i[0]+r[0],t[1]=i[1]+r[1],t[2]=i[2]+r[2],t}function ek(t,i,r){return t[0]=i[0]-r[0],t[1]=i[1]-r[1],t[2]=i[2]-r[2],t}function eN(t,i,r){return t[0]=i[0]*r[0],t[1]=i[1]*r[1],t[2]=i[2]*r[2],t}function eV(t,i,r){return t[0]=Math.min(i[0],r[0]),t[1]=Math.min(i[1],r[1]),t[2]=Math.min(i[2],r[2]),t}function eU(t,i,r){return t[0]=Math.max(i[0],r[0]),t[1]=Math.max(i[1],r[1]),t[2]=Math.max(i[2],r[2]),t}function ej(t,i,r){return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t}function eG(t,i,r,a){return t[0]=i[0]+r[0]*a,t[1]=i[1]+r[1]*a,t[2]=i[2]+r[2]*a,t}function eH(t,i){var r=i[0]-t[0],a=i[1]-t[1],n=i[2]-t[2];return Math.sqrt(r*r+a*a+n*n)}function eq(t,i){var r=i[0]-t[0],a=i[1]-t[1],n=i[2]-t[2];return r*r+a*a+n*n}function eZ(t){var i=t[0],r=t[1],a=t[2];return i*i+r*r+a*a}function e$(t,i){return t[0]=-i[0],t[1]=-i[1],t[2]=-i[2],t}function eW(t,i){var r=i[0],a=i[1],n=i[2],o=r*r+a*a+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=i[0]*o,t[1]=i[1]*o,t[2]=i[2]*o,t}function eX(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]}function eY(t,i,r){var a=i[0],n=i[1],o=i[2],s=r[0],l=r[1],h=r[2];return t[0]=n*h-o*l,t[1]=o*s-a*h,t[2]=a*l-n*s,t}function eK(t,i,r,a){var n=i[0],o=i[1],s=i[2];return t[0]=n+a*(r[0]-n),t[1]=o+a*(r[1]-o),t[2]=s+a*(r[2]-s),t}function eQ(t,i,r){var a=i[0],n=i[1],o=i[2],s=r[3]*a+r[7]*n+r[11]*o+r[15];return t[0]=(r[0]*a+r[4]*n+r[8]*o+r[12])/(s=s||1),t[1]=(r[1]*a+r[5]*n+r[9]*o+r[13])/s,t[2]=(r[2]*a+r[6]*n+r[10]*o+r[14])/s,t}function eJ(t,i,r){var a=i[0],n=i[1],o=i[2];return t[0]=a*r[0]+n*r[3]+o*r[6],t[1]=a*r[1]+n*r[4]+o*r[7],t[2]=a*r[2]+n*r[5]+o*r[8],t}function e0(t,i,r){var a=r[0],n=r[1],o=r[2],s=r[3],l=i[0],h=i[1],u=i[2],c=n*u-o*h,d=o*l-a*u,p=a*h-n*l;return t[0]=l+s*(c+=c)+n*(p+=p)-o*(d+=d),t[1]=h+s*d+o*c-a*p,t[2]=u+s*p+a*d-n*c,t}function e1(t){return t[0]=0,t[1]=0,t[2]=0,t}function e2(t,i){return t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]}var e3=function(t,i,r){return t[0]=i[0]/r[0],t[1]=i[1]/r[1],t[2]=i[2]/r[2],t};function e4(){var t=new ea(4);return ea!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function e5(t,i,r,a){var n=new ea(4);return n[0]=t,n[1]=i,n[2]=r,n[3]=a,n}function e6(t,i,r){return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=i[3]*r,t}function e8(t,i){var r=i[0],a=i[1],n=i[2],o=i[3],s=r*r+a*a+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=a*s,t[2]=n*s,t[3]=o*s,t}function e9(t,i,r){var a=i[0],n=i[1],o=i[2],s=i[3];return t[0]=r[0]*a+r[4]*n+r[8]*o+r[12]*s,t[1]=r[1]*a+r[5]*n+r[9]*o+r[13]*s,t[2]=r[2]*a+r[6]*n+r[10]*o+r[14]*s,t[3]=r[3]*a+r[7]*n+r[11]*o+r[15]*s,t}function e7(){var t=new ea(4);return ea!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function te(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function tt(t,i,r){r*=.5;var a=i[0],n=i[1],o=i[2],s=i[3],l=Math.sin(r),h=Math.cos(r);return t[0]=a*h+s*l,t[1]=n*h+o*l,t[2]=o*h-n*l,t[3]=s*h-a*l,t}function ti(t,i,r){r*=.5;var a=i[0],n=i[1],o=i[2],s=i[3],l=Math.sin(r),h=Math.cos(r);return t[0]=a*h-o*l,t[1]=n*h+s*l,t[2]=o*h+a*l,t[3]=s*h-n*l,t}function tr(t,i,r){r*=.5;var a=i[0],n=i[1],o=i[2],s=i[3],l=Math.sin(r),h=Math.cos(r);return t[0]=a*h+n*l,t[1]=n*h-a*l,t[2]=o*h+s*l,t[3]=s*h-o*l,t}eP(),e4();var ta,tn,to,ts=(ta=eP(),tn=eO(1,0,0),to=eO(0,1,0),function(t,i,r){var a,n,o=eX(i,r);return o<-.999999?(eY(ta,tn,i),1e-6>eL(ta)&&eY(ta,to,i),eW(ta,ta),n=Math.sin(a=.5*Math.PI),t[0]=n*ta[0],t[1]=n*ta[1],t[2]=n*ta[2],t[3]=Math.cos(a),t):o>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(eY(ta,i,r),t[0]=ta[0],t[1]=ta[1],t[2]=ta[2],t[3]=1+o,e8(t,t))});function tl(){var t=new ea(2);return ea!=Float32Array&&(t[0]=0,t[1]=0),t}function th(t,i){var r=new ea(2);return r[0]=t,r[1]=i,r}function tu(t,i,r){return t[0]=i[0]+r[0],t[1]=i[1]+r[1],t}function tc(t,i,r){return t[0]=i[0]-r[0],t[1]=i[1]-r[1],t}function td(t,i,r){return t[0]=i[0]*r,t[1]=i[1]*r,t}function tp(t){var i=t[0],r=t[1];return Math.sqrt(i*i+r*r)}function tf(t,i){var r=i[0],a=i[1],n=r*r+a*a;return n>0&&(n=1/Math.sqrt(n)),t[0]=i[0]*n,t[1]=i[1]*n,t}function t_(t,i){return t[0]*i[0]+t[1]*i[1]}function tm(t,i,r,a){let n=3*t,o=3*(r-t)-n,s=1-n-o,l=3*i,h=3*(a-i)-l,u=1-l-h;return function(t,i=1e-6){if(t<=0)return 0;if(t>=1)return 1;let r=t;for(let a=0;a<8;a++){let a=((s*r+o)*r+n)*r-t;if(Math.abs(a)<i)return((u*r+h)*r+l)*r;let c=(3*s*r+2*o)*r+n;if(1e-6>Math.abs(c))break;r-=a/c}let a=0,c=1;r=t;for(let l=0;l<20;l++){let l=((s*r+o)*r+n)*r;if(Math.abs(l-t)<i)break;t>l?a=r:c=r,r=.5*(a+c)}return((u*r+h)*r+l)*r}}function tg(t,i){this.x=t,this.y=i}function ty(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let r=0;r<t.length;r++)if(!ty(t[r],i[r]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==i){if("object"!=typeof i||Object.keys(t).length!==Object.keys(i).length)return!1;for(let r in t)if(!ty(t[r],i[r]))return!1;return!0}return t===i}function tx(t,i,r){let a=t[i];t[i]=t[r],t[r]=a}e7(),e7(),eo();function tv(t,i){return i.area-t.area}function tb(t,i){let r,a,n=t.length;if(n<=1)return[t];let o=[];for(let i=0;i<n;i++){let n=function(t){let i=0;for(let r,a,n=0,o=t.length,s=o-1;n<o;s=n++)r=t[n],i+=((a=t[s]).x-r.x)*(r.y+a.y);return i}(t[i]);0!==n&&(t[i].area=Math.abs(n),void 0===a&&(a=n<0),a===n<0?(r&&o.push(r),r=[t[i]]):r.push(t[i]))}if(r&&o.push(r),i>1)for(let t=0;t<o.length;t++){let r=o[t];r.length<=i||(function t(i,r,a=0,n=i.length-1,o=function(t,i){return t<i?-1:+(t>i)}){for(;n>a;){if(n-a>600){let s=n-a+1,l=r-a+1,h=Math.log(s),u=.5*Math.exp(2*h/3),c=.5*Math.sqrt(h*u*(s-u)/s)*(l-s/2<0?-1:1);t(i,r,Math.max(a,Math.floor(r-l*u/s+c)),Math.min(n,Math.floor(r+(s-l)*u/s+c)),o)}let s=i[r],l=a,h=n;for(tx(i,a,r),o(i[n],s)>0&&tx(i,a,n);l<h;
1){for(tx(i,l,h),l++,h--;0>o(i[l],s);)l++;for(;o(i[h],s)>0;)h--}0===o(i[a],s)?tx(i,a,h):tx(i,++h,n),h<=r&&(a=h+1),r<=h&&(n=h-1)}}(r,i,1,r.length-1,tv),o[t]=r.slice(0,i))}return o}function tw(t,i){t[0]=Math.min(t[0],i[0]),t[1]=Math.min(t[1],i[1]),t[2]=Math.max(t[2],i[0]),t[3]=Math.max(t[3],i[1])}function tT(t,i){return!(t[0]<=i[0]||t[2]>=i[2]||t[1]<=i[1]||t[3]>=i[3])}function tE(t,i,r=!1){let a=!1;for(let n=0,o=i.length;n<o;n++){let o=i[n];for(let i=0,n=o.length,s=n-1;i<n;s=i++){let n=o[s],l=o[i];if(function(t,i,r){let a=t[0]-i[0],n=t[1]-i[1],o=t[0]-r[0],s=t[1]-r[1];return a*s-o*n==0&&a*o<=0&&n*s<=0}(t,n,l))return r;n[1]>t[1]!=l[1]>t[1]&&t[0]<(l[0]-n[0])*(t[1]-n[1])/(l[1]-n[1])+n[0]&&(a=!a)}}return a}function tS(t,i,r,a){let n=a[0]-r[0],o=a[1]-r[1],s=(t[0]-r[0])*o-n*(t[1]-r[1]),l=(i[0]-r[0])*o-n*(i[1]-r[1]);return s>0&&l<0||s<0&&l>0}function tI(t,i,r,a){var n,o;return 0!=(n=[a[0]-r[0],a[1]-r[1]])[0]*(o=[i[0]-t[0],i[1]-t[1]])[1]-n[1]*o[0]&&!(!tS(t,i,r,a)||!tS(r,a,t,i))}tl(),tg.prototype={clone(){return new tg(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,i){return this.clone()._rotateAround(t,i)},matMult(t){return this.clone()._matMult(t)},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(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){let i=t.x-this.x,r=t.y-this.y;return i*i+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,i){return Math.atan2(this.x*i-this.y*t,this.x*t+this.y*i)},_matMult(t){let i=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=i,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){let t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){let i=Math.cos(t),r=Math.sin(t),a=r*this.x+i*this.y;return this.x=i*this.x-r*this.y,this.y=a,this},_rotateAround(t,i){let r=Math.cos(t),a=Math.sin(t),n=i.y+a*(this.x-i.x)+r*(this.y-i.y);return this.x=i.x+r*(this.x-i.x)-a*(this.y-i.y),this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:tg},tg.convert=function(t){if(t instanceof tg)return t;if(Array.isArray(t))return new tg(+t[0],+t[1]);if(void 0!==t.x&&void 0!==t.y)return new tg(+t.x,+t.y);throw Error("Expected [x, y] or {x, y} point format")};let tA=Math.PI/180,tC=180/Math.PI,tM=/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,tR=[[0,0],[1,0],[1,1],[0,1]];function tD(t){if(t<=0)return 0;if(t>=1)return 1;let i=t*t,r=i*t;return 4*(t<.5?r:3*(t-i)+r-.75)}function tP(t,i,r=0,a=!0){let n=new tg(r,r),o=t.sub(n),s=i.add(n),l=[o,new tg(s.x,o.y),s,new tg(o.x,s.y)];return a&&l.push(o.clone()),l}let tz=tm(.25,.1,.25,1);function tL(t,i,r){return Math.min(r,Math.max(i,t))}function tO(t,i,r){return(r=tL((r-t)/(i-t),0,1))*r*(3-2*r)}function tF(t,i,r){let a=r-i,n=((t-i)%a+a)%a+i;return n===i?r:n}function tB(t,i,r){if(!t.length)return r(null,[]);let a=t.length,n=Array(t.length),o=null;t.forEach((t,s)=>{i(t,(t,i)=>{t&&(o=t),n[s]=i,0==--a&&r(o,n)})})}function tk(t,i){let r={};for(let a=0;a<i.length;a++){let n=i[a];n in t&&(r[n]=t[n])}return r}let tN=1;function tV(){return function t(i){return i?(i^Math.random()*(16>>i/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function tU(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log2(t)))}function tj(t){return!!t&&tM.test(t)}function tG(t,i){t.forEach(t=>{i[t]&&(i[t]=i[t].bind(i))})}function tH(t,i,r){let a={};for(let r in t)a[r]=i.call(this,t[r],r,t);return a}function tq(t,i,r){let a={};for(let r in t)i.call(this,t[r],r,t)&&(a[r]=t[r]);return a}function tZ(t){return Array.isArray(t)?t.map(tZ):"object"==typeof t&&t?tH(t,tZ):t}function t$(t,i){for(let r=0;r<t.length;r++)if(i.includes(t[r]))return!0;return!1}let tW={};function tX(t){tW[t]||("undefined"!=typeof console&&console.warn(t),tW[t]=!0)}function tY(t,i,r){return(r.y-t.y)*(i.x-t.x)>(i.y-t.y)*(r.x-t.x)}function tK([t,i,r]){let a=(i+90)*tA,n=r*tA;return{x:t*Math.cos(a)*Math.sin(n),y:t*Math.sin(a)*Math.sin(n),z:t*Math.cos(n),azimuthal:i,polar:r}}function tQ(t,i,r){let a=Math.sqrt(t*t+i*i+r*r),n=a>0?Math.acos(r/a)*tC:0,o=0!==t||0!==i?Math.atan2(-i,-t)*tC+90:0;return o<0&&(o+=360),[a,o,n]}function tJ(t){return("undefined"!=typeof self||void 0!==t)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==t?t:self)instanceof WorkerGlobalScope}function t0(t){let i={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(t,r,a,n)=>{let o=a||n;return i[r]=!o||o.toLowerCase(),""}),i["max-age"]){let t=parseInt(i["max-age"],10);isNaN(t)?delete i["max-age"]:i["max-age"]=t}return i}function t1(t){return t?{cacheControl:t.get("cache-control"),expires:t.get("expires")}
1:{cacheControl:void 0,expires:void 0}}function t2(){return!!document.fullscreenElement||!!document.webkitFullscreenElement}function t3(t){try{let i=self[t];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function t4(t,i){return[t[4*i],t[4*i+1],t[4*i+2],t[4*i+3]]}function t5(t,i,r){t[4*i+0]=r[0],t[4*i+1]=r[1],t[4*i+2]=r[2],t[4*i+3]=r[3]}function t6(t,i){return[Math.pow(t[0],2.2)*i,Math.pow(t[1],2.2)*i,Math.pow(t[2],2.2)*i]}function t8(t){return[Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]}function t9(t,i,r,a){for(;i<r;){let n=i+r>>1;t[n]<a?i=n+1:r=n}return i}function t7(t,i,r,a){for(;i<r;){let n=i+r>>1;t[n]<=a?i=n+1:r=n}return i}function ie(t){return t>0?1/(1.001-t):1+t}function it(t){return t>0?1-1/(1.001-t):-t}function ii(t,i,r){return(t-i.min)*(r.max-r.min)/(i.max-i.min)+r.min}function ir(t){return t*t*t*t*t}function ia(t){return t>>>=0,(t=Math.imul((t=Math.imul((t=Math.imul(0xa3c59ac3^t,0x9e3779b9)>>>0)^t>>>16,0x9e3779b9)>>>0)^t>>>16,0x9e3779b9)>>>0)/0x100000000}function io(){return null==r&&(r=self.OffscreenCanvas&&!!new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),r}let is={requestIdleCallback:t=>{if("undefined"!=typeof requestIdleCallback)return requestIdleCallback(t);setTimeout(()=>t({didTimeout:!1,timeRemaining:()=>50}),0)},now:()=>void 0!==o?o:performance.now(),setNow(t){o=t},restoreNow(){o=void 0},frame(t){let i=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(i)}},getImageData(t,i=0){let{width:r,height:a}=t;s||(s=document.createElement("canvas"));let n=s.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("failed to create canvas 2d context");return(r>s.width||a>s.height)&&(s.width=r,s.height=a),n.clearRect(-i,-i,r+2*i,a+2*i),n.drawImage(t,0,0,r,a),n.getImageData(-i,-i,r+2*i,a+2*i)},resolveURL:t=>(a||(a=document.createElement("a")),a.href=t,a.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==n&&(n=window.matchMedia("(prefers-reduced-motion: reduce)")),n.matches)},hasCanvasFingerprintNoise(){if(void 0!==l)return l;if(!io())return l=!1,!1;let t=new OffscreenCanvas(85,1),i=t.getContext("2d",{willReadFrequently:!0}),r=0;for(let a=0;a<t.width;++a)i.fillStyle=`rgba(${r++},${r++},${r++}, 255)`,i.fillRect(a,0,1,1);let a=i.getImageData(0,0,t.width,t.height);r=0;for(let t=0;t<a.data.length;++t)if(t%4!=3&&r++!==a.data[t])return l=!0,!0;return l=!1,!1}},il=/firefox/i,ih=/macintosh/i;function iu(t,i,r){let a=document.createElement(t);return null!=i&&(a.className=i),r&&r.appendChild(a),a}function ic(t,i,r){let a=document.createElementNS("http://www.w3.org/2000/svg",t);for(let t of Object.keys(i))a.setAttributeNS(null,t,String(i[t]));return r&&r.appendChild(a),a}let id="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,ip=id&&void 0!==id.userSelect?"userSelect":"WebkitUserSelect";function i_(){id&&ip&&(h=id[ip],id[ip]="none")}function im(){id&&ip&&(id[ip]=h)}function ig(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",ig,!0)}function iy(){window.addEventListener("click",ig,!0),window.setTimeout(()=>{window.removeEventListener("click",ig,!0)},0)}function ix(t,i){let r=t.getBoundingClientRect();return iw(t,r,i)}function iv(t,i){let r=t.getBoundingClientRect(),a=[];for(let n=0;n<i.length;n++)a.push(iw(t,r,i[n]));return a}function ib(t){return il.test(navigator.userAgent)&&ih.test(navigator.userAgent)&&2===t.button&&t.ctrlKey?0:t.button}function iw(t,i,r){let a=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new tg((r.clientX-i.left)*a,(r.clientY-i.top)*a)}let iT={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(!iT.API_URL)return null;try{let t=new URL(iT.API_URL);return"api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){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",MES
1HOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/plugins/mapbox-gl-pmtiles-provider/v0.0.2/mapbox-gl-pmtiles-provider.js"})};function iE(){return new URL(iT.DRACO_URL,iT.API_URL).href}function iS(){if("object"!=typeof WebAssembly)throw Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(!function(){if(void 0===u){if("object"!=typeof WebAssembly)return!1;let t=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]);u=WebAssembly.validate(t)}return u}()?iT.MESHOPT_URL:iT.MESHOPT_SIMD_URL,iT.API_URL).href}function iI(){return new URL(iT.BUILDING_GEN_URL,iT.API_URL).href}let iA={supported:!1,testSupport:function(t){!iR&&iM&&(iD?iz(t):iC=t)}},iC,iM,iR=!1,iD=!1,iP="undefined"!=typeof self?self:{};function iz(t){let i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,iM),t.isContextLost())return;iA.supported=!0}
1catch(t){}t.deleteTexture(i),iR=!0}function iL(t,i){let r=t.indexOf("?");if(r<0)return`${t}?${new URLSearchParams(i).toString()}`;let a=new URLSearchParams(t.slice(r));for(let t in i)a.set(t,i[t]);return`${t.slice(0,r)}?${a.toString()}`}function iO(t,i={persistentParams:[]}){let r=t.indexOf("?");if(r<0)return t;let a=new URLSearchParams,n=new URLSearchParams(t.slice(r));for(let t of i.persistentParams){let i=n.get(t);i&&a.set(t,i)}let o=a.toString();return`${t.slice(0,r)}${o.length>0?`?${o}`:""}`}iP.document&&((iM=iP.document.createElement("img")).onload=function(){iC&&iz(iC),iC=null,iD=!0},iM.onerror=function(){iR=!0,iC=null},iM.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");let iF="mapbox-tiles",iB=500,ik=50,iN=["language","worldview","jobid"];function iV(){try{return caches}catch(t){}}function iU(){let t=iV();t&&null==c&&(c=t.open(iF))}let ij=1/0;function iG(t){++ij>ik&&(t.getActor().notify("enforceCacheSizeLimit",iB),ij=0)}function iH(t){return iT.API_URL_REGEX.test(t)}function iq(t){return 0===t.indexOf("mapbox:")}function iZ(t){return iT.API_CDN_URL_REGEX.test(t)}function i$(t){return iT.API_SPRITE_REGEX.test(t)}function iW(t){return iT.API_STYLE_REGEX.test(t)&&!i$(t)}let iX={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(iX);class iY extends Error{constructor(t,i,r){super(),this.url=r,this.statusText=t,this.status=i}get message(){return 401===this.status&&iH(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 iK(t){return"object"==typeof t&&null!==t&&"status"in t&&404===t.status}let iQ=tJ()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,iJ=/^\w+:/,i0=/[\r\n]+/;async function i1(t,i){return{data:"arrayBuffer"===t.type?await i.arrayBuffer():"json"===t.type?await i.json():await i.text(),headers:i.headers}}async function i2(t,i){var r;return i&&i.throwIfAborted(),(r=t.url).startsWith("file:")||iQ().startsWith("file:")&&!iJ.test(r)?async function(t,i){return new Promise((r,a)=>{let n=new XMLHttpRequest,o=()=>{i.removeEventListener("abort",o),n.abort(),a(i.reason)};for(let r in i&&i.addEventListener("abort",o),n.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(n.responseType="arraybuffer"),t.headers)n.setRequestHeader(r,t.headers[r]);"json"===t.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===t.credentials,n.onerror=()=>{i&&i.removeEventListener("abort",o),a(Error(n.statusText))},n.onload=()=>{if(i&&i.removeEventListener("abort",o),(n.status>=200&&n.status<300||0===n.status)&&null!==n.response){let i=n.response;if("json"===t.type)try{i=JSON.parse(n.response)}catch(t){return void a(t)}let o=new Headers;n.getAllResponseHeaders().trim().split(i0).forEach(t=>{let i=t.split(": "),r=i.shift(),a=i.join(": ");r&&o.set(r,a)}),r({data:i,headers:o})}else a(new iY(n.statusText,n.status,t.url))},n.send(t.body)})}(t,i):async function(t,i){var r;let a,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:iQ(),referrerPolicy:t.referrerPolicy,signal:i}),o=(r=n.url).indexOf("sku=")>0&&iH(r);if("json"===t.type&&n.headers.set("Accept","application/json"),o){let r=null;try{r=await async function(t){if(iU(),null==c)return null;
1let i=await c,r=iO(t.url,{persistentParams:iN}),a=t.headers.get("Range");a&&(r=iL(r,{range:a}));let n=await i.match(r);if(!n)return null;let o=function(t){if(!t)return!1;let i=new Date(t.headers.get("expires")||0),r=t0(t.headers.get("cache-control")||"");return Number(i)>Date.now()&&!r["no-cache"]}(n);return i.delete(r).catch(t=>tX(t.message)),o&&i.put(r,n.clone()).catch(t=>tX(t.message)),{response:n,fresh:o}}(n)}catch(t){"SecurityError"!==t.message&&tX(t.toString())}if(r&&r.fresh)return i&&i.throwIfAborted(),i1(t,r.response)}let s=Date.now();try{a=await fetch(n)}catch(i){if("AbortError"===i.name)throw i;throw Error(`${i.message} ${t.url}`,{cause:i})}if(i&&i.throwIfAborted(),!a.ok)throw new iY(a.statusText,a.status,t.url);let l=o?a.clone():null,h=await i1(t,a);return l&&async function(t,i,r){var a;if(iU(),null==c)return;let n=t0(i.headers.get("cache-control")||"");if(n["no-store"])return;let o={status:i.status,statusText:i.statusText,headers:new Headers(i.headers)};n["max-age"]&&o.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());let s=o.headers.get("expires");if(!s||new Date(s).getTime()-r<42e4)return;
1let l=iO(t.url,{persistentParams:iN});if(206===i.status){let i=t.headers.get("Range");if(!i)return;o.status=200,l=iL(l,{range:i})}let h=new Response(200!==(a=i.status)&&404!==a&&[101,103,204,205,304].includes(a)?null:i.body,o);if(iU(),null!=c)try{let t=await c;await t.put(l,h)}catch(t){tX(t.message)}}(n,l,s),h}(t,i)}async function i3(t,i){return i2(Object.assign(t,{type:"json"}),i)}async function i4(t,i){return i2(Object.assign(t,{type:"arrayBuffer"}),i)}async function i5(t,i){iA.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*");let r=await new Promise((t,r)=>{if(i&&i.aborted)return void r(i.reason);let a=()=>{let t=d.shift();t?t():p--};if(p<iT.MAX_PARALLEL_IMAGE_REQUESTS)return p++,void t(a);let n=()=>{i&&i.removeEventListener("abort",o),t(a)},o=()=>{let t=d.indexOf(n);-1!==t&&d.splice(t,1),r(i.reason)};i&&i.addEventListener("abort",o),d.push(n)});try{let r,{data:a,headers:n}=await i4(t,i);try{r=await createImageBitmap(new Blob([new Uint8Array(a)],{type:"image/png"}))}catch(t){throw Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`,{cause:t})}return i&&i.throwIfAborted(),{data:r,headers:n}}finally{r()}}d=[],p=0;let i6={create:"create",load:"load",fullLoad:"fullLoad"},i8={mark(t){performance.mark(t)},measure(t,i,r){performance.measure(t,i,r)}};function i9(t){let i=t.name.split("?")[0];return iZ(i)&&i.includes("mapbox-gl.js")?"javascript":iZ(i)&&i.includes("mapbox-gl.css")?"css":iT.API_FONTS_REGEX.test(i)?"fontRange":i$(i)?"sprite":iW(i)?"style":iT.API_TILEJSON_REGEX.test(i)?"tilejson":"other"}let i7=/(\.(png|jpg)\d*)(?=$)/,re=/^.+\/v4\//,rt=/\.[\w]+$/,ri=/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/,rr=/^access_token=(.*)$/,ra="NO_ACCESS_TOKEN";class rn{constructor(t,i,r){this._transformRequestFn=t,this._customAccessToken=i,this._silenceAuthErrors=!!r,this._createSkuToken()}_createSkuToken(){let t=function(){let t="";for(let i=0;i<10;i++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:"101"+t,tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}async transformRequest(t,i,r){return this._transformRequestFn&&await this._transformRequestFn(t,i,r?{signal:r}:{})||{url:t}}normalizeStyleURL(t,i){if(!iq(t))return t;let r=rs(t);return r.params.push(`sdk=js-${er}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeGlyphsURL(t,i){if(!iq(t))return t;let r=rs(t);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeModelURL(t,i){if(!iq(t))return t;let r=rs(t);return r.path=`/models/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeSourceURL(t,i,r,a){if(!iq(t))return t;let n=rs(t);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),r&&n.params.push(`language=${r}`),a&&n.params.push(`worldview=${a}`),this._makeAPIURL(n,this._customAccessToken||i)}normalizeIconsetURL(t,i){let r=rs(t);return iq(t)?(r.path=`/styles/v1${r.path}/iconset.pbf`,this._makeAPIURL(r,this._customAccessToken||i)):rl(r)}normalizeSpriteURL(t,i,r,a){let n=rs(t);return iq(t)?(n.path=`/styles/v1${n.path}/sprite${i}${r}`,this._makeAPIURL(n,this._customAccessToken||a)):(n.path+=`${i}${r}`,rl(n))}normalizeTileURL(t,i,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!iq(t))return t;let a=rs(t);a.path=a.path.replace(i7,`${i||r&&"raster"!==a.authority&&512===r?"@2x":""}${iA.supported?".webp":"$1"}`),"raster"===a.authority?a.path=`/${iT.RASTER_URL_PREFIX}${a.path}`:"rasterarrays"===a.authority?a.path=`/${iT.RASTERARRAYS_URL_PREFIX}${a.path}`:"3dtiles"===a.authority?a.path=`/${iT.TILES3D_URL_PREFIX}${a.path}`:(a.path=a.path.replace(re,"/"),a.path=`/${iT.TILE_URL_VERSION}${a.path}`);let n=this._customAccessToken||function(t){for(let i of t){let t=i.match(rr);if(t)return t[1]}return null}(a.params)||iT.ACCESS_TOKEN;return iT.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&a.params.push(`sku=${this._skuToken}`),this._makeAPIURL(a,n)}canonicalizeTileURL(t,i){let r=rs(t);if(!ri.test(r.path)||!rt.test(r.path))return t;let a="mapbox://";r.path.startsWith("/raster/v1/")?a+=`raster/${r.path.replace(`/${iT.RASTER_URL_PREFIX}/`,"")}`:r.path.startsWith("/rasterarrays/v1/")?a+=`rasterarrays/${r.path.replace(`/${iT.RASTERARRAYS_URL_PREFIX}/`,"")}`:a+=`tiles/${r.path.replace(`/${iT.TILE_URL_VERSION}/`,"")}`;let n=r.params;return i&&(n=n.filter(t=>!t.match(rr))),n.length&&(a+=`?${n.join("&")}`),a}canonicalizeTileset(t,i){let r=!!i&&iq(i),a=[];for(let i of t.tiles||[])iH(i)?a.push(this.canonicalizeTileURL(i,r)):a.push(i);return a}_makeAPIURL(t,i){let r="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",a=rs(iT.API_URL);if(t.protocol=a.protocol,t.authority=a.authority,"http"===t.protocol){let i=t.params.indexOf("secure");i>=0&&t.params.splice(i,1)}if("/"!==a.path&&(t.path=`${a.path}${t.path}`),!iT.REQUIRE_ACCESS_TOKEN)return rl(t);if(i=i||iT.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw Error(`An API access token is required to use Mapbox GL. ${r}`);if("s"===i[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return t.params=t.params.filter(t=>!t.includes("access_token")),t.params.push(`access_token=${i||""}`),rl(t)}}let ro=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function rs(t){let i=t.match(ro);if(!i)throw Error("Unable to parse URL object");return{protocol:i[1],authority:i[2],path:i[3]||"/",params:i[4]?i[4].split("&"):[]}}function rl(t){let i=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${i}`}let rh="mapbox.eventData";function ru(t){if(!t)return null;let i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(atob(i[1]).split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(t){return null}}function rc(t){return!(!iT.EVENTS_URL||!t&&!iT.ACCESS_TOKEN)}let rd=/^[\w.+-]+(\/[\w.+-]+)?$/,rp="other";class rf{constructor(t){this.type=t,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=!1}getStorageKey(t){let i=ru(iT.ACCESS_TOKEN),r="";return r=i&&i.u?btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(Number("0x"+i)))):iT.ACCESS_TOKEN||"",t?`${rh}.${t}:${r}`:`${rh}
1:${r}`}fetchEventData(){let t=t3("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid"),a=this.getStorageKey("uuidTimestamp");if(t)try{let t=localStorage.getItem(i);t&&(this.eventData=JSON.parse(t));let n=localStorage.getItem(r);n&&(this.anonId=n);let o=localStorage.getItem(a);o&&(this.anonIdTimestamp=Number(o));let s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<s)&&this.refreshUUID()}catch(t){tX("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=tV(),this.anonIdTimestamp=Date.now()}saveEventData(){let t=t3("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid"),a=this.getStorageKey("uuidTimestamp"),n=this.anonId,o=this.anonIdTimestamp;if(t&&n)try{localStorage.setItem(r,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),o&&localStorage.setItem(a,o.toString())}catch(t){tX("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,i,r,a){if(!iT.EVENTS_URL)return;let n=rs(iT.EVENTS_URL);n.params.push(`access_token=${a||iT.ACCESS_TOKEN||""}`);let o={event:this.type,created:new Date(t).toISOString()},s=i?Object.assign(o,i):o,l={url:rl(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=!0,(async function(t){return i2(Object.assign(t,{method:"POST"}),void 0)})(l).then(()=>{this.pendingRequest=!1,r(null),this.saveEventData(),this.processRequests(a)}).catch(t=>{this.pendingRequest=!1,r(t),this.saveEventData(),this.processRequests(a)})}queueRequest(t,i){this.queue.push(t),this.processRequests(i)}}class r_ extends rf{constructor(t){super("metrics"),t&&(this.data=t)}postMetricsEvent(t){if(!rc(t))return;this.anonId||this.fetchEventData(),tj(this.anonId)||this.refreshUUID();let i={...this.data,sessionId:this.anonId};this.queueRequest({timestamp:Date.now(),payload:i},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;let{timestamp:i,payload:r}=this.queue.shift();this.postEvent(i,r,()=>{},t)}}let rm=new class extends rf{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,i){rc(i)&&Array.isArray(t)&&t.some(t=>iq(t)||iH(t))&&this.queueRequest(Date.now(),i)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();let i=ru(iT.ACCESS_TOKEN),r=i?i.u:iT.ACCESS_TOKEN,a=r!==this.eventData.tokenU;tj(this.anonId)||(this.refreshUUID(),a=!0);let n=this.queue.shift();if(this.eventData.lastSuccess){let t=new Date(this.eventData.lastSuccess),i=new Date(n),r=(n-this.eventData.lastSuccess)/864e5;a=a||r>=1||r<-1||t.getDate()!==i.getDate()}else a=!0;if(!a)return void this.processRequests();let o={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:er,skuId:"01","enabled.telemetry":!1,userId:this.anonId,bundleFormat:"csp",bundleDistribution:rp};f&&(o.sdkInfo=f),this.postEvent(n,o,t=>{t||(this.eventData.lastSuccess=n,this.eventData.tokenU=r)},t)}},rg=rm.postTurnstileEvent.bind(rm),ry=new class extends rf{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,i,r,a){this.skuToken=i,this.errorCb=a,iT.EVENTS_URL&&(r||iT.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(Error(ra)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;let{id:i,timestamp:r}=this.queue.shift();if(i&&this.success[i])return;this.anonId&&this.anonIdTimestamp||this.fetchEventData(),tj(this.anonId)||this.refreshUUID();let a={version:"2.2",sdkIdentifier:"mapbox-gl-js",sdkVersion:er,skuId:"01",skuToken:this.skuToken,userId:this.anonId,bundleFormat:"csp",bundleDistribution:rp};f&&(a.sdkInfo=f),this.postEvent(r,a,t=>{t?this.errorCb(t):i&&(this.success[i]=!0)},t)}remove(){this.errorCb=null}},rx=ry.postMapLoadEvent.bind(ry),rv=new class extends rf{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=tV(),this.mapInstanceIdMap.set(t,i)),i}getEventId(t){let i=this.eventIdPerMapInstanceMap.get(t)||0;return this.eventIdPerMapInstanceMap.set(t,i+1),i}postStyleLoadEvent(t,i){let{map:r,style:a,importedStyles:n}=i;
1if(!rc(t))return;let o=this.getMapInstanceId(r),s={mapInstanceId:o,eventId:this.getEventId(o),style:a};n.length&&(s.importedStyles=n),this.queueRequest({timestamp:Date.now(),payload:s},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;let{timestamp:i,payload:r}=this.queue.shift();this.postEvent(i,r,()=>{},t)}},rb=rv.postStyleLoadEvent.bind(rv),rw=new r_({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),rT=rw.postMetricsEvent.bind(rw),rE=new r_({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),rS=rE.postMetricsEvent.bind(rE),rI=new class extends rf{constructor(){super("gljs.performance")}postPerformanceEvent(t,i){rc(t)&&this.queueRequest({timestamp:Date.now(),performanceData:i},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;let{timestamp:i,performanceData:r}=this.queue.shift(),a=function(t){let i=performance.getEntriesByType("resource"),r=performance.getEntriesByType("mark"),a=function(t){let i={};if(t){for(let r in t)if("other"!==r)for(let a of t[r]){let t=`${r}ResolveRangeMin`,n=`${r}ResolveRangeMax`,o=`${r}RequestCount`,s=`${r}RequestCachedCount`;i[t]=Math.min(i[t]||1/0,a.startTime),i[n]=Math.max(i[n]||-1/0,a.responseEnd);let l=t=>{void 0===i[t]&&(i[t]=0),++i[t]};void 0!==a.transferSize&&0===a.transferSize&&l(s),l(o)}}return i}(function(t,i){let r={};if(t)for(let a of t){let t=i(a);void 0===r[t]&&(r[t]=[]),r[t].push(a)}return r}(i,i9)),n=window.devicePixelRatio,o=navigator.connection||navigator.mozConnection||navigator.webkitConnection,s=o?o.effectiveType:void 0,l={counters:[],metadata:[],attributes:[]},h=(t,i,r)=>{null!=r&&t.push({name:i,value:r.toString()})};for(let t in a)h(l.counters,t,a[t]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(h(l.counters,"interactionRangeMin",t.interactionRange[0]),h(l.counters,"interactionRangeMax",t.interactionRange[1])),r)for(let t of Object.values(i6)){let i=r.find(i=>i.name===t);i&&h(l.counters,t,i.startTime)}return h(l.counters,"visibilityHidden",t.visibilityHidden),h(l.attributes,"style",function(t){if(t)for(let i of t){let t=i.name.split("?")[0];if(iW(t)){let i=t.split("/").slice(-2);if(2===i.length)return`mapbox://styles/${i[0]}/${i[1]}`}}}(i)),h(l.attributes,"terrainEnabled",t.terrainEnabled?"true":"false"),h(l.attributes,"fogEnabled",t.fogEnabled?"true":"false"),h(l.attributes,"projection",t.projection),h(l.attributes,"zoom",t.zoom),h(l.metadata,"devicePixelRatio",n),h(l.metadata,"connectionEffectiveType",s),h(l.metadata,"navigatorUserAgent",navigator.userAgent),h(l.metadata,"screenWidth",window.screen.width),h(l.metadata,"screenHeight",window.screen.height),h(l.metadata,"windowWidth",window.innerWidth),h(l.metadata,"windowHeight",window.innerHeight),h(l.metadata,"mapWidth",t.width/n),h(l.metadata,"mapHeight",t.height/n),h(l.metadata,"webglRenderer",t.renderer),h(l.metadata,"webglVendor",t.vendor),h(l.metadata,"sdkVersion",er),h(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(r);for(let t of a.metadata);for(let t of a.counters);for(let t of a.attributes);this.postEvent(i,a,()=>{},t)}},rA=rI.postPerformanceEvent.bind(rI),rC=new class extends rf{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,i,r,a){if(!iT.API_URL||!iT.SESSION_PATH)return;let n=rs(iT.API_URL+iT.SESSION_PATH);n.params.push(`sku=${i||""}`),n.params.push(`access_token=${a||iT.ACCESS_TOKEN||""}`);let o={url:rl(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=!0,(async function(t){return i2(Object.assign(t,{method:"GET"}),void 0)})(o).then(()=>{this.pendingRequest=!1,r(null),this.saveEventData(),this.processRequests(a)}).catch(t=>{this.pendingRequest=!1,r(t),this.saveEventData(),this.processRequests(a)})}getSessionAPI(t,i,r,a){this.skuToken=i,this.errorCb=a,iT.EVENTS_URL&&iT.SESSION_PATH&&iT.API_URL&&(r||iT.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(Error(ra)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;let{id:i,timestamp:r}=this.queue.shift();i&&this.success[i]||this.getSession(r,this.skuToken,t=>{t?this.errorCb(t):i&&(this.success[i]=!0)},t)}remove(){this.errorCb=null}},rM=rC.getSessionAPI.bind(rC),rR=new Set;function rD(t,i){i?rR.add(t):rR.delete(t)}function rP(t,i=0){let r=t.length,a=r-(3&r),n,o=0|i,s=0;for(;s<a;)n=255&t.charCodeAt(s)|(255&t.charCodeAt(s+1))<<8|(255&t.charCodeAt(s+2))<<16|(255&t.charCodeAt(s+3))<<24,s+=4,o^=n=Math.imul(n=(n=Math.imul(n,0xcc9e2d51))<<15|n>>>17,0x1b873593),o=Math.imul(o=o<<13|o>>>19,5)+0xe6546b64|0;n=0;let l=3&r;return l>0&&(l>=3&&(n^=(255&t.charCodeAt(s+2))<<16),l>=2&&(n^=(255&t.charCodeAt(s+1))<<8),n^=255&t.charCodeAt(s),o^=n=Math.imul(n=(n=Math.imul(n,0xcc9e2d51))<<15|n>>>17,0x1b873593)),o^=r,o^=o>>>16,o=Math.imul(o,0x85ebca6b),o^=o>>>13,o=Math.imul(o,0xc2b2ae35),(o^=o>>>16)>>>0}class rz{constructor(t,...i){Object.assign(this,i[0]||{}),this.type=t}}class rL extends rz{constructor(t,i={}){super("error",{error:t,...i})}}function rO(t,i,r){r[t]&&r[t].includes(i)||(r[t]=r[t]||[],r[t].push(i))}function rF(t,i,r){if(r&&r[t]){let a=r[t].indexOf(i);-1!==a&&r[t].splice(a,1)}}class rB{on(t,i){return this._listeners=this._listeners||{},rO(t,i,this._listeners),this}off(t,i){return rF(t,i,this._listeners),rF(t,i,this._oneTimeListeners),this}once(t,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},rO(t,i,this._oneTimeListeners),this):new Promise(i=>{this.once(t,i)})}fire(t,i){let r="string"==typeof t?new rz(t,i):t,a=r.type;if(this.listens(a)){for(let t of(r.target=this,this._listeners&&this._listeners[a]?this._listeners[a].slice():[]))t.call(this,r);for(let t of this._oneTimeListeners&&this._oneTimeListeners[a]?this._oneTimeListeners[a].slice():[])rF(a,t,this._oneTimeListeners),t.call(this,r);let t=this._eventedParent;t&&(Object.assign(r,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),t.fire(r))}else r instanceof rL&&console.error(r.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,i){return this._eventedParent=t,this._eventedParentData=i,this}}class rk{constructor(t){"string"==typeof t?this.name=t:(this.name=t.name,this.iconsetId=t.iconsetId)}static from(t){return new rk(t)}static toString(t){return t.iconsetId?`${t.name}�${t.iconsetId}`:t.name}static parse(t){let[i,r]=t.split("\x1f");return new rk({name:i,iconsetId:r})}
1static isEqual(t,i){return t.name===i.name&&t.iconsetId===i.iconsetId}toString(){return rk.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}class rN{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(t,i){this._updatedSourceCaches[t]=i,this.setDirty()}discardSourceCacheUpdate(t){delete this._updatedSourceCaches[t]}updateLayer(t){let i=t.scope;this._updatedLayers[i]=this._updatedLayers[i]||new Set,this._updatedLayers[i].add(t.id),this.setDirty()}removeLayer(t){let i=t.scope;this._removedLayers[i]=this._removedLayers[i]||{},this._updatedLayers[i]=this._updatedLayers[i]||new Set,this._removedLayers[i][t.id]=t,this._updatedLayers[i].delete(t.id),this._updatedPaintProps.delete(t.fqid),this.setDirty()}getRemovedLayer(t){return this._removedLayers[t.scope]?this._removedLayers[t.scope][t.id]:null}discardLayerRemoval(t){this._removedLayers[t.scope]&&delete this._removedLayers[t.scope][t.id]}getLayerUpdatesByScope(){let t={};for(let i in this._updatedLayers)t[i]=t[i]||{},t[i].updatedIds=Array.from(this._updatedLayers[i].values());for(let i in this._removedLayers)t[i]=t[i]||{},t[i].removedIds=Object.keys(this._removedLayers[i]);return t}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(t){this._updatedPaintProps.add(t.fqid),this.setDirty()}getUpdatedImages(t){return this._updatedImages[t]?Array.from(this._updatedImages[t].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(rk.toString(t)),this.setDirty()}resetUpdatedImages(t){this._updatedImages[t]&&this._updatedImages[t].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}var rV,rU={},rj=function(){if(rV)return rU;rV=1;var t={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 i(t){return(t=Math.round(t))<0?0:t>255?255:t}function r(t){return i("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function a(t){var i;return(i="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:i>1?1:i}function n(t,i,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(i-t)*r*6:2*r<1?i:3*r<2?t+(i-t)*(2/3-r)*6:t}try{rU.parseCSSColor=function(o){var s,l=o.replace(/ /g,"").toLowerCase();if(l in t)return t[l].slice();if("#"===l[0])return 4===l.length?(s=parseInt(l.substr(1),16))>=0&&s<=4095?[(3840&s)>>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)<<4,1]:null:7===l.length&&(s=parseInt(l.substr(1),16))>=0&&s<=0xffffff?[(0xff0000&s)>>16,(65280&s)>>8,255&s,1]:null;var h=l.indexOf("("),u=l.indexOf(")");if(-1!==h&&u+1===l.length){var c=l.substr(0,h),d=l.substr(h+1,u-(h+1)).split(","),p=1;switch(c){case"rgba":if(4!==d.length)break;p=a(d.pop());case"rgb":return 3!==d.length?null:[r(d[0]),r(d[1]),r(d[2]),p];case"hsla":if(4!==d.length)break;p=a(d.pop());case"hsl":if(3!==d.length)break;var f=(parseFloat(d[0])%360+360)%360/360,_=a(d[1]),m=a(d[2]),g=m<=.5?m*(_+1):m+_-m*_,y=2*m-g;return[i(255*n(y,g,f+1/3)),i(255*n(y,g,f)),i(255*n(y,g,f-1/3)),p]}}return null}}catch(t){}return rU}();function rG(t,i,r){return t*(1-r)+i*r}let rH=new Map;class rq{constructor(t,i,r,a=1){this.r=t,this.g=i,this.b=r,this.a=a}static parse(t){if(!t)return;if(t instanceof rq)return t;if("string"!=typeof t)return;let i=rH.get(t);if(i)return i;let r=rj.parseCSSColor(t);if(!r)return;let a=new rq(r[0]/255,r[1]/255,r[2]/255,r[3]);return rH.set(t,a),a}toString(){let{r:t,g:i,b:r,a:a}=this;return`rgba(${Math.round(255*t)},${Math.round(255*i)},${Math.round(255*r)},${a})`}
1toNonPremultipliedRenderColor(t){let{r:i,g:r,b:a,a:n}=this;return new r$(t,i,r,a,n)}toPremultipliedRenderColor(t){let{r:i,g:r,b:a,a:n}=this;return new rW(t,i*n,r*n,a*n,n)}clone(){return new rq(this.r,this.g,this.b,this.a)}}class rZ{constructor(t,i,r,a,n,o=!1){if(this.premultiplied=!1,this.premultiplied=o,t){let o=t.image.height,s=o*o;this.premultiplied?(i=0===n?0:i/n*(o-1),r=0===n?0:r/n*(o-1),a=0===n?0:a/n*(o-1)):(i*=o-1,r*=o-1,a*=o-1),i=Math.max(0,Math.min(o-1,i)),r=Math.max(0,Math.min(o-1,r)),a=Math.max(0,Math.min(o-1,a));let l=Math.floor(i),h=Math.floor(r),u=Math.floor(a),c=Math.ceil(i),d=Math.ceil(r),p=Math.ceil(a),f=i-l,_=r-h,m=a-u,g=t.image.data,y=4*(l+h*s+u*o),x=4*(l+h*s+p*o),v=4*(l+d*s+u*o),b=4*(l+d*s+p*o),w=4*(c+h*s+u*o),T=4*(c+h*s+p*o),E=4*(c+d*s+u*o),S=4*(c+d*s+p*o);this.r=rG(rG(rG(g[y],g[x],m),rG(g[v],g[b],m),_),rG(rG(g[w],g[T],m),rG(g[E],g[S],m),_),f)/255*(this.premultiplied?n:1),this.g=rG(rG(rG(g[y+1],g[x+1],m),rG(g[v+1],g[b+1],m),_),rG(rG(g[w+1],g[T+1],m),rG(g[E+1],g[S+1],m),_),f)/255*(this.premultiplied?n:1),this.b=rG(rG(rG(g[y+2],g[x+2],m),rG(g[v+2],g[b+2],m),_),rG(rG(g[w+2],g[T+2],m),rG(g[E+2],g[S+2],m),_),f)/255*(this.premultiplied?n:1),this.a=n}else this.r=i,this.g=r,this.b=a,this.a=n}toArray(){let{r:t,g:i,b:r,a:a}=this;return[255*t,255*i,255*r,a]}toHslaArray(){let t,{r:i,g:r,b:a,a:n}=this;if(this.premultiplied){if(0===n)return[0,0,0,0];let t=1/n;i*=t,r*=t,a*=t}let o=Math.min(Math.max(i,0),1),s=Math.min(Math.max(r,0),1),l=Math.min(Math.max(a,0),1),h=Math.min(o,s,l),u=Math.max(o,s,l),c=u-h,d=.5*(h+u);if(0===c)return[0,0,100*d,n];switch(u){case o:t=60*((s-l)/c+6*(s<l));break;case s:t=60*((l-o)/c+2);break;default:t=60*((o-s)/c+4)}return[t,100*(d>.5?c/(2-u-h):c/(u+h)),100*d,n]}toArray01(){let{r:t,g:i,b:r,a:a}=this;return[t,i,r,a]}toArray01Scaled(t){let{r:i,g:r,b:a}=this;return[i*t,r*t,a*t]}toArray01Linear(){let{r:t,g:i,b:r,a:a}=this;return[Math.pow(t,2.2),Math.pow(i,2.2),Math.pow(r,2.2),a]}}class r$ extends rZ{constructor(t,i,r,a,n){super(t,i,r,a,n,!1)}}class rW extends rZ{constructor(t,i,r,a,n){super(t,i,r,a,n,!0)}}function rX(t,i,r){return t.map((t,a)=>rG(t,i[a],r))}rq.black=new rq(0,0,0,1),rq.white=new rq(1,1,1,1),rq.transparent=new rq(0,0,0,0),rq.red=new rq(1,0,0,1),rq.blue=new rq(0,0,1,1);var rY=Object.freeze({__proto__:null,array:rX,color:function(t,i,r){return new rq(rG(t.r,i.r,r),rG(t.g,i.g,r),rG(t.b,i.b,r),rG(t.a,i.a,r))},number:rG});class rK extends Error{constructor(t,i){super(i),this.message=i,this.key=t}}class rQ{constructor(t,i=[]){for(let[r,a]of(this.parent=t,this.bindings={},i))this.bindings[r]=a}concat(t){return new rQ(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}let rJ={kind:"null"},r0={kind:"number"},r1={kind:"string"},r2={kind:"boolean"},r3={kind:"color"},r4={kind:"object"},r5={kind:"value"},r6={kind:"collator"},r8={kind:"formatted"},r9={kind:"resolvedImage"};function r7(t,i){return{kind:"array",itemType:t,N:i}}function ae(t){if("array"===t.kind){let i=ae(t.itemType);return"number"==typeof t.N?`array<${i}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${i}>`}return t.kind}let at=[rJ,r0,r1,r2,r3,r8,r4,r7(r5),r9];function ai(t,i){if("error"===i.kind)return null;if("array"===t.kind){if("array"===i.kind&&(0===i.N&&"value"===i.itemType.kind||!ai(t.itemType,i.itemType))&&("number"!=typeof t.N||t.N===i.N))return null}else{if(t.kind===i.kind)return null;if("value"===t.kind){for(let t of at)if(!ai(t,i))return null}}return`Expected ${ae(t)} but found ${ae(i)} instead.`}function ar(t,i){return i.some(i=>i.kind===t.kind)}function aa(t,i){return i.some(i=>"null"===i?null===t:"array"===i?Array.isArray(t):"object"===i?t&&!Array.isArray(t)&&"object"==typeof t:i===typeof t)}function an(t,i){return"array"===t.kind&&"array"===i.kind?t.N===i.N&&an(t.itemType,i.itemType):t.kind===i.kind}class ao{constructor(t,i,r){this.sensitivity=t?i?"variant":"case":i?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,i){return this.collator.compare(t,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class as{constructor(t,i,r,a,n){this.text=t.normalize?t.normalize():t,this.image=i,this.scale=r,this.fontStack=a,this.textColor=n}}class al{constructor(t){this.sections=t}static fromString(t){return new al([new as(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(t=>0!==t.text.length||!!t.image&&t.image.hasPrimary())}static factory(t){return t instanceof al?t:al.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map(t=>t.text).join("")}serialize(){let t=["format"];for(let i of this.sections){if(i.image){let r=i.image.getPrimary().id.toString();t.push(["image",r]);continue}t.push(i.text);let r={};i.fontStack&&(r["text-font"]=["literal",i.fontStack.split(",")]),i.scale&&(r["font-scale"]=i.scale),i.textColor&&(r["text-color"]=["rgba"].concat(i.textColor.toNonPremultipliedRenderColor(null).toArray())),t.push(r)}return t}}class ah{constructor(t,i={}){this.id=rk.from(t),this.params=i.params,this.sx=i.sx||1,this.sy=i.sy||1}toString(){return JSON.stringify(this)}static parse(t){let i,r,a,n;try{({id:i,params:r,sx:a,sy:n}=JSON.parse(t)||{})}catch(t){return null}return i?new ah(i,{params:r,sx:a,sy:n}):null}scaleSelf(t,i=t){return this.sx*=t,this.sy*=i,this}}class au{constructor(t,i,r,a,n=!1){this.primaryId=rk.from(t),this.primaryOptions=i,r&&(this.secondaryId=rk.from(r)),this.secondaryOptions=a,this.available=n}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new ah(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new ah(this.secondaryId,this.secondaryOptions):null}static from(t){return"string"==typeof t?au.build({name:t}):t}static build(t,i,r,a){return t&&("object"!=typeof t||"name"in t)?new au(t,r,i,a):null}}function ac(t,i,r,a){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[t,i,r,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[t,i,r,a]:[t,i,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ad(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof rq||t instanceof ao||t instanceof al||t instanceof au)return!0;
1if(Array.isArray(t)){for(let i of t)if(!ad(i))return!1;return!0}if("object"==typeof t){for(let i in t)if(!ad(t[i]))return!1;return!0}return!1}function ap(t){if(null===t)return rJ;if("string"==typeof t)return r1;if("boolean"==typeof t)return r2;if("number"==typeof t)return r0;if(t instanceof rq)return r3;if(t instanceof ao)return r6;if(t instanceof al)return r8;if(t instanceof au)return r9;if(Array.isArray(t)){let i,r=t.length;for(let r of t){let t=ap(r);if(i){if(i===t)continue;i=r5;break}i=t}return r7(i||r5,r)}return r4}function af(t){return null===t?"":"string"==typeof t||"number"==typeof t||"boolean"==typeof t?String(t):t instanceof al||t instanceof au||t instanceof rq?t.toString():JSON.stringify(t)}class a_{constructor(t,i){this.type=t,this.value=i}static parse(t,i){if(2!==t.length)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!ad(t[1]))return i.error("invalid value");let r=t[1],a=ap(r),n=i.expectedType;return"array"===a.kind&&0===a.N&&n&&"array"===n.kind&&("number"!=typeof n.N||0===n.N)&&(a=n),new a_(a,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof rq?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof al?this.value.serialize():this.value}}class am{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}let ag={string:r1,number:r0,boolean:r2,object:r4};class ay{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r,a=1,n=t[0];if("array"===n){let n,o;if(t.length>2){let r=t[1];if("string"!=typeof r||!(r in ag)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);n=ag[r],a++}else n=r5;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);o=t[2],a++}r=r7(n,o)}else r=ag[n];let o=[];for(;a<t.length;a++){let r=i.parse(t[a],a,r5);if(!r)return null;o.push(r)}return new ay(r,o)}evaluate(t){for(let i=0;i<this.args.length;i++){let r=this.args[i].evaluate(t);if(!ai(this.type,ap(r)))return r;if(i===this.args.length-1)throw new am(`The expression ${JSON.stringify(this.args[i].serialize())} evaluated to ${ae(ap(r))} but was expected to be of type ${ae(this.type)}.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){let t=this.type,i=[t.kind];if("array"===t.kind){let r=t.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){i.push(r.kind);let a=t.N;("number"==typeof a||this.args.length>1)&&i.push(a)}}return i.concat(this.args.map(t=>t.serialize()))}}class ax{constructor(t){this.type=r8,this.sections=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return i.error("First argument must be an image or text section.");let a=[],n=!1;for(let r=1;r<=t.length-1;++r){let o=t[r];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let t=null;if(o["font-scale"]&&!(t=i.parseObjectValue(o["font-scale"],r,"font-scale",r0)))return null;let s=null;if(o["text-font"]&&!(s=i.parseObjectValue(o["text-font"],r,"text-font",r7(r1))))return null;let l=null;if(o["text-color"]&&!(l=i.parseObjectValue(o["text-color"],r,"text-color",r3)))return null;let h=a.at(-1);h.scale=t,h.font=s,h.textColor=l}else{let o=i.parse(t[r],r,r5);if(!o)return null;let s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,a.push({content:o,scale:null,font:null,textColor:null})}}return new ax(a)}evaluate(t){return new al(this.sections.map(i=>{let r=i.content.evaluate(t);return an(ap(r),r9)?new as("",r,null,null,null):new as(af(r),null,i.scale?i.scale.evaluate(t):null,i.font?i.font.evaluate(t).join(","):null,i.textColor?i.textColor.evaluate(t):null)}))}eachChild(t){for(let i of this.sections)t(i.content),i.scale&&t(i.scale),i.font&&t(i.font),i.textColor&&t(i.textColor)}outputDefined(){return!1}serialize(){let t=["format"];for(let i of this.sections){t.push(i.content.serialize());let r={};i.scale&&(r["font-scale"]=i.scale.serialize()),i.font&&(r["text-font"]=i.font.serialize()),i.textColor&&(r["text-color"]=i.textColor.serialize()),t.push(r)}return t}}class av{constructor(t,i,r,a){this._imageWarnHistory={},this.type=r9,this.namePrimary=t,this.nameSecondary=i,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),a&&(this.paramsSecondary=a.params,this.iconsetIdSecondary=a.iconset?a.iconset.id:void 0)}static parse(t,i){if(t.length<2)return i.error("Expected two or more arguments.");let r=1,a=[];for(let n=0;n<2;n++)if(!function(){if(r<t.length){let n=i.parse(t[r],r++,r1);return n?(a.push({image:n,options:{}}),!0):(i.error(a.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}()||!function(){if(r<t.length){let n=t[r];
1if(null===n||"object"!=typeof n||Array.isArray(n))return!0;let o=n.params,s=n.iconset,l=i.concat(r);if(!o&&!s)return r++,!0;if(o){if("object"!=typeof o||o.constructor!==Object)return l.error('Image options "params" should be an object'),!1;let t={},i=l.concat(void 0,"params");for(let r in o){if(!r)return i.error("Image parameter name should be non-empty"),!1;let a=i.concat(void 0,r).parse(o[r],void 0,r3,void 0,{typeAnnotation:"coerce"});if(!a)return!1;t[r]=a}a.at(-1).options.params=t}if(s){if("object"!=typeof s||s.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!s.id)return l.error('Image options "iconset" should have an "id" property'),!1;a.at(-1).options.iconset=s}return r++,!0}return!0}())return;return new av(a[0].image,a[1]?a[1].image:void 0,a[0].options,a[1]?a[1].options:void 0)}evaluateParams(t,i){let r={};if(i){for(let a in i)if(i[a])try{r[a]=i[a].evaluate(t)}catch(t){continue}if(0!==Object.keys(r).length)return{params:r}}}evaluate(t){let i={name:this.namePrimary.evaluate(t),iconsetId:this.iconsetIdPrimary},r=this.nameSecondary?{name:this.nameSecondary.evaluate(t),iconsetId:this.iconsetIdSecondary}:void 0,a=au.build(i,r,this.paramsPrimary?this.evaluateParams(t,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(t,this.paramsSecondary):void 0);if(a&&t.availableImages){let i=a.getPrimary().id;if(a.available=t.availableImages.some(t=>rk.isEqual(t,i)),a.available){let i=a.getSecondary()?a.getSecondary().id:null;i&&(a.available=t.availableImages.some(t=>rk.isEqual(t,i)))}}return a}eachChild(t){if(t(this.namePrimary),this.paramsPrimary)for(let i in this.paramsPrimary)this.paramsPrimary[i]&&t(this.paramsPrimary[i]);if(this.nameSecondary&&(t(this.nameSecondary),this.paramsSecondary))for(let i in this.paramsSecondary)this.paramsSecondary[i]&&t(this.paramsSecondary[i])}outputDefined(){return!1}serializeOptions(t,i){let r={};if(i&&(r.iconset={id:i}),t)for(let i in r.params={},t)t[i]&&(r.params[i]=t[i].serialize());return Object.keys(r).length>0?r:void 0}serialize(){let t=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){let i=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);i&&t.push(i)}if(this.nameSecondary&&(t.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){let i=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);i&&t.push(i)}return t}}function ab(t){return aT(t)?"string":aE(t)?"number":aS(t)?"boolean":Array.isArray(t)?"array":null===t?"null":aw(t)?"object":typeof t}function aw(t){return null!=t&&!Array.isArray(t)&&"function"!=typeof t&&!(t instanceof String||t instanceof Number||t instanceof Boolean)&&"object"==typeof t}function aT(t){return"string"==typeof t||t instanceof String}function aE(t){return"number"==typeof t||t instanceof Number}function aS(t){return"boolean"==typeof t||t instanceof Boolean}let aI={"to-boolean":r2,"to-color":r3,"to-number":r0,"to-string":r1};class aA{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let r=t[0],a=[],n=rJ;if("to-array"===r){if(!Array.isArray(t[1]))return null;let r=t[1].length;if(i.expectedType){if("array"!==i.expectedType.kind)return i.error(`Expected ${i.expectedType.kind} but found array.`);n=r7(i.expectedType.itemType,r)}else{if(!(r>0&&ad(t[1][0])))return null;n=r7(ap(t[1][0]),r)}for(let o=0;o<r;o++){let r,s=t[1][o];if(Array.isArray(s))r=i.parse(s,void 0,n.itemType);else{let t=ab(s);if(t!==n.itemType.kind)return i.error(`Expected ${n.itemType.kind} but found ${t}.`);r=i.registry.literal.parse(["literal",void 0===s?null:s],i)}if(!r)return null;a.push(r)}}else{if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return i.error("Expected one argument.");n=aI[r];for(let r=1;r<t.length;r++){let n=i.parse(t[r],r,r5);if(!n)return null;a.push(n)}}return new aA(n,a)}evaluate(t){if("boolean"===this.type.kind)return!!this.args[0].evaluate(t);if("color"===this.type.kind){let i,r;for(let a of this.args){if(i=a.evaluate(t),r=null,i instanceof rq)return i;if("string"==typeof i){let r=t.parseColor(i);if(r)return r}else if(Array.isArray(i)&&!(r=i.length<3||i.length>4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:ac(i[0],i[1],i[2],i[3])))return new rq(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new am(r||`Could not parse color from value '${"string"==typeof i?i:String(JSON.stringify(i))}'`)}if("number"===this.type.kind){let i=null;for(let r of this.args){if(null===(i=r.evaluate(t)))return 0;let a=Number(i);if(!isNaN(a))return a}throw new am(`Could not convert ${JSON.stringify(i)} to number.`)}return"formatted"===this.type.kind?al.fromString(af(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?au.build(af(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map(i=>i.evaluate(t)):af(this.args[0].evaluate(t))}
1eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){if("formatted"===this.type.kind)return new ax([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new av(this.args[0]).serialize();let t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(i=>{t.push(i.serialize())}),t}}let aC=["Unknown","Point","LineString","Polygon"];class aM{constructor(t,i,r){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=t,this.options=i,this.iconImageUseTheme=r}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?aC[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(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){let t=this.featureDistanceData.center,i=this.featureDistanceData.scale,{x:r,y:a}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*i-t[0])+this.featureDistanceData.bearing[1]*(a*i-t[1])}return 0}parseColor(t){return rq.parse(t)}getConfig(t){return this.options?this.options.get(t):null}}class aR{constructor(t,i,r,a,n){this.name=t,this.type=i,this._evaluate=r,this.args=a,this._overloadIndex=n}evaluate(t){if(!this._evaluate){let t=aR.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(t=>t.serialize()))}static parse(t,i){let r=t[0],a=aR.definitions[r];if(!a)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let n=Array.isArray(a)?a[0]:a.type,o=Array.isArray(a)?[[a[1],a[2]]]:a.overloads,s=[],l=null,h=-1;for(let[a,u]of o){if(Array.isArray(a)&&a.length!==t.length-1)continue;s.push(a),h++,null===l?l=i._forkForSignature():l.errors.length=0;let o=[],c=!1;for(let i=1;i<t.length;i++){let r=t[i],n=Array.isArray(a)?a[i-1]:a.type,s=l.parse(r,1+o.length,n);if(!s){c=!0;break}o.push(s)}if(!c)if(Array.isArray(a)&&a.length!==o.length)l.error(`Expected ${a.length} arguments, but found ${o.length} instead.`);else{for(let t=0;t<o.length;t++){let i=Array.isArray(a)?a[t]:a.type;l.checkSubtype(i,o[t].type,t+1)}if(0===l.errors.length)return new aR(r,n,u,o,h)}}if(1===s.length)i.errors.push(...l.errors);else{let r=(s.length?s:o.map(([t])=>t)).map(aD).join(" | "),a=[];for(let r=1;r<t.length;r++){let n=i.parse(t[r],1+a.length);if(!n)return null;a.push(ae(n.type))}i.error(`Expected arguments of type ${r}, but found (${a.join(", ")}) instead.`)}return null}static register(t,i){for(let r in aR.definitions=i,i)t[r]=aR}}function aD(t){return Array.isArray(t)?`(${t.map(ae).join(", ")})`:`(${ae(t.type)}...)`}class aP{constructor(t,i,r){this.type=r6,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=i}static parse(t,i){if(2!==t.length)return i.error("Expected one argument."),null;let r=t[1];if("object"!=typeof r||Array.isArray(r))return i.error("Collator options argument must be an object."),null;let a=void 0===r["case-sensitive"]?i.parse(!1,1,r2):i.parseObjectValue(r["case-sensitive"],1,"case-sensitive",r2);if(!a)return null;let n=void 0===r["diacritic-sensitive"]?i.parse(!1,1,r2):i.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",r2);if(!n)return null;let o=null;return!r.locale||(o=i.parseObjectValue(r.locale,1,"locale",r1))?new aP(a,n,o):null}evaluate(t){return new ao(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){let t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}function az(t){return(180+t)/360}function aL(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function aO(t){return 360*t-180}function aF(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180)
1)-90}function aB(t,i){for(let r=0;r<t.length;++r)if(!tE(t[r],i))return!1;for(let r=0;r<t.length-1;++r)if(function(t,i,r){for(let a of r)for(let r=0,n=a.length,o=n-1;r<n;o=r++)if(tI(t,i,a[o],a[r]))return!0;return!1}(t[r],t[r+1],i))return!1;return!0}function ak(t,i,r){let a=[];for(let n=0;n<t.length;n++){let o=[];for(let a=0;a<t[n].length;a++){let s=function(t,i){let r=az(t[0]),a=aL(t[1]),n=Math.pow(2,i.z);return[Math.round(r*n*8192),Math.round(a*n*8192)]}(t[n][a],r);tw(i,s),o.push(s)}a.push(o)}return a}function aN(t,i,r){let a=[];for(let n=0;n<t.length;n++){let o=ak(t[n],i,r);a.push(o)}return a}function aV(t,i,r,a){if(t[0]<r[0]||t[0]>r[2]){let i=.5*a,n=t[0]-r[0]>i?-a:r[0]-t[0]>i?a:0;0===n&&(n=t[0]-r[2]>i?-a:r[2]-t[0]>i?a:0),t[0]+=n}tw(i,t)}function aU(t,i,r,a){let n=8192*Math.pow(2,a.z),o=[8192*a.x,8192*a.y],s=[];if(!t)return s;for(let a of t)for(let t of a){let a=[t.x+o[0],t.y+o[1]];aV(a,i,r,n),s.push(a)}return s}function aj(t,i,r,a){let n=8192*Math.pow(2,a.z),o=[8192*a.x,8192*a.y],s=[];if(!t)return s;for(let r of t){let t=[];for(let a of r){let r=[a.x+o[0],a.y+o[1]];tw(i,r),t.push(r)}s.push(t)}if(i[2]-i[0]<=n/2)for(let t of(i[0]=i[1]=1/0,i[2]=i[3]=-1/0,s))for(let a of t)aV(a,i,r,n);return s}class aG{constructor(t,i){this.type=r2,this.geojson=t,this.geometries=i}static parse(t,i){if(2!==t.length)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ad(t[1])){let i=t[1];if("FeatureCollection"===i.type)for(let t=0;t<i.features.length;++t){let r=i.features[t].geometry.type;if("Polygon"===r||"MultiPolygon"===r)return new aG(i,i.features[t].geometry)}else if("Feature"===i.type){let t=i.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new aG(i,i.geometry)}else if("Polygon"===i.type||"MultiPolygon"===i.type)return new aG(i,i)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,i){let r=[1/0,1/0,-1/0,-1/0],a=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if(!n)return!1;if("Polygon"===i.type){let o=ak(i.coordinates,a,n),s=aU(t.geometry(),r,a,n);if(!tT(r,a))return!1;for(let t of s)if(!tE(t,o))return!1}if("MultiPolygon"===i.type){let o=aN(i.coordinates,a,n),s=aU(t.geometry(),r,a,n);if(!tT(r,a))return!1;for(let t of s)if(!function(t,i){for(let r=0;r<i.length;r++)if(tE(t,i[r]))return!0;return!1}(t,o))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,i){let r=[1/0,1/0,-1/0,-1/0],a=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if(!n)return!1;if("Polygon"===i.type){let o=ak(i.coordinates,a,n),s=aj(t.geometry(),r,a,n);if(!tT(r,a))return!1;for(let t of s)if(!aB(t,o))return!1}if("MultiPolygon"===i.type){let o=aN(i.coordinates,a,n),s=aj(t.geometry(),r,a,n);if(!tT(r,a))return!1;for(let t of s)if(!function(t,i){for(let r=0;r<i.length;r++)if(aB(t,i[r]))return!0;return!1}(t,o))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}class aH{constructor(t=[],i=(t,i)=>t<i?-1:+(t>i)){if(this.data=t,this.length=this.data.length,this.compare=i,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;let t=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:i,compare:r}=this,a=i[t];for(;t>0;){let n=t-1>>1,o=i[n];if(r(a,o)>=0)break;i[t]=o,t=n}i[t]=a}_down(t){let{data:i,compare:r}=this,a=this.length>>1,n=i[t];for(;t<a;){let a=1+(t<<1),o=a+1;if(o<this.length&&0>r(i[o],i[a])&&(a=o),r(i[a],n)>=0)break;i[t]=i[a],t=a}i[t]=n}}let aq=1/298.257223563*(2-1/298.257223563),aZ=Math.PI/180;function a$(t){let i=6378.137*aZ*1e3,r=Math.cos(t*aZ),a=1/(1-aq*(1-r*r)),n=Math.sqrt(a);return[i*n*r,i*n*a*(1-aq)]}function aW(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}function aX(t,i,r,a){let n=aW(t[0]-i[0])*r,o=(t[1]-i[1])*a;return Math.sqrt(n*n+o*o)}function aY(t,i,r,a,n){let o=i[0],s=i[1],l=aW(r[0]-o)*a,h=(r[1]-s)*n;if(0!==l||0!==h){let i=(aW(t[0]-o)*a*l+(t[1]-s)*n*h)/(l*l+h*h);i>1?(o=r[0],s=r[1]):i>0&&(o+=l/a*i,s+=h/n*i)}return Math.sqrt((l=aW(t[0]-o)*a)*l+(h=(t[1]-s)*n)*h)}function aK(t,i){return i.dist-t.dist}function aQ(t){let i=[1/0,1/0,-1/0,-1/0];if(i.length!==t.length)return!1;for(let r=0;r<i.length;r++)if(i[r]!==t[r])return!1;return!0}function aJ(t){return t[1]-t[0]+1}function a0(t,i){let r=t[1]>=t[0]&&t[1]<i;return r||console.warn("Distance Expression: Index is out of range"),r}function a1(t,i){if(t[0]>
1t[1])return[null,null];let r=aJ(t);if(i){if(2===r)return[t,null];let i=Math.floor(r/2);return[[t[0],t[0]+i],[t[0]+i,t[1]]]}{if(1===r)return[t,null];let i=Math.floor(r/2)-1;return[[t[0],t[0]+i],[t[0]+i+1,t[1]]]}}function a2(t,i){let r=[1/0,1/0,-1/0,-1/0];if(!a0(i,t.length))return r;for(let a=i[0];a<=i[1];++a)tw(r,t[a]);return r}function a3(t){let i=[1/0,1/0,-1/0,-1/0];for(let r=0;r<t.length;++r)for(let a=0;a<t[r].length;++a)tw(i,t[r][a]);return i}function a4(t,i,r,a){if(aQ(t)||aQ(i))return NaN;let n=0,o=0;return t[2]<i[0]&&(n=i[0]-t[2]),t[0]>i[2]&&(n=t[0]-i[2]),t[1]>i[3]&&(o=t[1]-i[3]),t[3]<i[1]&&(o=i[1]-t[3]),aX([0,0],[n,o],r,a)}function a5(t,i,r=8192){let a=Math.pow(2,i.z),n=(t.y/r+i.y)/a;return[aO((t.x/r+i.x)/a),aF(n)]}function a6(t,i,r,a){let n=function(t,i,r,a){let n=1/0,o=t[0][0],s=t[0][1];for(let l=0;l<t.length-1;l++){let h=t[l][0],u=t[l][1],c=aW(t[l+1][0]-h)*r,d=(t[l+1][1]-u)*a,p=0;0===c&&0===d||((p=(aW(i[0]-h)*r*c+(i[1]-u)*a*d)/(c*c+d*d))>1?(h=t[l+1][0],u=t[l+1][1]):p>0&&(h+=c/r*p,u+=d/a*p));let f=(c=aW(i[0]-h)*r)*c+(d=(i[1]-u)*a)*d;f<n&&(n=f,o=h,s=u)}return[o,s]}(i,t,r,a);return aX(t,n,r,a)}function a8(t,i,r,a,n,o){let s=r.slice(a[0],a[1]+1),l=1/0;for(let r=i[0];r<=i[1];++r)if(0===(l=Math.min(l,a6(t[r],s,n,o))))return 0;return l}function a9(t,i,r,a,n,o){return Math.min(Math.min(aY(t,r,a,n,o),aY(i,r,a,n,o)),Math.min(aY(r,t,i,n,o),aY(a,t,i,n,o)))}function a7(t,i){for(let r of t)for(let t=0;t<=r.length-1;++t)if(tE(r[t],i,!0))return!0;return!1}function ne(t,i,r,a,n,o,s,l){if(null===s||null===l)return;let h=a4(a2(n,s),a2(o,l),r,a);h<i&&t.push({dist:h,range1:s,range2:l})}function nt(t,i,r,a,n,o,s=1/0){let l=Math.min(s,aX(t[0],r[0],n,o));if(0===l)return l;let h=new aH([{dist:0,range1:[0,t.length-1],range2:[0,r.length-1]}],aK),u=i?50:100,c=a?50:100;for(;h.length;){let s=h.pop();if(s.dist>=l)continue;let d=s.range1,p=s.range2;if(aJ(d)<=u&&aJ(p)<=c){if(!a0(d,t.length)||!a0(p,r.length))return NaN;if(i&&a?l=Math.min(l,function(t,i,r,a,n,o){if(!a0(i,t.length)||!a0(a,r.length))return NaN;let s=1/0;for(let l=i[0];l<i[1];++l)for(let i=a[0];i<a[1];++i){if(tI(t[l],t[l+1],r[i],r[i+1]))return 0;s=Math.min(s,a9(t[l],t[l+1],r[i],r[i+1],n,o))}return s}(t,d,r,p,n,o)):i||a?i&&!a?l=Math.min(l,a8(r,p,t,d,n,o)):!i&&a&&(l=Math.min(l,a8(t,d,r,p,n,o))):l=Math.min(l,function(t,i,r,a,n,o){if(!a0(i,t.length)||!a0(a,r.length))return NaN;let s=1/0;for(let l=i[0];l<=i[1];++l)for(let i=a[0];i<=a[1];++i)if(0===(s=Math.min(s,aX(t[l],r[i],n,o))))return s;return s}(t,d,r,p,n,o)),0===l)break}else{let s=a1(d,i),u=a1(p,a);ne(h,l,n,o,t,r,s[0],u[0]),ne(h,l,n,o,t,r,s[0],u[1]),ne(h,l,n,o,t,r,s[1],u[0]),ne(h,l,n,o,t,r,s[1],u[1])}}return l}function ni(t,i,r,a,n,o=1/0){let s=o,l=a2(t,[0,t.length-1]);for(let o of r)if(!(s!==1/0&&a4(l,a2(o,[0,o.length-1]),a,n)>=s)&&0===(s=Math.min(s,nt(t,i,o,!0,a,n,s))))break;return s}function nr(t,i,r,a,n,o=1/0){let s=o,l=a2(t,[0,t.length-1]);for(let o of r){if(s!==1/0&&a4(l,a3(o),a,n)>=s)continue;let r=function(t,i,r,a,n,o=1/0){let s=Math.min(aX(t[0],r[0][0],a,n),o);if(0===s)return s;let l=new aH([{dist:0,range1:[0,t.length-1],range2:[0,0]}],aK),h=i?50:100,u=a3(r);for(;l.length;){let o=l.pop();if(o.dist>=s)continue;let c=o.range1;if(aJ(c)<=h){if(!a0(c,t.length))return NaN;if(i){if(0===(s=Math.min(s,function(t,i,r,a,n){if(!a0(i,t.length))return NaN;for(let a=i[0];a<=i[1];++a)if(tE(t[a],r,!0))return 0;let o=1/0;for(let s=i[0];s<i[1];++s)for(let i of r)for(let r=0,l=i.length,h=l-1;r<l;h=r++){if(tI(t[s],t[s+1],i[h],i[r]))return 0;o=Math.min(o,a9(t[s],t[s+1],i[h],i[r],a,n))}return o}(t,c,r,a,n))))break}else for(let i=c[0];i<=c[1];++i)if(0===(s=Math.min(s,function(t,i,r,a){if(tE(t,i,!0))return 0;let n=1/0;for(let o of i){let i=o.length;if(i<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;
1if(o[0]!==o[i-1]&&0===(n=Math.min(n,aY(t,o[i-1],o[0],r,a)))||0===(n=Math.min(n,a6(t,o,r,a))))break}return n}(t[i],r,a,n))))return s}else{let r=a1(c,i);if(null!==r[0]){let i=a4(a2(t,r[0]),u,a,n);i<s&&l.push({dist:i,range1:r[0],range2:[0,0]})}if(null!==r[1]){let i=a4(a2(t,r[1]),u,a,n);i<s&&l.push({dist:i,range1:r[1],range2:[0,0]})}}}return s}(t,i,o,a,n,s);if(isNaN(r))return r;if(0===(s=Math.min(s,r)))break}return s}function na(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class nn{constructor(t,i){this.type=r0,this.geojson=t,this.geometries=i}static parse(t,i){if(2!==t.length)return i.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(ad(t[1])){let i=t[1];if("FeatureCollection"===i.type){for(let t=0;t<i.features.length;++t)if(na(i.features[t].geometry.type))return new nn(i,i.features[t].geometry)}else if("Feature"===i.type){if(na(i.geometry.type))return new nn(i,i.geometry)}else if(na(i.type))return new nn(i,i)}return i.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(t){let i=t.geometry(),r=t.canonicalID();if(null!=i&&null!=r){if("Point"===t.geometryType()){var a=this.geometries;let t=[];for(let a of i)for(let i of a)t.push(a5(i,r));let[n,o]=a$(t[0][1]);return"Point"===a.type||"MultiPoint"===a.type||"LineString"===a.type?nt(t,!1,"Point"===a.type?[a.coordinates]:a.coordinates,"LineString"===a.type,n,o):"MultiLineString"===a.type?ni(t,!1,a.coordinates,n,o):"Polygon"===a.type||"MultiPolygon"===a.type?nr(t,!1,"Polygon"===a.type?[a.coordinates]:a.coordinates,n,o):null}if("LineString"===t.geometryType())return function(t,i,r){let a=[];for(let r of t){let t=[];for(let a of r)t.push(a5(a,i));a.push(t)}let[n,o]=a$(a[0][0][1]);if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return ni("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,a,n,o);if("MultiLineString"===r.type){let t=1/0;for(let i=0;i<r.coordinates.length;i++){let s=ni(r.coordinates[i],!0,a,n,o,t);if(isNaN(s))return s;if(0===(t=Math.min(t,s)))break}return t}if("Polygon"===r.type||"MultiPolygon"===r.type){let t=1/0;for(let i=0;i<a.length;i++){let s=nr(a[i],!0,"Polygon"===r.type?[r.coordinates]:r.coordinates,n,o,t);if(isNaN(s))return s;if(0===(t=Math.min(t,s)))break}return t}return null}(i,r,this.geometries);if("Polygon"===t.geometryType())return function(t,i,r){let a=[];for(let r of tb(t,0)){let t=[];for(let a=0;a<r.length;++a)t.push(function(t,i){let r=[];for(let a=0;a<t.length;++a)r.push(a5(t[a],i));return r}(r[a],i));a.push(t)}let[n,o]=a$(a[0][0][0][1]);if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return nr("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,a,n,o);if("MultiLineString"===r.type){let t=1/0;for(let i=0;i<r.coordinates.length;i++){let s=nr(r.coordinates[i],!0,a,n,o,t);if(isNaN(s))return s;if(0===(t=Math.min(t,s)))break}return t}return"Polygon"===r.type||"MultiPolygon"===r.type?function(t,i,r,a){let n=1/0;for(let o of t)for(let t of i){let i=function(t,i,r,a,n=1/0){let o=a3(t),s=a3(i);if(n!==1/0&&a4(o,s,r,a)>=n)return n;if(tT(o,s)){if(a7(t,i))return 0}else if(a7(i,t))return 0;let l=n;for(let n of t)for(let t=0,o=n.length,s=o-1;t<o;s=t++)for(let o of i)for(let i=0,h=o.length,u=h-1;i<h;u=i++){if(tI(n[s],n[t],o[u],o[i]))return 0;l=Math.min(l,a9(n[s],n[t],o[u],o[i],r,a))}return l}(o,t,r,a,n);if(isNaN(i))return i;if(0===(n=Math.min(n,i)))return n}return n}("Polygon"===r.type?[r.coordinates]:r.coordinates,a,n,o):null}(i,r,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requires valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function no(t){if(t instanceof aR&&("get"===t.name&&1===t.args.length||"feature-state"===t.name||"has"===t.name&&1===t.args.length||"properties"===t.name||"geometry-type"===t.name||"id"===t.name||t.name.startsWith("filter-"))||t instanceof aG||t instanceof nn)return!1;if(t instanceof np)return t.featureConstant;let i=!0;return t.eachChild(t=>{i&&!no(t)&&(i=!1)}),i}function ns(t){if(t instanceof aR&&"feature-state"===t.name)return!1;let i=!0;return t.eachChild(t=>{i&&!ns(t)&&(i=!1)}),i}function nl(t,i){if(t instanceof aR&&i.has(t.name))return!1;let r=!0;return t.eachChild(t=>
1{r&&!nl(t,i)&&(r=!1)}),r}function nh(t,i){return nl(t,new Set(i))}function nu(t,i,r){return[t,i,r].filter(Boolean).join("\x1f")}function nc(t,i){switch(t){case"string":return af(i);case"number":return+i;case"boolean":return!!i;case"color":return rq.parse(i);case"formatted":return al.fromString(af(i));case"resolvedImage":return au.build(af(i))}return i}function nd(t,i,r,a){return void 0!==a&&(t=a*Math.round(t/a)),void 0!==i&&t<i&&(t=i),void 0!==r&&t>r&&(t=r),t}class np{constructor(t,i,r,a=!1){this.type=t,this.key=i,this.scope=r,this.featureConstant=a}static parse(t,i){let r=i.expectedType;if(null==r&&(r=r5),t.length<2||t.length>3)return i.error("Invalid number of arguments for 'config' expression.");let a=i.parse(t[1],1);if(!(a instanceof a_))return i.error("Key name of 'config' expression must be a string literal.");let n,o=!0,s=af(a.value);if(t.length>=3){let r=i.parse(t[2],2);if(!(r instanceof a_))return i.error("Scope of 'config' expression must be a string literal.");n=af(r.value)}if(i.options){let t=nu(s,n,i._scope),r=i.options.get(t);r&&(o=no(r.value||r.default))}return new np(r,s,n,o)}evaluate(t){let i=nu(this.key,this.scope,t.scope),r=t.getConfig(i);if(!r)return null;let{type:a,value:n,values:o,minValue:s,maxValue:l,stepValue:h}=r,u=r.default.evaluate(t),c=u;if(n){let i=t.scope;t.scope=(i||"").split("\x1f").slice(1).join("\x1f"),c=n.evaluate(t),t.scope=i}return a&&(c=nc(a,c)),void 0===c||void 0===s&&void 0===l&&void 0===h||("number"==typeof c?c=nd(c,s,l,h):Array.isArray(c)&&(c=c.map(t=>"number"==typeof t?nd(t,s,l,h):t))),void 0!==n&&void 0!==c&&o&&!o.includes(c)&&(c=u,a&&(c=nc(a,c))),(a&&a!==this.type||void 0!==c&&!an(ap(c),this.type))&&(c=nc(this.type.kind,c)),c}eachChild(){}outputDefined(){return!1}serialize(){let t=["config",this.key];return this.scope&&t.concat(this.scope),t}}class nf{constructor(t,i){this.type=i.type,this.name=t,this.boundExpression=i}static parse(t,i){if(2!==t.length||"string"!=typeof t[1])return i.error("'var' expression requires exactly one string literal argument.");let r=t[1];return i.scope.has(r)?new nf(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class n_{constructor(t,i=[],r,a=new rQ,n=[],o,s,l){this.registry=t,this.path=i,this.scope=a,this.errors=n,this.expectedType=r,this._scope=o,this.options=s,this.iconImageUseTheme=l}get key(){let t="";for(let i=0;i<this.path.length;i++){let r=this.path[i];t+="string"==typeof r?`['${r}']`:`[${r}]`}return t}parse(t,i,r,a,n={}){if(i||r){let o=this.expectedType,s=this.scope;a&&(this.scope=this.scope.concat(a)),this.expectedType=r||null;let l="number"==typeof i;l&&this.path.push(i);let h=this._parse(t,n);return l&&this.path.pop(),this.expectedType=o,this.scope=s,h}return this._parse(t,n)}parseObjectValue(t,i,r,a,n,o={}){let s=this.expectedType,l=this.scope;n&&(this.scope=this.scope.concat(n)),this.expectedType=a||null,this.path.push(i),this.path.push(r);let h=this._parse(t,o);return this.path.pop(),this.path.pop(),this.expectedType=s,this.scope=l,h}_parse(t,i){if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');let r="string"==typeof t[0]?this.registry[t[0]]:void 0;if(r){let a=r.parse(t,this);if(!a)return null;if(this.expectedType){let t=this.expectedType,r=a.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==r.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(t,r))return null}else a=ng(a,t,i.typeAnnotation||"coerce");else a=ng(a,t,i.typeAnnotation||"assert")}if(!(a instanceof a_)&&"resolvedImage"!==a.type.kind&&function t(i){if(i instanceof nf)return t(i.boundExpression);if(i instanceof aR&&"error"===i.name||i instanceof aP||i instanceof aG||i instanceof nn||i instanceof np)return!1;let r=i instanceof aA||i instanceof ay,a=!0;return i.eachChild(i=>{a=r?a&&t(i):a&&i instanceof a_}),!!a&&no(i)&&nl(i,nm)}(a)){let t=new aM(this._scope,this.options,this.iconImageUseTheme);try{a=new a_(a.type,a.evaluate(t))}catch(t){return this.error(t.message),null}}return a}return aA.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,i,r,a){let n=a?this.scope.concat(a):this.scope,o=this.path.slice();return"number"==typeof t&&o.push(t),"string"==typeof i&&o.push(i),new n_(this.registry,o,r||null,n,this.errors,this._scope,this.options,this.iconImageUseTheme)}_forkForSignature(){return new n_(this.registry,this.path.slice(),null,this.scope,[],this._scope,this.options,this.iconImageUseTheme)}error(t,...i){let r=`${this.key}${i.map(t=>`[${t}]`).join("")}`;this.errors.push(new rK(r,t))}checkSubtype(t,i,r){let a=ai(t,i);return a&&this.error(a,..."number"==typeof r?[r]:[]),a}}let nm=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 ng(t,i,r){return"assert"===r?new ay(i,[t]):"coerce"===r?new aA(i,[t]):t}function ny(t,i){let r=t.length-1,a,n,o=0,s=r,l=0;for(;o<=s;)if(a=t[l=Math.floor((o+s)/2)],n=t[l+1],a<=i){if(l===r||i<n)return l;o=l+1}else{if(!(a>i))throw new am("Input is not a number.");s=l-1}return 0}
1class nx{constructor(t,i,r){for(let[a,n]of(this.type=t,this.input=i,this.labels=[],this.outputs=[],r))this.labels.push(a),this.outputs.push(n)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(t[1],1,r0);if(!r)return null;let a=[],n=null;i.expectedType&&"value"!==i.expectedType.kind&&(n=i.expectedType);for(let r=1;r<t.length;r+=2){let o=1===r?-1/0:t[r],s=t[r+1],l=r,h=r+1;if("number"!=typeof o)return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',l);if(a.length&&a.at(-1)[0]>=o)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',l);let u=i.parse(s,h,n);if(!u)return null;n=n||u.type,a.push([o,u])}return new nx(n,r,a)}evaluate(t){let i=this.labels,r=this.outputs;if(1===i.length)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;return a>=i[n-1]?r[n-1].evaluate(t):r[ny(i,a)].evaluate(t)}eachChild(t){for(let i of(t(this.input),this.outputs))t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){let t=["step",this.input.serialize()];for(let i=0;i<this.labels.length;i++)i>0&&t.push(this.labels[i]),t.push(this.outputs[i].serialize());return t}}let nv=4/29,nb=6/29,nw=6/29*3*(6/29),nT=6/29*(6/29)*(6/29),nE=Math.PI/180,nS=180/Math.PI;function nI(t){return t>nT?Math.pow(t,1/3):t/nw+nv}function nA(t){return t>nb?t*t*t:nw*(t-nv)}
1function nC(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function nM(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function nR(t){let i=nM(t.r),r=nM(t.g),a=nM(t.b),n=nI((.4124564*i+.3575761*r+.1804375*a)/.95047),o=nI((.2126729*i+.7151522*r+.072175*a)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-nI((.0193339*i+.119192*r+.9503041*a)/1.08883)),alpha:t.a}}function nD(t){let i=(t.l+16)/116,r=isNaN(t.a)?i:i+t.a/500,a=isNaN(t.b)?i:i-t.b/200;return i=+nA(i),new rq(nC(3.2404542*(r=.95047*nA(r))-1.5371385*i-.4985314*(a=1.08883*nA(a))),nC(-.969266*r+1.8760108*i+.041556*a),nC(.0556434*r-.2040259*i+1.0572252*a),t.alpha)}let nP={forward:nR,reverse:nD,interpolate:function(t,i,r){return{l:rG(t.l,i.l,r),a:rG(t.a,i.a,r),b:rG(t.b,i.b,r),alpha:rG(t.alpha,i.alpha,r)}}},nz={forward:function(t){let{l:i,a:r,b:a}=nR(t),n=Math.atan2(a,r)*nS;return{h:n<0?n+360:n,c:Math.sqrt(r*r+a*a),l:i,alpha:t.a}},reverse:function(t){let i=t.h*nE,r=t.c;return nD({l:t.l,a:Math.cos(i)*r,b:Math.sin(i)*r,alpha:t.alpha})},interpolate:function(t,i,r){return{h:function(t,i,r){let a=i-t;return t+r*(a>180||a<-180?a-360*Math.round(a/360):a)}(t.h,i.h,r),c:rG(t.c,i.c,r),l:rG(t.l,i.l,r),alpha:rG(t.alpha,i.alpha,r)}}};var nL=Object.freeze({__proto__:null,hcl:nz,lab:nP});class nO{constructor(t,i,r,a,n){for(let[o,s]of(this.type=t,this.operator=i,this.interpolation=r,this.input=a,this.labels=[],this.outputs=[],n))this.labels.push(o),this.outputs.push(s)}static interpolationFactor(t,i,r,a){let n=0;if("exponential"===t.name)n=nF(i,t.base,r,a);else if("linear"===t.name)n=nF(i,1,r,a);else if("cubic-bezier"===t.name){let o=t.controlPoints;n=tm(o[0],o[1],o[2],o[3])(nF(i,1,r,a))}return n}static parse(t,i){let[r,a,n,...o]=t;if(!Array.isArray(a)||0===a.length)return i.error("Expected an interpolation type expression.",1);if("linear"===a[0])a={name:"linear"};else if("exponential"===a[0]){let t=a[1];if("number"!=typeof t)return i.error("Exponential interpolation requires a numeric base.",1,1);a={name:"exponential",base:t}}else{if("cubic-bezier"!==a[0])return i.error(`Unknown interpolation type ${String(a[0])}`,1,0);{let t=a.slice(1);if(4!==t.length||t.some(t=>"number"!=typeof t||t<0||t>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length-1>3&&(t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(!(n=i.parse(n,2,r0)))return null;let s=[],l=null;"interpolate-hcl"===r||"interpolate-lab"===r?l=r3:i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType);for(let t=0;t<o.length;t+=2){let r=o[t],a=o[t+1],n=t+3,h=t+4;if("number"!=typeof r)return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s.at(-1)[0]>=r)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);let u=i.parse(a,h,l);if(!u)return null;l=l||u.type,s.push([r,u])}return"number"===l.kind||"color"===l.kind||"array"===l.kind&&"number"===l.itemType.kind&&"number"==typeof l.N?new nO(l,r,a,n,s):i.error(`Type ${ae(l)} is not interpolatable.`)}evaluate(t){let i=this.labels,r=this.outputs;if(1===i.length)return r[0].evaluate(t);let a=this.input.evaluate(t);if(a<=i[0])return r[0].evaluate(t);let n=i.length;if(a>=i[n-1])return r[n-1].evaluate(t);let o=ny(i,a),s=nO.interpolationFactor(this.interpolation,a,i[o],i[o+1]),l=r[o].evaluate(t),h=r[o+1].evaluate(t);return"interpolate"===this.operator?rY[this.type.kind.toLowerCase()](l,h,s):"interpolate-hcl"===this.operator?nz.reverse(nz.interpolate(nz.forward(l),nz.forward(h),s)):nP.reverse(nP.interpolate(nP.forward(l),nP.forward(h),s))}eachChild(t){for(let i of(t(this.input),this.outputs))t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];let i=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)i.push(this.labels[t],this.outputs[t].serialize());return i}}function nF(t,i,r,a){let n=a-r,o=t-r;return 0===n?0:1===i?o/n:(Math.pow(i,o)-1)/(Math.pow(i,n)-1)}class nB{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expectected at least one argument."),null;let r=null,a=i.expectedType;a&&"value"!==a.kind&&(r=a);let n=[];for(let a of t.slice(1)){let t=i.parse(a,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,n.push(t)}return new nB(a&&n.some(t=>ai(a,t.type))?r5:r,n)}evaluate(t){let i,r=null,a=0;for(let n of this.args){if(a++,(r=n.evaluate(t))&&r instanceof au&&!r.available&&(i||(i=r),r=null,a===this.args.length))return i;if(null!==r)break}return r}
1eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){let t=["coalesce"];return this.eachChild(i=>{t.push(i.serialize())}),t}}let nk=/[^a-zA-Z0-9_]/;class nN{constructor(t,i){this.type=i.type,this.bindings=[].concat(t),this.result=i}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let i of this.bindings)t(i[1]);t(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);let r=[];for(let a=1;a<t.length-1;a+=2){let n=t[a];if("string"!=typeof n)return i.error(`Expected string, but found ${typeof n} instead.`,a);if(nk.test(n))return i.error("Variable names must contain only alphanumeric characters or '_'.",a);let o=i.parse(t[a+1],a+1);if(!o)return null;r.push([n,o])}let a=i.parse(t.at(-1),t.length-1,i.expectedType,r);return a?new nN(r,a):null}outputDefined(){return this.result.outputDefined()}serialize(){let t=["let"];for(let[i,r]of this.bindings)t.push(i,r.serialize());return t.push(this.result.serialize()),t}}class nV{constructor(t,i,r){this.type=t,this.index=i,this.input=r}static parse(t,i){if(3!==t.length)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,r0),a=i.parse(t[2],2,r7(i.expectedType||r5));return r&&a?new nV(a.type.itemType,r,a):null}evaluate(t){let i=this.index.evaluate(t),r=this.input.evaluate(t);if(i<0)throw new am("Array index out of bounds: negative index");if(i>=r.length)throw new am("Array index out of bounds: index exceeds array size");if(i!==Math.floor(i))throw new am("Array index must be an integer. Use at-interpolated for fractional indices");return r[i]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class nU{constructor(t,i,r){this.type=t,this.index=i,this.input=r}static parse(t,i){if(3!==t.length)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,r0),a=i.parse(t[2],2,r7(i.expectedType||r5));return r&&a?new nU(a.type.itemType,r,a):null}evaluate(t){let i=this.index.evaluate(t),r=this.input.evaluate(t);if(i<0)throw new am(`Array index out of bounds: ${i} < 0.`);if(i>r.length-1)throw new am(`Array index out of bounds: ${i} > ${r.length-1}.`);if(i===Math.floor(i))return r[i];let a=Math.floor(i),n=Math.ceil(i),o=r[a],s=r[n];if("number"!=typeof o||"number"!=typeof s)throw new am(`Cannot interpolate between non-number values at index ${i}.`);return rG(o,s,i-a)}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class nj{constructor(t,i){this.type=r2,this.needle=t,this.haystack=i}static parse(t,i){if(3!==t.length)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`),null;let r=i.parse(t[1],1,r5),a=i.parse(t[2],2,r5);return r&&a?ar(r.type,[r2,r1,r0,rJ,r5])?new nj(r,a):(i.error(`Expected first argument to be of type boolean, string, number or null, but found ${ae(r.type)} instead`),null):null}evaluate(t){let i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(null==r)return!1;if(!aa(i,["boolean","string","number","null"]))throw new am(`Expected first argument to be of type boolean, string, number or null, but found ${ae(ap(i))} instead.`);if(!aa(r,["string","array"]))throw new am(`Expected second argument to be of type array or string, but found ${ae(ap(r))} instead.`);return r.includes(i)}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class nG{constructor(t,i,r){this.type=r0,this.needle=t,this.haystack=i,this.fromIndex=r}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`),null;let r=i.parse(t[1],1,r5),a=i.parse(t[2],2,r5);if(!r||!a)return null;if(!ar(r.type,[r2,r1,r0,rJ,r5]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${ae(r.type)} instead`),null;if(4===t.length){let n=i.parse(t[3],3,r0);return n?new nG(r,a,n):null}return new nG(r,a)}evaluate(t){let i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!aa(i,["boolean","string","number","null"]))throw new am(`Expected first argument to be of type boolean, string, number or null, but found ${ae(ap(i))} instead.`);if(!aa(r,["string","array"]))throw new am(`Expected second argument to be of type array or string, but found ${ae(ap(r))} instead.`);if(this.fromIndex){let a=this.fromIndex.evaluate(t);return r.indexOf(i,a)}return r.indexOf(i)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){let t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class nH{constructor(t,i,r,a,n,o){this.inputType=t,this.type=i,this.input=r,this.cases=a,this.outputs=n,this.otherwise=o}static parse(t,i){let r,a;
1if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");i.expectedType&&"value"!==i.expectedType.kind&&(a=i.expectedType);let n={},o=[];for(let s=2;s<t.length-1;s+=2){let l=t[s],h=t[s+1];if(Array.isArray(l)||(l=[l]),0===l.length)return i.error("Expected at least one branch label.",s);for(let t of l){if("number"!=typeof t&&"string"!=typeof t)return i.error("Branch labels must be numbers or strings.",s);if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return i.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`,s);if("number"==typeof t&&Math.floor(t)!==t)return i.error("Numeric branch labels must be integer values.",s);if(r){if(i.checkSubtype(r,ap(t),s))return null}else r=ap(t);if(void 0!==n[String(t)])return i.error("Branch labels must be unique.",s);n[String(t)]=o.length}let u=i.parse(h,s,a);if(!u)return null;a=a||u.type,o.push(u)}let s=i.parse(t[1],1,r5);if(!s)return null;let l=i.parse(t.at(-1),t.length-1,a);return l?"value"!==s.type.kind&&i.checkSubtype(r,s.type,1)?null:new nH(r,a,s,n,o,l):null}evaluate(t){let i=this.input.evaluate(t);return(an(ap(i),this.inputType)&&this.outputs[this.cases[i]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){let t=["match",this.input.serialize()],i=Object.keys(this.cases).sort(),r=[],a={};for(let t of i){let i=a[this.cases[t]];void 0===i?(a[this.cases[t]]=r.length,r.push([this.cases[t],[t]])):r[i][1].push(t)}let n=t=>"number"===this.inputType.kind?Number(t):t;for(let[i,a]of r)t.push(1===a.length?n(a[0]):a.map(n)),t.push(this.outputs[i].serialize());return t.push(this.otherwise.serialize()),t}}class nq{constructor(t,i,r){this.type=t,this.branches=i,this.otherwise=r}static parse(t,i){let r;if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`),null;if(t.length%2!=0)return i.error("Expected an odd number of arguments."),null;i.expectedType&&"value"!==i.expectedType.kind&&(r=i.expectedType);let a=[];for(let n=1;n<t.length-1;n+=2){let o=i.parse(t[n],n,r2);if(!o)return null;let s=i.parse(t[n+1],n+1,r);if(!s)return null;a.push([o,s]),r=r||s.type}let n=i.parse(t.at(-1),t.length-1,r);return n?new nq(r,a,n):null}evaluate(t){for(let[i,r]of this.branches)if(i.evaluate(t))return r.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[i,r]of this.branches)t(i),t(r);t(this.otherwise)}outputDefined(){return this.branches.every(([t,i])=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){let t=["case"];return this.eachChild(i=>{t.push(i.serialize())}),t}}class nZ{constructor(t,i,r,a){this.type=t,this.input=i,this.beginIndex=r,this.endIndex=a}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`),null;let r=i.parse(t[1],1,r5),a=i.parse(t[2],2,r0);if(!r||!a)return null;if(!ar(r.type,[r7(r5),r1,r5]))return i.error(`Expected first argument to be of type array or string, but found ${ae(r.type)} instead`),null;if(4===t.length){let n=i.parse(t[3],3,r0);return n?new nZ(r.type,r,a,n):null}return new nZ(r.type,r,a)}evaluate(t){let i=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!aa(i,["string","array"]))throw new am(`Expected first argument to be of type array or string, but found ${ae(ap(i))} instead.`);if(this.endIndex){let a=this.endIndex.evaluate(t);return i.slice(r,a)}return i.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){let t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class n${constructor(t,i){this.type=r7(r1),this.str=t,this.delimiter=i}static parse(t,i){if(3!==t.length)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);let r=i.parse(t[1],1,r1),a=i.parse(t[2],2,r1);return r&&a?new n$(r,a):void 0}evaluate(t){let i=this.str.evaluate(t),r=this.delimiter.evaluate(t);return i.split(r)}eachChild(t){t(this.str),t(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function nW(t,i){return"=="===t||"!="===t?"boolean"===i.kind||"string"===i.kind||"number"===i.kind||"null"===i.kind||"value"===i.kind:"string"===i.kind||"number"===i.kind||"value"===i.kind}function nX(t,i,r,a){return 0===a.compare(i,r)}function nY(t,i,r){let a="=="!==t&&"!="!==t;
1return class n{constructor(t,i,r){this.type=r2,this.lhs=t,this.rhs=i,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===i.type.kind}static parse(t,i){if(3!==t.length&&4!==t.length)return i.error("Expected two or three arguments.");let r=t[0],o=i.parse(t[1],1,r5);if(!o)return null;if(!nW(r,o.type))return i.error(`"${r}" comparisons are not supported for type '${ae(o.type)}'.`,1);let s=i.parse(t[2],2,r5);if(!s)return null;if(!nW(r,s.type))return i.error(`"${r}" comparisons are not supported for type '${ae(s.type)}'.`,2);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return i.error(`Cannot compare types '${ae(o.type)}' and '${ae(s.type)}'.`);a&&("value"===o.type.kind&&"value"!==s.type.kind?o=new ay(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new ay(o.type,[s])));let l=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return i.error("Cannot use collator to compare non-string types.");if(!(l=i.parse(t[3],3,r6)))return null}return new n(o,s,l)}evaluate(n){let o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(a&&this.hasUntypedArgument){let i=ap(o),r=ap(s);if(i.kind!==r.kind||"string"!==i.kind&&"number"!==i.kind)throw new am(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${i.kind}, ${r.kind}) instead.`)}if(this.collator&&!a&&this.hasUntypedArgument){let t=ap(o),r=ap(s);if("string"!==t.kind||"string"!==r.kind)return i(n,o,s)}return this.collator?r(n,o,s,this.collator.evaluate(n)):i(n,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){let i=[t];return this.eachChild(t=>{i.push(t.serialize())}),i}}}let nK=nY("==",function(t,i,r){return i===r},nX),nQ=nY("!=",function(t,i,r){return i!==r},function(t,i,r,a){return!nX(0,i,r,a)}),nJ=nY("<",function(t,i,r){return i<r},function(t,i,r,a){return 0>a.compare(i,r)}),n0=nY(">",function(t,i,r){return i>r},function(t,i,r,a){return a.compare(i,r)>0}),n1=nY("<=",function(t,i,r){return i<=r},function(t,i,r,a){return 0>=a.compare(i,r)}),n2=nY(">=",function(t,i,r){return i>=r},function(t,i,r,a){return a.compare(i,r)>=0});class n3{constructor(t,i,r,a,n,o){this.type=r1,this.number=t,this.locale=i,this.currency=r,this.unit=a,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(t,i){if(3!==t.length)return i.error("Expected two arguments.");let r=i.parse(t[1],1,r0);if(!r)return null;let a=t[2];if("object"!=typeof a||Array.isArray(a))return i.error("NumberFormat options argument must be an object.");let n=null;if(a.locale&&!(n=i.parseObjectValue(a.locale,2,"locale",r1)))return null;let o=null;if(a.currency&&!(o=i.parseObjectValue(a.currency,2,"currency",r1)))return null;let s=null;if(a.unit&&!(s=i.parseObjectValue(a.unit,2,"unit",r1)))return null;let l=null;if(a["min-fraction-digits"]&&!(l=i.parseObjectValue(a["min-fraction-digits"],2,"min-fraction-digits",r0)))return null;let h=null;return!a["max-fraction-digits"]||(h=i.parseObjectValue(a["max-fraction-digits"],2,"max-fraction-digits",r0))?new n3(r,n,o,s,l,h):null}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){let t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class n4{constructor(t){this.type=r0,this.input=t}static parse(t,i){if(2!==t.length)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`),null;let r=i.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?(i.error(`Expected argument of type string or array, but found ${ae(r.type)} instead.`),null):new n4(r):null}evaluate(t){let i=this.input.evaluate(t);if("string"==typeof i||Array.isArray(i))return i.length;throw new am(`Expected value to be of type string or array, but found ${ae(ap(i))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){let t=["length"];return this.eachChild(i=>{t.push(i.serialize())}),t}}function n5(t){return function(){let i=Math.imul((t=0x6d2b79f5+(t|=0)|0)^t>>>15,1|t);return(((i=i+Math.imul(i^i>>>7,61|i)^i)^i>>>14)>>>0)/0x100000000}}let n6={"==":nK,"!=":nQ,">":n0,"<":nJ,">=":n2,"<=":n1,array:ay,at:nV,"at-interpolated":nU,boolean:ay,case:nq,coalesce:nB,collator:aP,format:ax,image:av,in:nj,"index-of":nG,interpolate:nO,"interpolate-hcl":nO,"interpolate-lab":nO,length:n4,let:nN,literal:a_,match:nH,number:ay,"number-format":n3,object:ay,slice:nZ,step:nx,string:ay,"to-boolean":aA,"to-color":aA,"to-number":aA,"to-string":aA,var:nf,within:aG,distance:nn,config:np,split:n$};function n8(t,[i,r,a,n]){i=i.evaluate(t),r=r.evaluate(t),a=a.evaluate(t);let o=n?n.evaluate(t):1,s=ac(i,r,a,o);if(s)throw new am(s);return new rq(i/255,r/255,a/255,o)}function n9(t,[i,r,a,n]){var o,s,l;i=i.evaluate(t),r=r.evaluate(t),a=a.evaluate(t);let h=n?n.evaluate(t):1,u=(o=i,s=r,l=a,"number"==typeof o&&o>=0&&o<=360?"number"==typeof s&&s>=0&&s<=100&&"number"==typeof l&&l>=0&&l<=100?void 0===h||"number"==typeof h&&h>=0&&h<=1?null:`Invalid hsla value [${[o,s,l,h].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof h?[o,s,l,h]:[o,s,l]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof h?[o,s,l,h]:[o,s,l]).join(", ")}]: 'h' must be between 0 and 360.`);if(u)throw new am(u);let c=`hsla(${i}, ${r}%, ${a}%, ${h})`,d=rq.parse(c);if(!d)throw new am(`Failed to parse HSLA color: ${c}`);return d}function n7(t,i){let r=i[t];return void 0===r?null:r}function oe(t){return{type:t}}function ot(t){if(t instanceof np)return new Set([t.key]);let i=new Set;return t.eachChild(t=>{i=new Set([...i,...ot(t)])}),i}function oi(t){if(t instanceof aR&&"is-active-floor"===t.name)return!0;let i=!1;return t.eachChild(t=>{!i&&oi(t)&&(i=!0)}),i}function or(t){return{result:"success",value:t}}function oa(t){return{result:"error",value:t}}aR.register(n6,{error:[{kind:"error"},[r1],(t,[i])=>{throw new am(i.evaluate(t))}],typeof:[r1,[r5],(t,[i])=>ae(ap(i.evaluate(t)))],"to-rgba":[r7(r0,4),[r3],(t,[i])=>i.evaluate(t).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[r7(r0,4),[r3],(t,[i])=>i.evaluate(t).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[r3,[r0,r0,r0],n8],rgba:[r3,[r0,r0,r0,r0],n8],hsl:[r3,[r0,r0,r0],n9],hsla:[r3,[r0,r0,r0,r0],n9],has:{type:r2,overloads:[[[r1],(t,[i])=>i.evaluate(t)in t.properties()],[[r1,r4],(t,[i,r])=>i.evaluate(t)in r.evaluate(t)]]},get:{type:r5,overloads:[[[r1],(t,[i])=>n7(i.evaluate(t),t.properties())],[[r1,r4],(t,[i,r])=>n7(i.evaluate(t),r.evaluate(t))]]},"feature-state":[r5,[r1],(t,[i])=>n7(i.evaluate(t),t.featureState||{})],properties:[r4,[],t=>t.properties()],"geometry-type":[r1,[],t=>t.geometryType()],worldview:[r1,[],t=>t.globals.worldview||""],"is-active-floor":[r2,oe(r1),(t,i)=>{if(!(t.globals&&t.globals.activeFloors&&t.globals.activeFloors.size>0))return!1;if(0===i.length)return!0;let r=t.globals.activeFloors;return i.some(i=>{let a=i.evaluate(t);return r.has(a)})}],id:[r5,[],t=>t.id()],zoom:[r0,[],t=>t.globals.zoom],pitch:[r0,[],t=>t.globals.pitch||0],"distance-from-center":[r0,[],t=>t.distanceFromCenter()],"measure-light":[r0,[r1],(t,[i])=>t.measureLight(i.evaluate(t))],"heatmap-density":[r0,[],t=>t.globals.heatmapDensity||0],"line-progress":[r0,[],t=>t.globals.lineProgress||0],"raster-value":[r0,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[r0,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[r0,[],t=>t.globals.skyRadialProgress||0],accumulated:[r5,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[r0,oe(r0),(t,i)=>{let r=0;for(let a of i)r+=a.evaluate(t);return r}],"*":[r0,oe(r0),(t,i)=>{let r=1;for(let a of i)r*=a.evaluate(t);return r}],"-":{type:r0,overloads:[[[r0,r0],(t,[i,r])=>i.evaluate(t)-r.evaluate(t)],[[r0],(t,[i])=>-i.evaluate(t)]]},"/":[r0,[r0,r0],(t,[i,r])=>i.evaluate(t)/r.evaluate(t)],"%":[r0,[r0,r0],(t,[i,r])=>i.evaluate(t)%r.evaluate(t)],ln2:[r0,[],()=>Math.LN2],pi:[r0,[],()=>Math.PI],e:[r0,[],()=>Math.E],"^":[r0,[r0,r0],(t,[i,r])=>Math.pow(i.evaluate(t),r.evaluate(t))],sqrt:[r0,[r0],(t,[i])=>Math.sqrt(i.evaluate(t))],log10:[r0,[r0],(t,[i])=>Math.log(i.evaluate(t))/Math.LN10],ln:[r0,[r0],(t,[i])=>Math.log(i.evaluate(t))],log2:[r0,[r0],(t,[i])=>Math.log2(i.evaluate(t))],sin:[r0,[r0],(t,[i])=>Math.sin(i.evaluate(t))],cos:[r0,[r0],(t,[i])=>Math.cos(i.evaluate(t))],tan:[r0,[r0],(t,[i])=>Math.tan(i.evaluate(t))],asin:[r0,[r0],(t,[i])=>Math.asin(i.evaluate(t))],acos:[r0,[r0],(t,[i])=>Math.acos(i.evaluate(t))],atan:[r0,[r0],(t,[i])=>Math.atan(i.evaluate(t))],min:[r0,oe(r0),(t,i)=>Math.min(...i.map(i=>i.evaluate(t)))],max:[r0,oe(r0),(t,i)=>Math.max(...i.map(i=>i.evaluate(t)))],abs:[r0,[r0],(t,[i])=>Math.abs(i.evaluate(t))],round:[r0,[r0],(t,[i])=>{let r=i.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[r0,[r0],(t,[i])=>Math.floor(i.evaluate(t))],ceil:[r0,[r0],(t,[i])=>Math.ceil(i.evaluate(t))],"filter-==":[r2,[r1,r5],(t,[i,r])=>t.properties()[i.value]===r.value],"filter-id-==":[r2,[r5],(t,[i])=>t.id()===i.value],"filter-type-==":[r2,[r1],(t,[i])=>t.geometryType()===i.value],"filter-<":[r2,[r1,r5],(t,[i,r])=>{let a=t.properties()[i.value],n=r.value;return typeof a==typeof n&&a<n}],"filter-id-<":[r2,[r5],(t,[i])=>{let r=t.id(),a=i.value;return typeof r==typeof a&&r<a}],"filter->":[r2,[r1,r5],(t,[i,r])=>{let a=t.properties()[i.value],n=r.value;return typeof a==typeof n&&a>n}],"filter-id->":[r2,[r5],(t,[i])=>{let r=t.id(),a=i.value;return typeof r==typeof a&&r>a}],"filter-<=":[r2,[r1,r5],(t,[i,r])=>{let a=t.properties()[i.value],n=r.value;return typeof a==typeof n&&a<=n}],"filter-id-<=":[r2,[r5],(t,[i])=>{let r=t.id(),a=i.value;return typeof r==typeof a&&r<=a}],"filter->=":[r2,[r1,r5],(t,[i,r])=>{let a=t.properties()[i.value],n=r.value;return typeof a==typeof n&&a>=n}],"filter-id->=":[r2,[r5],(t,[i])=>{let r=t.id(),a=i.value;return typeof r==typeof a&&r>=a}],"filter-has":[r2,[r5],(t,[i])=>i.value in t.properties()],"filter-has-id":[r2,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[r2,[r7(r1)],(t,[i])=>i.value.includes(t.geometryType())],"filter-id-in":[r2,[r7(r5)],(t,[i])=>i.value.includes(t.id())],"filter-in-small":[r2,[r1,r7(r5)],(t,[i,r])=>r.value.includes(t.properties()[i.value])],"filter-in-large":[r2,[r1,r7(r5)],(t,[i,r])=>(function(t,i,r,a){for(;r<=a;){let n=r+a>>1;if(i[n]===t)return!0;
1i[n]>t?a=n-1:r=n+1}return!1})(t.properties()[i.value],r.value,0,r.value.length-1)],all:{type:r2,overloads:[[[r2,r2],(t,[i,r])=>i.evaluate(t)&&r.evaluate(t)],[oe(r2),(t,i)=>{for(let r of i)if(!r.evaluate(t))return!1;return!0}]]},any:{type:r2,overloads:[[[r2,r2],(t,[i,r])=>i.evaluate(t)||r.evaluate(t)],[oe(r2),(t,i)=>{for(let r of i)if(r.evaluate(t))return!0;return!1}]]},"!":[r2,[r2],(t,[i])=>!i.evaluate(t)],"is-supported-script":[r2,[r1],(t,[i])=>{let r=t.globals&&t.globals.isSupportedScript;return!r||r(i.evaluate(t))}],upcase:[r1,[r1],(t,[i])=>i.evaluate(t).toUpperCase()],downcase:[r1,[r1],(t,[i])=>i.evaluate(t).toLowerCase()],concat:[r1,oe(r5),(t,i)=>i.map(i=>af(i.evaluate(t))).join("")],"resolved-locale":[r1,[r6],(t,[i])=>i.evaluate(t).resolvedLocale()],random:[r0,[r0,r0,r5],(t,i)=>{let r,[a,n,o]=i.map(i=>i.evaluate(t));if(a>n||a===n)return a;if("string"==typeof o)r=function(t){let i=0;if(0===t.length)return i;for(let r=0;r<t.length;r++)i=(i<<5)-i+t.charCodeAt(r),i&=i;return i}(o);else{if("number"!=typeof o)throw new am(`Invalid seed input: ${o}`);r=o}return a+n5(r)()*(n-a)}]});let on=/^(.*)-transition$/,oo=/^(.*)-use-theme$/;function os(t,i){return!!t&&!!t.parameters&&t.parameters.includes(i)}function ol(t){return"data-driven"===t["property-type"]}function oh(t){return os(t.expression,"measure-light")}function ou(t){return os(t.expression,"zoom")}function oc(t){return!!t.expression&&t.expression.interpolated}function od(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function op(t){return t}function of(t,i,r){return void 0!==t?t:void 0!==i?i:void 0!==r?r:void 0}function o_(t,i,r,a,n){return of(typeof r===n?a[r]:void 0,t.default,i.default)}function om(t,i,r){if(!aE(r))return of(t.default,i.default);let a=t.stops.length;if(1===a||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[a-1][0])return t.stops[a-1][1];let n=ny(t.stops.map(t=>t[0]),r);return t.stops[n][1]}function og(t,i,r){let a=void 0!==t.base?t.base:1;if(!aE(r))return of(t.default,i.default);let n=t.stops.length;if(1===n||r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];let o=ny(t.stops.map(t=>t[0]),r),s=function(t,i,r,a){let n=a-r,o=t-r;return 0===n?0:1===i?o/n:(Math.pow(i,o)-1)/(Math.pow(i,n)-1)}(r,a,t.stops[o][0],t.stops[o+1][0]),l=t.stops[o][1],h=t.stops[o+1][1],u=rY[i.type]||op;if(t.colorSpace&&"rgb"!==t.colorSpace){let i=nL[t.colorSpace];u=(t,r)=>i.reverse(i.interpolate(i.forward(t),i.forward(r),s))}return"function"==typeof l.evaluate?{evaluate(...t){let i=l.evaluate.apply(void 0,t),r=h.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==r)return u(i,r,s)}}:u(l,h,s)}function oy(t,i,r){return"color"===i.type?r=rq.parse(r):"formatted"===i.type?r=al.fromString(r.toString()):"resolvedImage"===i.type?r=au.build(r.toString()):ab(r)===i.type||"enum"===i.type&&i.values[r]||(r=void 0),of(r,t.default,i.default)}class ox{constructor(t,i,r,a,n){this.expression=t,this._warningHistory={},this._scope=r,this._options=a,this._iconImageUseTheme=n,this._evaluator=new aM(r,a,n),this._defaultValue=i?function(t){return"color"===t.type&&(od(t.default)||Array.isArray(t.default))?new rq(0,0,0,0):"color"===t.type?rq.parse(t.default)||null:void 0===t.default?null:t.default}(i):null,this._enumValues=i&&"enum"===i.type?i.values:null,this.configDependencies=ot(t),this.isIndoorDependent=oi(t)}evaluateWithoutErrorHandling(t,i,r,a,n,o,s,l){return this._evaluator.globals=t,this._evaluator.feature=i,this._evaluator.featureState=r,this._evaluator.canonical=a||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=l||null,this.expression.evaluate(this._evaluator)}evaluate(t,i,r,a,n,o,s,l,h){this._evaluator||(this._evaluator=new aM(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=t,this._evaluator.feature=i||null,this._evaluator.featureState=r||null,this._evaluator.canonical=a||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=l||null,this._evaluator.iconImageUseTheme=h||null;try{let t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new am(`Expected value to be one of ${Object.keys(this._enumValues).map(t=>JSON.stringify(t)).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function ov(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in n6}function ob(t,i,r,a,n){let o=new n_(n6,[],i?function(t){let i={color:r3,string:r1,number:r0,enum:r1,boolean:r2,formatted:r8,resolvedImage:r9};return"array"===t.type?r7(i[t.value]||r5,t.length):i[t.type]}(i):void 0,void 0,void 0,r,a,n),s=o.parse(t,void 0,void 0,void 0,i&&"string"===i.type?{typeAnnotation:"coerce"}:void 0);return s?or(new ox(s,i,r,a,n)):oa(o.errors)}class ow{constructor(t,i,r,a){this.kind=t,this._styleExpression=i,this.isLightConstant=r,this.isLineProgressConstant=a,this.isStateDependent="constant"!==t&&!ns(i.expression),this.configDependencies=ot(i.expression),this.isIndo
1orDependent=oi(i.expression)}evaluateWithoutErrorHandling(t,i,r,a,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,i,r,a,n,o)}evaluate(t,i,r,a,n,o,s){return this._styleExpression.evaluate(t,i,r,a,n,o,void 0,void 0,s)}}class oT{constructor(t,i,r,a,n,o){this.kind=t,this.zoomStops=r,this._styleExpression=i,this.isStateDependent="camera"!==t&&!ns(i.expression),this.isIndoorDependent=oi(i.expression),this.isLightConstant=n,this.isLineProgressConstant=o,this.configDependencies=ot(i.expression),this.interpolationType=a}evaluateWithoutErrorHandling(t,i,r,a,n,o){return this._styleExpression.evaluateWithoutErrorHandling(t,i,r,a,n,o)}evaluate(t,i,r,a,n,o){return this._styleExpression.evaluate(t,i,r,a,n,o)}interpolationFactor(t,i,r){return this.interpolationType?nO.interpolationFactor(this.interpolationType,t,i,r):0}}function oE(t,i,r,a,n){if("error"===(t=ob(t,i,r,a,n)).result)return t;let o=t.value.expression,s=no(o);if(!s&&!ol(i))return oa([new rK("","data expressions not supported")]);let l=nh(o,["zoom","pitch","distance-from-center"]);if(!l&&!ou(i))return oa([new rK("","zoom expressions not supported")]);let h=nh(o,["measure-light"]);if(!h&&!oh(i))return oa([new rK("","measure-light expression not supported")]);let u=nh(o,["line-progress"]);if(!u&&!os(i.expression,"line-progress"))return oa([new rK("","line-progress expression not supported")]);let c=i.expression&&i.expression.relaxZoomRestriction,d=function t(i){let r=null;if(i instanceof nN)r=t(i.result);else if(i instanceof nB){for(let a of i.args)if(r=t(a))break}else(i instanceof nx||i instanceof nO)&&i.input instanceof aR&&"zoom"===i.input.name&&(r=i);return r instanceof rK||i.eachChild(i=>{let a=t(i);a instanceof rK?r=a:r&&a&&r!==a&&(r=new rK("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),r}(o);return d||l||c?d instanceof rK?oa([d]):d instanceof nO&&!oc(i)?oa([new rK("",'"interpolate" expressions cannot be used with this property')]):or(d?new oT(s&&u?"camera":"composite",t.value,d.labels,d instanceof nO?d.interpolation:void 0,h,u):new ow(s&&u?"constant":"source",t.value,h,u)):oa([new rK("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class oS{constructor(t,i){this._parameters=t,this._specification=i,Object.assign(this,function t(i,r){let a,n,o,s="color"===r.type,l=i.stops&&"object"==typeof i.stops[0][0],h=l||!(l||void 0!==i.property),u=i.type||(oc(r)?"exponential":"interval");if(s&&((i={...i}).stops&&(i.stops=i.stops.map(t=>[t[0],rq.parse(t[1])])),i.default=rq.parse(i.default?i.default:r.default)),i.colorSpace&&"rgb"!==i.colorSpace&&!nL[i.colorSpace])throw Error(`Unknown color space: ${i.colorSpace}`);if("exponential"===u)a=og;else if("interval"===u)a=om;else if("categorical"===u){for(let t of(a=o_,n=Object.create(null),i.stops))n[t[0]]=t[1];o=typeof i.stops[0][0]}else{if("identity"!==u)throw Error(`Unknown function type "${u}"`);a=oy}if(l){let a={},n=[];for(let t=0;t<i.stops.length;t++){let r=i.stops[t],o=r[0].zoom;void 0===a[o]&&(a[o]={zoom:o,type:i.type,property:i.property,default:i.default,stops:[]},n.push(o)),a[o].stops.push([r[0].value,r[1]])}let o=[];for(let i of n)o.push([a[i].zoom,t(a[i],r)]);let s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:nO.interpolationFactor.bind(void 0,s),zoomStops:o.map(t=>t[0]),evaluate:({zoom:t},a)=>og({stops:o,base:i.base},r,t).evaluate(t,a)}}if(h){let t="exponential"===u?{name:"exponential",base:void 0!==i.base?i.base:1}:null;return{kind:"camera",interpolationType:t,interpolationFactor:nO.interpolationFactor.bind(void 0,t),zoomStops:i.stops.map(t=>t[0]),evaluate:({zoom:t})=>a(i,r,t,n,o)}}return{kind:"source",evaluate(t,s){let l=s&&s.properties?s.properties[i.property]:void 0;return void 0===l?of(i.default,r.default):a(i,r,l,n,o)}}}(this._parameters,this._specification))}static deserialize(t){return new oS(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}class oI{constructor(t,i,r){if(this.boxSeen=new Uint32Array(0),this.circleSeen=new Uint32Array(0),this.generation=0,t instanceof ArrayBuffer){let i=new Int32Array(t);this.width=i[0],this.height=i[1],this.xCellCount=i[2],this.yCellCount=i[3],this.boxUid=i[4],this.circleUid=i[5];let r=this.xCellCount*this.yCellCount,a=[];for(let t=0;t<r;t++){let r=i[6+t],n=i[6+t+1];a.push(r===n?null:i.subarray(r,n))}let n=i[6+r],o=[];for(let t=0;t<r;t++){let r=i[n+t],a=i[n+t+1];o.push(r===a?null:i.subarray(r,a))}let s=i[n+r];this.boxCells=a,this.circleCells=o,this.boxKeys=i.subarray(s,s+this.boxUid),s+=this.boxUid,this.circleKeys=i.subarray(s,s+this.circleUid),s+=this.circleUid,this.bboxes=i.subarray(s,s+4*this.boxUid),s+=4*this.boxUid,this.circles=i.subarray(s,s+3*this.circleUid)}else{this.width=t,this.height=i,this.xCellCount=Math.ceil(t/r),this.yCellCount=Math.ceil(i/r);let a=this.xCellCount*this.yCellCount,n=[],o=[];for(let t=0;t<a;t++)n.push([]),o.push([]);this.boxCells=n,this.circleCells=o,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(let t of this.boxCells)t&&(t.length=0);for(let t of this.circleCells)t&&(t.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(t,i,r,a,n){let o=this.boxUid++,s=this._xCell(i),l=this._yCell(r),h=this._xCell(a),u=this._yCell(n);for(let t=s;t<=h;t++)for(let i=l;i<=u;i++)this.boxCells[this.xCellCount*i+t].push(o);this.boxKeys.push(t),this.bboxes.push(i,r,a,n)}
1insertCircle(t,i,r,a){let n=this.circleUid++,o=this._xCell(i-a),s=this._yCell(r-a),l=this._xCell(i+a),h=this._yCell(r+a);for(let t=o;t<=l;t++)for(let i=s;i<=h;i++)this.circleCells[this.xCellCount*i+t].push(n);this.circleKeys.push(t),this.circles.push(i,r,a)}query(t,i,r,a,n){let o=[];if(r<0||t>this.width||a<0||i>this.height)return o;let s=this._nextGen(),{boxCells:l,circleCells:h,boxKeys:u,circleKeys:c,bboxes:d,circles:p,boxSeen:f,circleSeen:_,xCellCount:m}=this,g=this._xCell(t),y=this._yCell(i),x=this._xCell(r),v=this._yCell(a);for(let b=g;b<=x;b++)for(let g=y;g<=v;g++){let y=m*g+b,x=l[y];if(x)for(let l=0;l<x.length;l++){let h=x[l];if(f[h]===s)continue;f[h]=s;let c=4*h,p=d[c],_=d[c+1],m=d[c+2],g=d[c+3];t<=m&&i<=g&&r>=p&&a>=_&&(!n||n(u[h]))&&o.push({key:u[h],x1:p,y1:_,x2:m,y2:g})}let v=h[y];if(v)for(let l=0;l<v.length;l++){let h=v[l];if(_[h]===s)continue;_[h]=s;let u=3*h,d=p[u],f=p[u+1],m=p[u+2];this._circleAndRectCollide(d,f,m,t,i,r,a)&&(!n||n(c[h]))&&o.push({key:c[h],x1:d-m,y1:f-m,x2:d+m,y2:f+m})}}return o}queryKeys(t,i,r,a,n){let o=[];if(r<0||t>this.width||a<0||i>this.height)return o;let s=this._nextGen(),{boxCells:l,boxKeys:h,bboxes:u,boxSeen:c,xCellCount:d,xScale:p,yScale:f}=this,_=this._xCell(t),m=this._yCell(i),g=this._xCell(r),y=this._yCell(a);for(let x=_;x<=g;x++)for(let _=m;_<=y;_++){if(n&&!n(x/p,_/f,(x+1)/p,(_+1)/f))continue;let m=l[d*_+x];if(m)for(let l=0;l<m.length;l++){let d=m[l];if(c[d]===s)continue;c[d]=s;let p=4*d,f=u[p],_=u[p+1],g=u[p+2],y=u[p+3];(n?n(f,_,g,y):t<=g&&i<=y&&r>=f&&a>=_)&&o.push(h[d])}}return o}hitTest(t,i,r,a,n){if(r<0||t>this.width||a<0||i>this.height)return!1;let o=this._nextGen(),{boxCells:s,circleCells:l,boxKeys:h,circleKeys:u,bboxes:c,circles:d,boxSeen:p,circleSeen:f,xCellCount:_}=this,m=this._xCell(t),g=this._yCell(i),y=this._xCell(r),x=this._yCell(a);for(let v=m;v<=y;v++)for(let m=g;m<=x;m++){let g=_*m+v,y=s[g];if(y)for(let s=0;s<y.length;s++){let l=y[s];if(p[l]===o)continue;p[l]=o;let u=4*l;if(t<=c[u+2]&&i<=c[u+3]&&r>=c[u]&&a>=c[u+1]&&(!n||n(h[l])))return!0}let x=l[g];if(x)for(let s=0;s<x.length;s++){let l=x[s];if(f[l]===o)continue;f[l]=o;let h=3*l;if(this._circleAndRectCollide(d[h],d[h+1],d[h+2],t,i,r,a)&&(!n||n(u[l])))return!0}}return!1}hitTestCircle(t,i,r,a){let n=t-r,o=i-r,s=t+r,l=i+r;if(s<0||n>this.width||l<0||o>this.height)return!1;let h=this._nextGen(),{boxCells:u,circleCells:c,boxKeys:d,circleKeys:p,bboxes:f,circles:_,boxSeen:m,circleSeen:g,xCellCount:y}=this,x=this._xCell(n),v=this._yCell(o),b=this._xCell(s),w=this._yCell(l);for(let n=x;n<=b;n++)for(let o=v;o<=w;o++){let s=y*o+n,l=u[s];if(l)for(let n=0;n<l.length;n++){let o=l[n];if(m[o]===h)continue;m[o]=h;let s=4*o;if(this._circleAndRectCollide(t,i,r,f[s],f[s+1],f[s+2],f[s+3])&&(!a||a(d[o])))return!0}let x=c[s];if(x)for(let n=0;n<x.length;n++){let o=x[n];if(g[o]===h)continue;g[o]=h;let s=3*o;if(this._circlesCollide(_[s],_[s+1],_[s+2],t,i,r)&&(!a||a(p[o])))return!0}}return!1}static serialize(t,i){let r=t.toArrayBuffer();return i&&i.add(r),{buffer:r}}static deserialize(t){return new oI(t.buffer)}toArrayBuffer(){let t=this.xCellCount*this.yCellCount,i=0,r=0;for(let a=0;a<t;a++)i+=this.boxCells[a].length,r+=this.circleCells[a].length;let a=new Int32Array(6+(t+1)+i+(t+1)+r+this.boxUid+this.circleUid+4*this.boxUid+3*this.circleUid);a[0]=this.width,a[1]=this.height,a[2]=this.xCellCount,a[3]=this.yCellCount,a[4]=this.boxUid,a[5]=this.circleUid;let n=6+(t+1);for(let i=0;i<t;i++){a[6+i]=n;let t=this.boxCells[i];a.set(t,n),n+=t.length}a[6+t]=n;let o=n;n+=t+1;for(let i=0;i<t;i++){a[o+i]=n;let t=this.circleCells[i];a.set(t,n),n+=t.length}return a[o+t]=n,a.set(this.boxKeys,n),n+=this.boxUid,a.set(this.circleKeys,n),n+=this.circleUid,a.set(this.bboxes,n),n+=4*this.boxUid,a.set(this.circles,n),a.buffer}_xCell(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_yCell(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*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,0===this.generation&&(this.boxSeen.fill(0),this.circleSeen.fill(0),this.generation=1),this.generation}
1_circlesCollide(t,i,r,a,n,o){let s=a-t,l=n-i,h=r+o;return h*h>s*s+l*l}_circleAndRectCollide(t,i,r,a,n,o,s){let l=(o-a)/2,h=Math.abs(t-(a+l));if(h>l+r)return!1;let u=(s-n)/2,c=Math.abs(i-(n+u));if(c>u+r)return!1;if(h<=l||c<=u)return!0;let d=h-l,p=c-u;return d*d+p*p<=r*r}}let oA={};function oC(t,i,r={}){Object.defineProperty(t,"_classRegistryKey",{value:i,writable:!1}),oA[i]={klass:t,omit:r.omit||[]}}for(let t in oC(Object,"Object"),oC(oI,"Grid"),delete tg.prototype.constructor,oC(rq,"Color"),oC(al,"Formatted"),oC(as,"FormattedSection"),oC(au,"ResolvedImage"),oC(oS,"StylePropertyFunction"),oC(ox,"StyleExpression",{omit:["_evaluator"]}),oC(rk,"ImageId"),oC(ah,"ImageVariant"),oC(oT,"ZoomDependentExpression"),oC(ow,"ZoomConstantExpression"),oC(aR,"CompoundExpression",{omit:["_evaluate"]}),n6)oA[n6[t]._classRegistryKey]||oC(n6[t],`Expression${t}`);function oM(t){return t&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}let oR={Error,TypeError,RangeError,SyntaxError,ReferenceError,URIError,EvalError},oD=new Set(["message","stack","cause","errors","name","class"]);function oP(t,i){if(null===t)return null;let r=typeof t;if("object"!==r)return"bigint"===r?{$name:"BigInt",value:t.toString()}:t;if(Array.isArray(t)){let r=t.length,a=[];a.length=r;for(let n=0;n<r;n++)a[n]=oP(t[n],i);return a}if(ArrayBuffer.isView(t))return i&&i.add(t.buffer),t;if(oM(t)||t instanceof ImageBitmap)return i&&i.add(t),t;if(t instanceof ImageData)return i&&i.add(t.data.buffer),t;if(t instanceof Map){let r={$name:"Map",entries:[]};for(let[a,n]of t.entries())r.entries.push(oP(a),oP(n,i));return r}if(t instanceof Headers)return{$name:"Headers",entries:[...t]};if(t instanceof Set){let i={$name:"Set"},r=0;for(let a of t.values())i[++r]=oP(a);return i}if(t instanceof Date||t instanceof RegExp||t instanceof Boolean||t instanceof Number||t instanceof String)return t;if(t instanceof Error){let r=t.constructor&&t.constructor.name||"Error",a={$name:"$Error",class:t instanceof iY?"AJAXError":t instanceof DOMException?"DOMException":t instanceof AggregateError?"AggregateError":oR[r]?r:"Error",name:t.name,message:t.message};for(let r in t.stack&&(a.stack=t.stack),"cause"in t&&t.cause!==t&&(a.cause=oP(t.cause,i)),t instanceof AggregateError&&(a.errors=t.errors.filter(i=>i!==t).map(t=>oP(t,i))),t)Object.hasOwn(t,r)&&(oD.has(r)||(a[r]=oP(t[r],i)));return a}let a=t.constructor||Object,n=a._classRegistryKey;if(!n)throw Error(`Can't serialize object of unregistered class "${a.name}".`);let o=a.serialize?a.serialize(t,i):{};if(!a.serialize){let r=oA[n].omit;for(let a in t)Object.hasOwn(t,a)&&(r.includes(a)||(o[a]=oP(t[a],i)))}if(o.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(o.$name=n),o}function oz(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t)){for(let i=0;i<t.length;i++)t[i]=oz(t[i]);return t}if(ArrayBuffer.isView(t)||oM(t)||t instanceof ImageBitmap||t instanceof ImageData||t instanceof Date||t instanceof RegExp||t instanceof Boolean||t instanceof Number||t instanceof String)return t;let i=t.$name||"Object";if("Map"===i){let i=t.entries||[],r=new Map;for(let t=0;t<i.length;t+=2)r.set(oz(i[t]),oz(i[t+1]));return r}if("Headers"===i)return new Headers(t.entries);if("Set"===i){let i=new Set;for(let r in t)"$name"!==r&&i.add(oz(t[r]));return i}if("BigInt"===i)return BigInt(t.value);if("$Error"===i){let i,r=t.class||"Error",a=t.name||r,n=t.message||"";for(let o in i="DOMException"===r?new DOMException(n,a):"AggregateError"===r?AggregateError((t.errors||[]).map(oz),n):"AJAXError"===r?new iY(t.statusText,t.status,t.url):new(oR[r]||Error)(n),"DOMException"!==r&&(i.name=a),t.stack&&(i.stack=t.stack),"cause"in t&&(i.cause=oz(t.cause)),t)Object.hasOwn(t,o)&&("$name"===o||oD.has(o)||(i[o]=oz(t[o])));return i}let{klass:r}=oA[i];if(!r)throw Error(`Can't deserialize unregistered class "${i}".`);if(r.deserialize)return r.deserialize(t);let a=Object.create(r.prototype);for(let i in t)"$name"!==i&&(a[i]=oz(t[i]));return a}let oL=t=>t>=12288&&t<=12351,oO=t=>t>=12352&&t<=12447,oF=t=>t>=12448&&t<=12543,oB=t=>t>=13312&&t<=19903,ok=t=>t>=19968&&t<=40959,oN=t=>t>=44032&&t<=55215;function oV(t){return t>=1424&&t<=2303||t>=64336&&t<=65023||t>=65136&&t<=65279}let oU="deferred",oj="loading",oG="loaded",oH=null,oq="unavailable",oZ=null,o$=function(t){t&&(oq
1="error"),oH&&oH(t)};function oW(){oX.fire(new rz("pluginStateChange",{pluginStatus:oq,pluginURL:oZ}))}let oX=new rB,oY=function(){return oq},oK=function(){if(oq!==oU||!oZ)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");oq=oj,oW(),oZ&&i4({url:oZ}).then(()=>{oq=oG,oW()}).catch(t=>{o$(t)})},oQ={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>oq===oG||null!=oQ.applyArabicShaping,isLoading:()=>oq===oj,setState(t){oq=t.pluginStatus,oZ=t.pluginURL},isParsing:()=>"parsing"===oq,isParsed:()=>"parsed"===oq,getPluginURL:()=>oZ},oJ=function(){oQ.isLoading()||oQ.isLoaded()||"deferred"!==oY()||oK()};class o0{constructor(t,i){this.zoom=t,i?(this.now=i.now,this.fadeDuration=i.fadeDuration,this.transition=i.transition,this.pitch=i.pitch,this.brightness=i.brightness,this.worldview=i.worldview,this.activeFloors=i.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){var i=oQ.isLoaded();for(let r of t)if(!function(t,i){return!(!i&&oV(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||t>=6016&&t<=6143)}(r.charCodeAt(0),i))return!1;return!0}}class o1{constructor(t,i,r,a,n){this.property=t,this.value=i,this.expression=function(t,i,r,a,n){if(od(t))return new oS(t,i);if(ov(t)||Array.isArray(t)&&t.length>0){let o=oE(t,i,r,a,n);if("error"===o.result)throw Error(o.value.map(t=>`${t.key}: ${t.message}`).join(", "));return o.value}{let r=t;return"string"==typeof t&&"color"===i.type&&(r=rq.parse(t)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>r}}}(void 0===i?t.specification.default:i,t.specification,r,a,n)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,i,r,a){return this.property.possiblyEvaluate(this,t,i,r,a)}}class o2{constructor(t,i,r,a){this.property=t,this.value=new o1(t,void 0,i,r,a)}transitioned(t,i){return new o4(this.property,this.value,i,{...t.transition,...this.transition},t.now)}untransitioned(){return new o4(this.property,this.value,null,{},0)}}class o3{constructor(t,i,r,a){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=i,this._options=r,this._iconImageUseTheme=a,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(t){return tZ(this._values[t].value.value)}setValue(t,i){Object.hasOwn(this._values,t)||(this._values[t]=new o2(this._values[t].property,this._scope,this._options,this._iconImageUseTheme)),this._values[t].value=new o1(this._values[t].property,null===i?void 0:tZ(i),this._scope,this._options,this._iconImageUseTheme),this._values[t].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[t].value.isIndoorDependent())}setTransitionOrValue(t,i){i&&(this._options=i);let r=this._properties.properties;if(t)for(let i in t){let a=t[i];if(i.endsWith("-transition")){let t=i.slice(0,-11);r[t]&&this.setTransition(t,a)}else Object.hasOwn(r,i)&&this.setValue(i,a)}}getTransition(t){return tZ(this._values[t].transition)}setTransition(t,i){Object.hasOwn(this._values,t)||(this._values[t]=new o2(this._values[t].property)),this._values[t].transition=tZ(i)||void 0}serialize(){let t={};for(let i of Object.keys(this._values)){let r=this.getValue(i);void 0!==r&&(t[i]=r);let a=this.getTransition(i);void 0!==a&&(t[`${i}-transition`]=a)}return t}transitioned(t,i){let r=new o5(this._properties);for(let a of Object.keys(this._values))r._values[a]=this._values[a].transitioned(t,i._values[a]);return r}untransitioned(){let t=new o5(this._properties);for(let i of Object.keys(this._values))t._values[i]=this._values[i].untransitioned();return t}isIndoorDependent(){return this._isIndoorDependent}}class o4{constructor(t,i,r,a,n){let o=a.delay||0,s=a.duration||0;n=n||0,this.property=t,this.value=i,this.begin=n+o,this.end=this.begin+s,t.specification.transition&&(a.delay||a.duration)&&(this.prior=r)}possiblyEvaluate(t,i,r){let a=t.now||0,n=this.value.possiblyEvaluate(t,i,r),o=this.prior;if(o){if(a>this.end||this.value.isDataDriven())return this.prior=null,n;if(a<this.begin)return o.possiblyEvaluate(t,i,r);{let s=(a-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(t,i,r),n,tD(s))}}return n}}class o5{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,i,r){let a=new o9(this._properties);for(let n of Object.keys(this._values))a._values[n]=this._values[n].possiblyEvaluate(t,i,r);return a}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class o6{constructor(t,i,r,a){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._scope=i,this._options=r,this._iconImageUseTheme=a,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(t){return tZ(this._values[t].value)}setValue(t,i){this._values[t]=new o1(this._values[t].property,null===i?void 0:tZ(i),this._scope,this._options,this._iconImageUseTheme),this._values[t].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[t].isIndo
1orDependent())}serialize(){let t={};for(let i of Object.keys(this._values)){let r=this.getValue(i);void 0!==r&&(t[i]=r)}return t}possiblyEvaluate(t,i,r,a){let n=new o9(this._properties);for(let o of Object.keys(this._values))n._values[o]=this._values[o].possiblyEvaluate(t,i,r,a);return n}isIndoorDependent(){return this._isIndoorDependent}}class o8{constructor(t,i,r,a){this.property=t,this.value=i,this.parameters=r,this.iconImageUseTheme=a}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,i,r,a,n){return this.property.evaluate(this.value,this.parameters,t,i,r,a,this.iconImageUseTheme,n)}}class o9{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class o7{constructor(t){this.specification=t}possiblyEvaluate(t,i){return t.expression.evaluate(i)}interpolate(t,i,r){let a=rY[this.specification.type];return a?a(t,i,r):t}}class se{constructor(t,i){this.specification=t,this.overrides=i}possiblyEvaluate(t,i,r,a,n){return"constant"===t.expression.kind||"camera"===t.expression.kind?new o8(this,{kind:"constant",value:t.expression.evaluate(i,null,{},r,a,void 0,n)},i):new o8(this,t.expression,i,n)}interpolate(t,i,r){if("constant"!==t.value.kind||"constant"!==i.value.kind)return t;if(void 0===t.value.value||void 0===i.value.value)return new o8(this,{kind:"constant",value:void 0},t.parameters);let a=rY[this.specification.type];return a?new o8(this,{kind:"constant",value:a(t.value.value,i.value.value,r)},t.parameters):t}evaluate(t,i,r,a,n,o,s,l){return"constant"===t.kind?t.value:t.evaluate(i,r,a,n,o,l,s)}}class st{constructor(t){this.specification=t}possiblyEvaluate(t,i,r,a){return!!t.expression.evaluate(i,null,{},r,a)}interpolate(){return!1}}class si{constructor(t){this.specification=t}possiblyEvaluate(t,i){return function([t,i]){let r=tK([1,t,i]);return{x:r.x,y:r.y,z:r.z}}(t.expression.evaluate(i))}interpolate(t,i,r){return{x:rG(t.x,i.x,r),y:rG(t.y,i.y,r),z:rG(t.z,i.z,r)}}}class sr{constructor(t){this.specification=t}possiblyEvaluate(t,i){return tK(t.expression.evaluate(i))}interpolate(t,i,r){return{x:rG(t.x,i.x,r),y:rG(t.y,i.y,r),z:rG(t.z,i.z,r),azimuthal:rG(t.azimuthal,i.azimuthal,r),polar:rG(t.polar,i.polar,r)}}}class sa{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];let i=new o0(0,{});for(let r in t){let a=t[r],n=a.specification;n&&n.overridable&&this.overridableProperties.push(r);let o=this.defaultPropertyValues[r]=new o1(a,void 0),s=this.defaultTransitionablePropertyValues[r]=new o2(a);this.defaultTransitioningPropertyValues[r]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=o.possiblyEvaluate(i)}}}oC(se,"DataDrivenProperty"),oC(o7,"DataConstantProperty"),oC(st,"ColorRampProperty");var sn=JSON.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"}}
1,"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1
vendor: 41,124 bytes, line 1
1}},"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},"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-
1occlusion-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"]}}},"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-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}},"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
1":{"enabled":1,"disabled":1,"enabled-above-cutout":1},"expression":1}},"promoteId":{"*":{"type":"*"}}}');function so(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function ss(t){if(Array.isArray(t))return t.map(ss);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){let i={};for(let r in t)i[r]=ss(t[r]);return i}return so(t)}function sl(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(let i of t.slice(1))if(!sl(i)&&"boolean"!=typeof i)return!1;return!0;default:return!0}}function sh(t,i="",r=null,a="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};sl(t)||(t=function t(i){if(!i)return!0;let r=i[0];return i.length<=1?"any"!==r:"=="===r?sp(i[1],i[2],"=="):"!="===r?sm(sp(i[1],i[2],"==")):"<"===r||">"===r||"<="===r||">="===r?sp(i[1],i[2],r):"any"===r?["any"].concat(i.slice(1).map(t)):"all"===r?["all"].concat(i.slice(1).map(t)):"none"===r?["all"].concat(i.slice(1).map(t).map(sm)):"in"===r?sf(i[1],i.slice(2)):"!in"===r?sm(sf(i[1],i.slice(2))):"has"===r?s_(i[1]):"!has"!==r||sm(s_(i[1]))}(t));let n=t,o=!0;try{o=function(t){if(!su(t))return t;let i=ss(t);return function t(i){let r=!1,a=[];if("case"===i[0]){for(let t=1;t<i.length-1;t+=2)r=r||su(i[t]),a.push(i[t+1]);a.push(i.at(-1))}else if("match"===i[0]){r=r||su(i[1]);for(let t=2;t<i.length-1;t+=2)a.push(i[t+1]);a.push(i.at(-1))}else if("step"===i[0]){r=r||su(i[1]);for(let t=1;t<i.length-1;t+=2)a.push(i[t+1])}r&&(i.length=0,i.push("any",...a));for(let r=1;r<i.length;r++)t(i[r])}(i),i=function t(i){if(!Array.isArray(i))return i;let r=function(t){if(sc.has(t[0])){for(let i=1;i<t.length;i++)if(su(t[i]))return!0}return t}(i);return!0===r?r:r.map(i=>t(i))}(i)}(n)}catch(t){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(n,null,2)} 7 `)}let s=null,l=null;
7if("background"!==a&&"sky"!==a&&"slot"!==a){let t=ob(o,l=sn[`filter_${a}`],i,r);if("error"===t.result)throw Error(t.value.map(t=>`${t.key}: ${t.message}`).join(", "));s=(i,r,a)=>t.value.evaluate(i,r,{},a)}let h=null,u=null;if(o!==n){let t=ob(n,l,i,r);if("error"===t.result)throw Error(t.value.map(t=>`${t.key}: ${t.message}`).join(", "));h=(i,r,a,n,o)=>t.value.evaluate(i,r,{},a,void 0,void 0,n,o),u=!no(t.value.expression)}return{filter:s,dynamicFilter:h||void 0,needGeometry:function t(i){if(!Array.isArray(i))return!1;if("within"===i[0]||"distance"===i[0])return!0;for(let r=1;r<i.length;r++)if(t(i[r]))return!0;return!1}(o),needFeature:!!u}}function su(t){var i;if(!Array.isArray(t))return!1;if("pitch"===(i=t[0])||"distance-from-center"===i)return!0;for(let i=1;i<t.length;i++)if(su(t[i]))return!0;return!1}let sc=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function sd(t,i){return t<i?-1:+(t>i)}function sp(t,i,r){switch(t){case"$type":return[`filter-type-${r}`,i];case"$id":return[`filter-id-${r}`,i];default:return[`filter-${r}`,t,i]}}function sf(t,i){if(0===i.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",i]];case"$id":return["filter-id-in",["literal",i]];default:return i.length>200&&!i.some(t=>typeof t!=typeof i[0])?["filter-in-large",t,["literal",i.sort(sd)]]:["filter-in-small",t,["literal",i]]}}function s_(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function sm(t){return["!",t]}function sg(t){return t.includes("\x1f")}function sy(t,i){return i?`${t}�${i}`:t}function sx(t){let i=t.indexOf("\x1f");return i>=0?t.slice(0,i):t}function sv(t){let i=t.indexOf("\x1f");return i>=0?t.slice(i+1):""}let sb=()=>_||(_=new sa({"icon-size":new se(sn.layout_symbol["icon-size"]),"icon-image":new se(sn.layout_symbol["icon-image"]),"icon-rotate":new se(sn.layout_symbol["icon-rotate"]),"icon-offset":new se(sn.layout_symbol["icon-offset"]),"text-size":new se(sn.layout_symbol["text-size"]),"text-rotate":new se(sn.layout_symbol["text-rotate"]),"text-offset":new se(sn.layout_symbol["text-offset"])})),sw=()=>m||(m=new sa({"icon-opacity":new se(sn.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new se(sn.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new se(sn.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new se(sn.paint_symbol["text-emissive-strength"]),"icon-color":new se(sn.paint_symbol["icon-color"]),"icon-halo-color":new se(sn.paint_symbol["icon-halo-color"]),"icon-halo-width":new se(sn.paint_symbol["icon-halo-width"]),"icon-halo-blur":new se(sn.paint_symbol["icon-halo-blur"]),"icon-translate":new se(sn.paint_symbol["icon-translate"]),"text-opacity":new se(sn.paint_symbol["text-opacity"]),"text-occlusion-opacity":new se(sn.paint_symbol["text-occlusion-opacity"]),"text-color":new se(sn.paint_symbol["text-color"],{runtimeType:r3,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new se(sn.paint_symbol["text-halo-color"]),"text-halo-width":new se(sn.paint_symbol["text-halo-width"]),"text-halo-blur":new se(sn.paint_symbol["text-halo-blur"]),"text-translate":new se(sn.paint_symbol["text-translate"]),"symbol-z-offset":new se(sn.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}));class sT{constructor(t,i,r,a,n,o){this._conditionSpec=t,this._propertiesSpec=r;let s=ob(t,sn.appearance.condition);if("success"===s.result&&(this.condition=s.value),this.name=i,r)for(let t in this.layoutProperties=new o9(sb()),this.unevaluatedLayout=new o6(sb(),a,n,o),this.paintProperties=new o9(sw()),this.unevaluatedPaint=new o6(sw(),a,n,""),r)t in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(t,r[t]):t in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(t,r[t])}
7isActive(t){return!(this.condition||!t.isHidden||"hidden"!==this.name)||this.condition.evaluate(t.globals,t.feature,t.featureState,t.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(t){return this.layoutProperties.get(t)}getPaintProperty(t){return this.paintProperties.get(t)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(t){return this.unevaluatedLayout._values[t]}getUnevaluatedPaintProperty(t){return this.unevaluatedPaint._values[t]}recalculate(t,i,r){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(t,void 0,i,r)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(t,void 0,i,""))}serialize(){let t={};t.condition=this.condition.expression.serialize(),this.name&&(t.name=this.name);let i={...this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},...this.unevaluatedPaint?this.unevaluatedPaint.serialize():{}};return Object.keys(i).length>0&&(t.properties=i),t}hasIconLayoutProperties(){let t=this.hasLayoutProperty("icon-image"),i=this.hasLayoutProperty("icon-size"),r=this.hasLayoutProperty("icon-offset"),a=this.hasLayoutProperty("icon-rotate");return t||i||r||a}hasTextLayoutProperties(){let t=this.hasLayoutProperty("text-size"),i=this.hasLayoutProperty("text-offset"),r=this.hasLayoutProperty("text-rotate");return t||i||r}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(t=>!t.endsWith("-use-theme")).some(t=>(t.startsWith("icon-")||"symbol-z-offset"===t)&&this.hasPaintProperty(t))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(t=>!t.endsWith("-use-theme")).some(t=>(t.startsWith("text-")||"symbol-z-offset"===t)&&this.hasPaintProperty(t))}hasLayoutProperty(t){return this.unevaluatedLayout&&void 0!==this.unevaluatedLayout._values[t].value}hasPaintProperty(t){return this.unevaluatedPaint&&void 0!==this.unevaluatedPaint._values[t].value}}let sE="-transition",sS=new Set(["fill","line","background","hillshade","raster"]);class sI extends rB{constructor(t,i,r,a,n,o){if(super(),this.id=t.id,this.fqid=sy(this.id,r),this.type=t.type,this.scope=r,this.lut=a,this.options=n,this.iconImageUseTheme=o,this.appearances=[],this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type&&"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),t.slot&&(this.slot=t.slot),t.appearances&&this.setAppearances(t.appearances),i.layout&&(this._unevaluatedLayout=new o6(i.layout,this.scope,n,this.iconImageUseTheme)),i.paint)){for(let r in this._transitionablePaint=new o3(i.paint,this.scope,n),t.paint)this.setPaintProperty(r,t.paint[r]);for(let i in t.layout)this.setLayoutProperty(i,t.layout[i]);this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new o9(i.paint)}}onAdd(t){}onRemove(t){}isDraped(t){return!this.is3D(!0)&&sS.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,i){if("custom"===this.type&&"visibility"===t)return void(this.visibility=i);let r=this._unevaluatedLayout;r._properties.properties[t]&&(r.setValue(t,i),"visibility"===t&&this.possiblyEvaluateVisibility())}setAppearances(t){this.appearances=[],t.forEach(t=>{this.appearances.push(new sT(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(t){return t.endsWith(sE)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}isPaintProperty(t){return!!this._transitionablePaint._properties.properties[t]}setPaintProperty(t,i){let r=this._transitionablePaint,a=r._properties.properties;if(t.endsWith(sE)){let n=t.slice(0,-11);return a[n]&&r.setTransition(n,i||void 0),!1}if(!a[t])return!1;let n=r._values[t],o=n.value.isDataDriven(),s=n.value;r.setValue(t,i),this._handleSpecialPaintPropertyUpdate(t);let l=r._values[t].value,h=l.isDataDriven(),u=t.endsWith("pattern")||"line-dasharray"===t;return h||o||u||this._handleOverridablePaintPropertyUpdate(t,s,l)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,i,r){return null}_handleOverridablePaintPropertyUpdate(t,i,r){return!1}
7isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,i,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,i)}serialize(){let t={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 0!==this.appearances.length&&(t.appearances=this.appearances.map(t=>t.serialize())),tq(t,(t,i)=>!(void 0===t||"layout"===i&&!Object.keys(t).length||"paint"===i&&!Object.keys(t).length))}is3D(t){return!1}hasElevation(){return!1}mayUse(t){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(let t in this.paint._values){let i=this.paint.get(t);if(i instanceof o8&&ol(i.property.specification)&&("source"===i.value.kind||"composite"===i.value.kind)&&i.value.isStateDependent)return!0}for(let t of this.appearances)if(!ns(t.condition.expression))return!0;return!1}compileFilter(t){this._filterCompiled||(this._featureFilter=sh(this.filter,this.scope,t),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(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(t,i,r){return{}}queryRadius(t){}queryIntersectsFeature(t,i,r,a,n,o,s,l,h,u){}}function sA(t,i,r){if(!t._unevaluatedLayout)return!1;let a=t._unevaluatedLayout.getValue(i);return void 0!==a&&("string"!=typeof a||r(a))}function sC(t,i,r=2){let a,n,o,s=i&&i.length,l=s?i[0]*r:t.length,h=sM(t,0,l,r,!0),u=[];if(!h||h.next===h.prev)return u;if(s&&(h=function(t,i,r,a){let n=[];for(let r=0,o=i.length;r<o;r++){let s=sM(t,i[r]*a,r<o-1?i[r+1]*a:t.length,a,!1);s===s.next&&(s.steiner=!0),n.push(function(t){let i=t,r=t;do(i.x<r.x||i.x===r.x&&i.y<r.y)&&(r=i),i=i.next;while(i!==t);return r}(s))}n.sort(sD);for(let t=0;t<n.length;t++)r=function(t,i){let r=function(t,i){let r=i,a=t.x,n=t.y,o,s=-1/0;if(sF(t,r))return r;do{if(sF(t,r.next))return r.next;if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let t=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y
7);if(t<=a&&t>s&&(s=t,o=r.x<r.next.x?r:r.next,t===a))return o}r=r.next}while(r!==i);if(!o)return null;let l=o,h=o.x,u=o.y,c=1/0;r=o;do{if(a>=r.x&&r.x>=h&&a!==r.x&&sz(n<u?a:s,n,h,u,n<u?s:a,n,r.x,r.y)){var d,p;let i=Math.abs(n-r.y)/(a-r.x);sV(r,t)&&(i<c||i===c&&(r.x>o.x||r.x===o.x&&(d=o,p=r,0>sO(d.prev,d,p.prev)&&0>sO(p.next,d,d.next))))&&(o=r,c=i)}r=r.next}while(r!==l);return o}(t,i);if(!r)return i;let a=sU(r,t);return sR(a,a.next),sR(r,r.next)}(n[t],r);return r}(t,i,h,r)),t.length>80*r){a=t[0],n=t[1];let i=a,s=n;for(let o=r;o<l;o+=r){let r=t[o],l=t[o+1];r<a&&(a=r),l<n&&(n=l),r>i&&(i=r),l>s&&(s=l)}o=0!==(o=Math.max(i-a,s-n))?32767/o:0}return function t(i,r,a,n,o,s,l){if(!i)return;!l&&s&&function(t,i,r,a){let n=t;do 0===n.z&&(n.z=sP(n.x,n.y,i,r,a)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){let i,r=1;do{let a,n=t;t=null;let o=null;for(i=0;n;){i++;let s=n,l=0;for(let t=0;t<r&&(l++,s=s.nextZ);t++);let h=r;for(;l>0||h>0&&s;)0!==l&&(0===h||!s||n.z<=s.z)?(a=n,n=n.nextZ,l--):(a=s,s=s.nextZ,h--),o?o.nextZ=a:t=a,a.prevZ=o,o=a;n=s}o.nextZ=null,r*=2}while(i>1)}(n)}(i,n,o,s);let h=i;for(;i.prev!==i.next;){let u=i.prev,c=i.next;if(s?function(t,i,r,a){let n=t.prev,o=t.next;if(sO(n,t,o)>=0)return!1;let s=n.x,l=t.x,h=o.x,u=n.y,c=t.y,d=o.y,p=Math.min(s,l,h),f=Math.min(u,c,d),_=Math.max(s,l,h),m=Math.max(u,c,d),g=sP(p,f,i,r,a),y=sP(_,m,i,r,a),x=t.prevZ,v=t.nextZ;for(;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=p&&x.x<=_&&x.y>=f&&x.y<=m&&x!==n&&x!==o&&sL(s,u,l,c,h,d,x.x,x.y)&&sO(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=p&&v.x<=_&&v.y>=f&&v.y<=m&&v!==n&&v!==o&&sL(s,u,l,c,h,d,v.x,v.y)&&sO(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=_&&x.y>=f&&x.y<=m&&x!==n&&x!==o&&sL(s,u,l,c,h,d,x.x,x.y)&&sO(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=_&&v.y>=f&&v.y<=m&&v!==n&&v!==o&&sL(s,u,l,c,h,d,v.x,v.y)&&sO(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}(i,n,o,s):function(t){let i=t.prev,r=t.next;if(sO(i,t,r)>=0)return!1;let a=i.x,n=t.x,o=r.x,s=i.y,l=t.y,h=r.y,u=Math.min(a,n,o),c=Math.min(s,l,h),d=Math.max(a,n,o),p=Math.max(s,l,h),f=r.next;for(;f!==i;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&sL(a,s,n,l,o,h,f.x,f.y)&&sO(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}(i))r.push(u.i,i.i,c.i),sG(i),i=c.next,h=c.next;else if((i=c)===h){l?1===l?t(i=function(t,i){let r=t;do{let a=r.prev,n=r.next.next;!sF(a,n)&&sB(a,r,r.next,n)&&sV(a,n)&&sV(n,a)&&(i.push(a.i,r.i,n.i),sG(r),sG(r.next),r=t=n),r=r.next}while(r!==t);return sR(r)}(sR(i),r),r,a,n,o,s,2):2===l&&function(i,r,a,n,o,s){let l=i;do{let i=l.next.next;for(;i!==l.prev;){var h,u;if(l.i!==i.i&&(h=l,u=i,h.next.i!==u.i&&h.prev.i!==u.i&&!function(t,i){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==i.i&&r.next.i!==i.i&&sB(r,r.next,t,i))return!0;r=r.next}while(r!==t);return!1}(h,u)&&(sV(h,u)&&sV(u,h)&&function(t,i){let r=t,a=!1,n=(t.x+i.x)/2,o=(t.y+i.y)/2;do r.y>o!=r.next.y>
7o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(a=!a),r=r.next;while(r!==t);return a}(h,u)&&(sO(h.prev,h,u.prev)||sO(h,u.prev,u))||sF(h,u)&&sO(h.prev,h,h.next)>0&&sO(u.prev,u,u.next)>0))){let h=sU(l,i);return l=sR(l,l.next),h=sR(h,h.next),t(l,r,a,n,o,s,0),void t(h,r,a,n,o,s,0)}i=i.next}l=l.next}while(l!==i)}(i,r,a,n,o,s):t(sR(i),r,a,n,o,s,1);break}}}(h,u,r,a,n,o,0),u}function sM(t,i,r,a,n){let o;if(n===function(t,i,r,a){let n=0;for(let o=i,s=r-a;o<r;o+=a)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}(t,i,r,a)>0)for(let n=i;n<r;n+=a)o=sj(n/a|0,t[n],t[n+1],o);else for(let n=r-a;n>=i;n-=a)o=sj(n/a|0,t[n],t[n+1],o);return o&&sF(o,o.next)&&(sG(o),o=o.next),o}function sR(t,i){if(!t)return t;i||(i=t);let r,a=t;do if(r=!1,a.steiner||!sF(a,a.next)&&0!==sO(a.prev,a,a.next))a=a.next;else{if(sG(a),(a=i=a.prev)===a.next)break;r=!0}while(r||a!==i);return i}function sD(t,i){let r=t.x-i.x;return 0===r&&0==(r=t.y-i.y)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(i.next.y-i.y)/(i.next.x-i.x)),r}function sP(t,i,r,a,n){return(t=0x55555555&((t=0x33333333&((t=0xf0f0f0f&((t=0xff00ff&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(i=0x55555555&((i=0x33333333&((i=0xf0f0f0f&((i=0xff00ff&((i=(i-a)*n|0)|i<<8))|i<<4))|i<<2))|i<<1))<<1}function sz(t,i,r,a,n,o,s,l){return(n-s)*(i-l)>=(t-s)*(o-l)&&(t-s)*(a-l)>=(r-s)*(i-l)&&(r-s)*(o-l)>=(n-s)*(a-l)}function sL(t,i,r,a,n,o,s,l){return(t!==s||i!==l)&&sz(t,i,r,a,n,o,s,l)}function sO(t,i,r){return(i.y-t.y)*(r.x-i.x)-(i.x-t.x)*(r.y-i.y)}function sF(t,i){return t.x===i.x&&t.y===i.y}function sB(t,i,r,a){let n=sN(sO(t,i,r)),o=sN(sO(t,i,a)),s=sN(sO(r,a,t)),l=sN(sO(r,a,i));return n!==o&&s!==l||!(0!==n||!sk(t,r,i))||!(0!==o||!sk(t,a,i))||!(0!==s||!sk(r,t,a))||!(0!==l||!sk(r,i,a))}function sk(t,i,r){return i.x<=Math.max(t.x,r.x)&&i.x>=Math.min(t.x,r.x)&&i.y<=Math.max(t.y,r.y)&&i.y>=Math.min(t.y,r.y)}function sN(t){return t>0?1:t<0?-1:0}function sV(t,i){return 0>sO(t.prev,t,t.next)?sO(t,i,t.next)>=0&&sO(t,t.prev,i)>=0:0>sO(t,i,t.prev)||0>sO(t,t.next,i)}function sU(t,i){let r=sH(t.i,t.x,t.y),a=sH(i.i,i.x,i.y),n=t.next,o=i.prev;return t.next=i,i.prev=t,r.next=n,n.prev=r,a.next=r,r.prev=a,o.next=a,a.prev=o,a}function sj(t,i,r,a){let n=sH(t,i,r);return a?(n.next=a.next,n.prev=a,a.next.prev=n,a.next=n):(n.prev=n,n.next=n),n}function sG(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function sH(t,i,r){return{i:t,x:i,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function sq(t,i,r=1){if(!t)return null;let a="string"==typeof t?au.from(t).getPrimary():t.getPrimary(),n="string"==typeof t?null:t.getSecondary();for(let t of[a,n]){if(!t)continue;let a=t.id.toString();i.has(a)||i.set(a,[]),t.scaleSelf(r),i.get(a).push(t)}return{primary:a.toString(),secondary:n?n.toString():null}}function sZ(t,i,r,a){let n=a.patternDependencies,o=!1;for(let a of i){let i=a.paint.get(`${t}-pattern`);i.isConstant()||(o=!0),sq(i.constantOr(null),n,r)&&(o=!0)}return o}function s$(t,i,r,a,n,o){let s=o.patternDependencies;for(let l of i){let i=l.paint.get(`${t}-pattern`).value;if("constant"!==i.kind){let t=sq(i.evaluate({zoom:a},r,{},void 0,o.availableImages),s,n);if(!t)continue;let{primary:h,secondary:u}=t;h&&(r.patterns[l.id]=[h,u].filter(Boolean))}}return r}let sW=8192/Math.PI/2,sX=[64,32,16],sY=-sW;function sK(t,i,r,a=sW){return[t*Math.sin(r*=tA)*a,-i*a,t*Math.cos(r)*a]}function sQ(t,i,r){return sK(Math.cos(t*tA),Math.sin(t*tA),i,r)}let sJ=2*Math.PI*6371008.8;class s0{constructor(t,i){if(isNaN(t)||isNaN(i))throw Error(`Invalid LngLat object: (${t}, ${i})`);if(this.lng=+t,this.lat=+i,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new s0(tF(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let i=Math.PI/180,r=this.lat*i,a=t.lat*i;return 6371008.8*Math.acos(Math.min(Math.sin(r)*Math.sin(a)+Math.cos(r)*Math.cos(a)*Math.cos((t.lng-this.lng)*i),1))}toBounds(t=0){let i=360*t/0x2637f09,r=i/Math.cos(Math.PI/180*this.lat);return new s1({lng:this.lng-r,lat:this.lat-i},{lng:this.lng+r,lat:this.lat+i})}toEcef(t){return sQ(this.lat,this.lng,sW+t*sW/6371008.8)}static convert(t){if(t instanceof s0)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new s0(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new s0(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw 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>]")}}
7class s1{constructor(t,i){t&&(i?this.setSouthWest(t).setNorthEast(i):Array.isArray(t)&&4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof s0?new s0(t.lng,t.lat):s0.convert(t),this}setSouthWest(t){return this._sw=t instanceof s0?new s0(t.lng,t.lat):s0.convert(t),this}extend(t){let i,r,a=this._sw,n=this._ne;if(t instanceof s0)i=t,r=t;else{if(!(t instanceof s1))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(s1.convert(t)):this.extend(s0.convert(t)):"object"==typeof t&&null!==t&&Object.hasOwn(t,"lat")&&(Object.hasOwn(t,"lon")||Object.hasOwn(t,"lng"))?this.extend(s0.convert(t)):this;if(i=t._sw,r=t._ne,!i||!r)return this}return a||n?(a.lng=Math.min(i.lng,a.lng),a.lat=Math.min(i.lat,a.lat),n.lng=Math.max(r.lng,n.lng),n.lat=Math.max(r.lat,n.lat)):(this._sw=new s0(i.lng,i.lat),this._ne=new s0(r.lng,r.lat)),this}getCenter(){return new s0((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 s0(this.getWest(),this.getNorth())}getSouthEast(){return new s0(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(t){let{lng:i,lat:r}=s0.convert(t),a=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&a}static convert(t){if(t)return t instanceof s1?t:new s1(t)}}function s2(t){return sJ*Math.cos(t*Math.PI/180)}function s3(t){return Math.cos(tL(t,-85.051129,85.051129)*tA)}function s4(t,i){let r=Math.pow(2,tL(i,0,25.5));return s3(t)*sJ/(512*r)}function s5(t){return 1/Math.cos(t*Math.PI/180)}function s6(t,i=0){let r=Math.exp(Math.PI*(1-(t.y+i/8192)/(1<<t.z)*2));return 0x4c6fe12*r/(r*r+1)/8192/(1<<t.z)}class s8{constructor(t,i,r=0){this.x=+t,this.y=+i,this.z=+r}static fromLngLat(t,i=0){let r=s0.convert(t);return new s8(az(r.lng),aL(r.lat),i/s2(r.lat))}toLngLat(){return new s0(aO(this.x),aF(this.y))}toAltitude(){return this.z*s2(aF(this.y))}meterInMercatorCoordinateUnits(){return 1/sJ*s5(aF(this.y))}}function s9(t,i,r){let a=t[0],n=a.x,o=a.y;i(a);let s=[a];for(let l=1;l<t.length;l++){let h=t[l],{x:u,y:c}=h;i(h),function t(i,r,a,n,o,s,l,h,u){let c=(r+n)/2,d=(a+o)/2,p=new tg(c,d);h(p),function(t,i,r,a,n,o){let s=r-n,l=a-o;return Math.abs((a-i)*s-(r-t)*l)/Math.hypot(s,l)}(p.x,p.y,s.x,s.y,l.x,l.y)>=u?(t(i,r,a,c,d,s,p,h,u),t(i,c,d,n,o,p,l,h,u)):i.push(l)}(s,n,o,u,c,a,h,i,r),n=u,o=c,a=h}return s}let s7=-16383-1;function le(t,i,r){let a=t.loadGeometry(),n=t.extent,o=8192/n;if(i&&r&&r.projection.isReprojectedInTileSpace){let o=1<<i.z,{scale:s,x:l,y:h,projection:u}=r,c=t=>{let r=aO((i.x+t.x/n)/o),a=aF((i.y+t.y/n)/o),c=u.project(r,a);t.x=(c.x*s-l)*n,t.y=(c.y*s-h)*n};for(let i=0;i<a.length;i++)if(1!==t.type)a[i]=s9(a[i],c,1);else{let t=[];for(let r of a[i])r.x<0||r.x>=n||r.y<0||r.y>=n||(c(r),t.push(r));a[i]=t}}for(let t of a)for(let i of t){var s=i,l=o;let t=Math.round(s.x*l),r=Math.round(s.y*l);s.x=tL(t,s7,16383),s.y=tL(r,s7,16383),(t<s.x||t>s.x+1||r<s.y||r>s.y+1)&&tX("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return a}function lt(t,i){return{type:t.type,id:t.id,properties:t.properties,geometry:i?le(t):[]}}let li={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class lr{constructor(t,i){this._structArray=t,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}let la=new ArrayBuffer(0);class ln{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(t,i){return t._trim(),i&&t.arrayBuffer&&i.add(t.arrayBuffer),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){let i=Object.create(this.prototype);return i.arrayBuffer=t.arrayBuffer,i.length=t.length,t.arrayBuffer?i.capacity=t.arrayBuffer.byteLength/i.bytesPerElement:(i.capacity=0,i.arrayBuffer=la),i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}resizeExact(t){this.reserveExact(t),this.length=t}reserve(t){t>this.capacity&&this._allocate(Math.max(t,Math.floor(5*this.capacity),128))}reserveExact(t){(t>this.capacity||!this.arrayBuffer)&&this._allocate(t)}_allocate(t){this._reallocCount++,this.capacity=t,this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);let i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}reserveForAdditional(t){this.reserve(this.length+t)}_refreshViews(){throw Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(){throw Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(){throw 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 lo(t,i=1){let r=0,a=0;return{members:t.map(t=>{let n=li[t.type].BYTES_PER_ELEMENT,o=r=ls(r,Math.max(i,n)),s=t.components||1;return a=Math.max(a,n),r+=n*s,{name:t.name,type:t.type,components:s,offset:o}}),size:ls(r,Math.max(a,i)),alignment:i}}function ls(t,i){return Math.ceil(t/i)*i}class ll extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,i)}emplace(t,i,r){let a=2*t;return this.int16[a+0]=i,this.int16[a+1]=r,t}}ll.prototype.bytesPerElement=4,oC(ll,"StructArrayLayout2i4");class lh extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=3*t;return this.int16[n+0]=i,this.int16[n+1]=r,this.int16[n+2]=a,t}}lh.prototype.bytesPerElement=6,oC(lh,"StructArrayLayout3i6");class lu extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,i,r,a)}emplace(t,i,r,a,n){let o=4*t;return this.int16[o+0]=i,this.int16[o+1]=r,this.uint16[o+2]=a,this.uint16[o+3]=n,t}}lu.prototype.bytesPerElement=8,oC(lu,"StructArrayLayout2i2ui8");class lc extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.float32[+t+0]=i,t}}
7lc.prototype.bytesPerElement=4,oC(lc,"StructArrayLayout1f4");class ld extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=4*t;return this.int16[n+0]=i,this.int16[n+1]=r,this.float32[2*t+1]=a,t}}ld.prototype.bytesPerElement=8,oC(ld,"StructArrayLayout2i1f8");class lp extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=4*t;return this.int16[n+0]=i,this.int16[n+1]=r,this.int16[n+2]=a,t}}lp.prototype.bytesPerElement=8,oC(lp,"StructArrayLayout3i8");class lf extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,i,r,a)}emplace(t,i,r,a,n){let o=4*t;return this.int16[o+0]=i,this.int16[o+1]=r,this.int16[o+2]=a,this.int16[o+3]=n,t}}lf.prototype.bytesPerElement=8,oC(lf,"StructArrayLayout4i8");class l_ extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,t,i,r,a,n)}emplace(t,i,r,a,n,o){let s=5*t;return this.int16[s+0]=i,this.int16[s+1]=r,this.int16[s+2]=a,this.int16[s+3]=n,this.int16[s+4]=o,t}}l_.prototype.bytesPerElement=10,oC(l_,"StructArrayLayout5i10");class lm extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,i,r,a,n,o,s)}emplace(t,i,r,a,n,o,s,l){let h=6*t,u=12*t;return this.int16[h+0]=i,this.int16[h+1]=r,this.uint8[u+4]=a,this.uint8[u+5]=n,this.uint8[u+6]=o,this.uint8[u+7]=s,this.float32[3*t+2]=l,t}}lm.prototype.bytesPerElement=12,oC(lm,"StructArrayLayout2i4ub1f12");class lg extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=3*t;return this.float32[n+0]=i,this.float32[n+1]=r,this.float32[n+2]=a,t}}lg.prototype.bytesPerElement=12,oC(lg,"StructArrayLayout3f12");class ly extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,t,i,r,a,n)}emplace(t,i,r,a,n,o){let s=6*t;return this.uint16[s+0]=i,this.uint16[s+1]=r,this.uint16[s+2]=a,this.uint16[s+3]=n,this.float32[3*t+2]=o,t}}ly.prototype.bytesPerElement=12,oC(ly,"StructArrayLayout4ui1f12");class lx extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,i,r,a)}emplace(t,i,r,a,n){let o=4*t;return this.uint16[o+0]=i,this.uint16[o+1]=r,this.uint16[o+2]=a,this.uint16[o+3]=n,t}}lx.prototype.bytesPerElement=8,oC(lx,"StructArrayLayout4ui8");class lv extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o){let s=this.length;return this.resize(s+1),this.emplace(s,t,i,r,a,n,o)}emplace(t,i,r,a,n,o,s){let l=6*t;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=a,this.int16[l+3]=n,this.int16[l+4]=o,this.int16[l+5]=s,t}}lv.prototype.bytesPerElement=12,oC(lv,"StructArrayLayout6i12");class lb extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o,s,l,h,u,c,d){let p=this.length;return this.resize(p+1),this.emplace(p,t,i,r,a,n,o,s,l,h,u,c,d)}emplace(t,i,r,a,n,o,s,l,h,u,c,d,p){let f=12*t;return this.int16[f+0]=i,this.int16[f+1]=r,this.int16[f+2]=a,this.int16[f+3]=n,this.uint16[f+4]=o,this.uint16[f+5]=s,this.uint16[f+6]=l,this.uint16[f+7]=h,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=d,this.int16[f+11]=p,t}}lb.prototype.bytesPerElement=24,oC(lb,"StructArrayLayout4i4ui4i24");class lw extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o){let s=this.length;return this.resize(s+1),this.emplace(s,t,i,r,a,n,o)}emplace(t,i,r,a,n,o,s){let l=10*t,h=5*t;return this.int16[l+0]=i,this.int16[l+1]=r,this.int16[l+2]=a,this.float32[h+2]=n,this.float32[h+3]=o,this.float32[h+4]=s,t}}lw.prototype.bytesPerElement=20,oC(lw,"StructArrayLayout3i3f20");class lT extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,i,r,a)}emplace(t,i,r,a,n){let o=4*t;return this.float32[o+0]=i,this.float32[o+1]=r,this.float32[o+2]=a,this.float32[o+3]=n,t}}lT.prototype.bytesPerElement=16,oC(lT,"StructArrayLayout4f16");class lE extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint32[+t+0]=i,t}}lE.prototype.bytesPerElement=4,oC(lE,"StructArrayLayout1ul4");class lS extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,i)}emplace(t,i,r){let a=2*t;return this.uint16[a+0]=i,this.uint16[a+1]=r,t}}lS.prototype.bytesPerElement=4,oC(lS,"StructArrayLayout2ui4");class lI extends ln{_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(t,i,r,a,n,o,s,l,h,u,c,d,p){let f=this.length;return this.resize(f+1),this.emplace(f,t,i,r,a,n,o,s,l,h,u,c,d,p)}emplace(t,i,r,a,n,o,s,l,h,u,c,d,p,f){let _=20*t,m=10*t;return this.int16[_+0]=i,this.int16[_+1]=r,this.int16[_+2]=a,this.int16[_+3]=n,this.int16[_+4]=o,this.float32[m+3]=s,this.float32[m+4]=l,this.float32[m+5]=h,this.float32[m+6]=u,this.int16[_+14]=c,this.uint32[m+8]=d,this.uint16[_+18]=p,this.uint16[_+19]=f,t}}lI.prototype.bytesPerElement=40,oC(lI,"StructArrayLayout5i4f1i1ul2ui40");class lA extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,i,r,a,n,o,s)}emplace(t,i,r,a,n,o,s,l){let h=8*t;return this.int16[h+0]=i,this.int16[h+1]=r,this.int16[h+2]=a,this.int16[h+4]=n,this.int16[h+5]=o,this.int16[h+6]=s,this.int16[h+7]=l,t}}lA.prototype.bytesPerElement=16,oC(lA,"StructArrayLayout3i2i2i16");class lC extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,t,i,r,a,n)}emplace(t,i,r,a,n,o){let s=4*t,l=8*t;return this.float32[s+0]=i,this.float32[s+1]=r,this.float32[s+2]=a,this.int16[l+6]=n,this.int16[l+7]=o,t}}lC.prototype.bytesPerElement=16,oC(lC,"StructArrayLayout2f1f2i16");class lM extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o){let s=this.length;return this.resize(s+1),this.emplace(s,t,i,r,a,n,o)}emplace(t,i,r,a,n,o,s){let l=20*t,h=5*t;return this.uint8[l+0]=i,this.uint8[l+1]=r,this.float32[h+1]=a,this.float32[h+2]=n,this.float32[h+3]=o,this.float32[h+4]=s,t}}lM.prototype.bytesPerElement=20,oC(lM,"StructArrayLayout2ub4f20");class lR extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r){let a=this.length;return this.resize(a+1),this.emplace(a,t,i,r)}emplace(t,i,r,a){let n=3*t;return this.uint16[n+0]=i,this.uint16[n+1]=r,this.uint16[n+2]=a,t}}lR.prototype.bytesPerElement=6,oC(lR,"StructArrayLayout3ui6");class lD extends ln{_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(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b){let w=this.length;return this.resize(w+1),this.emplace(w,t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b)}emplace(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w){let T=30*t,
7E=15*t,S=60*t;return this.int16[T+0]=i,this.int16[T+1]=r,this.int16[T+2]=a,this.float32[E+2]=n,this.float32[E+3]=o,this.uint16[T+8]=s,this.uint16[T+9]=l,this.uint32[E+5]=h,this.uint32[E+6]=u,this.uint32[E+7]=c,this.uint16[T+16]=d,this.uint16[T+17]=p,this.uint16[T+18]=f,this.float32[E+10]=_,this.float32[E+11]=m,this.uint8[S+48]=g,this.uint8[S+49]=y,this.uint8[S+50]=x,this.uint32[E+13]=v,this.int16[T+28]=b,this.uint8[S+58]=w,t}}lD.prototype.bytesPerElement=60,oC(lD,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class lP extends ln{_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(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w,T,E,S,I,A,C,M,R,D,P,z){let L=this.length;return this.resize(L+1),this.emplace(L,t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w,T,E,S,I,A,C,M,R,D,P,z)}emplace(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w,T,E,S,I,A,C,M,R,D,P,z,L){let O=20*t,F=40*t;return this.float32[O+0]=i,this.float32[O+1]=r,this.int16[F+4]=a,this.int16[F+5]=n,this.int16[F+6]=o,this.int16[F+7]=s,this.int16[F+8]=l,this.int16[F+9]=h,this.int16[F+10]=u,this.int16[F+11]=c,this.int16[F+12]=d,this.uint16[F+13]=p,this.uint16[F+14]=f,this.uint16[F+15]=_,this.uint16[F+16]=m,this.uint16[F+17]=g,this.uint16[F+18]=y,this.uint16[F+19]=x,this.uint16[F+20]=v,this.uint16[F+21]=b,this.uint16[F+22]=w,this.uint16[F+23]=T,this.uint16[F+24]=E,this.uint16[F+25]=S,this.uint16[F+26]=I,this.uint16[F+27]=A,this.uint32[O+14]=C,this.float32[O+15]=M,this.float32[O+16]=R,this.float32[O+17]=D,this.float32[O+18]=P,this.uint8[80*t+76]=z,this.uint16[F+39]=L,t}}lP.prototype.bytesPerElement=80,oC(lP,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class lz extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o){let s=this.length;return this.resize(s+1),this.emplace(s,t,i,r,a,n,o)}emplace(t,i,r,a,n,o,s){let l=6*t;return this.float32[l+0]=i,this.float32[l+1]=r,this.float32[l+2]=a,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,t}}lz.prototype.bytesPerElement=24,oC(lz,"StructArrayLayout6f24");class lL extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n){let o=this.length;return this.resize(o+1),this.emplace(o,t,i,r,a,n)}emplace(t,i,r,a,n,o){let s=5*t;return this.float32[s+0]=i,this.float32[s+1]=r,this.float32[s+2]=a,this.float32[s+3]=n,this.float32[s+4]=o,t}}lL.prototype.bytesPerElement=20,oC(lL,"StructArrayLayout5f20");class lO extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,i,r,a,n,o,s)}emplace(t,i,r,a,n,o,s,l){let h=7*t;return this.float32[h+0]=i,this.float32[h+1]=r,this.float32[h+2]=a,this.float32[h+3]=n,this.float32[h+4]=o,this.float32[h+5]=s,this.float32[h+6]=l,t}}lO.prototype.bytesPerElement=28,oC(lO,"StructArrayLayout7f28");class lF extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o,s,l,h,u,c){let d=this.length;return this.resize(d+1),this.emplace(d,t,i,r,a,n,o,s,l,h,u,c)}emplace(t,i,r,a,n,o,s,l,h,u,c,d){let p=11*t;return this.float32[p+0]=i,this.float32[p+1]=r,this.float32[p+2]=a,this.float32[p+3]=n,this.float32[p+4]=o,this.float32[p+5]=s,this.float32[p+6]=l,this.float32[p+7]=h,this.float32[p+8]=u,this.float32[p+9]=c,this.float32[p+10]=d,t}}lF.prototype.bytesPerElement=44,oC(lF,"StructArrayLayout11f44");class lB extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o,s,l,h){let u=this.length;return this.resize(u+1),this.emplace(u,t,i,r,a,n,o,s,l,h)}emplace(t,i,r,a,n,o,s,l,h,u){let c=9*t;return this.float32[c+0]=i,this.float32[c+1]=r,this.float32[c+2]=a,this.float32[c+3]=n,this.float32[c+4]=o,this.float32[c+5]=s,this.float32[c+6]=l,this.float32[c+7]=h,this.float32[c+8]=u,t}}lB.prototype.bytesPerElement=36,oC(lB,"StructArrayLayout9f36");class lk extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,i)}emplace(t,i,r){let a=2*t;return this.float32[a+0]=i,this.float32[a+1]=r,t}}lk.prototype.bytesPerElement=8,oC(lk,"StructArrayLayout2f8");class lN extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,r,a){let n=this.length;return this.resize(n+1),this.emplace(n,t,i,r,a)}emplace(t,i,r,a,n){let o=6*t;return this.uint32[3*t+0]=i,this.uint16[o+2]=r,this.uint16[o+3]=a,this.uint16[o+4]=n,t}}lN.prototype.bytesPerElement=12,oC(lN,"StructArrayLayout1ul3ui12");class lV extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint16[+t+0]=i,t}}lV.prototype.bytesPerElement=2,oC(lV,"StructArrayLayout1ui2");class lU extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m){let g=this.length;return this.resize(g+1),this.emplace(g,t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m)}emplace(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g){let y=16*t;return this.float32[y+0]=i,this.float32[y+1]=r,this.float32[y+2]=a,this.float32[y+3]=n,this.float32[y+4]=o,this.float32[y+5]=s,this.float32[y+6]=l,this.float32[y+7]=h,this.float32[y+8]=u,this.float32[y+9]=c,this.float32[y+10]=d,this.float32[y+11]=p,this.float32[y+12]=f,this.float32[y+13]=_,this.float32[y+14]=m,this.float32[y+15]=g,t}}lU.prototype.bytesPerElement=64,oC(lU,"StructArrayLayout16f64");class lj extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,r,a,n,o,s){let l=this.length;return this.resize(l+1),this.emplace(l,t,i,r,a,n,o,s)}emplace(t,i,r,a,n,o,s,l){let h=10*t,u=5*t;return this.uint16[h+0]=i,this.uint16[h+1]=r,this.uint16[h+2]=a,this.uint16[h+3]=n,this.float32[u+2]=o,this.float32[u+3]=s,this.float32[u+4]=l,t}}lj.prototype.bytesPerElement=20,oC(lj,"StructArrayLayout4ui3f20");class lG extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){let i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.int16[+t+0]=i,t}}lG.prototype.bytesPerElement=2,oC(lG,"StructArrayLayout1i2");class lH extends ln{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){let i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint8[+t+0]=i,t}}lH.prototype.bytesPerElement=1,oC(lH,"StructArrayLayout1ub1");class lq extends lr{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]}}lq.prototype.size=40;class lZ extends lI{get(t){return new lq(this,t)}}oC(lZ,"CollisionBoxArray");class l$ extends lr{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}
vendor: 5,360 bytes, line 7
7get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}l$.prototype.size=60;class lW extends lD{get(t){return new l$(this,t)}}oC(lW,"PlacedSymbolArray");class lX extends lr{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}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(t){this._structArray.float32[this._pos4+18]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}lX.prototype.size=80;class lY extends lP{get(t){return new lX(this,t)}}oC(lY,"SymbolInstanceArray");class lK extends lc{getoffsetX(t){return this.float32[+t+0]}}oC(lK,"GlyphOffsetArray");class lQ extends ll{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}oC(lQ,"SymbolLineVertexArray");class lJ extends lr{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]}}lJ.prototype.size=12;class l0 extends lN{get(t){return new lJ(this,t)}}oC(l0,"FeatureIndexArray");class l1 extends lS{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}oC(l1,"FillExtrusionCentroidArray");class l2 extends lr{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]}}l2.prototype.size=6;class l3 extends lh{get(t){return new l2(this,t)}}oC(l3,"FillExtrusionWallArray");let l4=lo([{name:"a_pos",components:2,type:"Int16"}],4),l5=lo([{name:"a_road_z_offset",components:1,type:"Float32"}],4),l6=lo([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),l8=lo([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);class l9{constructor(t=[]){this.segments=t}_prepareSegment(t,i,r,a,n){let o=this.segments.at(-1);return t>
7l9.MAX_VERTEX_ARRAY_LENGTH&&tX(`Max vertices per segment is ${l9.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!o||o.vertexLength+t>l9.MAX_VERTEX_ARRAY_LENGTH||o.sortKey!==a||void 0!==n&&o&&void 0!==o.batchIndex&&o.batchIndex!==n)&&(o={vertexOffset:i,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==a&&(o.sortKey=a),void 0!==n&&(o.batchIndex=n),this.segments.push(o)),o}prepareSegment(t,i,r,a,n){return this._prepareSegment(t,i.length,r.length,a,n)}get(){return this.segments}destroy(){for(let t of this.segments)for(let i in t.vaos)t.vaos[i].destroy()}static simpleSegment(t,i,r,a){return new l9([{vertexOffset:t,primitiveOffset:i,vertexLength:r,primitiveLength:a,vaos:{},sortKey:0}])}}function l7(t,i){return 256*(t=tL(Math.floor(t),0,255))+tL(Math.floor(i),0,255)}l9.MAX_VERTEX_ARRAY_LENGTH=65535,oC(l9,"SegmentVector");let he=lo([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),ht=lo([{name:"a_pattern_b",components:4,type:"Uint16"}]),hi=lo([{name:"a_dash",components:4,type:"Uint16"}]);class hr{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,i,r,a){this.ids.push(ha(t)),this.positions.push(i,r,a)}eachPosition(t,i){let r=ha(t),a=0,n=this.ids.length-1;for(;a<n;){let t=a+n>>1;this.ids[t]>=r?n=t:a=t+1}for(;this.ids[a]===r;)i(this.positions[3*a],this.positions[3*a+1],this.positions[3*a+2]),a++}static serialize(t,i){let r=new Float64Array(t.ids),a=new Uint32Array(t.positions);return function t(i,r,a,n){for(;a<n;){let o=i[a+n>>1],s=a-1,l=n+1;for(;;){do s++;while(i[s]<o);do l--;while(i[l]>o);if(s>=l)break;hn(i,s,l),hn(r,3*s,3*l),hn(r,3*s+1,3*l+1),hn(r,3*s+2,3*l+2)}l-a<n-l?(t(i,r,a,l),a=l+1):(t(i,r,l+1,n),n=l)}}(r,a,0,r.length-1),i&&(i.add(r.buffer),i.add(a.buffer)),{ids:r,positions:a}}static deserialize(t){let i,r=new hr;for(let a of(r.ids=t.ids,r.positions=t.positions,r.ids))a!==i&&r.uniqueIds.push(a),i=a;return r.indexed=!0,r}}function ha(t){let i=+t;return Number.isSafeInteger(i)?i:rP(String(t))}function hn(t,i,r){let a=t[i];t[i]=t[r],t[r]=a}oC(hr,"FeaturePositionMap");class ho{constructor(t){this.gl=t.gl,this.initialized=!1}fetchUniformLocation(t,i){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(t,i),this.initialized=!0),!!this.location}set(t,i,r){throw Error("Uniform#set() must be implemented by each concrete Uniform")}}class hs extends ho{constructor(t){super(t),this.current=0}set(t,i,r){this.fetchUniformLocation(t,i)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}}class hl extends ho{constructor(t){super(t),this.current=0}set(t,i,r){this.fetchUniformLocation(t,i)&&this.current!==r&&(this.current=r,this.gl.uniform1f(this.location,r))}}class hh extends ho{constructor(t){super(t),this.current=[0,0]}set(t,i,r){this.fetchUniformLocation(t,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])))}}class hu extends ho{constructor(t){super(t),this.current=[0,0,0]}set(t,i,r){this.fetchUniformLocation(t,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2])))}}class hc extends ho{constructor(t){super(t),this.current=[0,0,0,0]}set(t,i,r){this.fetchUniformLocation(t,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4ui(this.location,r[0],r[1],r[2],r[3])))}}class hd extends ho{constructor(t){super(t),this.current=[0,0,0,0]}set(t,i,r){this.fetchUniformLocation(t,i)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4f(this.location,r[0],r[1],r[2],r[3])))}}class hp extends ho{constructor(t){super(t),this.current=rq.transparent.toPremultipliedRenderColor(null)}set(t,i,r){this.fetchUniformLocation(t,i)&&(r.r===this.current.r&&r.g===this.current.g&&r.b===this.current.b&&r.a===this.current.a||(this.current=r,this.gl.uniform4f(this.location,r.r,r.g,r.b,r.a)))}}
vendor: 5,069 bytes, line 7
7class hf extends ho{constructor(t){super(t),this.current=new Float32Array(16)}set(t,i,r){if(!this.fetchUniformLocation(t,i))return;let a=this.current;if(r[12]!==a[12]||r[0]!==a[0])return a.set(r),void this.gl.uniformMatrix4fv(this.location,!1,a);for(let t=1;t<16;t++)if(r[t]!==a[t]){a.set(r),this.gl.uniformMatrix4fv(this.location,!1,a);break}}}class h_ extends ho{constructor(t){super(t),this.current=new Float32Array(9)}set(t,i,r){if(!this.fetchUniformLocation(t,i))return;let a=this.current;for(let t=0;t<9;t++)if(r[t]!==a[t]){a.set(r),this.gl.uniformMatrix3fv(this.location,!1,a);break}}}class hm extends ho{constructor(t){super(t),this.current=new Float32Array(4)}set(t,i,r){if(!this.fetchUniformLocation(t,i))return;let a=this.current;for(let t=0;t<4;t++)if(r[t]!==a[t]){a.set(r),this.gl.uniformMatrix2fv(this.location,!1,a);break}}}function hg(t){return[l7(255*t.r,255*t.g),l7(255*t.b,255*t.a)]}function hy(t,i,r,a,n,o,s,l){return!!t&&("composite"===t.kind||"source"===t.kind?"none"===t.evaluate(new o0(0,{brightness:o,worldview:l}),i,r,n,a,s):"none"===t.value)}class hx{constructor(t,i,r,a){this.value=t,this.uniformNames=i.map(t=>`u_${t}`),this.type=r,this.context=a}setUniform(t,i,r,a,n){let o=a.constantOr(this.value);i.set(t,n,o instanceof rq?o.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):o)}getBinding(t,i){return"color"===this.type?new hp(t):new hl(t)}}class hv{constructor(t,i){this.uniformNames=i.map(t=>`u_${t}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(t,i){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br),this.patternTransition=i?i.tl.concat(i.br):this.pattern}setUniform(t,i,r,a,n){let o=null;"u_pattern"!==n&&"u_dash"!==n||(o=this.pattern),"u_pattern_b"===n&&(o=this.patternTransition),"u_pixel_ratio"===n&&(o=this.pixelRatio),o&&i.set(t,n,o)}getBinding(t,i){return"u_pattern"===i||"u_pattern_b"===i||"u_dash"===i?new hc(t):new hl(t)}}class hb{constructor(t,i,r,a){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=i.map(t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0})),this.paintVertexArray=new a}populatePaintArray(t,i,r,a,n,o,s,l){let h=this.paintVertexArray.length,u="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new o0(0,{brightness:o,worldview:l}),i,{},n,a,s):"constant"===this.expression.kind&&this.expression.value,c=hy(this.lutExpression,i,{},a,n,o,s,l);this.paintVertexArray.resize(t),this._setPaintValue(h,t,u,c?null:this.context.lut)}updatePaintArray(t,i,r,a,n,o,s,l){let h="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:s,worldview:l},r,a,void 0,n):"constant"===this.expression.kind&&this.expression.value,u=hy(this.lutExpression,r,a,n,void 0,s,void 0,l);this._setPaintValue(t,i,h,u?null:this.context.lut)}_setPaintValue(t,i,r,a){if("color"===this.type){let n=hg(r.toPremultipliedRenderColor(a));for(let r=t;r<i;r++)this.paintVertexArray.emplace(r,n[0],n[1])}else{for(let a=t;a<i;a++)this.paintVertexArray.emplace(a,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&"constant"!==this.lutExpression.kind&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||"constant"!==this.expression.kind&&(this.expression.isStateDependent||!this.expression.isLightConstant)))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class hw{constructor(t,i,r,a,n,o){this.expression=t,this.uniformNames=i.map(t=>`u_${t}_t`),this.type=r,this.useIntegerZoom=a,this.context=n,this.maxValue=0,this.paintVertexAttributes=i.map(t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(t,i,r,a,n,o,s,l){let h=this.expression.evaluate(new o0(this.context.zoom,{brightness:o,worldview:l}),i,{},n,a,s),u=this.expression.evaluate(new o0(this.context.zoom+1,{brightness:o,worldview:l}),i,{},n,a,s),c=hy(this.lutExpression,i,{},a,n,o,s,l),d=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(d,t,h,u,c?null:this.context.lut)}updatePaintArray(t,i,r,a,n,o,s,l){let h=this.expression.evaluate({zoom:this.context.zoom,brightness:s,worldview:l},r,a,void 0,n),u=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s,worldview:l},r,a,void 0,n),c=hy(this.lutExpression,r,a,n,void 0,s,void 0,l);this._setPaintValue(t,i,h,u,c?null:this.context.lut)}_setPaintValue(t,i,r,a,n){if("color"===this.type){let o=hg(r.toPremultipliedRenderColor(n)),s=hg(a.toPremultipliedRenderColor(n));for(let r=t;r<i;r++)this.paintVertexArray.emplace(r,o[0],o[1],s[0],s[1])}else{for(let n=t;n<i;n++)this.paintVertexArray.emplace(n,r,a);
7this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(a))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,i,r,a,n){let o=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,s=tL(this.expression.interpolationFactor(o,this.context.zoom,this.context.zoom+1),0,1);i.set(t,n,s)}getBinding(t,i){return new hl(t)}}class hT{constructor(t,i,r,a,n){this.expression=t,this.layerId=n,this.paintVertexAttributes=("array"===r?hi:he).members;for(let t=0;t<i.length;++t);this.paintVertexArray=new a,this.paintTransitionVertexArray=new lx}populatePaintArray(t,i,r,a){let n=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValues(n,t,i.patterns&&i.patterns[this.layerId],r)}updatePaintArray(t,i,r,a,n,o,s){this._setPaintValues(t,i,r.patterns&&r.patterns[this.layerId],o)}_setPaintValues(t,i,r,a){if(!a||!r)return;let n=a[r[0]],o=a[r[1]];if(n){if(n){let{tl:r,br:a,pixelRatio:o}=n;for(let n=t;n<i;n++)this.paintVertexArray.emplace(n,r[0],r[1],a[0],a[1],o)}if(o){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);let{tl:r,br:a}=o;for(let n=t;n<i;n++)this.paintTransitionVertexArray.emplace(n,r[0],r[1],a[0],a[1])}}}upload(t){let i=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,i)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=t.createVertexBuffer(this.paintTransitionVertexArray,ht.members,i))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class hE{constructor(t,i,r=()=>!0){this.binders={},this._buffers=[],this.context=i;let a=[];for(let n in t.paint._values){let o=t.paint.get(n);if(n.endsWith("-use-theme")||!r(n)||!(o instanceof o8&&ol(o.property.specification)))continue;let s=function(t,i){return hI[t]||[t.replace(`${i}-`,"").replace(/-/g,"_")]}(n,t.type),l=o.value,h=o.property.specification.type,u=!!o.property.useIntegerZoom,c="line-dasharray"===n||n.endsWith("pattern"),d=t.paint.get(`${n}-use-theme`),p="line-dasharray"===n&&"constant"!==t.layout.get("line-cap").value.kind||d&&"constant"!==d.value.kind;if("constant"!==l.kind||p)if("source"===l.kind||p||c){let i=hM(n,h,"source");this.binders[n]=c?new hT(l,s,h,i,t.id):new hb(l,s,h,i),a.push(`/a_${n}`)}else{let t=hM(n,h,"composite");this.binders[n]=new hw(l,s,h,u,i,t),a.push(`/z_${n}`)}else this.binders[n]=c?new hv(l.value,s):new hx(l.value,s,h,i),a.push(`/u_${n}`);d&&(this.binders[n].lutExpression=d.value)}this.cacheKey=a.sort().join("")}updateExpressions(t){for(let i in this.binders){let r=this.binders[i];(r instanceof hb||r instanceof hw||r instanceof hT)&&(r.expression=t.paint.get(i).value)}}getMaxValue(t){let i=this.binders[t];return i instanceof hb||i instanceof hw?i.maxValue:0}populatePaintArrays(t,i,r,a,n,o,s,l){for(let h in this.binders){let u=this.binders[h];u.context=this.context,(u instanceof hb||u instanceof hw||u instanceof hT)&&u.populatePaintArray(t,i,r,a,n,o,s,l)}}setConstantPatternPositions(t,i){for(let r in this.binders){let a=this.binders[r];a instanceof hv&&a.setConstantPatternPositions(t,i)}}getPatternTransitionVertexBuffer(t){let i=this.binders[t];return i instanceof hT?i.paintTransitionVertexBuffer:null}updatePaintArrays(t,i,r,a,n,o,s,l,h,u){let c=!1,d=Object.keys(t),p=0!==d.length&&!l,f=p?d:i.uniqueIds;for(let l in this.context.lut=n.lut,this.binders){let d=this.binders[l];if(d.context=this.context,(d instanceof hb||d instanceof hw||d instanceof hT)&&d.expression&&d.expression.kind&&"constant"!==d.expression.kind&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){for(let r of(d.expression=n.paint.get(l).value,f)){let n=t[r.toString()];i.eachPosition(r,(t,i,r)=>{let l=a.feature(t);d.updatePaintArray(i,r,l,n,o,s,h,u)})}if(!p)for(let i of r.uniqueIds){let n=t[i.toString()];r.eachPosition(i,(t,i,r)=>{let l=a.feature(t);d.updatePaintArray(i,r,l,n,o,s,h,u)})}c=!0}}return c}defines(){let t=[];for(let i in this.binders){let r=this.binders[i];(r instanceof hx||r instanceof hv)&&t.push(...r.uniformNames.map(t=>`#define HAS_UNIFORM_${t}`))}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t){let i=[];for(let r in this.binders){let a=this.binders[r];if(a instanceof hx||a instanceof hv||a instanceof hw)for(let n of a.uniformNames)i.push({name:n,property:r,binding:a.getBinding(t,n)})}return i}setUniforms(t,i,r,a,n){for(let{name:i,property:o,binding:s}of r)this.binders[o].setUniform(t,s,n,a.get(o),i)}updatePaintBuffers(){for(let t in this._buffers=[],this.binders){let i=this.binders[t];(i instanceof hb||i instanceof hw||i instanceof hT)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer),i instanceof hT&&i.paintTransitionVertexBuffer&&this._buffers.push(i.paintTransitionVertexBuffer)}}upload(t){for(let i in this.binders){let r=this.binders[i];(r instanceof hb||r instanceof hw||r instanceof hT)&&r.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let i=this.binders[t];(i instanceof hb||i instanceof hw||i instanceof hT)&&i.destroy()}}}class hS{constructor(t,i,r=()=>!0){for(let a of(this.programConfigurations={},t))this.programConfigurations[a.id]=new hE(a,i,r);this.needsUpload=!1,this._featureMap=new hr,this._featureMapWithoutIds=new hr,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,i,r,a,n,o,s,l,h){for(let r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,i,a,n,o,s,l,h);void 0!==i.id?this._featureMap.add(i.id,r,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,i,r,a,n,o,s,l){for(let h of r)this.needsUpload=this.programConfigurations[h.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,i,h,a,n,o,s||0,l)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let i in this.programConfigurations)this.programConfigurations[i].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}updateExpressions(t){let i=new Set;for(let r of t){let t=this.programConfigurations[r.id];t&&(t.updateExpressions(r),i.add(r.id))}for(let t in this.programConfigurations)i.has(t)||delete this.programConfigurations[t]}}let hI={"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"]},hA={"line-pattern":{source:ly,composite:ly},"fill-pattern":{source:ly,composite:ly},"fill-extrusion-pattern":{source:ly,composite:ly},"line-dasharray":{source:lx,composite:lx}},hC={color:{source:lk,composite:lT},number:{source:lc,composite:lk}};function hM(t,i,r){let a=hA[t];return a&&a[r]||hC[i][r]}oC(hx,"ConstantBinder"),oC(hv,"PatternConstantBinder"),oC(hb,"SourceExpressionBinder",{omit:["expression"]}),oC(hT,"PatternCompositeBinder",{omit:["expression"]}),oC(hw,"CompositeExpressionBinder",{omit:["expression"]}),oC(hE,"ProgramConfiguration",{omit:["_buffers"]}),oC(hS,"ProgramConfigurationSet");class hR{constructor(t,i,r){this.layoutVertexArray=new ll,this.indexArray=new lR,this.lineIndexArray=new lS,this.triangleSegments=new l9,this.lineSegments=new l9,this.programConfigurations=new hS(t,{zoom:i,lut:r}),this.uploaded=!1}update(t,i,r,a,n,o,s,l){this.programConfigurations.updatePaintArrays(t,i,n,r,a,o,s,l)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,l4.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.lineIndexBuffer=t.createIndexBuffer(this.lineIndexArray)),this.programConfigurations.upload(t),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(t,i,r,a,n,o,s){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,a,n,o,void 0,s)}}oC(hR,"FillBufferData");class hD{constructor(t){this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=t.lut,this.bufferData=new hR(t.layers,t.zoom,t.lut),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.projection=t.projection,this.sourceLayerIndex=t.sourceLayerIndex,this.sourceLayerName=t.sourceLayerName||"",this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,i){}updateAppearances(t,i,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,i,r,a){this.hasPattern=sZ("fill",this.layers,this.pixelRatio,i);let n=this.layers[0].layout.get("fill-sort-key"),o=[];for(let{feature:s,id:l,index:h,sourceLayerIndex:u}of t){let t=this.layers[0]._featureFilter.needGeometry,c=lt(s,t);if(!this.layers[0]._featureFilter.filter(new o0(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),c,r))continue;let d=n?n.evaluate(c,{},r,i.availableImages):void 0,p={id:l,properties:s.properties,type:s.type,sourceLayerIndex:u,index:h,geometry:t?c.geometry:le(s,r,a),patterns:{},sortKey:d};o.push(p)}for(let a of(n&&o.sort((t,i)=>t.sortKey-i.sortKey),o)){let{geometry:n,index:o,sourceLayerIndex:s}=a;if(this.hasPattern){let t=s$("fill",this.layers,a,this.zoom,this.pixelRatio,i);this.patternFeatures.push(t)}else this.addFeature(a,n,o,r,{},i.availableImages,i.brightness,i.elevationFeatures);i.featureIndex.insert(t[o].feature,n,o,s,this.index)}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this)}update(t,i,r,a,n,o,s){this.bufferData.update(t,i,r,a,n,o,s,this.worldview),this.hdExt&&this.hdExt.update(t,i,r,a,n,o,s,this.worldview)}updateExpressions(t){this.bufferData.programConfigurations.updateExpressions(t),this.hdExt&&this.hdExt.updateExpressions(t)}addFeatures(t,i,r,a,n,o){for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,i,r,a,o,t.elevationFeatures);this.hdExt&&this.hdExt.buildFrcSegments(this)}isEmpty(){return this.bufferData.isEmpty()&&(!this.hdExt||this.hdExt.isEmpty())}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||null!=this.hdExt&&this.hdExt.needsUpload()}upload(t){this.bufferData.upload(t),this.hdExt&&this.hdExt.upload(t)}destroy(){this.bufferData.destroy(),this.hdExt&&this.hdExt.destroy()}
7addFeature(t,i,r,a,n,o=[],s,l){let h=this.hdExt?this.hdExt.trackFeatureFrc(t.properties):null,u=this.bufferData.indexArray.length,c=tb(i,500);null!=this.hdExt&&this.hdExt.handleFeature(t,c,r,a,l,this)||this.addGeometry(c,this.bufferData),this.bufferData.populatePaintArrays(t,r,n,o,a,s,this.worldview),this.hdExt&&this.hdExt.populatePaintArrays(t,r,n,o,a,s,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,u,this.bufferData.indexArray.length,h)}addGeometry(t,i,r,a){let n=1/0,o=-1/0,s=null;r&&null!=(s=r.elevationSampler.constantElevation(r.elevation,r.bias))&&(n=s,o=s);let l=r?i:null,h=(t,i,a)=>{if(null!=r)if(i.push(t),null!=s)l.elevatedLayoutVertexArray.emplaceBack(s),a.push(s);else{let i=r.elevationSampler.pointElevation(t,r.elevation,r.bias);l.elevatedLayoutVertexArray.emplaceBack(i),a.push(i),n=Math.min(n,i),o=Math.max(o,i)}};for(let n of t){let t=0;for(let i of n)t+=i.length;let o=i.triangleSegments.prepareSegment(t,i.layoutVertexArray,i.indexArray),s=o.vertexLength,l=[],u=[],c=[],d=[],p=[],f=i.layoutVertexArray.length;for(let t of n){if(0===t.length)continue;t!==n[0]&&u.push(l.length/2);let a=i.lineSegments.prepareSegment(t.length,i.layoutVertexArray,i.lineIndexArray),o=a.vertexLength;r&&p.push(i.layoutVertexArray.length-f),h(t[0],c,d),i.layoutVertexArray.emplaceBack(t[0].x,t[0].y),i.lineIndexArray.emplaceBack(o+t.length-1,o),l.push(t[0].x),l.push(t[0].y);for(let r=1;r<t.length;r++)h(t[r],c,d),i.layoutVertexArray.emplaceBack(t[r].x,t[r].y),i.lineIndexArray.emplaceBack(o+r-1,o+r),l.push(t[r].x),l.push(t[r].y);a.vertexLength+=t.length,a.primitiveLength+=t.length}let _=sC(l,u);for(let t=0;t<_.length;t+=3)i.indexArray.emplaceBack(s+_[t],s+_[t+1],s+_[t+2]);if(_.length>0&&r&&a){let t=r.elevation.isTunnel(),i=r.elevation.safeArea,n=a.addVertices(c,d);a.addTriangles(_,n,t);let o=p.length;if(o>0){for(let s=0;s<o-1;s++)a.addRenderableRing(r.index,p[s]+n,p[s+1]-p[s],t,i,r.featureInfo);a.addRenderableRing(r.index,p[o-1]+n,c.length-p[o-1],t,i,r.featureInfo)}}o.vertexLength+=t,o.primitiveLength+=_.length/3}return[n,o]}}oC(hD,"FillBucket",{omit:["layers","patternFeatures"]});let hP=lo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),hz=lo([{name:"a_z_offset_width",components:4,type:"Float32"}],4),hL=lo([{name:"a_elevation_id_col",components:3,type:"Float32"}],4),hO=lo([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:hF}=hP,{members:hB}=lo([{name:"a_packed",components:3,type:"Float32"}]),{members:hk}=lo([{name:"a_pattern_data",components:3,type:"Float32"}]);class hN{constructor(t,i,r,a,n){for(this.properties=Object.create(null),this.extent=r,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=a,this._values=n;t.pos<i;){let i=t.readVarint();if(8===i)this.id=t.readVarint();else if(18===i){let i=t.readVarint()+t.pos;for(;t.pos<i;){let i=a[t.readVarint()],r=n[t.readVarint()];this.properties[i]=r}}else 24===i?this.type=t.readVarint():(34===i&&(this._geometry=t.pos),t.skip(i))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let i=t.readVarint()+t.pos,r=[],a,n=1,o=0,s=0,l=0;for(;t.pos<i;){if(o<=0){let i=t.readVarint();if(n=7&i,0==(o=i>>3))continue}if(o--,1===n)s+=t.readSVarint(),l+=t.readSVarint(),a&&r.push(a),a=[new tg(s,l)];else if(2===n)s+=t.readSVarint(),l+=t.readSVarint(),a&&a.push(new tg(s,l));else{if(7!==n)throw Error(`unknown command ${n}`);a&&a.push(a[0].clone())}}return a&&r.push(a),r}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let i=t.readVarint()+t.pos,r=1,a=0,n=0,o=0,s=1/0,l=-1/0,h=1/0,u=-1/0;for(;t.pos<i;){if(a<=0){let i=t.readVarint();if(r=7&i,0==(a=i>>3))continue}if(a--,1===r||2===r)n+=t.readSVarint(),o+=t.readSVarint(),n<s&&(s=n),n>l&&(l=n),o<h&&(h=o),o>u&&(u=o);else if(7!==r)throw Error(`unknown command ${r}`)}return[s,h,l,u]}toGeoJSON(t,i,r){let a,n=this.extent*Math.pow(2,r),o=this.extent*t,s=this.extent*i,l=this.loadGeometry();function h(t){return[360*(t.x+o)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+s)/n)*Math.PI))-90]}function u(t){return t.map(h)}if(1===this.type){let t=[];for(let i of l)t.push(i[0]);let i=u(t);a=1===t.length?{type:"Point",coordinates:i[0]}:{type:"MultiPoint",coordinates:i}}else if(2===this.type){let t=l.map(u);a=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}}else{if(3!==this.type)throw Error("unknown feature type");{let t=function(t){let i,r,a=t.length;if(a<=1)return[t];let n=[];for(let o=0;o<a;o++){let a=function(t){let i=0;for(let r,a,n=0,o=t.length,s=o-1;n<o;s=n++)r=t[n],i+=((a=t[s]).x-r.x)*(r.y+a.y);return i}(t[o]);0!==a&&(void 0===r&&(r=a<0),r===a<0?(i&&n.push(i),i=[t[o]]):i&&i.push(t[o]))}return i&&n.push(i),n}(l),i=[];for(let r of t)i.push(r.map(u));a=1===i.length?{type:"Polygon",coordinates:i[0]}:{type:"MultiPolygon",coordinates:i}}}let c={type:"Feature",geometry:a,properties:this.properties};return null!=this.id&&(c.id=this.id),c}}hN.types=["Unknown","Point","LineString","Polygon"];class hV{constructor(t,i){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],void 0===i&&(i=t.length);t.pos<i;){let i=t.readVarint();10===i?this.name=t.readString():18===i?(this._features.push(t.pos),t.skip(i)):26===i?this._keys.push(t.readString()):34===i?this._values.push(function(t){let i=null,r=t.readVarint()+t.pos;for(;t.pos<r;){let r=t.readVarint();i=10===r?t.readString():21===r?t.readFloat():25===r?t.readDouble():32===r?t.readVarint(!0):40===r?t.readVarint():48===r?t.readSVarint():56===r?t.readBoolean():(t.skip(r),null)}if(null==i)throw Error("unknown feature value");return i}(t)):40===i?this.extent=t.readVarint():120===i?this.version=t.readVarint():t.skip(i)}this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[t];let i=this._pbf.readVarint()+this._pbf.pos;return new hN(this._pbf,i,this.extent,this._keys,this._values)}}class hU{constructor(t,i=t.length){let r=Object.create(null);for(;t.pos<i;){let i=t.readVarint();if(26===i){let i=new hV(t,t.readVarint()+t.pos);i.length&&(r[i.name]=i)}else t.skip(i)}this.layers=r}}function hj(t,i){for(let r=0;r<t.length;r++)if(hW(i,t[r]))return!0;for(let r=0;r<i.length;r++)if(hW(t,i[r]))return!0;return!!hH(t,i)}function hG(t,i){if(1===t.length)return h$(i,t[0]);for(let r=0;r<i.length;r++){let a=i[r];for(let i=0;i<a.length;i++)if(hW(t,a[i]))return!0}for(let r=0;r<t.length;r++)if(h$(i,t[r]))return!0;for(let r=0;r<i.length;r++)if(hH(t,i[r]))return!0;return!1}function hH(t,i){if(0===t.length||0===i.length)return!1;for(let s=0;s<t.length-1;s++){let l=t[s],h=t[s+1];for(let t=0;t<i.length-1;t++){var r,a,n,o;if(r=l,a=h,n=i[t],tY(r,n,o=i[t+1])!==tY(a,n,o)&&tY(r,a,n)!==tY(r,a,o))return!0}}return!1}
7function hq(t,i,r){return(t.x-r.x)*(i.y-r.y)-(t.y-r.y)*(i.x-r.x)}function hZ(t,i,r){let a=r*r;if(1===i.length)return t.distSqr(i[0])<a;for(let r=1;r<i.length;r++)if(function(t,i,r){let a=i.distSqr(r);if(0===a)return t.distSqr(i);let n=((t.x-i.x)*(r.x-i.x)+(t.y-i.y)*(r.y-i.y))/a;return t.distSqr(n<0?i:n>1?r:r.sub(i)._mult(n)._add(i))}(t,i[r-1],i[r])<a)return!0;return!1}function h$(t,i){let r,a,n,o=!1;for(let s=0;s<t.length;s++){r=t[s];for(let t=0,s=r.length-1;t<r.length;s=t++)a=r[t],n=r[s],a.y>i.y!=n.y>i.y&&i.x<(n.x-a.x)*(i.y-a.y)/(n.y-a.y)+a.x&&(o=!o)}return o}function hW(t,i){let r=!1;for(let a=0,n=t.length-1;a<t.length;n=a++){let o=t[a],s=t[n];o.y>i.y!=s.y>i.y&&i.x<(s.x-o.x)*(i.y-o.y)/(s.y-o.y)+o.x&&(r=!r)}return r}function hX(t,i,r,a,n){for(let o of t)if(i<=o.x&&r<=o.y&&a>=o.x&&n>=o.y)return!0;let o=[new tg(i,r),new tg(i,n),new tg(a,n),new tg(a,r)];if(t.length>2){for(let i of o)if(hW(t,i))return!0}for(let i=0;i<t.length-1;i++)if(hY(t[i],t[i+1],o))return!0;return!1}function hY(t,i,r){let a=r[0],n=r[2];if(t.x<a.x&&i.x<a.x||t.x>n.x&&i.x>n.x||t.y<a.y&&i.y<a.y||t.y>n.y&&i.y>n.y)return!1;let o=tY(t,i,r[0]);return o!==tY(t,i,r[1])||o!==tY(t,i,r[2])||o!==tY(t,i,r[3])}function hK(t,i,r,a,n,o){let s=i.y-t.y,l=t.x-i.x;if(o=o||0){let t=s*s+l*l;if(0===t)return!0;let i=Math.sqrt(t);s/=i,l/=i}return!((r.x-t.x)*s+(r.y-t.y)*l-o<0||(a.x-t.x)*s+(a.y-t.y)*l-o<0||(n.x-t.x)*s+(n.y-t.y)*l-o<0)}function hQ(t,i,r,a,n,o,s){return!(hK(t,i,a,n,o,s)||hK(i,r,a,n,o,s)||hK(r,t,a,n,o,s)||hK(a,n,t,i,r,s)||hK(n,o,t,i,r,s)||hK(o,a,t,i,r,s))}class hJ extends tg{constructor(t,i,r){super(t,i),this.z=r}}class h0 extends hJ{constructor(t,i,r,a){super(t,i,r),this.w=a}}function h1(t,i,r,a){let n="x"===r?"y":"x",o=(a-t[r])/(i[r]-t[r]);t[n]=Math.round(t[n]+(i[n]-t[n])*o),t[r]=a,Object.hasOwn(t,"z")&&(t.z=rG(t.z,i.z,o)),Object.hasOwn(t,"w")&&(t.w=rG(t.w,i.w,o))}function h2(t,i,r,a){for(let n of["x","y"]){let o=t,s=i;o[n]>=s[n]&&(o=i,s=t),o[n]<r&&s[n]>r&&h1(o,s,n,r),o[n]<a&&s[n]>a&&h1(s,o,n,a)}}function h3(t,i,r,a,n,o){let s=[];for(let l=0;l<t.length;l++){let h,u=t[l],c=s.length,d=0;for(let t=0;t<u.length-1;t++){let c,p,f=u[t],_=u[t+1],m=0,g=d;o&&(d+=m=Math.hypot(_.x-f.x,_.y-f.y),c=f,p=_),f.x<i&&_.x<i||(f.x<i?f=new tg(i,f.y+(i-f.x)/(_.x-f.x)*(_.y-f.y))._round():_.x<i&&(_=new tg(i,f.y+(i-f.x)/(_.x-f.x)*(_.y-f.y))._round()),f.y<r&&_.y<r||(f.y<r?f=new tg(f.x+(r-f.y)/(_.y-f.y)*(_.x-f.x),r)._round():_.y<r&&(_=new tg(f.x+(r-f.y)/(_.y-f.y)*(_.x-f.x),r)._round()),f.x>=a&&_.x>=a||(f.x>=a?f=new tg(a,f.y+(a-f.x)/(_.x-f.x)*(_.y-f.y))._round():_.x>=a&&(_=new tg(a,f.y+(a-f.x)/(_.x-f.x)*(_.y-f.y))._round()),f.y>=n&&_.y>=n||(f.y>=n?f=new tg(f.x+(n-f.y)/(_.y-f.y)*(_.x-f.x),n)._round():_.y>=n&&(_=new tg(f.x+(n-f.y)/(_.y-f.y)*(_.x-f.x),n)._round()),h&&f.equals(h.at(-1))||(h=[f],s.push(h),o&&o.push({progress:{min:g+h4(c,p,f)*m,max:1},parentIndex:l,prevPoint:c,nextPoint:p})),h.push(_),o&&(o.at(-1).progress.max=g+h4(c,p,_)*m,o.at(-1).nextPoint=p)))))}if(o&&d>0)for(let t=c;t<s.length;t++)o[t].progress.min/=d,o[t].progress.max/=d}return s}function h4(t,i,r){return t.x!==i.x?(r.x-t.x)/(i.x-t.x):t.y!==i.y?(r.y-t.y)/(i.y-t.y):0}function h5(t,{width:i,height:r}
7,a,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==i*r*a)throw RangeError("mismatched image size")}else n=new Uint8Array(i*r*a);return t.width=i,t.height=r,t.data=n,t}function h6(t,i,r){let{width:a,height:n}=i;a===t.width&&n===t.height||(h8(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,a),height:Math.min(t.height,n)},r,null),t.width=a,t.height=n,t.data=i.data)}function h8(t,i,r,a,n,o,s,l){if(0===n.width||0===n.height)return i;if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw RangeError("out of range source coordinates for image copy");if(n.width>i.width||n.height>i.height||a.x>i.width-n.width||a.y>i.height-n.height)throw RangeError("out of range destination coordinates for image copy");let h=t.data,u=i.data,c=4===o&&l;for(let l=0;l<n.height;l++){let d=((r.y+l)*t.width+r.x)*o,p=((a.y+l)*i.width+a.x)*o;if(c)for(let t=0;t<n.width;t++){let i=d+t*o+3,r=p+t*o;u[r+0]=255,u[r+1]=255,u[r+2]=255,u[r+3]=h[i]}else if(s)for(let t=0;t<n.width;t++){let i=d+t*o,r=p+t*o,a=new rq(h[i+0]/255,h[i+1]/255,h[i+2]/255,h[i+3]).toNonPremultipliedRenderColor(s).toArray();u[r+0]=a[0],u[r+1]=a[1],u[r+2]=a[2],u[r+3]=a[3]}else for(let t=0;t<n.width*o;t++)u[p+t]=h[d+t]}return i}class h9{constructor(t,i){h5(this,t,1,i)}resize(t){h6(this,new h9(t),1)}clone(){return new h9({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,r,a,n){h8(t,i,r,a,n,1,null)}}class h7{constructor(t,i){h5(this,t,4,i)}resize(t){h6(this,new h7(t),4)}replace(t,i){i?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new h7({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,r,a,n,o,s){h8(t,i,r,a,n,4,o,s)}}class ue{constructor(t,i){this.width=t.width,this.height=t.height,this.data=i instanceof Uint8Array?new Float32Array(i.buffer):i}}oC(h9,"AlphaImage"),oC(h7,"RGBAImage"),oC(class{constructor(t,i){this.width=t,this.height=i,this.nextRow=0,this.image=new h9({width:t,height:i}),this.positions={},this.uploaded=!1}getDash(t,i){let r=this.getKey(t,i);return this.positions[r]}trim(){let t=this.width,i=this.height=tU(this.nextRow);this.image.resize({width:t,height:i})}getKey(t,i){return t.join(",")+i}getDashRanges(t,i,r){let a=[],n=t.length%2==1?-t.at(-1)*r:0,o=t[0]*r,s=!0;a.push({left:n,right:o,isDash:s,zeroLength:0===t[0]});let l=t[0];for(let i=1;i<t.length;i++){s=!s;let h=t[i];n=l*r,l+=h,o=l*r,a.push({left:n,right:o,isDash:s,zeroLength:0===h})}return a}addRoundDash(t,i,r){let a=i/2;for(let i=-r;i<=r;i++){let n=this.width*(this.nextRow+r+i),o=0,s=t[0];for(let l=0;l<this.width;l++){let h;l/s.right>1&&(s=t[++o]);let u=Math.min(Math.abs(l-s.left),Math.abs(l-s.right)),c=i/r*(a+1);if(s.isDash){let t=a-Math.abs(c);h=Math.sqrt(u*u+t*t)}else h=a-Math.sqrt(u*u+c*c);this.image.data[n+l]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t,i){for(let i=t.length-1;i>=0;--i){let r=t[i],a=t[i+1];r.zeroLength?t.splice(i,1):a&&a.isDash===r.isDash&&(a.left=r.left,t.splice(i,1))}let r=t[0],a=t.at(-1);r.isDash===a.isDash&&(r.left=a.left-this.width,a.right=r.right+this.width);let n=this.width*this.nextRow,o=0,s=t[0];for(let r=0;r<this.width;r++){r/s.right>1&&(s=t[++o]);let a=Math.min(Math.abs(r-s.left),Math.abs(r-s.right));this.image.data[n+r]=Math.max(0,Math.min(255,(s.isDash?a:-a)+i+128))}}addDash(t,i){let r=this.getKey(t,i);if(this.positions[r])return this.positions[r];let a="round"===i,n=7*!!a,o=2*n+1;if(this.nextRow+o>this.height)return tX("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let i=0;i<t.length;i++)t[i]<0&&(tX("Negative value is found in line dasharray, replacing values with 0"),t[i]=0),s+=t[i];if(0!==s){let r=this.width/s,o=this.getDashRanges(t,this.width,r);a?this.addRoundDash(o,r,n):this.addRegularDash(o,"square"===i?.5*r:0)}let l=this.nextRow+n;this.nextRow+=o;let h=Math.floor(s),u={tl:[l,n],br:[h,Math.round(65535*(s-h))]};return this.positions[r]=u,u}},"LineAtlas");let ut="3d_elevation_id",ui="level",ur=hN.types,ua=Math.cos(Math.PI/180*37.5),un=Math.cos(Math.PI/180*5);class uo{constructor(t){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.showElevationIdDebug=!1,this.terrainEnabled=!1,this.zoom=t.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=t.overscaling,this.pixelRatio=t.pixelRatio,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={}
7,this.layers.forEach(t=>{this.gradients[t.id]={}}),this.layoutVertexArray=new lm,this.layoutVertexArray2=new lg,this.patternVertexArray=new lg,this.indexArray=new lR,this.programConfigurations=new hS(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new l9,this.sourceLayerName=t.sourceLayerName||"",this.maxLineLength=0,this.zOffsetVertexArray=new lT,this.elevationIdColVertexArray=new lg,this.elevationGroundScaleVertexArray=new lc,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.tessellationStep=t.tessellationStep?t.tessellationStep:128,this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,i){}updateAppearances(t,i,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,i,r,a){this.showElevationIdDebug=i.showElevationIdDebug,this.terrainEnabled=i.terrainEnabled,this.hasPattern=sZ("line",this.layers,this.pixelRatio,i);let n=this.layers[0].layout.get("line-sort-key");this.tileToMeter=s6(r);let o=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===o)this.elevationType="road";else{let t=this.layers[0].layout.get("line-z-offset"),i=t.isConstant()&&!t.constantOr(0);this.elevationType="sea"!==o&&"ground"!==o&&i?"none":"offset","offset"===this.elevationType&&"none"===o&&tX(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference="sea"===o}let s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==s;let l=[];for(let{feature:o,id:s,index:h,sourceLayerIndex:u}of t){let t=this.layers[0]._featureFilter.needGeometry,c=lt(o,t);if(!this.layers[0]._featureFilter.filter(new o0(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),c,r))continue;let d=n?n.evaluate(c,{},r):void 0,p={id:s,properties:o.properties,type:o.type,sourceLayerIndex:u,index:h,geometry:t?c.geometry:le(o,r,a),patterns:{},sortKey:d};l.push(p)}n&&l.sort((t,i)=>t.sortKey-i.sortKey);let{lineAtlas:h,featureIndex:u}=i,c=this.addConstantDashes(h);for(let a of l){let{geometry:n,index:o,sourceLayerIndex:s}=a;if(c&&this.addFeatureDashes(a,h),this.hasPattern){let t=s$("line",this.layers,a,this.zoom,this.pixelRatio,i);this.patternFeatures.push(t)}else this.addFeature(a,n,o,r,h.positions,i.availableImages,i.brightness,i.elevationFeatures,i.elevationParams,i.crossSourceElevationEnabled);u.insert(t[o].feature,n,o,s,this.index)}!this.hasPattern&&this.hdExt&&this.hdExt.buildFrcSegments(this),this.hdExt&&this.hdExt.endPopulate()}addConstantDashes(t){let i=!1;for(let r of this.layers){let a=r.paint.get("line-dasharray").value,n=r.layout.get("line-cap").value;if("constant"!==a.kind||"constant"!==n.kind)i=!0;else{let i=n.value,r=a.value;if(!r)continue;t.addDash(r,i)}}return i}addFeatureDashes(t,i){let r=this.zoom;for(let a of this.layers){let n,o,s=a.paint.get("line-dasharray").value,l=a.layout.get("line-cap").value;if("constant"!==s.kind||"constant"!==l.kind){if("constant"===s.kind){if(!(n=s.value))continue}else n=s.evaluate({zoom:r},t);o="constant"===l.kind?l.value:l.evaluate({zoom:r},t),i.addDash(n,o),t.patterns[a.id]=[i.getKey(n,o)]}}}update(t,i,r,a,n,o,s,l,h){this.programConfigurations.updatePaintArrays(t,i,n,r,a,o,s,h)}updateExpressions(t){this.programConfigurations.updateExpressions(t)}addFeatures(t,i,r,a,n,o){for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,i,r,a,o,t.elevationFeatures,t.elevationParams,t.crossSourceElevationEnabled);this.hdExt&&(this.hdExt.buildFrcSegments(this),this.hdExt.endPopulate())}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,hB)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,hk)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,hz.members,!0)),!this.elevationIdColVertexBuffer&&this.elevationIdColVertexArray.length>0&&(this.elevationIdColVertexBuffer=t.createVertexBuffer(this.elevationIdColVertexArray,hL.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=t.createVertexBuffer(this.elevationGroundScaleVertexArray,hO.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,hF),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),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(t,i){let r,a;
7if(i&&i>0?(r=`mapbox_clip_start_${i}`,a=`mapbox_clip_end_${i}`):(r="mapbox_clip_start",a="mapbox_clip_end"),t.properties&&Object.hasOwn(t.properties,r)&&Object.hasOwn(t.properties,a))return{start:+t.properties[r],end:+t.properties[a]}}addFeature(t,i,r,a,n,o,s,l,h,u){let c=this.layers[0].layout,d=this.hdExt?this.hdExt.trackFeatureFrc(t.properties):null,p=this.indexArray.length,f=c.get("line-join").evaluate(t,{}),_=c.get("line-cap").evaluate(t,{}),m=c.get("line-miter-limit"),g=c.get("line-round-limit");this.lineClips=this.lineFeatureClips(t),this.lineFeature=t;let y=!(!t.properties||!Object.hasOwn(t.properties,"mapbox_line_metrics"))&&t.properties.mapbox_line_metrics;this.zOffsetValue=c.get("line-z-offset").value;let x=this.layers[0].paint,v=x.get("line-width").value;"constant"!==v.kind&&!1===v.isLineProgressConstant&&(this.variableWidthValue=v);let b=x.get("line-emissive-strength").value;if("constant"!==b.kind&&!1===b.isLineProgressConstant&&(this.variableEmissiveStrengthValue=b),this.isSeaLevelReference){let t=c.get("line-elevation-ground-scale").value;"constant"===t.kind&&0===t.value||(this.elevationGroundScaleValue=t)}
7if(null==this.hdExt||!this.hdExt.handleFeature(t,i,a,l,h,!!u,f,_,m,g,this))for(let r=0;r<i.length;r++)this.addLine(i[r],t,a,f,_,m,g,void 0,y&&r>0?r:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,n,o,a,s,void 0,this.worldview),this.hdExt&&this.hdExt.recordFeatureRange(this,p,this.indexArray.length,d)}fillNonElevatedRoadSegment(t){for(let i=Math.max(t,this.zOffsetVertexArray.length);i<this.layoutVertexArray.length;i++)this.zOffsetVertexArray.emplaceBack(0,0,0,0),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)}addLine(t,i,r,a,n,o,s,l,h){let u,c,d,p,f,_,m,g;this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0,this.lineClips=h?this.lineFeatureClips(i,h):this.lineClips;let y="none"===a;this.patternJoinNone=this.hasPattern&&y,this.currentLineJoinType=a,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];let x=l&&l.progress.min>0,v=l&&l.progress.max<1;if(this.lineClips){let r={min:this.lineClips.start,max:this.lineClips.end},a=1;if(l){var b,w,T;let t=this.lineClips.end-this.lineClips.start;b=l.progress,w={min:0,max:1},T=r,r={min:ii(b.min,w,T),max:ii(b.max,w,T)},t>0&&(a=(r.max-r.min)/t)}let n=+i.properties.mapbox_clip_feature_len,o=+i.properties.mapbox_clip_seg_len;if(Number.isNaN(n)||Number.isNaN(o)){for(let i=0;i<t.length-1;i++)this.totalDistance+=t[i].dist(t[i+1]);let i=this.totalDistance/(r.max-r.min);this.totalFeatureLength=Number.isFinite(i)?i:0,this.lineClips.start=r.min,this.lineClips.end=r.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=n,this.distance=o*a,this.lineClips.start=r.min,this.lineClips.end=r.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}let E="Polygon"===ur[i.type],S=t.length;for(;S>=2&&t[S-1].equals(t[S-2]);)S--;let I=0;for(;I<S-1&&t[I].equals(t[I+1]);)I++;if(S<(E?3:2))return;"bevel"===a&&(o=1.05);let A=this.segments.prepareSegment(10*S,this.layoutVertexArray,this.indexArray);l&&l.prevDir&&(_=l.prevDir.perp()),l&&l.nextDir&&(m=l.nextDir.perp()),this.e1=this.e2=-1,E&&(u=t[S-2],f=t[I].sub(u)._unit()._perp());for(let i=I;i<S;i++){if((d=i===S-1?E?t[I+1]:void 0:t[i+1])&&t[i].equals(d))continue;f&&(p=f),u&&(c=u),u=t[i],g=this.evaluateLineProgressFeatures(c?c.dist(u):0),f=d?d.sub(u)._unit()._perp():p,p=p||f;let r=c&&d,l=r?a:E||y?"butt":n,h=p.x*f.x+p.y*f.y;if(y){let t=function(t){if(t.patternJoinNone){let i=t.segmentPoints.length/2,r=t.lineSoFar-t.segmentStart;for(let a=0;a<i;++a){let i=t.segmentPoints[2*a+1],n=Math.round(t.segmentPoints[2*a])+.5+.25*i;t.patternVertexArray.emplaceBack(n,r,t.segmentStart),t.patternVertexArray.emplaceBack(n,r,t.segmentStart)}t.segmentPoints.length=0}t.e1=t.e2=-1};if(r&&h<un){this.updateDistance(c,u),this.addCurrentVertex(u,p,1,1,A,g),t(this),this.addCurrentVertex(u,f,-1,-1,A,g);continue}if(c){if(!d){this.updateDistance(c,u),this.addCurrentVertex(u,p,1,1,A,g),t(this);continue}l="miter"}}let b=p.add(f);0===b.x&&0===b.y||b._unit();let w=b.x*f.x+b.y*f.y,T=0!==w?1/w:1/0,C=2*Math.sqrt(2-2*w),M=w<ua&&c&&d,R=p.x*f.y-p.y*f.x>0,D=this.overscaling<=16?122880/(512*this.overscaling):0;if(r&&"round"===l){if(T<s)l="miter";else if(T<=2){let t=us(u,-10,8202);l="offset"===this.elevationType&&(t||this.hasCrossSlope)?"miter":"fakeround"}}if("miter"===l&&T>o&&(l="bevel"),"bevel"===l&&(T>2&&(l="flipbevel"),T<o&&(l="miter")),c&&!("miter"===l&&M)&&this.updateDistance(c,u),"miter"===l)if(M){let t=u.dist(c);if(t>2*D){let i=u.sub(u.sub(c)._mult(D/t)._round());this.updateDistance(c,i),this.addCurrentVertex(i,p,0,0,A,g),c=i}this.updateDistance(c,u),b._mult(T),this.addCurrentVertex(u,b,0,0,A,g);let i=u.dist(d);if(i>2*D){let t=u.add(d.sub(u)._mult(D/i)._round());this.updateDistance(u,t),this.addCurrentVertex(t,f,0,0,A,g),u=t}}else b._mult(T),this.addCurrentVertex(u,b,0,0,A,g);else if("flipbevel"===l){if(T>100)b=f.mult(-1);else{let t=T*p.add(f).mag()/p.sub(f).mag();b._perp()._mult(t*(R?-1:1))}this.addCurrentVertex(u,b,0,0,A,g),this.addCurrentVertex(u,b.mult(-1),0,0,A,g)}else if("bevel"===l||"fakeround"===l){let t=u.dist(c),i=1;if("offset"===this.elevationType&&"bevel"===l&&"round"!==this.currentLineJoinType&&!this.patternJoinNone&&null!=g&&c&&d){let r=4*D;t<r&&(i=Math.max(0,t/r))}null!=g&&c&&this.addCurrentVertex(u,m||p,-i,-i,A,g);let r=t<=2*D&&"bevel"!==l,a=b.mult(R?1:-1);a._mult(T);
7let n=f.mult(R?-1:1),o=p.mult(R?-1:1),s=this.evaluateLineProgressFeatures(this.distance);if(null==g&&(this.addHalfVertex(u,a.x,a.y,!1,!R,0,A,s),r||this.addHalfVertex(u,a.x+2*o.x,a.y+2*o.y,!1,R,0,A,s)),"fakeround"===l){let t=Math.round(180*C/Math.PI/20);this.addHalfVertex(u,o.x,o.y,!1,R,0,A,s);for(let i=0;i<t;i++){let r=i/t;if(.5!==r){let t=r-.5;r+=r*t*(r-1)*((1.0904+h*(h*(3.55645-1.43519*h)-3.2452))*t*t+(.848013+h*(.215638*h-1.06021)))}let a=n.sub(o)._mult(r)._add(o)._unit();this.addHalfVertex(u,a.x,a.y,!1,R,0,A,s)}this.addHalfVertex(u,n.x,n.y,!1,R,0,A,s)}r||null!=g||this.addHalfVertex(u,a.x+2*n.x,a.y+2*n.y,!1,R,0,A,s),null!=g&&d&&this.addCurrentVertex(u,_||f,i,i,A,g)}else if("butt"===l)this.addCurrentVertex(u,b,0,0,A,g);else if("square"===l){if(!c){let t=x?0:-1;this.addCurrentVertex(u,b,t,t,A,g)}if(this.addCurrentVertex(u,b,0,0,A,g),c){let t=+!v;this.addCurrentVertex(u,b,t,t,A,g)}}else if("round"===l){if(c){let t=!r&&m?m:p;this.addCurrentVertex(u,t,0,0,A,g),!r&&v||this.addCurrentVertex(u,t,1,1,A,g,!0)}if(d){let t=!r&&_?_:f;!r&&x||this.addCurrentVertex(u,t,-1,-1,A,g,!0),this.addCurrentVertex(u,t,0,0,A,g)}}}}addVerticesTo(t,i,r,a,n,o,s,l,h,u){let c=(i.w-t.w)/this.tessellationStep|0,d=0,p=this.scaledDistance;if(c>1){this.lineSoFar=t.w;let r=(i.x-t.x)/c,a=(i.y-t.y)/c,n=(i.z-t.z)/c,o=(i.w-t.w)/c,s=i.x-t.x,l=i.y-t.y,p=Math.sqrt(s*s+l*l);if(0===p)return;let f=-l/p,_=s/p,m=-f,g=-_;for(let i=1;i<c;++i){t.x+=r,t.y+=a,t.z+=n,this.lineSoFar+=o,d+=o;let i=this.evaluateLineProgressFeatures(this.prevDistance+d);this.scaledDistance=(this.prevDistance+d)/this.totalDistance,this.addHalfVertex(t,f,_,u,!1,0,h,i),this.addHalfVertex(t,m,g,u,!0,0,h,i)}}this.lineSoFar=i.w,this.scaledDistance=p;let f=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(i,r,a,u,!1,s,h,f),this.addHalfVertex(i,n,o,u,!0,-l,h,f)}evaluateLineProgressFeatures(t){if(!this.variableWidthValue&&!this.variableEmissiveStrengthValue&&"offset"!==this.elevationType)return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+t)/this.totalFeatureLength):tX(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let i=0;this.variableWidthValue&&"constant"!==this.variableWidthValue.kind&&(i=.5*(this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0));let r=0;this.variableEmissiveStrengthValue&&"constant"!==this.variableEmissiveStrengthValue.kind&&(r=this.variableEmissiveStrengthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);let a=this.evaluateElevationGroundScale();return"offset"!==this.elevationType?{zOffset:0,variableWidth:i,elevationGroundScale:a,variableEmissiveStrength:r}:"constant"===this.zOffsetValue.kind?{zOffset:this.zOffsetValue.value,variableWidth:i,elevationGroundScale:a,variableEmissiveStrength:r}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:i,elevationGroundScale:a,variableEmissiveStrength:r}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?"constant"===this.elevationGroundScaleValue.kind?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(t,i,r,a,n,o,s=!1){let l=i.x+i.y*r,h=i.y-i.x*r,u=i.y*a-i.x,c=-i.y-i.x*a;if(null!=o){let i="offset"===this.elevationType,d="offset"===this.elevationType?2:10,p=-d,f=8192+d,_=o.zOffset,m=new h0(t.x,t.y,_,this.lineSoFar),g=!!i&&us(t,p,f),y=this.lineS
7oFar,x=this.distance;if(this.currentVertex)if(g){let i=this.currentVertexIsOutside,o=this.currentVertex,d=new h0(t.x,t.y,_,this.lineSoFar);if(h2(o,d,p,f),!us(d,p,f)){if(i){this.e1=this.e2=-1,this.distance-=o.dist(m),this.lineSoFar=o.w;let t=this.evaluateLineProgressFeatures(o.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(o,l,h,s,!1,r,n,t),this.addHalfVertex(o,u,c,s,!0,-a,n,t),this.prevDistance=this.distance}this.distance=this.prevDistance+o.dist(d),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(o,d,l,h,u,c,r,a,n,s),this.distance=x,this.scaledDistance=this.distance/this.totalDistance}}else{let t=this.currentVertex;if(this.currentVertexIsOutside){h2(t,m,p,f),this.e1=this.e2=-1,this.distance-=t.dist(m),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t.w;let i=this.evaluateLineProgressFeatures(t.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(t,l,h,s,!1,r,n,i),this.addHalfVertex(t,u,c,s,!0,-a,n,i),this.prevDistance=this.distance,this.distance=x,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(t,m,l,h,u,c,r,a,n,s)}else g||(this.addHalfVertex(t,l,h,s,!1,r,n,o),this.addHalfVertex(t,u,c,s,!0,-a,n,o));this.currentVertex=m,this.currentVertexIsOutside=g,this.lineSoFar=y}else this.addHalfVertex(t,l,h,s,!1,r,n,o),this.addHalfVertex(t,u,c,s,!0,-a,n,o)}addHalfVertex({x:t,y:i},r,a,n,o,s,l,h){if(this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),o||this.segmentPoints.push(this.lineSoFar-this.segmentStart,s)),this.layoutVertexArray.emplaceBack((t<<1)+ +!!n,(i<<1)+ +!!o,Math.round(63*r)+128,Math.round(63*a)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){let t=rG(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,t)}let u=l.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),l.primitiveLength++),o?this.e2=u:this.e1=u,null!=h&&(this.zOffsetVertexArray.emplaceBack(h.zOffset,h.variableWidth,h.variableWidth,h.variableEmissiveStrength),this.showElevationIdDebug&&this.elevationIdColVertexArray.emplaceBack(0,0,0)),this.elevationGroundScaleValue){let t=h?h.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(t)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(t,i){this.prevDistance=this.distance,this.distance+=t.dist(i),this.updateScaledDistance()}}function us(t,i,r){return t.x<i||t.x>r||t.y<i||t.y>r}oC(uo,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});let ul=lo([{name:"a_pos",components:2,type:"Int16"}],4),uh=lo([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),uu=lo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class uc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new ll,this.indexArray=new lR,this.segments=new l9,this.programConfigurations=new hS(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,i){}updateAppearances(t,i,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,i,r,a){let n=this.layers[0],o=[],s=null;for(let{feature:l,id:h,index:u,sourceLayerIndex:c}of("circle"===n.type&&(s=n.layout.get("circle-sort-key")),t)){let t=this.layers[0]._featureFilter.needGeometry,n=lt(l,t);if(!this.layers[0]._featureFilter.filter(new o0(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),n,r))continue;let d=s?s.evaluate(n,{},r):void 0,p={id:h,properties:l.properties,type:l.type,sourceLayerIndex:c,index:u,geometry:t?n.geometry:le(l,r,a),patterns:{},sortKey:d};o.push(p)}s&&o.sort((t,i)=>t.sortKey-i.sortKey);let l=null;for(let n of("globe"===a.projection.name&&(this.globeExtVertexArray=new lv,l=a.projection),o)){let{geometry:a,index:o,sourceLayerIndex:s}=n,h=t[o].feature;this.addFeature(n,a,o,i.availableImages,r,l,i.brightness,i.elevationFeatures),i.featureIndex.insert(h,a,o,s,this.index)}this.hdExt&&this.hdExt.finalize()}update(t,i,r,a,n,o,s){this.programConfigurations.updatePaintArrays(t,i,n,r,a,o,s,this.worldview)}updateExpressions(t){this.programConfigurations.updateExpressions(t)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ul.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,uu.members)),this.hdExt&&this.hdExt.upload(t)),this.programConfigurations.upload(t),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(t,i,r,a,n,o,s,l){for(let r of(this.hdExt&&this.hdExt.beginFeature(t,l,n),i))for(let i of r){let r=i.x,a=i.y;if(r<0||r>=8192||a<0||a>=8192)continue;
7if(o){let t=o.projectTilePoint(r,a,n),i=o.upVector(n,r,a);this.addGlobeExtVertex(t,i),this.addGlobeExtVertex(t,i),this.addGlobeExtVertex(t,i),this.addGlobeExtVertex(t,i)}let s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),l=s.vertexLength;this.addCircleVertex(r,a,-1,-1),this.addCircleVertex(r,a,1,-1),this.addCircleVertex(r,a,1,1),this.addCircleVertex(r,a,-1,1),this.hdExt&&this.hdExt.writeVertexQuad(r,a),this.indexArray.emplaceBack(l,l+1,l+2),this.indexArray.emplaceBack(l,l+2,l+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},a,n,s,void 0,this.worldview)}addCircleVertex(t,i,r,a){this.layoutVertexArray.emplaceBack(2*t+(r+1)/2,2*i+(a+1)/2)}addGlobeExtVertex(t,i){this.globeExtVertexArray.emplaceBack(t.x,t.y,t.z,16384*i[0],16384*i[1],16384*i[2])}}oC(uc,"CircleBucket",{omit:["layers"]});let ud=lo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),up=lo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),uf=lo([{name:"a_projected_pos",components:4,type:"Float32"}],4);lo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);let u_=lo([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),um=lo([{name:"a_feature_index",components:1,type:"Float32"}],4),ug=lo([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),uy=lo([{name:"a_texb",components:2,type:"Uint16"}]),ux=lo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),uv=lo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);lo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);let ub=lo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),uw=lo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);lo([{name:"triangle",components:3,type:"Uint16"}]),lo([{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"}]),lo([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}
7]),lo([{type:"Float32",name:"offsetX"}]),lo([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);let uT=class t{static getBlockIndices(i){let r=t._blockIndicesTemplate;if(!r){r=t._blockIndicesTemplate=new Uint32Array(i);for(let t=0;t<i;t++)r[t]=t}return r}constructor(t,i,r,a){this.batchIndex=i,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=t||null,this.propsDwords=r,this.totalBytes=4*this.propsDwords,this.headerData=a,this.propertiesData=new Float32Array(this.propsDwords),this._headerDirty=!0,this._propsDirtyMin=-1,this._propsDirtyMax=-1,this._blockIndicesDirty=!0,t&&this._initBuffers(t)}_initBuffers(i){let r=i.gl;if(this.totalBytes>i.maxUniformBlockSize)throw Error(`UBO size ${this.totalBytes} exceeds device limit ${i.maxUniformBlockSize}`);if(this.headerBuffer=r.createBuffer(),!this.headerBuffer)throw Error("Failed to create header UBO buffer");if(r.bindBuffer(r.UNIFORM_BUFFER,this.headerBuffer),r.bufferData(r.UNIFORM_BUFFER,t.HEADER_BYTES,r.DYNAMIC_DRAW),this.propertiesBuffer=r.createBuffer(),!this.propertiesBuffer)throw Error("Failed to create properties UBO buffer");if(r.bindBuffer(r.UNIFORM_BUFFER,this.propertiesBuffer),r.bufferData(r.UNIFORM_BUFFER,this.totalBytes,r.DYNAMIC_DRAW),this.blockIndicesBuffer=r.createBuffer(),!this.blockIndicesBuffer)throw Error("Failed to create block-indices UBO buffer");r.bindBuffer(r.UNIFORM_BUFFER,this.blockIndicesBuffer),r.bufferData(r.UNIFORM_BUFFER,this.totalBytes,r.DYNAMIC_DRAW),r.bindBuffer(r.UNIFORM_BUFFER,null)}writeDataDrivenBlock(i,r){let a=this.headerData,n=4*a[2];if(0===n)return;let o=r*n;if(o+n>this.propertiesData.length)throw Error(`UBO write out of bounds: feature index ${r} exceeds propertiesData capacity`);let s=a[0],l=a[1],h=l>>>16;for(let r=0;r<9;r++)s&1<<r&&this._copyFromFlat(o+a[3+r],r,i,t.EVAL_FLAT_OFFSETS[r],l,h);(-1===this._propsDirtyMin||o<this._propsDirtyMin)&&(this._propsDirtyMin=o);let u=o+n;u>this._propsDirtyMax&&(this._propsDirtyMax=u)}rightSizeForTransfer(){let t=-1===this._propsDirtyMax?0:this._propsDirtyMax;t<this.propertiesData.length&&(this.propertiesData=this.propertiesData.slice(0,t))}_copyFromFlat(i,r,a,n,o,s){let l=r<2,h=8===r,u=!!(o&1<<r);if(this.propertiesData.set(a.subarray(n,n+(l||h&&u?4:h||u?2:1)),i),s&1<<r){let n=l||h?4:2,o=t.EVAL_FLAT_ZOOM_OFFSETS[r];this.propertiesData[i+n]=a[o],this.propertiesData[i+n+1]=a[o+1]}}upload(i){this.context||(this.context=i);let r=i.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(i);let a=!1;if(this._headerDirty&&(r.bindBuffer(r.UNIFORM_BUFFER,this.headerBuffer),r.bufferSubData(r.UNIFORM_BUFFER,0,this.headerData),this._headerDirty=!1,a=!0),-1!==this._propsDirtyMin){let t=this._propsDirtyMin,i=this._propsDirtyMax;r.bindBuffer(r.UNIFORM_BUFFER,this.propertiesBuffer),r.bufferSubData(r.UNIFORM_BUFFER,4*t,this.propertiesData,t,i-t),this._propsDirtyMin=-1,this._propsDirtyMax=-1,a=!0}this._blockIndicesDirty&&(r.bindBuffer(r.UNIFORM_BUFFER,this.blockIndicesBuffer),r.bufferSubData(r.UNIFORM_BUFFER,0,t.getBlockIndices(this.propsDwords)),this._blockIndicesDirty=!1,a=!0),a&&r.bindBuffer(r.UNIFORM_BUFFER,null)}bind(t,i){let r=t.gl,a=(t,a,n)=>{if(!a)return;let o=r.getUniformBlockIndex(i,t);o!==r.INVALID_INDEX&&(r.uniformBlockBinding(i,o,n),r.bindBufferBase(r.UNIFORM_BUFFER,n,a))},n=3*this.batchIndex;a("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,n),a("SymbolPaintPropertiesUniform",this.propertiesBuffer,n+1),a("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,n+2)}destroy(){if(this.context){let t=this.context.gl;this.headerBuffer&&(t.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(t.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(t.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};function uE(t,i,r,a,n,o,s,l){return!!t&&("constant"===t.kind?"none"===t.value:"none"===t.evaluate({zoom:0,brightness:o,worldview:l},i,r,n,a,s))}function uS(t){if(!(t instanceof o8))return!1;let i=t.value;return("source"===i.kind||"composite"===i.kind)&&i.isStateDependent}uT.HEADER_DWORDS=12,uT.HEADER_BYTES=48,uT.EVAL_FLAT_OFFSETS=[0,4,8,10,12,14,16,18,20],uT.EVAL_FLAT_ZOOM_OFFSETS=[24,26,28,30,32,34,36,38,40],uT.
7EVAL_FLAT_TOTAL=42,uT._blockIndicesTemplate=null,oC(uT,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});let uI=["icon","text"].map(t=>[`${t}-color`,`${t}-halo-color`,`${t}-opacity`,`${t}-halo-width`,`${t}-halo-blur`,`${t}-emissive-strength`,`${t}-occlusion-opacity`,"symbol-z-offset",`${t}-translate`]),uA=new Float32Array(uT.EVAL_FLAT_TOTAL),uC=[0,0],uM=new WeakMap;class uR{constructor(t,i,r,a,n="",o,s){this.layer=t,this.zoom=i,this.lut=r,this.isText=a,this.worldview=n,this.maxUniformBufferBindings=o||24,this.uboSizeDwords=s||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.activeAppearanceByVtIndex=null,this.sharedZoomRanges=new Float32Array(18),this._zoomRangeScratch=new Float32Array(2),this._floorZoom=Math.floor(this.zoom),this.header=new Uint32Array(uT.HEADER_DWORDS),this.updateHeader(),this.isAllConstant=0===this.header[0];let l=4*this.header[2];this.maxFeaturesPerBatch=0===l?Number.MAX_SAFE_INTEGER:Math.floor(this.uboSizeDwords/l)}updateHeader(){let t=this.layer.paint,i=0,r=0,a=0,n=0,o=0,s=!0,l=this._floorZoom,h=uI[+this.isText];for(let u=0;u<9;u++){let c,d,p=h[u],f=u<2,_=8===u,m=t.get(p),g=!(!m||"function"!=typeof m.isConstant||m.isConstant()),y=this._appearancesHavePaintProperties(p);if(!g&&!y){let t=this._layerUnevaluated(p);t&&t.expression&&"camera"===t.expression.kind&&(n|=1<<u);continue}i|=1<<u;let x=this._collectZoomSignatures(p,l),v=x.hasZoom,b=x.differs;v&&(r|=1<<u),b&&(a|=1<<u);let w=m&&m.value;w&&!1===w.isLightConstant&&(s=!1),b?(c=!0,d=f||_?8:4):d=(c=f||_&&v)?4:_||v?2:1,c&&o%4!=0?o=o+3&-4:_&&o%4==3&&o++,this.header[3+u]=o,o+=d,v&&!b&&x.representative&&this._computeZoomRange(x.representative,l,this.sharedZoomRanges,2*u)}let u=0===o?0:o+3&-4;this.header[0]=i,this.header[1]=r|a<<16,this.header[2]=u/4,this.isLightConstant=s,this.cameraMask=n}_recomputeSharedRanges(){let t=this._floorZoom,i=uI[+this.isText],r=0;for(let a=0;a<9;a++){let n=i[a];if(this.header[0]&1<<a){if(this.header[1]&1<<a&&!(this.header[1]>>>16&1<<a)){let i=this._collectZoomSignatures(n,t);i.representative&&this._computeZoomRange(i.representative,t,this.sharedZoomRanges,2*a)}}else{let t=this._layerUnevaluated(n);t&&t.expression&&"camera"===t.expression.kind&&(r|=1<<a)}}this.cameraMask=r}_collectZoomSignatures(t,i){let r=!1,a=!1,n=null,o=0,s=0,l=t=>{if(!t)return;this._computeZoomRange(t,i,this._zoomRangeScratch,0);let l=this._zoomRangeScratch[0],h=this._zoomRangeScratch[1];r?l===o&&h===s||(a=!0):(r=!0,o=l,s=h,n=t)};for(let i of(l(this._zoomExprOf(this._layerUnevaluated(t))),this.layer.getAppearances()||[]))i.hasPaintProperty(t)&&l(this._zoomExprOf(i.getUnevaluatedPaintProperty(t)));return{hasZoom:r,differs:a,representative:n}}evaluateAllProperties(t,i,r,a,n,o,s){let l={brightness:n,worldview:this.worldview},h={feature:t,featureState:i,canonical:r,availableImages:a,params:new o0(this.zoom,l),paramsNext:new o0(this.zoom+1,l),formattedSection:o,activeAppearance:s},u=this.header,c=uI[+this.isText],d=u[1]>>>16;for(let t=0;t<9;t++){let i=c[t],r=8===t,a=!!(u[1]&1<<t),n=!!(d&1<<t),o=uT.EVAL_FLAT_OFFSETS[t],s=uT.EVAL_FLAT_ZOOM_OFFSETS[t];t<2?this._evaluateColorValue(i,a,n,s,h,o):r?this._evaluateTranslateValue(i,a,n,s,h,o):this._evaluateFloatValue(i,a,n,s,h,o)}return uA}_resolveProp(t,i,r=!1,a){let n=this.layer.paint,o=n.get(t),s=!(!i||!i.hasPaintProperty(t)),l=s?a&&o&&o.property.overrides&&o.property.overrides.hasOverride(a)?o:i.paintProperties.get(t):n.get(t);if(r||!l||"function"!=typeof l.isConstant||!l.isConstant())return l;let h=s?i.getUnevaluatedPaintProperty(t):this._layerUnevaluated(t);return this._unbakeCamera(l,h)}_unbakeCamera(t,i){let r=i&&i.expression;if(!r||"camera"!==r.kind)return t;let a=uM.get(i);return a||(a=new o8(t.property,r,t.parameters,t.iconImageUseTheme),uM.set(i,a)),a}_layerUnevaluated(t){let i=this.layer._transitionablePaint._values[t];return i&&i.value}_zoomExprOf(t){let i=t&&t.expression;return i&&("composite"===i.kind||"camera"===i.kind)?i:null}_evalAt(t,i,r){return t.property.evaluate(t.value,i,r.feature,r.featureState,r.canonical,r.availableImages,t.iconImageUseTheme,r.formattedSection)}_evaluateColorValue(t,i,r,a,n,o){let s=this._resolveProp(t,n.activeAppearance,!1,n.formattedSection);if(r&&this._writeZoomRange(s,a),!s)return uA[o]=0,uA[o+1]=0,uA[o+2]=0,void(uA[o+3]=1);let l=this._resolveProp(`${t}-use-theme`,n.activeAppearance,!0),h=uE(l&&"string"!=typeof l?l.value:void 0,n.feature,n.featureState,n.availableImages,n.canonical,n.params.brightness,n.formattedSection,this.worldview)?null:this.lut,u=(s.isConstant()?s.constantOr(rq.transparent):this._evalAt(s,n.params,n)||rq.transparent).toNonPremultipliedRenderColor(h);if(uA[o]=l7(255*u.r,255*u.g),uA[o+1]=l7(255*u.b,255*u.a),i){let t=(this._evalAt(s,n.paramsNext,n)||rq.transparent).toNonPremultipliedRenderColor(h);uA[o+2]=l7(255*t.r,255*t.g),uA[o+3]=l7(255*t.b,255*t.a)}else uA[o+2]=0,uA[o+3]=0}_computeZoomRange(t,i,r,a){let n=0,o=1,s=t&&("composite"===t.kind||"camera"===t.kind)?t.zoomStops:null;if(s&&s.length>0)if(null==t.interpolationType){for(let t of(n=o=1,s))if(t>i&&t<i+1){n=o=t-i;break}}else s[0]>i&&s[0]<i+1&&(n=s[0]-i);r[a]=n,r[a+1]=o}_writeZoomRange(t,i){this._computeZoomRange(t&&t.value,this._floorZoom,uA,i)}_evaluateFloatValue(t,i,r,a,n,o){let s=+!!t.endsWith("opacity"),l=this._resolveProp(t,n.activeAppearance);r&&this._writeZoomRange(l,a);let h=l?l.isConstant()?l.constantOr(s):this._evalAt(l,n.params,n):s;if(uA[o]=null!=h?h:s,i){let t=this._evalAt(l,n.paramsNext,n);uA[o+1]=null!=t?t:s}else uA[o+1]=0}_evaluateTranslateValue(t,i,r,a,n,o){let s=this._resolveProp(t,n.activeAppearance);r&&this._writeZoomRange(s,a);let l=!!s&&"function"==typeof s.isConstant&&!s.isConstant(),h=s?"function"!=typeof s.isConstant?s:l?this._evalAt(s,n.params,n):s.constantOr(uC):void 0;if(uA[o]=h?h[0]:0,uA[o+1]=h?h[1]:0,i){let t=l?this._evalAt(s,n.paramsNext,n):h;uA[o+2]=t?t[0]:0,uA[o+3]=t?t[1]:0}else uA[o+2]=0,uA[o+3]=0}_appearancesHavePaintProperties(t){return this.layer.getAppearances().some(i=>i.hasPaintProperty(t))}hasStateDependentPaint(t){let i=t.paint,r=uI[+this.isText];for(let t of r)if(uS(i.get(t)))return!0;for(let i of t.getAppearances()||[])for(let t of r)if(i.hasPaintProperty(t)&&uS(i.paintProperties.get(t)))return!0;return!1}hasPerFeatureTranslate(){return!!(256&this.header[0])}getCurrentBatchIndex(){return 0===this.maxFeaturesPerBatch?0:Math.floor(this.featureCount/this.maxFeaturesPerBatch)}_writeFeatureBlock(t,i){let r=this.isAllConstant?0:t,a=Math.floor(r/this.maxFeaturesPerBatch),n=r%this.maxFeaturesPerBatch;this._batchExceedsDeviceLimit(a)&&(a=0,n=0);let o=this.ubos[a];return!!o&&(o.writeDataDrivenBlock(i,n),!0)}_batchExceedsDeviceLimit(t){return 3*t+2>=this.maxUniformBufferBindings}_reevaluateAt(t,i,r,a,n,o){if(!i)return;let s=this.allFeatureVtIndices[t],l=i.feature(s);if(!l)return;let h=this.allFeatureIds[t],u=null!=h&&n[h]||{},c={type:l.type,id:h,properties:l.properties||{},geometry:[]},d=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(s):void 0,p=this.evaluateAllProperties(c,u,r,a,o,(this.allFormattedSections?this.allFormattedSections[t]:void 0)||void 0,d);this._writeFeatureBlock(t,p)}_ensureRangeMaps(){if(!this.featureVertexRangesFromId){this.featureVertexRangesFromId=new Map,this.featureVertexRangesFromVtIndex=new Map;for(let t=0;t<this.allFeatureVtIndices.length;t++){let i=this.allFeatureIds[t];if(null!=i){let r=this.featureVertexRangesFromId.get(i);r||this.featureVertexRangesFromId.set(i,r=[]),r.push(t)}let r=this.allFeatureVtIndices[t],a=this.featureVertexRangesFromVtIndex.get(r);a||this.featureVertexRangesFromVtIndex.set(r,a=[]),a.push(t)}}}populateUBO(t,i,r,a,n,o){let s,l,h=t.id,u=this.header,c=this.evaluateAllProperties(t,{},r,a,n,o);this.isAllConstant?(s=0,(l=0===this.featureCount)&&(this.featureCount=1)):(s=this.featureCount++,l=!0);let d=Math.floor(s/this.maxFeaturesPerBatch),p=s%this.maxFeaturesPerBatch;return l&&(this._batchExceedsDeviceLimit(d)?(tX(`Too many symbol features: batch ${d} requires binding points up to ${3*d+2}, device limit ${this.maxUniformBufferBindings}. Some features will render incorrectly.`),d=0,p=0):(this.ubos[d]||(this.ubos[d]=new uT(null,d,this.uboSizeDwords,u)),this.ubos[d].writeDataDrivenBlock(c,p))),this.allFeatureVtIndices.push(i),this.allFeatureIds.push(h),this.allFormattedSections.push(o||null),p}updateFeatures(t,i,r,a,n,o,s){for(let l of(this.layer=i,this.cachedConstantUniforms=null,this._ensureRangeMaps(),t)){let t=this.featureVertexRangesFromId.get(l);if(t)for(let i of t)this._reevaluateAt(i,r,a,n,o,s)}}updateDynamicExpressions(t,i,r,a,n,o){if(this.layer=t,this.cachedConstantUniforms=null,this._recomputeSharedRanges(),0!==this.header[0])for(let t=0;t<this.allFeatureVtIndices.length;t++)this._reevaluateAt(t,i,r,a,n,o)}
7updateFeaturePaintForAppearance(t,i,r,a,n,o,s){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(t,s||null),0===this.header[0]))return!1;this._ensureRangeMaps();let l=this.featureVertexRangesFromVtIndex.get(t);if(!l)return!1;let h=!1;for(let t of l){let l=this.evaluateAllProperties(i,r,a,n,o,(this.allFormattedSections?this.allFormattedSections[t]:void 0)||void 0,s);h=this._writeFeatureBlock(t,l)||h}return h}getConstantUniformValues(t,i){let r=this.header,a=!!this.cameraMask,n=!!r[1];if(this.cachedConstantUniforms&&this.cachedConstantBrightness===i&&(!a&&!n||this.cachedConstantRenderZoom===t))return this.cachedConstantUniforms;let o=this.layer.paint,s=a?new o0(t,{brightness:i,worldview:this.worldview}):null,l={type:1,id:void 0,properties:{},geometry:[]},h=uI[+this.isText],u=t=>{let r=h[t],a=o.get(r);if(!a)return[0,0,0,1];let n=o.get(`${r}-use-theme`),u=uE(n&&"string"!=typeof n?n.value:void 0,l,{},[],void 0,i,void 0,this.worldview)?null:this.lut;return(this.cameraMask&1<<t&&s?a.property.evaluate(a.value,s,l,{},void 0,[])||rq.transparent:a.constantOr(rq.transparent)).toNonPremultipliedRenderColor(u).toArray01()},c=(t,i)=>{let r=o.get(h[t]);if(!r)return i;if(this.cameraMask&1<<t&&s){let t=r.property.evaluate(r.value,s,l,{},void 0,[]);return null!=t?t:i}return r.constantOr(i)},d=new Float32Array(9);if(n){let i=t-Math.floor(t);for(let t=0;t<9;t++){if(!(r[1]&1<<t))continue;let a=this.sharedZoomRanges[2*t],n=this.sharedZoomRanges[2*t+1];d[t]=a===n?+(i>=a):Math.max(0,Math.min(1,(i-a)/(n-a)))}}let p={fill_np_color:u(0),halo_np_color:u(1),opacity:c(2,1),halo_width:c(3,0),halo_blur:c(4,0),emissive_strength:c(5,0),occlusion_opacity:c(6,1),z_offset:c(7,0),zoomFactors:d};return this.cachedConstantUniforms=p,this.cachedConstantRenderZoom=t,this.cachedConstantBrightness=i,p}finalize(){for(let t of this.ubos)t.rightSizeForTransfer()}upload(t){for(let i of this.ubos)i.upload(t)}bind(t,i,r=0){this.ubos[r]&&this.ubos[r].bind(t,i)}destroy(){for(let t of this.ubos)t.destroy();this.ubos=[],this.featureVertexRangesFromId=null,this.featureVertexRangesFromVtIndex=null,this.allFeatureVtIndices=[],this.allFeatureIds=[],this.featureCount=0,this.maxFeaturesPerBatch=0}}oC(uR,"SymbolPropertyBinderUBO",{omit:["layer","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","activeAppearanceByVtIndex","featureVertexRangesFromId","featureVertexRangesFromVtIndex"]});let uD={"!":"ï¸","#":"ï¼",$:"ï¼","%":"ï¼
","&":"ï¼","(":"︵",")":"︶","*":"ï¼","+":"ï¼",",":"ï¸","-":"︲",".":"ã»","/":"ï¼",":":"ï¸",";":"ï¸","<":"︿","=":"ï¼",">":"ï¹","?":"ï¸","@":"ï¼ ","[":"ï¹","\\":"ï¼¼","]":"ï¹","^":"ï¼¾",_:"︳","`":"ï½","{":"︷","|":"â","}":"︸","~":"ï½","\xa2":"ï¿ ","\xa3":"ï¿¡","\xa5":"ï¿¥","\xa6":"¦","\xac":"ï¿¢","\xaf":"ï¿£","â":"︲","â":"︱","â":"ï¹","â":"ï¹","â":"ï¹","â":"ï¹","â¦":"ï¸","â§":"ã»","â©":"₩","ã":"ï¸","ã":"ï¸","ã":"︿","ã":"ï¹","ã":"︽","ã":"︾","ã":"ï¹","ã":"ï¹","ã":"ï¹","ã":"ï¹","ã":"︻","ã":"︼","ã":"︹","ã":"︺","ã":"ï¸","ã":"ï¸","ï¼":"ï¸","ï¼":"︵","ï¼":"︶","ï¼":"ï¸","ï¼":"︲","ï¼":"ã»","ï¼":"ï¸","ï¼":"ï¸","ï¼":"︿","ï¼":"ï¹","ï¼":"ï¸","ï¼»":"ï¹","ï¼½":"ï¹","_":"︳","ï½":"︷","ï½":"â","ï½":"︸","ï½":"︵","ï½ ":"︶","。":"ï¸","ï½¢":"ï¹","ï½£":"ï¹","â":"â","â":"â"},uP="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class uz{constructor(t){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(t,i,r=this.length){let a;for(;a=this.nextField(r);)t(a,i,this);return i}readMessage(t,i){return this.readFields(t,i,this.readVarint()+this.pos)}readFixed32(){let t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){let t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){let t=this.dataView.getUint32(this.pos,!0)+0x100000000*this.dataView.getUint32(this.pos+4,!0);return this.pos+=8,t}readSFixed64(){let t=this.dataView.getUint32(this.pos,!0)+0x100000000*this.dataView.getInt32(this.pos+4,!0);return this.pos+=8,t}readFloat(){let t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){let t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){let i=this.buf,r=i[this.pos++];if(r<128)return r;let a,n=127&r;return n|=(127&(a=i[this.pos++]))<<7,a<128?n:(n|=(127&(a=i[this.pos++]))<<14,a<128?n:(n|=(127&(a=i[this.pos++]))<<21,a<128?n:function(t,i,r){let a,n,o=r.buf;if(a=(112&(n=o[r.pos++]))>>4,n<128||(a|=(127&(n=o[r.pos++]))<<3,n<128)||(a|=(127&(n=o[r.pos++]))<<10,n<128)||(a|=(127&(n=o[r.pos++]))<<17,n<128)||(a|=(127&(n=o[r.pos++]))<<24,n<128)||(a|=(1&(n=o[r.pos++]))<<31,n<128))return function(t,i,r){return r?0x100000000*i+(t>>>0):0x100000000*(i>>>0)+(t>>>0)}(t,a,i);throw Error("Expected varint not more than 10 bytes")}(n|=(15&(a=i[this.pos]))<<28,t,this)))}readSVarint(){let t=this.readVarint();return t%2==1?-((t+1)/2):t/2}readBoolean(){return!!this.readVarint()}readString(){let t=this.readVarint()+this.pos,i=this.pos;return this.pos=t,t-i>=12&&uP?uP.decode(this.buf.subarray(i,t)):function(t,i,r){let a="",n=i;for(;n<r;){let i=t[n],o,s,l,h=null,u=i>239?4:i>223?3:i>191?2:1;if(n+u>r)break;
71===u?i<128&&(h=i):2===u?128==(192&(o=t[n+1]))&&(h=(31&i)<<6|63&o)<=127&&(h=null):3===u?(o=t[n+1],s=t[n+2],128==(192&o)&&128==(192&s)&&((h=(15&i)<<12|(63&o)<<6|63&s)<=2047||h>=55296&&h<=57343)&&(h=null)):4===u&&(o=t[n+1],s=t[n+2],l=t[n+3],128==(192&o)&&128==(192&s)&&128==(192&l)&&((h=(15&i)<<18|(63&o)<<12|(63&s)<<6|63&l)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,u=1):h>65535&&(h-=65536,a+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),a+=String.fromCharCode(h),n+=u}return a}(this.buf,i,t)}readBytes(){let t=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,t);return this.pos=t,i}readPackedVarint(t=[],i){let r=this.readPackedEnd();for(;this.pos<r;)t.push(this.readVarint(i));return t}readPackedSVarint(t=[]){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFloat());return t}readPackedDouble(t=[]){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}nextField(t=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=t)return 0;let i=this.readVarint();return this.type=7&i,this._valueStart=this.pos,i>>>3}skip(t){let i=7&t;if(0===i)for(;this.buf[this.pos++]>127;);else if(2===i)this.pos=this.readVarint()+this.pos;else if(5===i)this.pos+=4;else{if(1!==i)throw Error(`Unimplemented type: ${i}`);this.pos+=8}}}let uL={horizontal:1,vertical:2,horizontalOnly:3};function uO(t){let i=.5,r=.5;switch(t){case"right":case"top-right":case"bottom-right":i=1;break;case"left":case"top-left":case"bottom-left":i=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:i,verticalAlign:r}}function uF(t,i,r,a){let{expression:n}=i;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new o0(t+1,{worldview:r}),void 0,void 0,void 0,a)};if("source"===n.kind)return{kind:"source"};{let{zoomStops:i,interpolationType:o}=n,s=0;for(;s<i.length&&i[s]<=t;)s++;let l=s=Math.max(0,s-1);for(;l<i.length&&i[l]<t+1;)l++;l=Math.min(i.length-1,l);let h=i[s],u=i[l];return"composite"===n.kind?{kind:"composite",minZoom:h,maxZoom:u,interpolationType:o}:{kind:"camera",minZoom:h,maxZoom:u,minSize:n.evaluate(new o0(h,{worldview:r}),void 0,void 0,void 0,a),maxSize:n.evaluate(new o0(u,{worldview:r}),void 0,void 0,void 0,a),interpolationType:o}}}function uB(t,{uSize:i,uSizeT:r},{lowerSize:a,upperSize:n}
7){return"source"===t.kind?a/128:"composite"===t.kind?rG(a/128,n/128,r):i}function uk(t,i,r=1){let a=0,n=0;if("constant"===t.kind)n=t.layoutSize*r;else if("source"!==t.kind){let{interpolationType:o,minZoom:s,maxZoom:l}=t,h=o?tL(nO.interpolationFactor(o,i,s,l),0,1):0;"camera"===t.kind?n=rG(t.minSize,t.maxSize,h)*r:a=h*r}return{uSizeT:a,uSize:n}}class uN extends tg{constructor(t,i,r,a,n){super(t,i),this.angle=a,this.z=r,void 0!==n&&(this.segment=n)}clone(){return new uN(this.x,this.y,this.z,this.angle,this.segment)}}function uV(t){let i=0,r=0;for(let a of t)i+=a.w*a.h,r=Math.max(r,a.w);t.sort((t,i)=>i.h-t.h);let a=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(i/.95)),r),h:1/0}],n=0,o=0;for(let i of t)for(let t=a.length-1;t>=0;t--){let r=a[t];if(!(i.w>r.w||i.h>r.h)){if(i.x=r.x,i.y=r.y,o=Math.max(o,i.y+i.h),n=Math.max(n,i.x+i.w),i.w===r.w&&i.h===r.h){let i=a.pop();i&&t<a.length&&(a[t]=i)}else i.h===r.h?(r.x+=i.w,r.w-=i.w):(i.w===r.w||a.push({x:r.x+i.w,y:r.y,w:r.w-i.w,h:i.h}),r.y+=i.h,r.h-=i.h);break}}return{w:n,h:o,fill:i/(n*o)||0}}function uU(t,i){return t.id<i.id?-1:t.id>i.id?1:t.version<i.version?-1:t.version>i.version?1:t.sx<i.sx?-1:t.sx>i.sx?1:t.sy<i.sy?-1:+(t.sy>i.sy)}function uj(t){let i=0;for(let r=0;r<t.length;r++)i=(i<<5)-i+t.charCodeAt(r),i&=i;return i}function uG(t,i){return(t<<5)-t+i}function uH(t,i,r,a){for(let[n]of t.entries()){let t=a&&a.get(n)||ah.parse(n),o=t.id.toString(),s=i.get(o)||0;r.push({id:n,version:s,sx:t.sx,sy:t.sy})}}oC(uN,"Anchor");class uq{constructor(t,i,r,a,n){this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=i.size>0,uH(t,r,this.iconDescriptors,n),uH(i,r,this.patternDescriptors,n),this.iconDescriptors.sort(uU),this.patternDescriptors.sort(uU);let o=0,s=a?a.data:"";for(let t of(s&&(o=uG(o,uj(s))),o=uG(o,1),this.iconDescriptors))o=uG(o,uj(t.id)),o=uG(o,t.version),o=uG(o,t.sx),o=uG(o,t.sy);for(let t of(o=uG(o,1),this.patternDescriptors))o=uG(o,uj(t.id)),o=uG(o,t.version),o=uG(o,t.sx),o=uG(o,t.sy);this.hash=o}subsetOf(t){return this.isSubsetArray(this.iconDescriptors,t.iconDescriptors,uU)&&this.isSubsetArray(this.patternDescriptors,t.patternDescriptors,uU)}isSubsetArray(t,i,r){let a=0,n=0;if(t.length>i.length)return!1;for(;a<t.length&&n<i.length;){let o=r(t[a],i[n]);if(0===o)a++,n++;else{if(o<0)return!1;n++}}return a===t.length}}function uZ(t){switch(t){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 u$(t){switch(t){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}}oC(uq,"AtlasContentDescriptor");class uW{constructor(t,i,r,a){this.context=t,this.format=r,this.useMipmap=a&&a.useMipmap,this.texture=t.gl.createTexture(),this.update(i,{premultiply:a&&a.premultiply})}update(t,i){let r=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,a=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:n}=this,{gl:o}=n,{x:s,y:l}=i&&i.position?i.position:{x:0,y:0},h=s+r,u=l+a;this.size&&(this.size[0]!==h||this.size[1]!==u)&&(!i||void 0===i.recreateWhenResize||i.recreateWhenResize)&&(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!i||!1!==i.premultiply));let c=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&h>0&&u>0){let t=this.useMipmap?Math.floor(Math.log2(Math.max(h,u)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,h,u),this.size=[h,u]}this.size&&(c?o.texSubImage2D(o.TEXTURE_2D,0,s,l,uZ(this.format),u$(this.format),t):"data"in t&&t.data&&o.texSubImage2D(o.TEXTURE_2D,0,s,l,r,a,uZ(this.format),u$(this.format),t.data)),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,i,r=!1){let{context:a}=this,{gl:n}=a;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap&&!r?t===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),i!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,i),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,i),this.wrapS=i)}bindExtraParam(t,i,r,a,n){let{context:o}=this,{gl:s}=o;s.bindTexture(s.TEXTURE_2D,this.texture),i!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,i),this.magFilter=i),t!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?t===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),r!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r),this.wrapS=r),a!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,a),this.wrapT=a),n!==this.compareMode&&(n?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,n)):s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE),this.compareMode=n)}destroy(){let{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class uX{constructor(t,i,r,a){this.context=t,this.format=a,this.size=r,this.texture=t.gl.createTexture();let[n,o,s]=this.size,{gl:l}=t;l.bindTexture(l.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in i&&i.data&&l.texImage3D(l.TEXTURE_3D,0,this.format,n,o,s,0,uZ(this.format),u$(this.format),i.data)}bind(t,i){let{context:r}=this,{gl:a}=r;a.bindTexture(a.TEXTURE_3D,this.texture),t!==this.minFilter&&(a.texParameteri(a.TEXTURE_3D,a.TEXTURE_MAG_FILTER,t),a.texParameteri(a.TEXTURE_3D,a.TEXTURE_MIN_FILTER,t),this.minFilter=t),i!==this.wrapS&&(a.texParameteri(a.TEXTURE_3D,a.TEXTURE_WRAP_S,i),a.texParameteri(a.TEXTURE_3D,a.TEXTURE_WRAP_T,i),this.wrapS=i)}destroy(){let{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class uY{constructor(t,i){this.context=t,this.texture=i}bind(t,i){let{context:r}=this,{gl:a}=r;a.bindTexture(a.TEXTURE_2D,this.texture),t!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,t),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,t),this.minFilter=t),i!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,i),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,i),this.wrapS=i)}}class uK{static getImagePositionScale(t,i,r){if(i&&t){let{sx:i,sy:r}=t;return{x:i,y:r}}return{x:r,y:r}}constructor(t,i,r,a){this.paddedRect=t;let{pixelRatio:n,version:o,stretchX:s,stretchY:l,content:h,sdf:u,usvg:c}=i;this.pixelRatio=n,this.stretchX=s,this.stretchY=l,this.content=h,this.version=o,this.padding=r,this.sdf=u,this.usvg=c,this.scale=uK.getImagePositionScale(a,c,n)}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 uQ(t,i){let r=[];for(let[a,n]of t.entries()){let t=ah.parse(a);t&&(r.push({key:a,value:n,variant:t}),i&&i.set(a,t))}r.sort((t,i)=>{let r=t.variant.id.toString().localeCompare(i.variant.id.toString());return 0!==r?r:t.variant.sx!==i.variant.sx?t.variant.sx-i.variant.sx:t.variant.sy!==i.variant.sy?t.variant.sy-i.variant.sy:t.key.localeCompare(i.key)});let a=new Map;for(let t of r)a.set(t.key,t.value);return a}class uJ{constructor(t){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(t&&t.maxTextureMemoryMB?t.maxTextureMemoryMB:256)*1024,this.currentFrameAtlases=new Set,this.finalizationRegistry=new FinalizationRegistry(t=>{this.cache.delete(t),this.clearExpiredTextures()})}beginFrame(){this.currentFrameAtlases.clear()}calculateTextureMemory(t){return t.image?Math.ceil(t.image.width*t.image.height*4*(t.patternPositions.size>0?1.33:1)):0}evictTexture(t){let i=this.textures.get(t);if(i){let r=this.calculateTextureMemory(t);i.destroy(),this.textures.delete(t),this.textureAccessTimes.delete(t),this.textureMemoryUsed-=r,t.uploaded=!1}}evictTexturesIfNeeded(t){for(;this.textureMemoryUsed+t>this.maxTextureMemory&&this.textures.size>0;){let t=null,i=1/0;for(let[r]of this.textures.entries()){if(this.currentFrameAtlases.has(r))continue;let a=this.textureAccessTimes.get(r)||0;a<i&&(i=a,t=r)}if(!t)break;this.evictTexture(t)}}findCachedAtlas(t){let i=this.cache.get(t.hash);if(i){let r=i.deref();if(r&&r.contentDescriptor&&this.isMipmapCompatible(t,r.contentDescriptor))return r}for(let[,i]of this.cache.entries()){let r=i.deref();if(r&&r.contentDescriptor){let i=t.subsetOf(r.contentDescriptor),a=this.isMipmapCompatible(t,r.contentDescriptor);if(i&&a)return r}}}getTextureForAtlas(t,i,r){this.textureAccessTimes.set(t,performance.now()),this.currentFrameAtlases.add(t);let a=this.textures.get(t);if(a)return a;
7if(t.image){let n=this.calculateTextureMemory(t);return this.evictTexturesIfNeeded(n),a=new uW(i,t.image,r,{useMipmap:!!t.patternPositions.size}),this.textures.set(t,a),this.textureMemoryUsed+=n,a}return null}clearExpiredTextures(){for(let[t]of this.textures.entries())if(!this.isAtlasCached(t)){let i=this.textures.get(t);if(i){let r=this.calculateTextureMemory(t);i.destroy(),this.textureMemoryUsed-=r}this.textures.delete(t),this.textureAccessTimes.delete(t)}}isAtlasCached(t){if(!t.contentDescriptor)return!1;let i=this.cache.get(t.contentDescriptor.hash);return!!i&&i.deref()===t}getOrCache(t){if(!("image"in t)){let i=this.cache.get(t.sourceAtlasHash);if(i){let t=i.deref();if(t)return t}return tX("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!t.contentDescriptor)return t;let i=t.contentDescriptor,r=i.hash,a=this.cache.get(r);if(a){let t=a.deref();if(t&&t.contentDescriptor&&this.isMipmapCompatible(i,t.contentDescriptor))return t}return this.cache.set(r,new WeakRef(t)),this.finalizationRegistry.register(t,r,t),t}isMipmapCompatible(t,i){return!t.requiresMipMaps||i.requiresMipMaps}destroyTextures(){for(let t of this.textures.values())t&&t.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}clear(){for(let t of this.textures.values())t&&t.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}}oC(uK,"ImagePosition"),oC(class{constructor(t,i,r,a){let n=new Map,o=new Map;this.haveRenderCallbacks=[];let s=[],l=void 0!==a,h=l?new Map:void 0,u=l?uQ(t,h):t,c=l?uQ(i,h):i;this.addImages(u,n,1,s),this.addImages(c,o,2,s);let{w:d,h:p}=uV(s),f=new h7({width:d||1,height:p||1});for(let[t,i]of u.entries()){let r=n.get(t).paddedRect;h7.copy(i.data,f,{x:0,y:0},{x:r.x+1,y:r.y+1},i.data,null,i.sdf)}for(let[t,i]of c.entries()){let a=o.get(t),n=a.paddedRect,s=a.padding,l=n.x+s,h=n.y+s,u=i.data.width,c=i.data.height;s=s>1?s-1:s,h7.copy(i.data,f,{x:0,y:0},{x:l,y:h},i.data,r),h7.copy(i.data,f,{x:0,y:c-s},{x:l,y:h-s},{width:u,height:s},r),h7.copy(i.data,f,{x:0,y:0},{x:l,y:h+c},{width:u,height:s},r),h7.copy(i.data,f,{x:u-s,y:0},{x:l-s,y:h},{width:s,height:c},r),h7.copy(i.data,f,{x:0,y:0},{x:l+u,y:h},{width:s,height:c},r),h7.copy(i.data,f,{x:u-s,y:c-s},{x:l-s,y:h-s},{width:s,height:s},r),h7.copy(i.data,f,{x:0,y:c-s},{x:l+u,y:h-s},{width:s,height:s},r),h7.copy(i.data,f,{x:0,y:0},{x:l+u,y:h+c},{width:s,height:s},r),h7.copy(i.data,f,{x:u-s,y:0},{x:l-s,y:h+c},{width:s,height:s},r)}this.lut=r,this.image=f,this.iconPositions=n,this.patternPositions=o,l&&(this.contentDescriptor=new uq(u,c,a,r,h))}addImages(t,i,r,a){for(let[n,o]of t.entries()){let{bin:t,imagePosition:s,imageVariant:l}=function(t,i,r){let a=ah.parse(t),n=function(t,i,r=[1,1]){return{x:0,y:0,w:(t.data?t.data.width:t.width*r[0])+2*i,h:(t.data?t.data.height:t.height*r[1])+2*i}}(i,r,[a.sx,a.sy]);return{bin:n,imagePosition:new uK(n,i,r,a),imageVariant:a}}(n,o,r);i.set(n,s),a.push(t),o.hasRenderCallback&&this.haveRenderCallbacks.push(l.id)}}patchUpdatedImages(t,i,r,a){for(let n of(this.haveRenderCallbacks=this.haveRenderCallbacks.filter(i=>t.hasImage(i,r)),t.dispatchRenderCallbacks(this.haveRenderCallbacks,r),t.getUpdatedImages(r))){for(let a of this.iconPositions.keys()){let o=ah.parse(a);if(rk.isEqual(o.id,n)){let o=t.getImage(n,r);this.patchUpdatedImage(this.iconPositions.get(a),o,i,null)}}for(let o of this.patternPositions.keys()){let s=ah.parse(o);if(rk.isEqual(s.id,n)){let s=t.getImage(n,r);this.patchUpdatedImage(this.patternPositions.get(o),s,i,a||this.lut)}}}}patchUpdatedImage(t,i,r,a=null){if(!t||!i||t.version===i.version)return;t.version=i.version;let[n,o]=t.tl,s=t.sdf;if(this.lut||s){let t={width:i.data.width,height:i.data.height},l=new h7(t);h7.copy(i.data,l,{x:0,y:0},{x:0,y:0},t,a,s),r.update(l,{position:{x:n,y:o},recreateWhenResize:!1})}else r.update(i.data,{position:{x:n,y:o},recreateWhenResize:!1})}},"ImageAtlas",{omit:["lut"]}),oC(class{constructor(t){this.sourceAtlasHash=t}},"ImageAtlasReference");class u0{constructor(t){this.pendingRequests=new Map,this.cachedRanges=new Map,this.fontstackCompositing=t&&t.fontstackCompositing||"client"}loadGlyphRange(t,i,r,a,n){if("server"===this.fontstackCompositing)return void u0.loadGlyphRange(t,i,r,a,n);let o=t.split(",").map(t=>t.trim()).filter(t=>t.length>0);0!==o.length?1!==o.length?this._loadMultipleFonts(o,i,r,a,n):this._loadFont(o[0],i,r,a,n):n(Error("Empty fontstack"))}_loadMultipleFonts(t,i,r,a,n){let o=t.map(()=>null),s={completed:0,firstError:null,callbackCalled:!1},l=(i,r,a)=>{if(!s.callbackCalled&&(r&&!s.firstError&&(s.firstError=r),a&&(o[i]=a),s.completed++,s.c
7ompleted===t.length)){s.callbackCalled=!0;let t=o.filter(t=>null!==t);if(0===t.length)return void n(s.firstError||Error("All fonts failed to load"));n(null,this._composeGlyphs(t))}};for(let n=0;n<t.length;n++)this._loadFont(t[n],i,r,a,(t,i)=>{l(n,t,i)})}_loadFont(t,i,r,a,n){let o=`${t}:${i}`;if(this.cachedRanges.has(o)){let t=this.cachedRanges.get(o);return void is.frame(()=>n(null,t))}let s=this.pendingRequests.get(o);s?s.push(n):(this.pendingRequests.set(o,[n]),u0.loadGlyphRange(t,i,r,a,(t,i)=>{t||this.cachedRanges.set(o,i||null);let r=this.pendingRequests.get(o);if(this.pendingRequests.delete(o),r)for(let a of r)a(t,i)}))}_composeGlyphs(t){let i,r,a={};for(let n of t)if(void 0===i&&void 0!==n.ascender&&(i=n.ascender),void 0===r&&void 0!==n.descender&&(r=n.descender),n.glyphs)for(let t in n.glyphs)void 0===a[t]&&(a[t]=n.glyphs[t]);return{glyphs:a,ascender:i,descender:r}}}u0.loadGlyphRange=async function(t,i,r,a,n){let o,s=256*i;try{let i=await a.transformRequest(a.normalizeGlyphsURL(r).replace("{fontstack}",t).replace("{range}",`${s}-${s+255}`),iX.Glyphs),{data:n}=await i4(i),l={},h=function(t){let i;var r=new uz(t);let a={glyphs:[]};for(;i=r.nextField();)1===i&&function(t,i,r){let a;for(;a=t.nextField(i);)3===a?r.glyphs.push(function(t,i){let r,a,n=0,o=0,s=0,l=0,h=0,u=0;for(;a=t.nextField(i);)1===a?n=t.readVarint():2===a?r=t.readBytes():3===a?o=t.readVarint():4===a?s=t.readVarint():5===a?l=t.readSVarint():6===a?h=t.readSVarint():7===a&&(u=t.readVarint());return{id:n,bitmap:new h9({width:o+6,height:s+6},r),metrics:{width:o,height:s,left:l,top:h,advance:u}}}(t,t.readVarint()+t.pos)):4===a?r.ascender=t.readSVarint():5===a&&(r.descender=t.readSVarint())}(r,r.readVarint()+r.pos,a);return a}(n);for(let t of h.glyphs)l[t.id]=t;o={glyphs:l,ascender:h.ascender,descender:h.descender}}catch(t){return n(t)}n(null,o)};let u1=new Float64Array(256);for(let t=0;t<256;t++){let i=.5-Math.pow(t/255,1/2.2);u1[t]=i*Math.abs(i)}function u2(t,i,r,a,n,o,s,l,h){for(let u=i;u<i+a;u++)u3(t,r*o+u,o,n,s,l,h);for(let u=r;u<r+n;u++)u3(t,u*o+i,1,a,s,l,h)}function u3(t,i,r,a,n,o,s){o[0]=0,s[0]=-1e20,s[1]=1e20,n[0]=t[i];for(let l=1,h=0,u=0;l<a;l++){n[l]=t[i+l*r];let a=l*l;do{let t=o[h];u=(n[l]-n[t]+a-t*t)/(l-t)/2}while(u<=s[h]&&--h>-1);o[++h]=l,s[h]=u,s[h+1]=1e20}for(let l=0,h=0;l<a;l++){for(;s[h+1]<l;)h++;let a=o[h],u=l-a;t[i+l*r]=n[a]+u*u}}u1[255]=-1e20;let u4=/bold/i,u5=/medium/i,u6=/light/i;class u8{constructor(t,i,r,a){this.requestManager=t,this.localGlyphMode=i,this.localFontFamily=r,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new u0({fontstackCompositing:a})}setURL(t){this.url=t}prefetchRange(t,i){let r=this.url||iT.GLYPHS_URL;if(!r)return;let a=this.entries[t];a||(a=this.entries[t]={glyphs:{},requests:{},ranges:{}}),a.ranges[i]||a.requests[i]||(a.requests[i]=[],this.glyphLoader.loadGlyphRange(t,i,r,this.requestManager,(t,r)=>{if(r){for(let t in a.ascender=r.ascender,a.descender=r.descender,r.glyphs)this._doesCharSupportLocalGlyph(+t)||(a.glyphs[+t]=r.glyphs[+t]);a.ranges[i]=!0}for(let n of a.requests[i]||[])n(t,r);delete a.requests[i]}))}getGlyphs(t,i){let r=[],a=this.url||iT.GLYPHS_URL;for(let i in t)for(let a of t[i])r.push({stack:i,id:a});tB(r,({stack:t,id:i},r)=>{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[i];if(void 0!==o)return void r(null,{stack:t,id:i,glyph:o});if(o=this._tinySDF(n,t,i))return n.glyphs[i]=o,void r(null,{stack:t,id:i,glyph:o});let s=Math.floor(i/256);if(256*s>65535)return tX("glyphs > 65535 not supported"),void r(null,{stack:t,id:i,glyph:o});if(n.ranges[s])return void r(null,{stack:t,id:i,glyph:o});let l=n.requests[s];l||(l=n.requests[s]=[],this.glyphLoader.loadGlyphRange(t,s,a,this.requestManager,(t,i)=>{if(i){for(let t in n.ascender=i.ascender,n.descender=i.descender,i.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=i.glyphs[+t]);n.ranges[s]=!0}for(let r of l)r(t,i);delete n.requests[s]})),l.push((a,n)=>{a?r(a):n&&r(null,{stack:t,id:i,glyph:n.glyphs[i]||null})})},(t,r)=>{if(t)i(t);else if(r){let t={};for(let{stack:i,id:a,glyph:n}of r)void 0===t[i]&&(t[i]={}),void 0===t[i].glyphs&&(t[i].glyphs={}),t[i].glyphs[a]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},t[i].ascender=this.entries[i].ascender,t[i].descender=this.entries[i].descender;i(null,t)}})}_doesCharSupportLocalGlyph(t){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&
7(ok(t)||oN(t)||oO(t)||oF(t)||oL(t)||oB(t)||t>=131072&&t<=173791||t>=66736&&t<=66815))}_tinySDF(t,i,r){let a=this.localFontFamily;if(!a||!this._doesCharSupportLocalGlyph(r))return;let n=t.tinySDF;if(!n){let r="400";u4.test(i)?r="900":u5.test(i)?r="500":u6.test(i)&&(r="200"),(n=t.tinySDF=new u8.TinySDF({fontFamily:a,fontWeight:r,fontSize:48,buffer:6,radius:16})).fontWeight=r}let o=n.fontWeight;if(this.localGlyphs[o][r])return this.localGlyphs[o][r];let s=String.fromCodePoint(r),{data:l,width:h,height:u,glyphWidth:c,glyphHeight:d,glyphLeft:p,glyphTop:f,glyphAdvance:_}=n.draw(s);return this.localGlyphs[o][r]={id:r,bitmap:new h9({width:h,height:u},l),metrics:{width:c/2,height:d/2,left:p/2,top:f/2-27,advance:_/2,localGlyph:!0}}}}function u9(t,i){return t+i[1]-i[0]}function u7(t,i,r){let a=0;for(let n of t)a+=Math.max(i,Math.min(r,n[1]))-Math.max(i,Math.min(r,n[0]));return a}function ce(t,i,r){let a=[{fixed:-1,stretch:0}];for(let[i,r]of t){let t=a.at(-1);a.push({fixed:i-t.stretch,stretch:t.stretch}),a.push({fixed:i-t.stretch,stretch:t.stretch+(r-i)})}return a.push({fixed:i+1,stretch:r}),a}u8.TinySDF=class{constructor({fontSize:t=24,buffer:i=3,radius:r=8,cutoff:a=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:l=null}={}){this.buffer=i,this.radius=r,this.cutoff=a,this.lang=l;let h=this.size=t+4*i,u=this._createCanvas(h),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(h*h),this.gridInner=new Float64Array(h*h),this.f=new Float64Array(h),this.z=new Float64Array(h+1),this.v=new Uint16Array(h)}_createCanvas(t){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,t);let i=document.createElement("canvas");return i.width=i.height=t,i}draw(t){let{width:i,actualBoundingBoxAscent:r,actualBoundingBoxDescent:a,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(r),l=Math.floor(-n),h=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o)-l)),u=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(a))),c=h+2*this.buffer,d=u+2*this.buffer,p=Math.max(c*d,0),f=new Uint8ClampedArray(p),_={data:f,width:c,height:d,glyphWidth:h,glyphHeight:u,glyphTop:s,glyphLeft:l,glyphAdvance:i};if(0===h||0===u)return _;let{ctx:m,buffer:g,gridInner:y,gridOuter:x}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,h,u),m.fillText(t,g-l,g+s);let v=m.getImageData(g,g,h,u);x.fill(1e20,0,p),y.fill(0,0,p);let b=3;for(let t=0;t<u;t++){let i=(t+g)*c+g;for(let t=0;t<h;t++,b+=4,i++){let t=v.data[b];if(0===t)continue;let r=u1[t];x[i]=Math.max(0,r),y[i]=Math.max(0,-r)}}u2(x,0,0,c,d,c,this.f,this.v,this.z);let w=Math.min(g,1);u2(y,g-w,g-w,h+2*w,u+2*w,c,this.f,this.v,this.z);let T=255/this.radius,E=255*(1-this.cutoff);for(let t=0;t<p;t++){let i=Math.sqrt(x[t])-Math.sqrt(y[t]);f[t]=Math.round(E-T*i)}return _}};let ct=Math.sqrt(2);function ci(t,[i,r]){let a=0,n=0;if(r===1/0){i<0&&(i=0);let r=i/ct;switch(t){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-i;break;case"top":n=i-7}switch(t){case"top-right":case"bottom-right":a=-r;break;case"top-left":case"bottom-left":a=r;break;case"left":a=i;break;case"right":a=-i}}else{switch(i=Math.abs(i),r=Math.abs(r),t){case"top-right":case"top-left":case"top":n=r-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-r}switch(t){case"top-right":case"bottom-right":case"right":a=-i;break;case"top-left":case"bottom-left":case"left":a=i}}return[a,n]}function cr(t,i,r,a,n,o,s,l,h,u){var c,d,p,f,_,m,g;if(!t)return;let y=(c=i,d=r,p=a,f=n,_=o,m=h,g=u,"camera"===c.kind?c.maxSize:"composite"===c.kind?Math.max(d.possiblyEvaluate(new o0(c.maxZoom,{worldview:m}),p,g).evaluate(_,{},p,g),d.possiblyEvaluate(new o0(c.minZoom,{worldview:m}),p,g).evaluate(_,{},p,g)):d.possiblyEvaluate(new o0(f,{worldview:m}),p,g).evaluate(_,{},p,g));return t.scaleSelf(y*l*s)}function ca(t,i,r,a,n,o,s,l,h,u){return{iconPrimary:cr(t.getPrimary(),i,r,a,n,o,s,l,h,u),iconSecondary:cr(t.getSecondary(),i,r,a,n,o,s,l,h,u)}}let{members:cn}=lo([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),co=lo([{name:"a_pos_3",components:3,type:"Int16"}]);var cs=lo([{name:"a_pos",type:"Int16",components:2}]);class cl{constructor(t,i){this.pos=t,this.dir=i}intersectsPlane(t,i,r){let a=t_(i,this.dir);if(1e-6>
7Math.abs(a))return!1;let n=((t[0]-this.pos[0])*i[0]+(t[1]-this.pos[1])*i[1])/a;return r[0]=this.pos[0]+this.dir[0]*n,r[1]=this.pos[1]+this.dir[1]*n,!0}}class ch{constructor(t,i){this.pos=t,this.dir=i}intersectsPlane(t,i,r){let a=eX(i,this.dir);if(1e-6>Math.abs(a))return!1;let n=((t[0]-this.pos[0])*i[0]+(t[1]-this.pos[1])*i[1]+(t[2]-this.pos[2])*i[2])/a;return r[0]=this.pos[0]+this.dir[0]*n,r[1]=this.pos[1]+this.dir[1]*n,r[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(t,i,r){var a,n,o,s,l,h,u;if(a=this.pos,n=a[0],o=a[1],s=a[2],l=t[0],h=t[1],u=t[2],Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-h)<=1e-6*Math.max(1,Math.abs(o),Math.abs(h))&&Math.abs(s-u)<=1e-6*Math.max(1,Math.abs(s),Math.abs(u))||0===i)return r[0]=r[1]=r[2]=0,!1;let[c,d,p]=this.dir,f=this.pos[0]-t[0],_=this.pos[1]-t[1],m=this.pos[2]-t[2],g=c*c+d*d+p*p,y=2*(f*c+_*d+m*p),x=y*y-4*g*(f*f+_*_+m*m-i*i);if(x<0){let t=Math.max(-y/2,0),a=f+c*t,n=_+d*t,o=m+p*t,s=Math.hypot(a,n,o);return r[0]=a*i/s,r[1]=n*i/s,r[2]=o*i/s,!1}{let t=(-y-Math.sqrt(x))/(2*g);if(t<0){let t=Math.hypot(f,_,m);return r[0]=f*i/t,r[1]=_*i/t,r[2]=m*i/t,!1}return r[0]=f+c*t,r[1]=_+d*t,r[2]=m+p*t,!0}}}class cu{constructor(t,i,r,a,n){this.TL=t,this.TR=i,this.BR=r,this.BL=a,this.horizon=n}static fromInvProjectionMatrix(t,i,r){let a=[-1,1,1],n=[1,1,1],o=[1,-1,1],s=[-1,-1,1],l=eQ(a,a,t),h=eQ(n,n,t);return new cu(l,h,eQ(o,o,t),eQ(s,s,t),i/r)}}function cc(t,i,r,a){let n=i[0],o=i[1],s=i[2],l=r[0],h=r[1],u=r[2],c=1/0,d=-1/0;for(let i=0;i<t.length;i++){let r=t[i],a=(r[0]-n)*l+(r[1]-o)*h+(r[2]-s)*u;a<c&&(c=a),a>d&&(d=a)}return a[0]=c,a[1]=d,a}function cd(t,i){let r=!0;for(let a=0;a<t.planes.length;a++){let n=t.planes[a],o=0;for(let t=0;t<i.length;t++)o+=+(eX(n,i[t])+n[3]>=0);if(0===o)return 0;o!==i.length&&(r=!1)}return r?2:1}let cp=[0,0];function cf(t,i){for(let r of t.projections){let a=cc(i,t.points[0],r.axis,cp);if(r.projection[1]<a[0]||r.projection[0]>a[1])return 0}return 1}function c_(t,i){let r=i[0],a=i[1],n=i[2],o=i[3];for(let i=0;i<t.length;i++){let s=t[i];if(r*s[0]+a*s[1]+n*s[2]+o>=0)return!0}return!1}class cm{constructor(t,i){for(let r of(this.points=t||Array(8).fill([0,0,0]),this.planes=i||Array(6).fill([0,0,0,0]),this.bounds=cg.fromPoints(this.points),this.projections=[],this.frustumEdges=[ek([],this.points[2],this.points[3]),ek([],this.points[0],this.points[3]),ek([],this.points[4],this.points[0]),ek([],this.points[5],this.points[1]),ek([],this.points[6],this.points[2]),ek([],this.points[7],this.points[3])],this.frustumEdges)){let t=[0,-r[2],r[1]],i=[r[2],0,-r[0]];this.projections.push({axis:t,projection:cc(this.points,this.points[0],t,[0,0])}),this.projections.push({axis:i,projection:cc(this.points,this.points[0],i,[0,0])})}}static fromInvProjectionMatrix(t,i,r,a){let n=Math.pow(2,r),o=[[-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(r=>{var o;let s=e9([],r,t),l=1/s[3]/i*n;return s[0]=s[0]*(o=[l,l,a?1/s[3]:l,l])[0],s[1]=s[1]*o[1],s[2]=s[2]*o[2],s[3]=s[3]*o[3],s}),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(t=>{let i=eW([],eY([],ek([],o[t[0]],o[t[1]]),ek([],o[t[2]],o[t[1]]))),r=-eX(i,o[t[1]]);return i.concat(r)}),l=[];for(let t=0;t<o.length;t++)l.push([o[t][0],o[t][1],o[t][2]]);return new cm(l,s)}intersectsPrecise(t,i,r){for(let r=0;r<i.length;r++)if(!c_(t,i[r]))return 0;for(let i=0;i<this.planes.length;i++)if(!c_(t,this.planes[i]))return 0;let a=this.points,n=a[0][0],o=a[0][1],s=a[0][2];for(let i of r)for(let r of this.frustumEdges){let l=i[1]*r[2]-i[2]*r[1],h=i[2]*r[0]-i[0]*r[2],u=i[0]*r[1]-i[1]*r[0];if(0===l&&0===h&&0===u)continue;let c=1/0,d=-1/0;for(let t=0;t<a.length;t++){let i=a[t],r=(i[0]-n)*l+(i[1]-o)*h+(i[2]-s)*u;r<c&&(c=r),r>d&&(d=r)}let p=1/0,f=-1/0;for(let i=0;i<t.length;i++){let r=t[i],a=(r[0]-n)*l+(r[1]-o)*h+(r[2]-s)*u;a<p&&(p=a),a>f&&(f=a)}if(c>f||p>d)return 0}return 1}containsPoint(t){for(let i of this.planes){let r=i[3];if(eX([i[0],i[1],i[2]],t)+r<0)return!1}return!0}}class cg{static fromPoints(t){let i=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let a of t)eV(i,i,a),eU(r,r,a);return new cg(i,r)}static fromTileIdAndHeight(t,i,r){let a=1<<t.canonical.z,n=t.canonical.x,o=t.canonical.y;return new cg([n/a,o/a,i],[(n+1)/a,(o+1)/a,r])}static applyTransform(t,i){let r=t.getCorners();for(let t=0;t<r.length;++t)eQ(r[t],r[t],i);return cg.fromPoints(r)}static applyTransformFast(t,i){let r=[i[12],i[13],i[14]],a=[...r];for(let n=0;n<3;n++)for(let o=0;o<3;o++){let s=i[4*o+n],l=s*t.min[o],h=s*t.max[o];r[n]+=Math.min(l,h),a[n]+=Math.max(l,h)}return new cg(r,a)}static projectAabbCorners(t,i){let r=t.getCorners();for(let t=0;t<r.length;++t)eQ(r[t],r[t],i);return r}constructor(t,i){this.min=t,this.max=i,this.center=ej([],eB([],this.min,this.max),.5)}quadrant(t){let i=[t%2==0,t<2],r=ez(this.min),a=ez(this.max);for(let t=0;t<i.length;t++)r[t]=i[t]?this.min[t]:this.center[t],a[t]=i[t]?this.center[t]:this.max[t];return a[2]=this.max[2],new cg(r,a)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){let t=this.min,i=this.max;return[[t[0],t[1],t[2]],[i[0],t[1],t[2]],[i[0],i[1],t[2]],[t[0],i[1],t[2]],[t[0],t[1],i[2]],[i[0],t[1],i[2]],[i[0],i[1],i[2]],[t[0],i[1],i[2]]]}intersects(t){return this.intersectsAabb(t.bounds)?cd(t,this.getCorners()):0}intersectsFlat(t){return this.intersectsAabb(t.bounds)?cd(t,[[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(t,i){return i||this.intersects(t)?cf(t,this.getCorners()):0}intersectsPreciseFlat(t,i){return i||this.intersectsFlat(t)?cf(t,[[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(t){for(let i=0;i<3;++i)if(this.min[i]>t.max[i]||t.min[i]>this.max[i])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],t.min[i]),this.max[i]=Math.max(this.max[i],t.max[i])}encapsulatePoint(t){for(let i=0;i<3;i++)this.min[i]=Math.min(this.min[i],t[i]),this.max[i]=Math.max(this.max[i],t[i])}closestPoint(t){return[Math.max(Math.min(this.max[0],t[0]),this.min[0]),Math.max(Math.min(this.max[1],t[1]),this.min[1]),Math.max(Math.min(this.max[2],t[2]),this.min[2])]}}function cy(t){return t*sW/6371008.8}oC(cg,"Aabb");let cx=[new cg([sY,sY,sY],[sW,sW,sW]),new cg([sY,sY,sY],[0,0,sW]),new cg([0,sY,sY],[sW,0,sW]),new cg([sY,0,sY],[0,sW,sW]),new cg([0,0,sY],[sW,sW,sW])];function cv(t,i,r,a=!0){let n=ej([],t._camera.position,t.worldSize),o=[i,r,1,1];e9(o,o,t.pixelMatrixInverse),e6(o,o,1/o[3]);let s=eW([],ek([],o,n)),l=t.globeMatrix,h=[l[12],l[13],l[14]],u=ek([],h,n),c=eL(u),d=eW([],u),p=t.worldSize/(2*Math.PI),f=eX(d,s),_=Math.asin(p/c);if(_<Math.acos(f)){if(!a)return null;let t=[],i=[];
7ej(t,s,c/f),eW(i,ek(i,t,u)),eW(s,eB(s,u,ej(s,i,Math.tan(_)*c)))}let m=[];new ch(n,s).closestPointOnSphere(h,p,m);let g=eW([],t4(l,0)),y=eW([],t4(l,1)),x=eW([],t4(l,2)),v=eX(g,m),b=eX(y,m),w=eX(x,m),T=Math.asin(-b/p)*tC,E=Math.atan2(v,w)*tC;return new s8(az(E=t.center.lng+function(t,i){let r=(i-t+180)%360-180;return r<-180?r+360:r}(t.center.lng,E)),tL(aL(T),0,1))}class cb{constructor(t,i,r){this.a=ek([],t,r),this.b=ek([],i,r),this.center=r;let a=eW([],this.a),n=eW([],this.b);this.angle=Math.acos(eX(a,n))}}function cw(t,i){let r;return 0===t.angle||(r=0===t.a[i]?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[i]/t.a[i]/Math.sin(t.angle)-1/Math.tan(t.angle)))<0||r>1?null:function(t,i,r,a){let n=Math.sin(r);return Math.sin((1-a)*r)/n*t+Math.sin(a*r)/n*i}(t.a[i],t.b[i],t.angle,tL(r,0,1))+t.center[i]}function cT(t){if(t.z<=1)return cx[t.z+2*t.y+t.x];let i=cM(cC(t));return cg.fromPoints(i)}function cE(t,i,r){return ej(t,t,1-r),eG(t,t,i,r)}function cS(t,i){let r=cN(i.zoom);if(0===r)return cT(t);let a=cC(t),n=cM(a),o=az(a.getWest())*i.worldSize,s=az(a.getEast())*i.worldSize,l=aL(a.getNorth())*i.worldSize,h=aL(a.getSouth())*i.worldSize,u=[o,l,0],c=[s,l,0],d=[o,h,0],p=[s,h,0],f=em([],i.globeMatrix);return eQ(u,u,f),eQ(c,c,f),eQ(d,d,f),eQ(p,p,f),n[0]=cE(n[0],d,r),n[1]=cE(n[1],p,r),n[2]=cE(n[2],c,r),n[3]=cE(n[3],u,r),cg.fromPoints(n)}function cI(t,i,r){for(let a of t)eQ(a,a,i),ej(a,a,r)}function cA(t,i,r,a){let n=i/t.worldSize,o=t.globeMatrix;if(r.z<=1){let t=cT(r).getCorners();return cI(t,o,n),cg.fromPoints(t)}let s=cC(r,a),l=cM(s,sW+cy(t._tileCoverLift));cI(l,o,n);let h=Number.MAX_VALUE,u=[-h,-h,-h],c=[h,h,h];if(s.contains(t.center)){for(let t of l)eV(c,c,t),eU(u,u,t);u[2]=0;let i=t.point,r=[i.x*n,i.y*n,0];return eV(c,c,r),eU(u,u,r),new cg(c,u)}if(t._tileCoverLift>0){for(let t of l)eV(c,c,t),eU(u,u,t);return new cg(c,u)}let d=[o[12]*n,o[13]*n,o[14]*n],p=s.getCenter(),f=tL(t.center.lat,-85.051129,85.051129),_=tL(p.lat,-85.051129,85.051129),m=az(t.center.lng),g=aL(f),y=m-az(p.lng),x=g-aL(_);y>.5?y-=1:y<-.5&&(y+=1);let v=0;Math.abs(y)>Math.abs(x)?v=y>=0?1:3:(v=x>=0?0:2,eG(d,d,[o[4]*n,o[5]*n,o[6]*n],-Math.sin((x>=0?s.getSouth():s.getNorth())*tA)*sW));let b=l[v],w=l[(v+1)%4],T=new cb(b,w,d),E=[cw(T,0)||b[0],cw(T,1)||b[1],cw(T,2)||b[2]],S=cN(t.zoom);if(S>0){let a=function({x:t,y:i,z:r},a,n,o,s){let l=1/(1<<r),h=t*l,u=h+l,c=i*l,d=c+l,p=0,f=(h+u)/2-o;return f>.5?p=-1:f<-.5&&(p=1),h=((h+p)*a-(o*=a))*n+o,u=((u+p)*a-o)*n+o,c=(c*a-(s*=a))*n+s,[[h,d=(d*a-s)*n+s,0],[u,d,0],[u,c,0],[h,c,0]]}(r,i,t._pixelsPerMercatorPixel,m,g);for(let t=0;t<l.length;t++)cE(l[t],a[t],S);let n=eB([],a[v],a[(v+1)%4]);ej(n,n,.5),cE(E,n,S)}for(let t of l)eV(c,c,t),eU(u,u,t);return c[2]=Math.min(b[2],w[2]),eV(c,c,E),eU(u,u,E),new cg(c,u)}function cC({x:t,y:i,z:r},a=!1){let n=1/(1<<r);return new s1(new s0(aO(t*n),i===(1<<r)-1&&a?-90:aF((i+1)*n)),new s0(aO((t+1)*n),0===i&&a?90:aF(i*n)))}function cM(t,i=sW){let r=t.getNorth()*tA,a=t.getSouth()*tA,n=Math.cos(r),o=Math.cos(a),s=Math.sin(r),l=Math.sin(a),h=t.getWest(),u=t.getEast();return[sK(o,l,h,i),sK(o,l,u,i),sK(n,s,u,i),sK(n,s,h,i)]}function cR(t,i,r,a){let n=1<<r.z,o=(t/8192+r.x)/n;return sQ(aF((i/8192+r.y)/n),aO(o),a)}function cD({min:t,max:i}){return 16383/Math.max(i[0]-t[0],i[1]-t[1],i[2]-t[2])}let cP=new Float64Array(16);function cz(t){let i=cD(t),r=eE(cP,[i,i,i]);return ey(r,r,e$([],t.min))}function cL(t){let i=1/cD(t);return eT(cP,t.min),ex(cP,cP,[i,i,i])}function cO(t){return t/(2*Math.PI)/(8192/(2*Math.PI))}function cF(t,i){return 8192/(512*Math.pow(2,t))*cD(cT(i))}function cB(t,i,r,a,n){let o=cO(r),s=[t,i,-r/(2*Math.PI)],l=ef(new Float64Array(16));return ey(l,l,s),ex(l,l,[o,o,o]),ev(l,l,-n*tA),eb(l,l,-a*tA),l}function ck(t){let i=t.pixelsPerMeter,r=i/(1/s2(t.center.lat)),a=ef(new Float64Array(16));return ey(a,a,[t.point.x,t.point.y,0]),ex(a,a,[r,r,i]),Float32Array.from(a)}function cN(t){return tO(5,6,t)}function cV(t,i,r){let a=ef(new Float64Array(16)),n=(i/(1<<t)-.5)*Math.PI*2;return eb(a,r.globeMatrix,n),Float32Array.from(a)}function cU(t,i,r){let a=cN(r.zoom),n=t.style.map._antialias,o=t.terrain&&t.terrain.exaggeration()>0;return 0===a&&!n&&!o}function cj(t,i,r,a){let n=i.getNorth(),o=i.getSouth(),s=i.getWest(),l=i.getEast(),h=1<<t.z,u=l-s,c=n-o,d=u/64,p=-c/sX[r],f=[0,d,0,p,0,0,n,s,0];if(t.z>0){let t=180/a;eh(f,f,[t/u+1,0,0,0,t/c+1,0,-.5*t/d,.5*t/p,1])}return f[2]=h,f[5]=t.x,f[8]=t.y,f}function cG(t){return Math.round(Math.pow(Math.abs(Math.sin((t=tL(t,-80.051129,80.051129)/80.051129*90)*tA)),3)*(sX.length-1))}function cH(t){let i=[0,0,0],r=ef(new Float64Array(16));return eg(r,t.pixelMatrix,t.globeMatrix),eQ(i,i,r),new tg(i[0],i[1])}function cq(t,i){var r,a,n,o,s,l,h,u;let c=sQ(i.lat,i.lng);return a=(r=ek([],function(t){let i=sQ(t._center.lat,t._center.lng),r=eY([],eO(0,1,0),i),a=eS([],-t.angle,i);r=eQ(r,r,a),eS(a,-t._pitch,r);let n=eW([],i);return ej(n,n,cy(t.cameraToCenterDistance/t.pixelsPerMeter)),eQ(n,n,a),eB([],i,n)}
7(t),c))[0],n=r[1],o=r[2],s=c[0],Math.acos(Math.min(Math.max((u=Math.sqrt((a*a+n*n+o*o)*(s*s+(l=c[1])*l+(h=c[2])*h)))&&eX(r,c)/u,-1),1))}function cZ(t,i){return cq(t,i)>Math.PI/2*1.01}let c$=85*tA,cW=Math.cos(c$),cX=Math.sin(c$);class cY{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){for(let t of(this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy(),this._poleSegments))t.destroy();for(let t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}_fillGridMeshWithLods(t,i){let r=new ll,a=new lR,n=[],o=t+1+2,s=i[0]+1,l=i[0]+1+(1+i.length),h=(t,i,r)=>{let a=t===o-1?t-2:0===t?t:t-1;return[a+=24575*!!r,i]};for(let t=0;t<o;++t)r.emplaceBack(...h(t,0,!0));for(let t=0;t<s;++t)for(let i=0;i<o;++i)r.emplaceBack(...h(i,t,0===i||i===o-1));for(let t=0;t<i.length;++t){let a=i[t];for(let t=0;t<o;++t)r.emplaceBack(...h(t,a,!0))}for(let t=0;t<i.length;++t){let s=a.length,h=i[t]+1+2,u=new lR;for(let r=0;r<h-1;r++){let n=r===h-2,s=n?o*(l-i.length+t-r):o;for(let t=0;t<o-1;t++){let i=r*o+t;0===r||n||0===t||t===o-2?(u.emplaceBack(i+1,i,i+s),u.emplaceBack(i+s,i+s+1,i+1)):(a.emplaceBack(i+1,i,i+s),a.emplaceBack(i+s,i+s+1,i+1))}}let c=l9.simpleSegment(0,s,r.length,a.length-s);for(let t=0;t<u.uint16.length;t+=3)a.emplaceBack(u.uint16[t],u.uint16[t+1],u.uint16[t+2]);let d=l9.simpleSegment(0,s,r.length,a.length-s);n.push({withoutSkirts:c,withSkirts:d})}return{vertices:r,indices:a,segments:n}}_createGrid(t){let i=this._fillGridMeshWithLods(64,sX);this._gridSegments=i.segments,this._gridBuffer=t.createVertexBuffer(i.vertices,cs.members),this._gridIndexBuffer=t.createIndexBuffer(i.indices,!0)}_createPoles(t){let i=new lR;for(let t=0;t<=64;t++)i.emplaceBack(0,t+1,t+2);this._poleIndexBuffer=t.createIndexBuffer(i,!0);let r=new lL,a=new lL,n=new lL,o=new lL;this._poleSegments=[];for(let t=0,i=0;t<6;t++){let s=360/(1<<t);r.emplaceBack(0,-sW,0,.5,0),a.emplaceBack(0,-sW,0,.5,1),n.emplaceBack(0,-sW,0,.5,.5),o.emplaceBack(0,-sW,0,.5,.5);for(let t=0;t<=64;t++){let i=t/64,l=0,h=rG(0,s,i),[u,c,d]=sK(cW,cX,h,sW);r.emplaceBack(u,c,d,i,l),a.emplaceBack(u,c,d,i,1-l);let p=h*tA;i=.5+.5*Math.sin(p),l=.5+.5*Math.cos(p),n.emplaceBack(u,c,d,i,l),o.emplaceBack(u,c,d,i,1-l)}this._poleSegments.push(l9.simpleSegment(i,0,66,64)),i+=66}this._poleNorthVertexBuffer=t.createVertexBuffer(r,cn,!1),this._poleSouthVertexBuffer=t.createVertexBuffer(a,cn,!1),this._texturedPoleNorthVertexBuffer=t.createVertexBuffer(n,cn,!1),this._texturedPoleSouthVertexBuffer=t.createVertexBuffer(o,cn,!1)}getGridBuffers(t,i){return[this._gridBuffer,this._gridIndexBuffer,i?this._gridSegments[t].withSkirts:this._gridSegments[t].withoutSkirts]}getPoleBuffers(t,i){return[i?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,i?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[t]]}}function cK(t,i){let r=t.fovAboveCenter,a=Math.min(t.elevation?t.elevation.getMinElevationBelowMSL()*i:0,t.isOrthographic?-10*i:0),n=(t._camera.position[2]*t.worldSize-a)/Math.cos(t._pitch),o=Math.sin(r)*n/Math.sin(Math.max(Math.PI/2-t._pitch-r,.01)),s=Math.sin(t._pitch)*o+n,l=n*(1/t._horizonShift);if(!t.elevation||0===t.elevation.exaggeration()){let i=Math.max(t.zoom-17,0);t.isOrthographic&&(i/=10),s*=1+i}return Math.min(1.01*s,l)}class cQ{constructor(t,i,r){this.z=t,this.x=i,this.y=r,this.key=c1(0,t,t,i,r)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}isChildOf(t){let i=this.z-t.z;return 0===t.z||t.z<this.z&&t.x===this.x>>i&&t.y===this.y>>i}url(t,i){let r=function(t,i,r){let a=2**r,n=2*Math.PI*6378137,o=n*(t/a-.5),s=n*(.5-(i+1)/a);return`${o},${s},${o+n/a},${s+n/a}`}(this.x,this.y,this.z),a=function(t,i,r){let a,n="";for(let o=t;o>0;o--)n+=(i&(a=1<<o-1)?1:0)+(r&a?2:0);return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.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("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",a).replace("{bbox-epsg-3857}",r)}toString(){return`${this.z}/${this.x}/${this.y}`}}
7class cJ{constructor(t,i){this.wrap=t,this.canonical=i,this.key=c1(t,i.z,i.z,i.x,i.y)}}class c0{constructor(t,i,r,a,n){this.overscaledZ=t,this.wrap=i,this.canonical=new cQ(r,+a,+n),this.key=0===i&&t===r?this.canonical.key:c1(i,t,r,a,n)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){let i=this.canonical.z-t;return t>this.canonical.z?new c0(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new c0(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(t,i=!0){if(this.overscaledZ===t&&i)return this.key;if(t>this.canonical.z)return c1(this.wrap*i,t,this.canonical.z,this.canonical.x,this.canonical.y);{let r=this.canonical.z-t;return c1(this.wrap*i,t,t,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;let i=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.z<this.canonical.z&&t.canonical.x===this.canonical.x>>i&&t.canonical.y===this.canonical.y>>i}children(t){if(this.overscaledZ>=t)return[new c0(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=2*this.canonical.x,a=2*this.canonical.y;return[new c0(i,this.wrap,i,r,a),new c0(i,this.wrap,i,r+1,a),new c0(i,this.wrap,i,r,a+1),new c0(i,this.wrap,i,r+1,a+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new c0(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new c0(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new cJ(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function c1(t,i,r,a,n){let o=1<<Math.min(r,22),s=n%o*o+a%o;return t&&r<22&&(s+=o*o*((t<0?-2*t-1:2*t)%(1<<2*(22-r)))),16*(32*s+r)+(i-r)}let c2=[t=>{let i=t.canonical.x-1,r=t.wrap;return i<0&&(i=(1<<t.canonical.z)-1,r--),new c0(t.overscaledZ,r,t.canonical.z,i,t.canonical.y)},t=>{let i=t.canonical.x+1,r=t.wrap;return i===1<<t.canonical.z&&(i=0,r++),new c0(t.overscaledZ,r,t.canonical.z,i,t.canonical.y)},t=>new c0(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<<t.canonical.z:t.canonical.y)-1),t=>new c0(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)];function c3(t,i){if(!i.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:i};let r=Math.pow(2,-t.z),a=t.x*r,n=(t.x+1)*r,o=t.y*r,s=(t.y+1)*r,l=aO(a),h=aO(n),u=aF(o),c=aF(s),d=i.project(l,u),p=i.project(h,u),f=i.project(h,c),_=i.project(l,c),m=Math.min(d.x,p.x,f.x,_.x),g=Math.min(d.y,p.y,f.y,_.y),y=Math.max(d.x,p.x,f.x,_.x),x=Math.max(d.y,p.y,f.y,_.y),v=r/16;function b(t,r,a,n,o,s){let l=(a+o)/2,h=(n+s)/2,u=i.project(aO(l),aF(h)),c=Math.max(0,m-u.x,g-u.y,u.x-y,u.y-x);m=Math.min(m,u.x),y=Math.max(y,u.x),g=Math.min(g,u.y),x=Math.max(x,u.y),c>v&&(b(t,u,a,n,l,h),b(u,r,l,h,o,s))}b(d,p,a,o,n,o),b(p,f,n,o,n,s),b(f,_,n,s,a,s),b(_,d,a,s,a,o),m-=v,g-=v,y+=v,x+=v;let w=1/Math.max(y-m,x-g);return{scale:w,x:m*w,y:g*w,x2:y*w,y2:x*w,projection:i}}function c4(t,i,r,a,n,o,s,l,h){if("globe"===h.name)return cA(t,i,new cQ(r,a,n),!1);let u=c3({z:r,x:a,y:n},h);return new cg([(o+u.x/u.scale)*i,i*(u.y/u.scale),s],[(o+u.x2/u.scale)*i,i*(u.y2/u.scale),l])}function c5(t,{x:i,y:r},a=0){return new tg(((i-a)*t.scale-t.x)*8192,(r*t.scale-t.y)*8192)}function c6(t,i,r=0){return eO(((i.x-r)*t.scale-t.x)*8192,(i.y*t.scale-t.y)*8192,i.z*s2(aF(i.y)))}oC(cQ,"CanonicalTileID"),oC(c0,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});let c8=ef(new Float32Array(16));class c9{constructor(t){this.spec=t,this.name=t.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(t,i){return{x:0,y:0,z:0}}unproject(t,i){return new s0(0,0)}projectTilePoint(t,i,r){return{x:t,y:i,z:0}}locationPoint(t,i,r,a=!0){return t._coordinatePoint(t.locationCoordinate(i,r),a)}pixelsPerMeter(t,i){return 1/s2(t)*i}pixelSpaceConversion(t,i,r){return 1}farthestPixelDistance(t){return cK(t,t.pixelsPerMeter)}pointCoordinate(t,i,r,a){let n=new tg(i,Math.max(t.horizonLineFromTop(!1),r));return t.rayIntersectionCoordinate(t.pointRayIntersection(n,a))}pointCoordinate3D(t,i,r){let a=new tg(i,r);if(t.elevation)return t.elevation.pointCoordinate(a);{let i=this.pointCoordinate(t,a.x,a.y,0);return[i.x,i.y,i.z]}}isPointAboveHorizon(t,i){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,i.x,i.y);let r=t.horizonLineFromTop();return i.y<r}createInversionMatrix(t,i){return c8}createTileMatrix(t,i,r){let a,n,o,s=r.canonical,l=ef(new Float64Array(16));if(this.isReprojectedInTileSpace){let h=c3(s,this);a=1,n=h.x+r.wrap*h.scale,o=h.y,ex(l,l,[a/h.scale,a/h.scale,t.pixelsPerMeter/i])}else a=i/t.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*r.wrap)*a,o=s.y*a;return ey(l,l,[n,o,0]),ex(l,l,[a/8192,a/8192,1]),l}upVector(t,i,r){return[0,0,1]}upVectorScale(t,i,r){return{metersToTile:1}}}class c7 extends c9{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];let[i,r]=this.parallels=t.parallels||[29.5,45.5],a=Math.sin(i*tA);this.n=(a+Math.sin(r*tA))/2,this.c=1+a*(2*this.n-a),this.r0=Math.sqrt(this.c)/this.n}project(t,i){let{n:r,c:a,r0:n}=this,o=(t-this.center[0])*tA,s=Math.sqrt(a-2*r*Math.sin(i*tA))/r;return{x:s*Math.sin(o*r),y:s*Math.cos(o*r)-n,z:0}}unproject(t,i){let{n:r,c:a,r0:n}=this,o=n+i,s=Math.atan2(t,Math.abs(o))*Math.sign(o);
7o*r<0&&(s-=Math.PI*Math.sign(t)*Math.sign(o));let l=this.center[0]*tA*r,h=tL((s=tF(s,-Math.PI-l,Math.PI-l))/r*tC+this.center[0],-180,180),u=Math.asin(tL((a-(t*t+o*o)*r*r)/(2*r),-1,1));return new s0(h,tL(u*tC,-85.051129,85.051129))}}let de=Math.sqrt(3)/2;class dt extends c9{project(t,i){i=i/180*Math.PI,t=t/180*Math.PI;let r=Math.asin(de*Math.sin(i)),a=r*r,n=a*a*a;return{x:.5*(t*Math.cos(r)/(de*(1.340264+-.24331799999999998*a+n*(.0062510000000000005+.034164*a)))/Math.PI+.5),y:1-.5*(r*(1.340264+-.081106*a+n*(893e-6+.003796*a))/Math.PI+1),z:0}}unproject(t,i){t=(2*t-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,a=r*r,n=a*a*a;for(let t,o,s=0;s<12&&(o=r*(1.340264+-.081106*a+n*(893e-6+.003796*a))-i,n=(a=(r=tL(r-(t=o/(1.340264+-.24331799999999998*a+n*(.0062510000000000005+.034164*a))),-Math.PI/3,Math.PI/3))*r)*a*a,!(1e-12>Math.abs(t)));++s);let o=de*t*(1.340264+-.24331799999999998*a+n*(.0062510000000000005+.034164*a))/Math.cos(r),s=Math.asin(Math.sin(r)/de);return new s0(tL(180*o/Math.PI,-180,180),tL(180*s/Math.PI,-85.051129,85.051129))}}class di extends c9{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,i){return{x:.5+t/360,y:.5-i/360,z:0}}unproject(t,i){return new s0(360*(t-.5),tL(360*(.5-i),-85.051129,85.051129))}}let dr=Math.PI/2;function da(t){return Math.tan((dr+t)/2)}class dn extends c9{constructor(t){super(t),this.center=t.center||[0,30];let[i,r]=this.parallels=t.parallels||[30,30],a=i*tA,n=r*tA;this.southernCenter=a+n<0,this.southernCenter&&(a=-a,n=-n);let o=Math.cos(a),s=da(a);this.n=a===n?Math.sin(a):Math.log(o/Math.cos(n))/Math.log(da(n)/s),this.f=o*Math.pow(da(a),this.n)/this.n}project(t,i){i*=tA,this.southernCenter&&(i=-i),t=(t-this.center[0])*tA;let{n:r,f:a}=this;a>0?i<-dr+1e-6&&(i=-dr+1e-6):i>dr-1e-6&&(i=dr-1e-6);let n=a/Math.pow(da(i),r),o=n*Math.sin(r*t),s=a-n*Math.cos(r*t);return o=.5*(o/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:o,y:this.southernCenter?s:1-s,z:0}}unproject(t,i){t=(2*t-.5)*Math.PI,this.southernCenter&&(i=1-i);let{n:r,f:a}=this,n=a-(i=(2*(1-i)-.5)*Math.PI),o=Math.sign(n),s=Math.sign(r)*Math.sqrt(t*t+n*n),l=Math.atan2(t,Math.abs(n))*o;n*r<0&&(l-=Math.PI*Math.sign(t)*o);let h=tL(l/r*tC+this.center[0],-180,180),u=tL((2*Math.atan(Math.pow(a/s,1/r))-dr)*tC,-85.051129,85.051129);return new s0(h,this.southernCenter?-u:u)}}class ds extends c9{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,i){return{x:az(t),y:aL(i),z:0}}unproject(t,i){return new s0(aO(t),aF(i))}}let dl=85.051129*tA;class dh extends c9{project(t,i){let r=(i*=tA)*i,a=r*r;return{x:.5*((t*=tA)*(.8707-.131979*r+a*(a*(.003971*r-.001529*a)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+r*(.015085+a*(.028874*r-.044475-.005916*a)))/Math.PI+1),z:0}}unproject(t,i){t=(2*t-.5)*Math.PI;let r=i=(2*(1-i)-1)*Math.PI,a=25,n=0,o=r*r;do{let t=(o=r*r)*o;n=(r*(1.007226+o*(.015085+t*(.028874*o-.044475-.005916*t)))-i)/(1.007226+o*(.045255+t*(.259866*o-.311325-.005916*11*t))),r=tL(r-n,-dl,dl)}while(Math.abs(n)>1e-6&&--a>0);return new s0(tL(t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))*tC,-180,180),r*tC)}}let du=85.051129*tA;class dc extends c9{project(t,i){i*=tA,t*=tA;let r=Math.cos(i),a=Math.acos(r*Math.cos(t/2)),n=Math.sin(a)/a;return{x:.5*((.5*(2/Math.PI*t+2*r*Math.sin(t/2)/n)||0)/Math.PI+.5),y:1-.5*((.5*(i+Math.sin(i)/n)||0)/Math.PI+1),z:0}}unproject(t,i){let r=t=(2*t-.5)*Math.PI,a=i=(2*(1-i)-1)*Math.PI,n=25,o=0,s=0;do{let n=Math.cos(a),l=Math.sin(a),h=2*l*n,u=l*l,c=n*n,d=Math.cos(r/2),p=Math.sin(r/2),f=2*d*p,_=p*p,m=1-c*d*d,g=m?1/m:0,y=m?Math.acos(n*d)*Math.sqrt(1/m):0,x=.5*(2*y*n*p+2*r/Math.PI)-t,v=.5*(y*l+a)-i,b=.5*g*(c*_+y*n*d*u)+1/Math.PI,w=g*(f*h/4-y*l*p),T=.125*g*(h*p-y*l*c*f),E=.5*g*(u*d+y*_*n)+.5,S=w*T-E*b;o=(v*w-x*E)/S,s=(x*T-v*b)/S,r=tL(r-o,-Math.PI,Math.PI),a=tL(a-s,-du,du)}while((Math.abs(o)>1e-6||Math.abs(s)>1e-6)&&--n>0);return new s0(r*tC,a*tC)}}class dd extends c9{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(this.parallels[0]*tA)),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,i){let{scale:r,cosPhi:a}=this;return{x:t*tA*a*r+.5,y:-Math.sin(i*tA)/a*r+.5,z:0}}unproject(t,i){let{scale:r,cosPhi:a}=this,n=tL((t-.5)/r*tC/a,-180,180),o=Math.asin(tL(-(i-.5)/r*a,-1,1));return new s0(n,tL(o*tC,-85.051129,85.051129))}}class dp extends ds{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,i,r){let a=cR(t,i,r);return eQ(a,a,cz(cT(r))),{x:a[0],y:a[1],z:a[2]}}locationPoint(t,i,r){let a=sQ(i.lat,i.lng),n=eW([],a),o=r?t._centerAltitude+r:t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(i),t._centerAltitude):t._centerAltitude;eG(a,a,n,1/s2(0)*8192*o);let s=ef(new Float64Array(16));return eg(s,t.pixelMatrix,t.globeMatrix),eQ(a,a,s),new tg(a[0],a[1])}pixelsPerMeter(t,i){return 1/s2(0)*i}pixelSpaceConversion(t,i,r){let a=1/s2(t)*i,n=rG(1/s2(45)*i,a,r);return this.pixelsPerMeter(t,i)/n}createTileMatrix(t,i,r){let a=cL(cT(r.canonical));return eg(new Float64Array(16),t.globeMatrix,a)}createInversionMatrix(t,i){let{center:r}=t,a=cz(cT(i));return eb(a,a,r.lng*tA),ev(a,a,r.lat*tA),ex(a,a,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(a)}pointCoordinate(t,i,r,a){return cv(t,i,r,!0)||new s8(0,0)}pointCoordinate3D(t,i,r){let a=this.pointCoordinate(t,i,r,0);return[a.x,a.y,a.z]}isPointAboveHorizon(t,i){return!cv(t,i.x,i.y,!1)}farthestPixelDistance(t){let i=function(t,i){let r,a=t.cameraToCenterDistance,n=t._centerAltitude*i,o=t._camera,s=t._camera.forward(),l=eB([],ej([],s,-a),[0,0,n]),h=t.worldSize/(2*Math.PI),u=[0,0,-h],c=t.width/t.height,d=Math.tan(t.fovAboveCenter),p=ej([],o.up(),d),f=ej([],o.r
7ight(),d*c),_=eW([],eB([],eB([],s,p),f)),m=[];if(new ch(l,_).closestPointOnSphere(u,h,m)){let i=ek([],eB([],m,u),l);r=Math.cos(t.fovAboveCenter)*eL(i)}else{let t=ek([],l,u),i=ek([],u,l);eW(i,i);let a=eL(t)-h,n=Math.acos((r=Math.sqrt(a*(a+2*h)))/(h+a))-Math.acos(eX(s,i));r*=Math.cos(n)}return 1.01*r}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=cN(t.zoom);if(r>0){let a=cK(t,1/s2(t.center.lat)*t.worldSize);return rG(i,a+t.worldSize/(2*Math.PI)*(1-Math.cos(Math.max(t.width,t.height)/t.worldSize*Math.PI)),Math.pow(r,10))}return i}upVector(t,i,r){return cR(i,r,t,1)}upVectorScale(t){return{metersToTile:cy(cD(cT(t)))}}}function df(t){let i=t.parallels,r=!!i&&.01>Math.abs(i[0]+i[1]);switch(t.name){case"mercator":return new ds(t);case"equirectangular":return new di(t);case"naturalEarth":return new dh(t);case"equalEarth":return new dt(t);case"winkelTripel":return new dc(t);case"albers":return r?new dd(t):new c7(t);case"lambertConformalConic":return r?new dd(t):new dn(t);case"globe":return new dp(t)}throw Error(`Invalid projection name: ${t.name}`)}let d_=Number.MAX_SAFE_INTEGER,dm=d_-1;function dg(t,i,r,a){return t.order<i||t.order===d_||!(t.clipMask&r)||function(t,i){if(0===i.length)return!1;let r=t;for(;""!==r;){if(i.includes(r))return!1;r=sv(r)}return!0}(a,t.clipScope)}class dy{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new tg(1/0,1/0),max:new tg(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,i=!1){let r=dT(new tg(0,0),new tg(8192,8192),t),a=[];if(i&&!db(r,this._globalClipBounds))return a;for(let i of this._activeRegions){if(i.hiddenByOverlap||!db(r,i))continue;let n=function(t,i,r){let a=1<<r.canonical.z,n=((i.x-r.wrap)*a-r.canonical.x)*8192,o=(i.y*a-r.canonical.y)*8192;return{min:new tg(((t.x-r.wrap)*a-r.canonical.x)*8192,(t.y*a-r.canonical.y)*8192),max:new tg(n,o)}}(i.min,i.max,t);a.push({min:n.min,max:n.max,sourceId:this._sourceIds[i.priority],footprint:i.footprint,footprintTileId:i.tileId,order:i.order,clipMask:i.clipMask,clipScope:i.clipScope})}return a}setSources(t){this._setSources(t.map(t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{let i=[];for(let r of t.cache.getVisibleCoordinates()){let a=t.cache.getTile(r).buckets[t.layer];a&&a.updateFootprints(r.toUnwrapped(),i)}return i},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope})))}_addSource(t){let i=t.getFootprints();if(0===i.length)return;let r=t.getOrder(),a=t.getClipMask(),n=t.getClipScope();for(let t of i){if(!t.footprint)continue;let i=dT(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:i.min,max:i.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:r,clipMask:a,clipScope:n})}this._sourceIds.push(t.getSourceId())}_computeReplacement(){this._activeRegions.sort((t,i)=>t.priority-i.priority||dx(t.min,i.min)||dx(t.max,i.max)||t.order-i.order||t.clipMask-i.clipMask||function(t,i){let r=(t,i)=>t+i;return t.length-i.length||t.reduce(r,"").localeCompare(i.reduce(r,""))}(t.clipScope,i.clipScope));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let i=0;for(;!t&&i!==this._activeRegions.length;){let r=this._activeRegions[i],a=this._prevRegions[i];t=r.priority!==a.priority||!dv(r,a)||r.order!==a.order||r.clipMask!==a.clipMask||!ty(r.clipScope,a.clipScope),this._activeRegions[i].hiddenByOverlap=a.hiddenByOverlap,++i}}if(t){for(let t of(++this._updateTime,this._activeRegions))t.order!==d_&&(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));let t=t=>{let i=this._activeRegions;if(t>=i.length)return t;let r=i[t].priority;for(;t<i.length&&i[t].priority===r;)++t;return t};if(this._sourceIds.length>1){let i=0,r=t(0);for(;i!==r;){let a=i,n=i;for(;a!==r;){let t=this._activeRegions[a];t.hiddenByOverlap=!1;for(let i=0;i<n;i++){let r=this._activeRegions[i];if(!r.hiddenByOverlap&&t.order===d_&&db(t,r)&&(t.hiddenByOverlap=function t(i,r,a,n){if(!i||!a)return!1;let o=i.vertices;if(!r.canonical.equals(n.canonical)||r.wrap!==n.wrap){if(a.vertices.length<i.vertices.length)return t(a,n,i,r);let s=r.canonical,l=n.canonical,h=Math.pow(2,l.z-s.z);o=i.vertices.map(t=>new tg((t.x+8192*s.x)*h-8192*l.x,(t.y+8192*s.y)*h-8192*l.y))}return dE(a,o,i.indices,0,i.indices.length,0,0)}(t.footprint,t.tileId,r.footprint,r.tileId),t.hiddenByOverlap))break}++a}r=t(i=r)}}}}_setSources(t){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let i=t.length-1;i>=0;i--)this._addSource(t[i]);this._computeReplacement()}}function dx(t,i){return t.x-i.x||t.y-i.y}function dv(t,i){return 0===dx(t.min,i.min)&&0===dx(t.max,i.max)}function db(t,i){return!(t.min.x>i.max.x||t.max.x<i.min.x||t.min.y>i.max.y||t.max.y<i.min.y)}function dw(t,i){if(t.length!==i.length)return!1;for(let r=0;r<t.length;
7r++)if(t[r].sourceId!==i[r].sourceId||!dv(t[r],i[r])||t[r].order!==i[r].order||t[r].clipMask!==i[r].clipMask||!ty(t[r].clipScope,i[r].clipScope))return!1;return!0}function dT(t,i,r){let a=1/(1<<r.canonical.z),n=(1220703125e-13*i.x+r.canonical.x)*a+r.wrap,o=(1220703125e-13*i.y+r.canonical.y)*a;return{min:new tg((1220703125e-13*t.x+r.canonical.x)*a+r.wrap,(1220703125e-13*t.y+r.canonical.y)*a),max:new tg(n,o)}}function dE(t,i,r,a,n,o,s){let l=t.indices,h=t.vertices,u=[];for(let c=a;c<a+n;c+=3){let a=i[r[c+0]+o],n=i[r[c+1]+o],d=i[r[c+2]+o],p=Math.min(a.x,n.x,d.x),f=Math.max(a.x,n.x,d.x),_=Math.min(a.y,n.y,d.y),m=Math.max(a.y,n.y,d.y);u.length=0,t.grid.query(new tg(p,_),new tg(f,m),u);for(let t=0;t<u.length;t++){let i=u[t];if(hQ(h[l[3*i+0]],h[l[3*i+1]],h[l[3*i+2]],a,n,d,s))return!0}}return!1}function dS(t,i,r,a){let n=Math.pow(2,a.z-r.z);return new tg((t+8192*r.x)*n-8192*a.x,(i+8192*r.y)*n-8192*a.y)}function dI(t,i){let r=[];i.grid.queryPoint(t,r);let a=i.indices,n=i.vertices;for(let i=0;i<r.length;i++){let o=r[i];if(hW([n[a[3*o+0]],n[a[3*o+1]],n[a[3*o+2]]],t))return!0}return!1}class dA{constructor(t,i){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=i,this.appearances=t;let r=t.map(t=>(function(t){if(!t.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};let i=t.condition.expression;return{featureDependent:!no(i),stateDependent:!ns(i),zoomDependent:!nh(i,["zoom"]),pitchDependent:!nh(i,["pitch"]),brightnessDependent:!nh(i,["brightness","measure-light"]),worldviewDependent:!nh(i,["worldview"])}})(t));this.anyFeatureDependent=r.some(t=>t.featureDependent),this.anyStateDependent=r.some(t=>t.stateDependent)}update(t,i){let r=this.lastParams,a=!r||r.zoom!==t.zoom||r.pitch!==(t.pitch||0)||r.brightness!==(t.brightness||0)||r.worldview!==t.worldview;this.lastParams={zoom:t.zoom,pitch:t.pitch||0,brightness:t.brightness||0,worldview:t.worldview};let n=i&&this.anyStateDependent;if(!a&&!n&&-2!==this.lastAllFeaturesIndex)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!n){let i=this.evaluateAllFeatures(t);return i===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=i,{kind:"all-features",appearanceIndex:i})}return{kind:"per-feature"}}evaluateAllFeatures(t){for(let i=0;i<this.appearances.length;i++){let r=this.appearances[i];if(r.condition&&r.condition.evaluate(t,void 0,void 0,void 0))return i}return -1}}let dC=hN.types,dM=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function dR(t,i,r,a,n,o,s,l,h,u,c,d,p){let f=l?Math.min(32640,Math.round(l[0])):0,_=l?Math.min(32640,Math.round(l[1])):0;t.emplaceBack(i,r,Math.round(32*a),Math.round(32*n),o,s,(f<<1)+ +!!h,0+(_<<1),16*u,16*c,256*d,256*p)}function dD(t,i,r){t.emplaceBack(i,r)}function dP(t,i,r,a,n,o,s){t.emplaceBack(i,r,a,n,o,s)}function dz(t,i,r,a,n){let o=5*i+2;t.float32[o+0]=r,t.float32[o+1]=a,t.float32[o+2]=n}function dL(t,i,r,a,n){t.emplaceBack(i,r,a,n),t.emplaceBack(i,r,a,n),t.emplaceBack(i,r,a,n),t.emplaceBack(i,r,a,n)}class dO{constructor(t){this.layoutVertexArray=new lb,this.indexArray=new lR,this.programConfigurations=t,this.segments=new l9,this.dynamicLayoutVertexArray=new lT,this.opacityVertexArray=new lE,this.placedSymbolArray=new lW,this.iconTransitioningVertexArray=new lS,this.globeExtVertexArray=new lw,this.zOffsetVertexArray=new lc,this.orientationVertexArray=new lz,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new lc,this.featureIdBuffer=null,this.cachedBatchIndices=null,this.cachedBatchSegments=null}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}getBatchGrouping(t){let i=t.get().length===this.segments.get().length;if(i&&this.cachedBatchIndices&&this.cachedBatchSegments)return{batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};let r=new Map;for(let i of t.get()){let t=void 0!==i.batchIndex?i.batchIndex:0;r.has(t)||r.set(t,[]),r.get(t).push(i)}let a=Array.from(r.keys()).sort((t,i)=>t-i),n=new Map;for(let t of a){let i=r.get(t);n.set(t,new l9(i))}return i&&(this.cachedBatchIndices=a,this.cachedBatchSegments=n),{batchIndices:a,batchSegments:n}}
7snapshotSymbolVertexData(t,i){let r=12*t;return this.layoutVertexArray.uint16.slice(r,r+12*i)}restoreSymbolVertexData(t,i){this.layoutVertexArray.uint16.set(i,12*t)}snapshotIconTransitioningVertexData(t,i){let r=2*t;return this.iconTransitioningVertexArray.uint16.slice(r,r+2*i)}restoreIconTransitioningVertexData(t,i){this.iconTransitioningVertexArray.uint16.set(i,2*t)}updateSymbolVertexData(t,i,r,a,n,o,s,l,h,u,c,d,p){let f=this.layoutVertexArray.uint16,_=12*t;f[_]=i,f[_+1]=r,f[_+2]=a,f[_+3]=n,f[_+4]=o,f[_+5]=s,f[_+6]=l,f[_+7]=h,f[_+8]=u,f[_+9]=c,f[_+10]=d,f[_+11]=p}upload(t,i,r,a,n,o){this.isEmpty()||(r&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ud.members,!!o),this.indexBuffer=t.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,uf.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,dM,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,uy.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,up.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,u_.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=t.createVertexBuffer(this.orientationVertexArray,ug.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray.length>0&&(this.featureIdBuffer=t.createVertexBuffer(this.featureIdArray,um.members,!1))),(r||a)&&(this.programConfigurations.upload(t),this.uboBinder&&this.uboBinder.upload(t)))}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())}}oC(dO,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class dF{constructor(t,i,r){this.layoutVertexArray=new t,this.layoutAttributes=i,this.indexArray=new r,this.segments=new l9,this.collisionVertexArray=new lM,this.collisionVertexArrayExt=new lT}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,ux.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,uv.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.de
7stroy())}}oC(dF,"CollisionBuffers");class dB{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ef([]),this.placementViewportMatrix=ef([]);let i=this.layers[0]._unevaluatedLayout._values;this.worldview=t.worldview,this.localizable=t.localizable,this.maxUniformBufferBindings=t.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=t.maxUniformBlockSizeDwords,this.textSizeData=uF(this.zoom,i["text-size"],this.worldview,t.availableImages),this.iconSizeData=uF(this.zoom,i["icon-size"],this.worldview,t.availableImages);let r=this.layers[0].layout,a=r.get("symbol-sort-key"),n=r.get("symbol-z-order");this.lut=t.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==a.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(t=>uL[t]),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.sourceID=t.sourceID,this.projection=t.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(t){let i=this.layers[0].getAppearances();if(!i||0===i.length)return!1;let r=Array.isArray(t)?t:[t];return i.some(t=>r.some(i=>t.hasLayoutProperty(i)))}getAppearanceFeatureData(t){return this.featureAppearanceData.get(t)}createArrays(){this.text=new dO(new hS(this.layers,{zoom:this.zoom,lut:this.lut},t=>t.startsWith("text")||t.startsWith("symbol"))),this.icon=new dO(new hS(this.layers,{zoom:this.zoom,lut:this.lut},t=>t.startsWith("icon")||t.startsWith("symbol"))),this.text.uboBinder=new uR(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new uR(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.glyphOffsetArray=new lK,this.lineVertexArray=new lQ,this.symbolInstances=new lY}calculateGlyphDependencies(t,i,r,a,n){for(let r of t){let t=r.codePointAt(0);if(void 0===t)break;if(i[t]=!0,a&&n&&t<=65535){let t=uD[r];t&&(i[t.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(t,i,r,a,n,o,s){if(!t.hasLayoutProperty("icon-size"))return s*o;let l=1,h=t.getUnevaluatedLayoutProperty("icon-size"),u=uF(this.zoom,h,this.worldview,n),c=uk(u,i);if("constant"!==u.kind&&"camera"!==u.kind||(l=c.uSize),"composite"===u.kind){let{minZoom:t,maxZoom:i}=u,o=h.possiblyEvaluate(new o0(t,{worldview:this.worldview}),a),s=h.possiblyEvaluate(new o0(i,{worldview:this.worldview}),a),d=o.evaluate(r,{},a,n);l=d+(s.evaluate(r,{},a,n)-d)*c.uSizeT}return"source"===u.kind&&(l=h.possiblyEvaluate(new o0(this.zoom,{worldview:this.worldview}),a).evaluate(r,{},a,n)),l*o}updateFootprints(t,i){}updateReplacement(t,i){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;let r=i.getReplacementRegionsForTile(t.toUnwrapped(),!0);return!dw(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(t){return"string"==typeof t?au.build(t):t}populate(t,i,r,a){let n=this.layers[0],o=n.layout,s="globe"===this.projection.name,l=o.get("text-font"),h=o.get("text-field"),u=o.get("icon-image"),[c,d]=o.get("icon-size-scale-range"),p=tL(i.scaleFactor||1,c,d),[f,_]=o.get("text-size-scale-range"),m=tL(i.scaleFactor||1,f,_),g=("constant"!==h.value.kind||h.value.value instanceof al&&!h.value.value.isEmpty()||h.value.value.toString().length>0)&&("constant"!==l.value.kind||l.value.value.length>0),y="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,x=this.hasAnyAppearanceLayoutProperty("icon-image"),v=o.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!g&&!y&&!x)return;let b=i.iconDependencies,w=i.glyphDependencies,T=i.availableImages,E=new o0(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),S=t=>{let i=t.id.toString();b.has(i)?b.get(i).push(t):b.set(i,[t])};for(let i of t){let t,h,{feature:u,id:c,index:d,sourceLayerIndex:f}=i,_=n._featureFilter.needGeometry,I=lt(u,_);if(!n._featureFilter.filter(E,I,r))continue;if(_||(I.geometry=le(u,r,a)),s&&1!==u.type&&r.z<=5){let t=I.geometry,i=(t,i)=>.98078528056>eX(cR(t.x,t.y,r,1),cR(i.x,i.y,r,1));for(let r=0;r<t.length;r++)t[r]=function(t,i){let r=t[0],a=[r];for(let n=1;n<t.length;n++){let o=t[n];(function t(i,r,a,n){if(n(r,a)){let o=r.add(a)._mult(.5);t(i,r,o,n),t(i,o,a,n)}else i.push(a)}
7)(a,r,o,i),r=o}return a}(t[r],i)}if(g){let i=n.getValueAndResolveTokens("text-field",I,r,T),a=al.factory(i);(function(t){for(let i of t.sections)if(function(t){for(let i of t)if(oV(i.charCodeAt(0)))return!0;return!1}(i.text))return!0;return!1})(a)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===oY()||this.hasRTLText&&oQ.isParsed())&&(t=function(t,i,r){return t.sections.forEach(t=>{t.text=function(t,i,r){let a=i.layout.get("text-transform").evaluate(r,{});return"uppercase"===a?t=t.toLocaleUpperCase():"lowercase"===a&&(t=t.toLocaleLowerCase()),t}(t.text,i,r)}),t}(a,n,I))}if(y){let t=n.getValueAndResolveTokens("icon-image",I,r,T);h=this.getResolvedImageFromTokens(t)}let A=this.layers[0],C=!1;if(!h&&x){for(let t of A.getAppearances())if(t.getLayoutProperty("icon-image")){let i=A.getAppearanceValueAndResolveTokens(t,"icon-image",I,r,T);if(i){h=this.getResolvedImageFromTokens(i),C=!0;break}}}if(!t&&!h)continue;let M=this.sortFeaturesByKey?v.evaluate(I,{},r):void 0,R={id:c,text:t,icon:h,index:d,sourceLayerIndex:f,geometry:I.geometry,properties:u.properties,type:dC[u.type],sortKey:M};if(this.features.push(R),this.featureAppearanceData.set(d,{id:c,properties:u.properties,usesAppearanceIconAsPlaceholder:C}),h){let t=A._unevaluatedLayout._values,{iconPrimary:i,iconSecondary:a}=ca(h,this.iconSizeData,t["icon-size"],r,this.zoom,R,this.pixelRatio,p,this.worldview,T);S(i),a&&(this.hasAnySecondaryIcon=!0,S(a))}let D=A.getAppearances();if(0!==D.length&&D.forEach(t=>{if(!t.getLayoutProperty("icon-image"))return;let{iconPrimary:i,iconSecondary:a}=this.getCombinedIconVariants(t,A,I,r,T,R,p);i&&(S(i),a&&(this.hasAnySecondaryIcon=!0,S(a)))}),t){let i=l.evaluate(I,{},r).join(","),a="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");for(let r of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.includes(uL.vertical),t.sections))if(r.image){let t=r.image.getPrimary().scaleSelf(this.pixelRatio*m),i=t.id.toString(),a=b.get(i)||[];a.push(t),b.set(i,a)}else{let n=function(t){for(let i of t)if(function(t){return!(746!==t&&747!==t&&(t<4352||!(t>=12704&&t<=12735||t>=12544&&t<=12591||t>=65072&&t<=65103&&!(t>=65097&&t<=65103)||t>=63744&&t<=64255||t>=13056&&t<=13311||t>=11904&&t<=12031||t>=12736&&t<=12783||!(!oL(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||oB(t)||ok(t)||t>=12800&&t<=13055||t>=12592&&t<=12687||t>=43360&&t<=43391||t>=55216&&t<=55295||t>=4352&&t<=4607||oN(t)||oO(t)||t>=12272&&t<=12287||t>=12688&&t<=12703||t>=12032&&t<=12255||t>=12784&&t<=12799||oF(t)&&12540!==t||!(!(t>=65280&&t<=65519)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!(t>=65104&&t<=65135)||t>=65112&&t<=65118||t>=65123&&t<=65126)||t>=5120&&t<=5759||t>=6320&&t<=6399||t>=65040&&t<=65055||t>=19904&&t<=19967||t>=40960&&t<=42127||t>=42128&&t<=42191)))}(i.charCodeAt(0)))return!0;return!1}(t.toString()),o=r.fontStack||i,s=w[o]=w[o]||{};this.calculateGlyphDependencies(r.text,s,a,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){let i={},r={},a=[],n=0;function o(i){a.push(t[i]),n++}function s(t,i,n){let o=r[t];return delete r[t],r[i]=o,a[o].geometry[0].pop(),a[o].geometry[0]=a[o].geometry[0].concat(n[0]),o}function l(t,r,n){let o=i[r];return delete i[r],i[t]=o,a[o].geometry[0].shift(),a[o].geometry[0]=n[0].concat(a[o].geometry[0]),o}function h(t,i,r){let a=r?i[0].at(-1):i[0][0];return`${t}:${a.x}:${a.y}`}for(let u=0;u<t.length;u++){let c=t[u],d=c.geometry,p=c.text?c.text.toString():null;if(!p||d.length>1){o(u);continue}let f=h(p,d,!1),_=h(p,d,!0);if(f in r&&_ in i&&r[f]!==i[_]){let t=l(f,_,d),n=s(f,_,a[t].geometry);delete i[f],delete r[_],r[h(p,a[n].geometry,!0)]=n,a[t].geometry=null}else f in r?s(f,_,d):_ in i?l(f,_,d):(o(u),i[f]=n-1,r[_]=n-1)}return a.filter(t=>t.geometry)}(this.features)),"hd-road-markup"===o.get("symbol-elevation-reference")?(this.elevationType="road",this.hdExt&&i.elevationFeatures&&i.elevationFeatures.length>0&&this.hdExt.addElevationFeatures(i.elevationFeatures)):o.get("symbol-z-elevate")&&(this.elevationType="offset"),"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((t,i)=>t.sortKey-i.sortKey)}getCombinedIconVariants(t,i,r,a,n,o,s){let l;if(t.hasLayoutProperty("icon-image")){let o=i.getAppearanceValueAndResolveTokens(t,"icon-image",r,a,n);l=this.getResolvedImageFromTokens(o)}else{let t=i.getValueAndResolveTokens("icon-image",r,a,n);l=this.getResolvedImageFromTokens(t)}if(l){let r=t.hasLayoutProperty("icon-size")?t.getUnevaluatedLayoutProperty("icon-size"):i._unevaluatedLayout._values["icon-size"],{iconPrimary:h,iconSecondary:u}=ca(l,uF(this.zoom,r,this.worldview,n),r,a,this.zoom,o,this.pixelRatio,s,this.worldview,n);return{iconPrimary:h,iconSecondary:u}}return{iconPrimary:void 0,iconSecondary:void 0}}getCombinedIconPrimary(t,i,r,a,n,o,s){return this.getCombinedIconVariants(t,i,r,a,n,o,s).iconPrimary}updateSymbolInstanceIconVertices(t,i,r,a,n,o){let{canonical:s,availableImages:l,globalProperties:h,layer:u,iconScaleFactor:c,featureState:d,layoutIconOffset:p,layoutIconSize:f,layoutIconRotate:_}=o;if(t.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(i.activeAppearanceIndex===r)return{vertexOffsetDelta:t.numIconVertices,hasChanges:!1};let m=r>=0?u.appearances[r]:null;if(m){let r={sortKey:void 0,text:void 0,icon:null,index:t.featureIndex,sourceLayerIndex:t.featureIndex,geometry:[],properties:i.properties,type:"Point",id:i.id},{iconPrimary:o,iconSecondary:g}=this.getCombinedIconVariants(m,u,a,s,l,r,c);if(!o)return{vertexOffsetDelta:0,hasChanges:!1};let y=o.toString(),x=this.iconAtlasPositions&&this.iconAtlasPositions.get(y);if(x){let{appearanceIconOffset:r,appearanceIconRotate:o}=function(t,i,r,a,n,o,s,l){let h=t.hasLayoutProperty("icon-offset")?i.getAppearanceValueAndResolveTokens(t,"icon-offset",r,a,[]):null,u=h&&Array.isArray(h)?h:n,c=t.hasLayoutProperty("icon-rotate")?i.getAppearanceValueAndResolveTokens(t,"icon-rotate",r,a,[]):null,d=t.hasLayoutProperty("icon-size")?i.getAppearanceValueAndResolveTokens(t,"icon-size",r,a,[]):null;return{appearanceIconOffset:u,appearanceIconRotate:"number"==typeof c?c:o,appearanceIconSize:"number"==typeof d?d*l:s}}(m,u,a,s,p,_,f,c),y=u.layout.get("icon-anchor").evaluate(a,d,s),v=function(t,i,r,a){let{horizontalAlign:n,verticalAlign:o}=uO(a),s=r[0]-t.displaySize[0]*n,l=r[1]-t.displaySize[1]*o;return{imagePrimary:t,imageSecondary:i,top:l,bottom:l+t.displaySize[1],left:s,right:s+t.displaySize[0]}}(x,g?this.iconAtlasPositions&&this.iconAtlasPositions.get(g.toString()):void 0,r,y),b=x.sdf,w=u.layout.get("icon-text-fit").constantOr("none");"none"!==w&&i.textShaping&&i.iconTextFitPadding&&i.fontScale&&(v=function(t,i,r,a,n,o){let s,l,h,u,c,d=t.imagePrimary;if(d.content){let t=d.content,i=d.pixelRatio||1;s=[t[0]/i,t[1]/i,d.displaySize[0]-t[2]/i,d.displaySize[1]-t[3]/i]}let p=i.left*o,f=i.right*o;"width"===r||"both"===r?(c=n[0]+p-a[3],h=n[0]+f+a[1]):h=(c=n[0]+(p+f-d.displaySize[0])/2)+d.displaySize[0];let _=i.top*o,m=i.bottom*o;return"height"===r||"both"===r?(l=n[1]+_-a[0],u=n[1]+m+a[2]):u=(l=n[1]+(_+m-d.displaySize[1])/2)+d.displaySize[1],{imagePrimary:d,imageSecondary:void 0,top:l,right:h,bottom:u,left:c,collisionPadding:s}}(v,i.textShaping,w,i.iconTextFitPadding,r,i.fontScale));
7let T=1+(Math.min(32640,Math.round(128*this.calculateEffectiveAppearanceIconSize(m,h.zoom,a,s,l,c,f)))<<1),E=function(t,i,r,a,n=1){let o=[],s=t.imagePrimary,l=s.pixelRatio,h=s.paddedRect.w-2,u=s.paddedRect.h-2,c=(t.right-t.left)*n,d=(t.bottom-t.top)*n,p=s.stretchX||[[0,h]],f=s.stretchY||[[0,u]],_=p.reduce(u9,0),m=f.reduce(u9,0),g=h-_,y=u-m,x=0,v=_,b=0,w=m,T=0,E=g,S=0,I=y;if(s.content&&a){let t=s.content;x=u7(p,0,t[0]),b=u7(f,0,t[1]),v=u7(p,t[0],t[2]),w=u7(f,t[1],t[3]),T=t[0]-x,S=t[1]-b,E=t[2]-t[0]-v,I=t[3]-t[1]-w}let A=(a,o,h,u)=>{var p,f,g,y;let A=(a.stretch-x)/v*c+t.left*n,C=(p=a.fixed-T,p-E*a.stretch/_),M=(o.stretch-b)/w*d+t.top*n,R=(f=o.fixed-S,f-I*o.stretch/m),D=(h.stretch-x)/v*c+t.left*n,P=(g=h.fixed-T,g-E*h.stretch/_),z=(u.stretch-b)/w*d+t.top*n,L=(y=u.fixed-S,y-I*u.stretch/m),O=new tg(A,M),F=new tg(D,M),B=new tg(D,z),k=new tg(A,z),N=new tg(C/l,R/l),V=new tg(P/l,L/l),U=i*Math.PI/180;if(U){let t=Math.sin(U),i=Math.cos(U),r=[i,-t,t,i];O._matMult(r),F._matMult(r),k._matMult(r),B._matMult(r)}let j=a.stretch+a.fixed,G=h.stretch+h.fixed,H=o.stretch+o.fixed,q=u.stretch+u.fixed,Z=t.imageSecondary;return{tl:O,tr:F,bl:k,br:B,texPrimary:{x:s.paddedRect.x+1+j,y:s.paddedRect.y+1+H,w:G-j,h:q-H},texSecondary:Z?{x:Z.paddedRect.x+1+j,y:Z.paddedRect.y+1+H,w:G-j,h:q-H}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:N,pixelOffsetBR:V,minFontScaleX:E/l/c,minFontScaleY:I/l/d,isSDF:r}};if(s.stretchX||s.stretchY){let t=ce(p,g,_),i=ce(f,y,m);for(let r=0;r<t.length-1;r++){let a=t[r],n=t[r+1];for(let t=0;t<i.length-1;t++)o.push(A(a,i[t],n,i[t+1]))}}else o.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:h+1},{fixed:0,stretch:u+1}));return o}(v,o,b,"none"!==w,c),S=this.icon.iconTransitioningVertexArray.length>0;i.isUsingAppearanceIconVertexData||(i.isUsingAppearanceIconVertexData=!0,i.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(n,t.numIconVertices),S&&(i.layoutBasedIconTransitioningVertexData=this.icon.snapshotIconTransitioningVertexData(n,t.numIconVertices)));let I=Math.floor(t.numIconVertices/4),A=Math.min(E.length,I),C=n,M=S?this.icon.iconTransitioningVertexArray.uint16:null;for(let r=0;r<A;++r){let a=E[r],n=i.layoutBasedIconVertexData[0]||t.tileAnchorX,o=i.layoutBasedIconVertexData[1]||t.tileAnchorY,s=16*a.pixelOffsetTL.x,l=16*a.pixelOffsetTL.y,h=16*a.pixelOffsetBR.x,u=16*a.pixelOffsetBR.y,c=16*a.minFontScaleX,d=16*a.minFontScaleY;if(this.icon.updateSymbolVertexData(C,n,o,Math.round(32*a.tl.x),Math.round(32*a.tl.y),a.texPrimary.x,a.texPrimary.y,0,T,s,l,c,d),this.icon.updateSymbolVertexData(C+1,n,o,Math.round(32*a.tr.x),Math.round(32*a.tr.y),a.texPrimary.x+a.texPrimary.w,a.texPrimary.y,0,T,h,l,c,d),this.icon.updateSymbolVertexData(C+2,n,o,Math.round(32*a.bl.x),Math.round(32*a.bl.y),a.texPrimary.x,a.texPrimary.y+a.texPrimary.h,0,T,s,u,c,d),this.icon.updateSymbolVertexData(C+3,n,o,Math.round(32*a.br.x),Math.round(32*a.br.y),a.texPrimary.x+a.texPrimary.w,a.texPrimary.y+a.texPrimary.h,0,T,h,u,c,d),M){let t=a.texSecondary?a.texSecondary:a.texPrimary,i=2*C;M[i]=t.x,M[i+1]=t.y,M[i+2]=t.x+t.w,M[i+3]=t.y,M[i+4]=t.x,M[i+5]=t.y+t.h,M[i+6]=t.x+t.w,M[i+7]=t.y+t.h}C+=4}let R=t.numIconVertices-4*A;for(let t=0;t<R;++t)this.icon.updateSymbolVertexData(C+t,0,0,0,0,0,0,0,0,0,0,0,0);return{vertexOffsetDelta:t.numIconVertices,hasChanges:!0}}}else{if(i.usesAppearanceIconAsPlaceholder)return this.icon.updateSymbolVertexData(n,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(n+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(n+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(n+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:t.numIconVertices,hasChanges:!0};if(i.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(n,i.layoutBasedIconVertexData),i.layoutBasedIconTransitioningVertexData&&this.icon.restoreIconTransitioningVertexData(n,i.layoutBasedIconTransitioningVertexData),i.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:i.layoutBasedIconVertexData.length/12,hasChanges:!0}}return{vertexOffsetDelta:t.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(t,i,r,a,n,o){let{canonical:s,layer:l,textScaleFactor:h,imageMap:u,featureState:c,layoutTextOffset:d,layoutTextSize:p,layoutTextRotate:f,layoutMinZoomSize:_,layoutMaxZoomSize:m,layoutTextSizeMinZoom:g,layoutTextSizeMaxZoom:y,availableImages:x}=o,v=t.numHorizontalGlyphVertices>0||t.numVerticalGlyphVertices>0;if(!v)return{vertexOffsetDelta:v?t.numHorizontalGlyphVertices+t.numVerticalGlyphVertices:0,hasChanges:!1};if(i.activeAppearanceIndex===r)return{vertexOffsetDelta:t.numHorizontalGlyphVertices+t.numVerticalGlyphVertices,hasChanges:!1};let b=r>=0?l.appearances[r]:null;if(b&&i.textShaping){var w,T;let r,{appearanceTextOffset:o,appearanceTextRotate:v,appearanceTextSize:E}=function(t,i,r,a,n,o,s){let l=t.hasLayoutProperty("text-offset")?i.getAppearanceValueAndResolveTokens(t,"text-offset",r,a,[]):null,h=l&&Array.isArray(l)?[24*l[0],24*l[1]]:n,u=t.hasLayoutProperty("text-rotate")?i.getAppearanceValueAndResolveTokens(t,"text-rotate",r,a,[]):null,c=t.hasLayoutProperty("text-size")?i.getAppearanceValueAndResolveTokens(t,"text-size",r,a,[]):null;return{appearanceTextOffset:h,appearanceTextRotate:"number"==typeof u?u:o,appearanceTextSize:"number"==typeof c?c:s}}(b,l,a,s,d,f,p);i.fontScale=E*i.textScaleFactor/24;let S=b.getUnevaluatedLayoutProperty("text-size"),I=this.textSizeData,A=g,C=y;b.hasLayoutProperty("text-size")&&(I=uF(this.zoom,S,this.worldview,x),A="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,C="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0);
7let M=i.textShaping.bottom-d[1],R=i.textShaping.left-d[0],D=i.textShaping.right-d[0];i.textShaping.top=o[1]+(i.textShaping.top-d[1]),i.textShaping.bottom=o[1]+M,i.textShaping.left=o[0]+R,i.textShaping.right=o[0]+D;let P=function(t,i,r,a,n,o,s,l,h,u=1){let c=[];if(0===i.positionedLines.length)return c;let d=(void 0!==h?h:a.layout.get("text-rotate").evaluate(o,{}))*Math.PI/180,p=function(t){let i=t[0],r=t[1],a=i*r;return a>0?[i,-r]:a<0?[-i,r]:0===i?[r,i]:[r,-i]}(r),f=Math.abs(i.top-i.bottom);for(let t of i.positionedLines)f-=t.lineOffset;let _=i.positionedLines.length,m=f/_,g=i.top-r[1];for(let t=0;t<_;++t){let a=i.positionedLines[t];for(let n of(g=function(t,i,r,a){let n=i+t.positionedLines[a].lineOffset;return 0===a?r+n/2:r+(n+(i+t.positionedLines[a-1].lineOffset))/2}(i,m,g,t),a.positionedGlyphs)){let t,a,o,h;if(!n.rect)continue;let f=n.rect||{},_=4,m=!0,y=1,x=0;if(n.image){let t=s.get(n.image.toString());if(!t)continue;if(t.sdf){tX("SDF images are not supported in formatted text and will be ignored.");continue}m=!1,_=1/(y=t.pixelRatio),t.usvg||(y/=u)}let v=l&&n.vertical,b=n.metrics.advance*n.scale/2,w=n.metrics,T=n.rect;if(null===T)continue;l&&i.verticalizable&&(x=n.image?b-n.metrics.width*n.scale/2:0);let E=[0,0],S=[0,0],I=[0,0],A=!1;v?(I=[n.x+b+p[0],n.y+p[1]-x],A=!0):S=[n.x+b+r[0],n.y+r[1]-x];let C=T.w*n.scale/(y*(n.localGlyph?2:1)),M=T.h*n.scale/(y*(n.localGlyph?2:1));if(v){let i=n.y-g,r=new tg(-b,b-i),s=-Math.PI/2,l=new tg(...I);(t=new tg(-b+S[0],S[1]))._rotateAround(s,r)._add(l),t.x+=-i+b,t.y-=(w.left-_)*n.scale;let u=n.image?w.advance*n.scale:24*n.scale,c=String.fromCodePoint(n.glyph);"︶"===c||"ï¹"===c||"︸"===c||"ï¹"===c||"ï¹"===c||"︾"===c||"︼"===c||"︺"===c||"ï¸"===c||"ï¹"===c||"ï¸"===c||"ï¸"===c||"ï¸"===c||"ï½"===c||"ï¿£"===c||"ï¸"===c||"ï¸"===c?t.x+=(1-_)*n.scale:"︵"===c||"ï¹"===c||"︷"===c||"ï¹"===c||"ï¹"===c||"︽"===c||"︻"===c||"︹"===c||"ï¸"===c||"︿"===c?t.x+=u-w.height*n.scale+(-_-1)*n.scale:t.x+=n.image||w.width+2*_===T.w&&w.height+2*_===T.h?(u-M)/2:(u-(w.height+2*_)*n.scale)/2,a=new tg(t.x,t.y-C),o=new tg(t.x+M,t.y),h=new tg(t.x+M,t.y-C)}else{let i=(w.left-_)*n.scale-b+S[0],r=(-w.top-_)*n.scale+S[1],s=i+C,l=r+M;t=new tg(i,r),a=new tg(s,r),o=new tg(i,l),h=new tg(s,l)}if(d){let i;i=A?new tg(p[0],p[1]):new tg(r[0],r[1]),t._rotateAround(d,i),a._rotateAround(d,i),o._rotateAround(d,i),h._rotateAround(d,i)}let R=new tg(0,0),D=new tg(0,0);c.push({tl:t,tr:a,bl:o,br:h,texPrimary:f,texSecondary:void 0,writingMode:i.writingMode,glyphOffset:E,sectionIndex:n.sectionIndex,isSDF:m,pixelOffsetTL:R,pixelOffsetBR:D,minFontScaleX:0,minFontScaleY:0})}}return c}(0,i.textShaping,o,l,0,a,u,this.allowVerticalPlacement,v),z=E&&"composite"===I.kind?S.possiblyEvaluate(new o0(A,{}),s).evaluate(a,c,s):_,L=E&&"composite"===I.kind?S.possiblyEvaluate(new o0(C,{}),s).evaluate(a,c,s):m,O=(w=b.name,r=null,"source"===(T=I).kind?(r=[128*E*h])[0]>32640&&tX(`${w}: Value for "text-size" or "icon-size" is >= 255. Reduce your "text-size" or "icon-size".`):"composite"===T.kind&&((r=[128*z*h,128*L*h])[0]>32640||r[1]>32640)&&tX(`${w}: Value for "text-size" or "icon-size" is >= 255. Reduce your "text-size" or "icon-size".`),r),F=1+(Math.min(32640,Math.round((Array.isArray(O)?O[1]:E)*128))<<1);i.isUsingAppearanceTextVertexData||(i.isUsingAppearanceTextVertexData=!0,i.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(n,t.numHorizontalGlyphVertices+t.numVerticalGlyphVertices));for(let i=0;i<P.length&&i<(t.numHorizontalGlyphVertices+t.numVerticalGlyphVertices)/4;++i){let r=P[i],a=r.glyphOffset[1],o=t.tileAnchorX,s=t.tileAnchorY,l=n+4*i;this.text.updateSymbolVertexData(l,o,s,Math.round(32*r.tl.x),Math.round(32*(a+r.tl.y)),r.texPrimary.x,r.texPrimary.y,0,F,r.pixelOffsetTL.x,r.pixelOffsetTL.y,r.minFontScaleX,r.minFontScaleY),this.text.updateSymbolVertexData(l+1,o,s,Math.round(32*r.tr.x),Math.round(32*(a+r.tr.y)),r.texPrimary.x+r.texPrimary.w,r.texPrimary.y,0,F,r.pixelOffsetBR.x,r.pixelOffsetTL.y,r.minFontScaleX,r.minFontScaleY),this.text.updateSymbolVertexData(l+2,o,s,Math.round(32*r.bl.x),Math.round(32*(a+r.bl.y)),r.texPrimary.x,r.texPrimary.y+r.texPrimary.h,0,F,r.pixelOffsetTL.x,r.pixelOffsetBR.y,r.minFontScaleX,r.minFontScaleY),this.text.updateSymbolVertexData(l+3,o,s,Math.round(32*r.br.x),Math.round(32*(a+r.br.y)),r.texPrimary.x+r.texPrimary.w,r.texPrimary.y+r.texPrimary.h,0,F,r.pixelOffsetBR.x,r.pixelOffsetBR.y,r.minFontScaleX,r.minFontScaleY)}return{vertexOffsetDelta:t.numHorizontalGlyphVertices+t.numVerticalGlyphVertices,hasChanges:!0}}return i.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(n,i.layoutBasedTextVertexData),i.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:i.layoutBasedTextVertexData.length/12,hasChanges:!0}):{vertexOffsetDelta:t.numHorizontalGlyphVertices+t.numVerticalGlyphVertices,hasChanges:!1}}updateExpressions(t){this.text&&this.text.programConfigurations.updateExpressions(t),this.icon&&this.icon.programConfigurations.updateExpressions(t)}update(t,i,r,a,n,o,s,l){if(this.text.uboBinder||this.text.programConfigurations.updatePaintArrays(t,i,n,r,a,o,s,this.worldview),this.icon.uboBinder||this.icon.programConfigurations.updatePaintArrays(t,i,n,r,a,o,s,this.worldview),l){if(o)for(let a of[this.text.uboBinder,this.icon.uboBinder])a&&!a.isLightConstant&&a.updateDynamicExpressions(n[0],i,l,r,t,s
7);else if(Object.keys(t).length>0){let a=n[0],o=[this.text.uboBinder,this.icon.uboBinder].filter(t=>t&&t.hasStateDependentPaint(a));if(o.length>0){let n=new Set(Object.keys(t).map(t=>{let i=Number(t);return!isNaN(i)&&Number.isSafeInteger(i)&&String(i)===t?i:t}));for(let h of o)h.updateFeatures(n,a,i,l,r,t,s)}}}}updateZOffset(){let t=(t,i,a)=>{(r+=i)>t.length&&t.resize(r);for(let n=-i;n<0;n++)t.emplace(n+r,a)},i=(t,i,r)=>{(a+=i)>t.length&&t.resize(a);for(let n=-i;n<0;n++)t.emplace(n+a,r)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,a=0;for(let r=0;r<this.symbolInstances.length;r++){let a=this.symbolInstances.get(r),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:o,numIconVertices:s}=a,l=a.zOffset,h=s>0;if((n>0||o>0)&&(t(this.text.zOffsetVertexArray,n,l),t(this.text.zOffsetVertexArray,o,l)),h){let{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=a;t>=0&&i(this.icon.zOffsetVertexArray,s,l),r>=0&&i(this.icon.zOffsetVertexArray,a.numVerticalIconVertices,l)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t,i,r,a,n){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(t=>t.appearances&&t.appearances.length>0)),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(t,i,r,a,n,o=!1){let s={hasLayoutChanges:!1,hasUboChanges:!1};if(!t||!r||!this.featureAppearanceData)return s;let l=i||{},h=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,u=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!h&&!u)return s;let c=this.layers[0],d=c.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===c.appearancesVersion||(this.featureAppearances=new dA(c.appearances,c.appearancesVersion));let p=this.featureAppearances.update(a,o);if("no-changes"===p.kind)return s;let f=1,_=0,m=!1,g=!1;if(h){let[t,i]=d.get("icon-size-scale-range");f=tL(1,t,i)}let y=1,x=0,v=!1;if(u){let[t,i]=d.get("text-size-scale-range");y=tL(1,t,i)}let b=new Map;if(n&&r)for(let t of r){let i=n.getImage(t,c.scope);if(i){let r=new ah(t.toString());b.set(r.toString(),i)}}let w=[this.text.uboBinder,this.icon.uboBinder];for(let i=0;i<this.symbolInstances.length;i++){let n,o=this.symbolInstances.get(i),s=this.getAppearanceFeatureData(o.featureIndex);if(!s)continue;let T=s.id,E=void 0!==T?l[String(T)]:void 0,S={type:"Point",id:s.id,properties:s.properties,geometry:[]};if("all-features"===p.kind)n=p.appearanceIndex;else{let i=c.appearances?c.appearances.findIndex(i=>i.isActive({globals:a,feature:S,canonical:t,featureState:E})):-1;n=i>=0?i:-1}let I=s.activeAppearanceIndex!==n;if(u){let i=d.get("text-size"),a="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,l="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0,h={canonical:t,layer:c,featureState:E,availableImages:r,textScaleFactor:y,imageMap:b,layoutTextOffset:d.get("text-offset").evaluate(S,E,t).map(t=>24*t),layoutTextSize:i.evaluate(S,E,t),layoutTextRotate:d.get("text-rotate").evaluate(S,E,t),layoutMinZoomSize:i.evaluate(S,{zoom:a},t),layoutMaxZoomSize:i.evaluate(S,{zoom:l},t),layoutTextSizeMinZoom:a,layoutTextSizeMaxZoom:l},u=this.updateSymbolInstanceTextVertices(o,s,n,S,x,h);x+=u.vertexOffsetDelta,v=v||u.hasChanges}if(h){let i={canonical:t,layer:c,featureState:E,availableImages:r,globalProperties:a,iconScaleFactor:f,layoutIconOffset:d.get("icon-offset").evaluate(S,E,t),layoutIconSize:d.get("icon-size").evaluate(S,E,t,r),layoutIconRotate:d.get("icon-rotate").evaluate(S,E,t)},l=this.updateSymbolInstanceIconVertices(o,s,n,S,_,i);_+=l.vertexOffsetDelta,m=m||l.hasChanges}if(I){let i=o.featureIndex,s=a?a.brightness:null,l=E||{},h=n>=0?c.appearances[n]:null;for(let a of w)a&&(a.layer=c,g=a.updateFeaturePaintForAppearance(i,S,l,t,r,s,h)||g)}s.activeAppearanceIndex=n}return m&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),m&&this.icon.iconTransitioningVertexBuffer&&this.icon.iconTransitioningVertexArray.length>0&&this.icon.iconTransitioningVertexArray.length===this.icon.iconTransitioningVertexBuffer.length&&this.icon.iconTransitioningVertexBuffer.updateData(this.icon.iconTransitioningVertexArray),v&&this.text.layoutVertexBuffer&&null!==this.text.layoutVertexArray.arrayBuffer&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:m||v,hasUboChanges:g}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=df(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,i){let r=this.lineVertexArray.length;if(void 0!==t.segment)for(let{x:t,y:r}of i)this.lineVertexArray.emplaceBack(t,r);return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y){let x=t.indexArray,v=t.layoutVertexArray,b=t.globeExtVertexArray,w=t.uboBinder?t.uboBinder.getCurrentBatchIndex():void 0,T=t.segments.prepareSegment(4*y,v,x,this.canOverlap?o.sortKey:void 0,w),E=this.glyphOffsetArray.length,S=T.vertexLength,I=this.allowVerticalPlacement&&s===uL.vertical?Math.PI/2:0,A=o.text&&o.text.sections,C=v.length,M=-1;for(let a=0;a<i.length;a++){let{tl:n,tr:s,bl:u,br:c,texPrimary:d,texSecondary:g,pixelOffsetTL:y,pixelOffsetBR:w,minFontScaleX:E,minFontScaleY:S,glyphOffset:R,isSDF:D,sectionIndex:P}=i[a],z=T.vertexLength,L=R[1];if(dR(v,h.x,h.y,n.x,L+n.y,d.x,d.y,r,D,y.x,y.y,E,S),dR(v,h.x,h.y,s.x,L+s.y,d.x+d.w,d.y,r,D,w.x,y.y,E,S),dR(v,h.x,h.y,u.x,L+u.y,d.x,d.y+d.h,r,D,y.x,w.y,E,S),dR(v,h.x,h.y,c.x,L+c.y,d.x+d.w,d.y+d.h,r,D,w.x,w.y,E,S),l){let{x:i,y:r,z:a}=l.anchor,[n,o,s]=l.up;dP(b,i,r,a,n,o,s),dP(b,i,r,a,n,o,s),dP(b,i,r,a,n,o,s),dP(b,i,r,a,n,o,s),dL(t.dynamicLayoutVertexArray,i,r,a,I)}else dL(t.dynamicLayoutVertexArray,h.x,h.y,h.z,I);if(m){let i=g||d;dD(t.iconTransitioningVertexArray,i.x,i.y),dD(t.iconTransitioningVertexArray,i.x+i.w,i.y),dD(t.iconTransitioningVertexArray,i.x,i.y+i.h),dD(t.iconTransitioningVertexArray,i.x+i.w,i.y+i.h)}if(x.emplaceBack(z,z+1,z+2),x.emplaceBack(z+1,z+2,z+3),T.vertexLength+=4,T.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(R[0]),(a===i.length-1||P!==i[a+1].sectionIndex)&&(t.uboBinder||t.programConfigurations.populatePaintArrays(v.length,o,o.index,{},p,f,_,A&&A[P],this.worldview),t.uboBinder)){let i=t.uboBinder.populateUBO(o,o.index,f,p,_,A&&A[P]);M=i;let r=v.length-C;for(let a=0;a<r;a++)t.featureIdArray.emplaceBack(i);C=v.length}}let R=y-i.length;if(0!==R&&(this._addNullVertices(R,v,r,l,b,t,m,T,x),t.uboBinder&&M>=0)){let i=4*R;for(let r=0;r<i;r++)t.featureIdArray.emplaceBack(M)}let D=l?l.anchor:h;t.placedSymbolArray.emplaceBack(D.x,D.y,D.z,h.x,h.y,E,this.glyphOffsetArray.length-E,S,u,c,h.segment,r?r[0]:0,r?r[1]:0,a[0],a[1],s,0,0,0,d,0),t.symbolInstanceIndices.push(g)}_addNullVertices(t,i,r,a,n,o,s,l,h){for(let u=0;u<t;u++){for(let t=0;t<4;t++)dR(i,0,0,0,0,0,0,r,!1,0,0,0,0),a&&dP(n,0,0,0,0,0,0),dL(o.dynamicLayoutVertexArray,0,0,0,0),s&&dD(o.iconTransitioningVertexArray,0,0);let t=l.vertexLength;h.emplaceBack(t,t+1,t+2),h.emplaceBack(t+1,t+2,t+3),l.vertexLength+=4,l.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(t,i,r,a,n,o,s){t.emplaceBack(i,r,a,n,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(t,i,r,a,n,o,s){let l=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),h=l.vertexLength,u=s.tileAnchorX,c=s.tileAnchorY;for(let t=0;t<4;t++)r.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(r.collisionVertexArrayExt,i,t.padding,s.zOffset),this._commitLayoutVertex(r.layoutVertexArray,a,n,o,u,c,new tg(t.x1,t.y1)),this._commitLayoutVertex(r.layoutVertexArray,a,n,o,u,c,new tg(t.x2,t.y1)),this._commitLayoutVertex(r.layoutVertexArray,a,n,o,u,c,new tg(t.x2,t.y2)),this._commitLayoutVertex(r.layoutVertexArray,a,n,o,u,c,new tg(t.x1,t.y2)),l.vertexLength+=4;let d=r.indexArray;d.emplaceBack(h,h+1),d.emplaceBack(h+1,h+2),d.emplaceBack(h+2,h+3),d.emplaceBack(h+3,h),l.primitiveLength+=4}_addTextDebugCollisionBoxes(t,i,r,a,n,o){for(let s=a;s<n;s++){let a=r.get(s),n=this.getSymbolInstanceTextSize(t,o,i,s);this._addCollisionDebugVertices(a,n,this.textCollisionBox,a.projectedAnchorX,a.projectedAnchorY,a.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(t,i,r,a,n,o){for(let s=a;s<n;s++){let a=r.get(s),n=this.getSymbolInstanceIconSize(t,i,o.placedIconSymbolIndex);this._addCollisionDebugVertices(a,n,this.iconCollisionBox,a.projectedAnchorX,a.projectedAnchorY,a.projectedAnchorZ,o)}}generateCollisionDebugBuffers(t,i,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new dF(lA,ub.members,lS),this.iconCollisionBox=new dF(lA,ub.members,lS);let a=uk(this.iconSizeData,t),n=uk(this.textSizeData,t,r);for(let r=0;r<this.symbolInstances.length;r++){let o=this.symbolInstances.get(r);this._addTextDebugCollisionBoxes(n,t,i,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(n,t,i,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(a,t,i,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(a,t,i,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(t,i,r,a){let n=this.text.placedSymbolArray.get(i.rightJustifiedTextSymbolIndex>=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:a),o=uB(this.textSizeData,t,n)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,i,r){let a=this.icon.placedSymbolArray.get(r),n=uB(this.iconSizeData,t,a);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(t,i,r,a){t.emplaceBack(i,-r,-r,a),t.emplaceBack(i,r,-r,a),t.emplaceBack(i,r,r,a),t.emplaceBack(i,-r,r,a)}_updateTextDebugCollisionBoxes(t,i,r,a,n,o,s){for(let s=a;s<n;s++){let a=r.get(s),n=this.getSymbolInstanceTextSize(t,o,i,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,a.padding,o.zOffset)}}_updateIconDebugCollisionBoxes(t,i,r,a,n,o,s){for(let s=a;s<n;s++){let a=r.get(s),n=this.getSymbolInstanceIconSize(t,i,o.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,a.padding,o.zOffset)}}updateCollisionDebugBuffers(t,i,r,a){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();let n=uk(this.iconSizeData,t,a),o=uk(this.textSizeData,t,r);for(let s=0;s<this.symbolInstances.length;s++){let l=this.symbolInstances.get(s);this._updateTextDebugCollisionBoxes(o,t,i,l.textBoxStartIndex,l.textBoxEndIndex,l,r),this._updateTextDebugCollisionBoxes(o,t,i,l.verticalTextBoxStartIndex,l.verticalTextBoxEndIndex,l,r),this._updateIconDebugCollisionBoxes(n,t,i,l.iconBoxStartIndex,l.iconBoxEndIndex,l,a),this._updateIconDebugCollisionBoxes(n,t,i,l.verticalIconBoxStartIndex,l.verticalIconBoxEndIndex,l,a)}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(t,i,r,a,n,o,s,l,h){let u={};if(i<r){let{x1:r,y1:a,x2:n,y2:o,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p,featureIndex:f}=t.get(i);u.textBox={x1:r,y1:a,x2:n,y2:o,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p},u.textFeatureIndex=f}if(a<n){let{x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p,featureIndex:f}=t.get(a);u.verticalTextBox={x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p},u.verticalTextFeatureIndex=f}
7if(o<s){let{x1:i,y1:r,x2:a,y2:n,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p,featureIndex:f}=t.get(o);u.iconBox={x1:i,y1:r,x2:a,y2:n,padding:s,projectedAnchorX:l,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p},u.iconFeatureIndex=f}if(l<h){let{x1:i,y1:r,x2:a,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p,featureIndex:f}=t.get(l);u.verticalIconBox={x1:i,y1:r,x2:a,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:h,projectedAnchorZ:c,tileAnchorX:d,tileAnchorY:p},u.verticalIconFeatureIndex=f}return u}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){let r=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,i){let r=t.placedSymbolArray.get(i),a=r.vertexStartIndex+4*r.numGlyphs;for(let i=r.vertexStartIndex;i<a;i+=4)t.indexArray.emplaceBack(i,i+1,i+2),t.indexArray.emplaceBack(i+1,i+2,i+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;let i=Math.sin(t),r=Math.cos(t),a=[],n=[],o=[];for(let t=0;t<this.symbolInstances.length;++t){o.push(t);let s=this.symbolInstances.get(t);a.push(0|Math.round(i*s.tileAnchorX+r*s.tileAnchorY)),n.push(s.featureIndex)}return o.sort((t,i)=>a[t]-a[i]||n[i]-n[t]),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;t<this.symbolInstances.length;++t)this.symbolInstanceIndexesSortedZOffset.push(t)}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort((t,i)=>this.symbolInstances.get(i).zOffset-this.symbolInstances.get(t).zOffset)}addToSortKeyRanges(t,i){let r=this.sortKeyRanges.at(-1);r&&r.sortKey===i?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesByY=!1;else{for(let i of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){let t=this.symbolInstances.get(i);this.featureSortOrder.push(t.featureIndex);let{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:a,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:l}=t;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),a>=0&&a!==r&&this.addIndicesForPlacedSymbol(this.text,a),n>=0&&n!==a&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),l>=0&&this.addIndicesForPlacedSymbol(this.icon,l)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}oC(dB,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),dB.addDynamicAttributes=dL;class dk extends hR{constructor(t,i,r){super(t,i,r),this.elevatedLayoutVertexArray=new lc}upload(t){let i=this.uploaded;super.upload(t),!i&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=t.createVertexBuffer(this.elevatedLayoutVertexArray,l5.members))}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),super.destroy()}}oC(dk,"ElevatedFillBufferData");class dN{constructor(){this.portals=[]}static isOnBorder(t,i){return t<=0&&i<=0||t>=8192&&i>=8192}static evaluate(t){if(0===t.length)return new dN;let i=[];for(let r of t)i.push(...r.portals);if(0===i.length)return new dN;for(let t of i){let i=t.va,r=t.vb;
7(dN.isOnBorder(i.x,r.x)||dN.isOnBorder(i.y,r.y))&&(t.type="border")}let r=i.filter(t=>"unevaluated"!==t.type),a=i.filter(t=>"unevaluated"===t.type);if(0===a.length)return new dN;a.sort((t,i)=>t.hash===i.hash?t.isTunnel===i.isTunnel?0:t.isTunnel?-1:1:t.hash<i.hash?1:-1),i=r.concat(a);let n=r.length,o=n,s=n;do if(++o===i.length||i[n].hash!==i[o].hash){if(o-n==2){s<n&&(i[s]=i[n],i[n]=null);let t=i[s],r=i[o-1];t.type=t.isTunnel!==r.isTunnel?"tunnel":"polygon",t.connection={a:t.connection.a,b:r.connection.a},s++}n=o}while(n!==i.length);return i.splice(s),i.sort((t,i)=>t.hash<i.hash?1:-1),{portals:i}}}oC(dN,"ElevationPortalGraph");class dV{constructor(t,i,r){this.outPositions=t,this.outNormals=i,this.outIndices=r,this.vertexLookup=new Map}addVertex(t,i,r){let a=t[2];null!=r&&(a*=r);let n=`${t[0]},${t[1]},${t[2]},${i[0]},${i[1]},${i[2]}`,o=this.vertexLookup.get(n);if(null!=o)return o;let s=this.outPositions.length;this.vertexLookup.set(n,s);let l=Math.trunc(16384*i[0]),h=Math.trunc(16384*i[1]),u=Math.trunc(16384*i[2]);return this.outPositions.emplaceBack(t[0],t[1],a),this.outNormals.emplaceBack(l,h,u),s}addTriangle(t,i,r){this.outIndices.emplaceBack(t,i,r)}addTriangles(t,i,r,a=0){if(0===t.length)return;let n=eP(),o=eP();for(let s=0;s<t.length;s+=3){let l=i[t[s+0]],h=i[t[s+1]],u=i[t[s+2]],c=r[t[s+1]]+a,d=r[t[s+2]]+a;eF(n,l.x,l.y,r[t[s+0]]+a);let p=this.addVertex(n,o);eF(n,h.x,h.y,c);let f=this.addVertex(n,o);eF(n,u.x,u.y,d);let _=this.addVertex(n,o);this.outIndices.emplaceBack(p,f,_)}}addQuad(t,i,r,a,n,o){let s=this.addVertex(t,n,o),l=this.addVertex(i,n,o),h=this.addVertex(r,n,o),u=this.addVertex(a,n,o);this.addTriangle(s,l,h),this.addTriangle(h,u,s)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class dU{constructor(t,i,r,a){this.unevaluatedPortals=new dN,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new ld,this.vertexNormals=new lp,this.indexArray=new lR,this.tileToMeters=s6(t),this.bridgeProgramConfigurations=new hS(i,{zoom:r,lut:a},t=>"fill-tunnel-structure-color"!==t),this.tunnelProgramConfigurations=new hS(i,{zoom:r,lut:a},t=>"fill-bridge-guard-rail-color"!==t)}addVertices(t,i){let r=this.unevalVertices.length;for(let r=0;r<t.length;r++)this.unevalVertices.push(t[r]),this.unevalHeights.push(i[r]);return r}
7addTriangles(t,i,r){let a=r?this.unevalTunnelTriangles:this.unevalTriangles;for(let r of t)a.push(r+i)}addRenderableRing(t,i,r,a,n,o){let s=[new tg(n.min.x,n.min.y),new tg(n.max.x,n.min.y),new tg(n.max.x,n.max.y),new tg(n.min.x,n.max.y)];for(let l=0;l<r-1;l++){let r=i+l,h=r+1,u=this.unevalVertices[r],c=this.unevalVertices[h];if(!(u.x>=n.min.x&&u.x<=n.max.x&&u.y>=n.min.y&&u.y<=n.max.y||c.x>=n.min.x&&c.x<=n.max.x&&c.y>=n.min.y&&c.y<=n.max.y||hY(u,c,s))||this.isOnBorder(u.x,c.x)||this.isOnBorder(u.y,c.y))continue;let d=dU.computeEdgeHash(this.unevalVertices[r],this.unevalVertices[h]),p,f=this.vertexHashLookup.get(dU.computePosHash(u));p=null!=f?f.next:null!=(f=this.vertexHashLookup.get(dU.computePosHash(c)))?f.prev:d,this.unevalEdges.push({polygonIdx:t,a:r,b:h,hash:d,portalHash:p,isTunnel:a,type:"unevaluated",featureInfo:o})}}addPortalCandidates(t,i,r,a,n){if(0!==i.length)for(let n of(this.vertexHashLookup.clear(),i)){if(0===n.length)continue;let i=n[0],o=dU.computeEdgeHash(i[i.length-2],i.at(-1));for(let n=0;n<i.length-1;n++){let s=i[n+0],l=i[n+1],h=th(l.x-s.x,l.y-s.y),u=tp(h);if(0===u)continue;let c="unevaluated",d=a.pointElevation(s),p=a.pointElevation(l);.01>Math.abs(d)&&.01>Math.abs(p)?c="entrance":(this.isOnBorder(s.x,l.x)||this.isOnBorder(s.y,l.y))&&(c="border");let f=dU.computeEdgeHash(s,l);this.unevaluatedPortals.portals.push({connection:{a:t,b:void 0},va:s,vb:l,vab:h,length:u,hash:f,isTunnel:r,type:c});let _=dU.computePosHash(s);this.vertexHashLookup.set(_,{prev:o,next:f}),o=f}}}construct(t){if(0===this.unevalVertices.length)return;let i=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=t=>{t.primitiveLength=this.indexArray.length-t.primitiveOffset},a=new dV(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(t.portals,this.unevalEdges);let n=i(),o=i(),s=i(),l=(t,i)=>{t.sort((t,r)=>t.type===i&&r.type!==i?-1:+(t.type!==i&&r.type===i));let r=t.findIndex(t=>t.type!==i);return r>=0?r:t.length},h=0;this.unevalEdges.length>0&&(h=l(this.unevalEdges,"none"),this.constructBridgeStructures(a,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:h},this.tileToMeters)),r(s);let u=i(),c=i();if(this.unevalEdges.length>0){let t=this.unevalEdges.splice(h),i=l(t,"tunnel")+h;this.unevalEdges.push(...t),this.constructTunnelStructures(a,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:h},{min:h,max:i})}r(u),a.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(c),a.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(o),a.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights,4),r(n),this.maskSegments=l9.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.depthSegments=l9.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableBridgeSegments=l9.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableTunnelSegments=l9.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.shadowCasterSegments=l9.simpleSegment(0,n.primitiveOffset,0,n.primitiveLength)}update(t,i,r,a,n,o,s,l){this.bridgeProgramConfigurations.updatePaintArrays(t,i,n,r,a,o,s,l),this.tunnelProgramConfigurations.updatePaintArrays(t,i,n,r,a,o,s,l)}upload(t){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=t.createVertexBuffer(this.vertexPositions,l6.members),this.vertexBufferNormal=t.createVertexBuffer(this.vertexNormals,l8.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(t),this.tunnelProgramConfigurations.upload(t))}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(t,i,r,a,n){let o=(o,s)=>{for(let l=0;l<s.length-1;l++){let h=s[l].featureIndex,u=s[l+1].vertexStart,c=t.feature(h);o.populatePaintArrays(u,c,h,{},r,i,a,void 0,n)}};o(this.bridgeProgramConfigurations,this.bridgeFeatureSections),o(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(t,i,r,a,n){let o=new Map;for(let s=a;s<n;s++){let a=r[s],n=a.a,l=a.b,h=dU.computePosHash(t[n]),u=dU.computePosHash(t[l]),c=o.get(h);c||(c={},o.set(h,c));let d=o.get(u);d||(d={},o.set(u,d)),i[n]<=0&&i[l]<=0||(c.to=l,d.from=n)}return o}isTerminalVertex(t,i){let r=dU.computePosHash(this.unevalVertices[t]),a=i.get(r);return!a||!a.from||!a.to}constructBridgeStructures(t,i,r,a,n,o){t.clearVertexLookup();let s=this.computeVertexConnections(i,r,a,n.min,n.max),l=1/o,h=.5*l,u=(t,a)=>eF(t,i[a].x,i[a].y,r[a]*l),c=eP(),d=eP(),p=eP(),f=eP(),_=eP(),m=(t,r)=>{let a=s.get(dU.computePosHash(i[r])),n=a.from,o=a.to;
7if(!n||!o)return;u(c,n),u(d,r),u(p,o),e1(f),e2(c,d)||(ek(_,d,c),eW(f,_)),e2(p,d)||(ek(_,p,d),eB(f,f,eW(_,_)));let l=eL(f);return l>0?ej(t,f,1/l):void 0},g=1/0;this.sortSubarray(a,n.min,n.max,(t,i)=>t.featureInfo.featureIndex-i.featureInfo.featureIndex);let y=eP(),x=eP(),v=eP(),b=eP(),w=eP(),T=eP(),E=eP(),S=eP(),I=eP(),A=[eP(),eP(),eP(),eP()],C=[eP(),eP(),eP(),eP()],M=[{coord:new tg(0,0),height:0},{coord:new tg(0,0),height:0}],R=(t,i)=>t>i;for(let u=n.min;u<n.max;u++){let n=a[u];if(!n.featureInfo.guardRailEnabled||!this.prepareEdgePoints(M,i,r,n,R))continue;let[c,d]=M;if(eF(y,c.coord.x,c.coord.y,l*c.height),eF(x,d.coord.x,d.coord.y,l*d.height),e2(y,x))continue;ek(v,x,y),eW(v,v);let p=m(S,n.a)||v,f=m(I,n.b)||v;eF(b,p[1],-p[0],0),eW(b,b),eF(w,f[1],-f[0],0),eW(w,w),eY(S,b,p),eW(T,S),eY(S,w,f),eW(E,S),eB(A[0],y,ej(S,ek(S,b,T),h)),eB(A[1],y,ej(S,eB(S,b,T),h)),eB(A[2],y,ej(S,T,h)),A[3]=y,eB(C[0],x,ej(S,ek(S,w,E),h)),eB(C[1],x,ej(S,eB(S,w,E),h)),eB(C[2],x,ej(S,E,h)),C[3]=x,g=this.addFeatureSection(n.featureInfo.featureIndex,g,this.bridgeFeatureSections,t);let _=t.addVertex(A[0],b,o),D=t.addVertex(A[1],b,o),P=t.addVertex(C[0],w,o),z=t.addVertex(C[1],w,o);t.addTriangle(_,D,P),t.addTriangle(D,z,P);let L=t.addVertex(A[1],T,o),O=t.addVertex(A[2],T,o),F=t.addVertex(C[1],E,o),B=t.addVertex(C[2],E,o);t.addTriangle(L,O,F),t.addTriangle(O,B,F),e$(b,b),e$(w,w);let k=t.addVertex(A[2],b,o),N=t.addVertex(A[3],b,o),V=t.addVertex(C[2],w,o),U=t.addVertex(C[3],w,o);t.addTriangle(k,N,V),t.addTriangle(N,U,V);let j=this.isTerminalVertex(n.a,s),G=this.isTerminalVertex(n.b,s);c.height<.01&&j&&t.addQuad(A[3],A[2],A[1],A[0],e$(p,p),o),d.height<.01&&G&&t.addQuad(C[0],C[1],C[2],C[3],f,o)}this.bridgeFeatureSections.push({featureIndex:1/0,vertexStart:t.getVertexCount()})}constructTunnelStructures(t,i,r,a,n,o){t.clearVertexLookup();let s=1/0,l=(t,i)=>t.featureInfo.featureIndex-i.featureInfo.featureIndex;this.sortSubarray(a,n.min,n.max,l),this.sortSubarray(a,o.min,o.max,l);let h=t=>eW(t,t),u=[{coord:new tg(0,0),height:0},{coord:new tg(0,0),height:0}],c=(t,i)=>t<i,d=eP(),p=eP(),f=eP(),_=eP(),m=eP();for(let o=n.min;o<n.max;o++){if(!this.prepareEdgePoints(u,i,r,a[o],c))continue;let[n,l]=u,g=h(eF(m,-(l.coord.y-n.coord.y),l.coord.x-n.coord.x,0));s=this.addFeatureSection(a[o].featureInfo.featureIndex,s,this.tunnelFeatureSections,t),t.addQuad(eF(d,n.coord.x,n.coord.y,n.height),eF(p,l.coord.x,l.coord.y,l.height),eF(f,l.coord.x,l.coord.y,a[o].isTunnel?l.height+4:0),eF(_,n.coord.x,n.coord.y,a[o].isTunnel?n.height+4:0),g)}for(let n=o.min;n<o.max;n++){let o=a[n];o.isTunnel&&([o.a,o.b]=[o.b,o.a]);let l=i[o.a],u=i[o.b],c=h(eF(m,-(u.y-l.y),u.x-l.x,0));s=this.addFeatureSection(o.featureInfo.featureIndex,s,this.tunnelFeatureSections,t),t.addQuad(eF(d,u.x,u.y,0),eF(p,l.x,l.y,0),eF(f,l.x,l.y,r[o.a]+4),eF(_,u.x,u.y,r[o.b]+4),c),t.addQuad(eF(d,l.x,l.y,0),eF(p,u.x,u.y,0),eF(f,u.x,u.y,r[o.b]+4),eF(_,l.x,l.y,r[o.a]+4),c)}this.tunnelFeatureSections.push({featureIndex:1/0,vertexStart:t.getVertexCount()})}setElevatedPoint(t,i,r,a){t.coord.x=i,t.coord.y=r,t.height=a}prepareEdgePoints(t,i,r,a,n){let o=i[a.a].x,s=i[a.a].y,l=i[a.b].x,h=i[a.b].y,u=r[a.a],c=r[a.b],d=n(u,0),p=n(c,0);if(d&&p)return this.setElevatedPoint(t[0],o,s,u),this.setElevatedPoint(t[1],l,h,c),!0;if(!d&&!p)return!1;if(d){if(!p){let t=c/(c-u);l=rG(l,o,t),h=rG(h,s,t),c=rG(c,u,t)}}else{let t=u/(u-c);o=rG(o,l,t),s=rG(s,h,t),u=rG(u,c,t)}return this.setElevatedPoint(t[0],o,s,u),this.setElevatedPoint(t[1],l,h,c),!0}prepareEdges(t,i){if(0===i.length)return;i.sort((t,i)=>t.hash===i.hash?i.polygonIdx-t.polygonIdx:i.hash>t.hash?1:-1);let r=0,a=0,n=0,o=i[0].polygonIdx;do(++a===i.length||i[r].hash!==i[a].hash)&&((1==a-r||i[a-1].polygonIdx!==o)&&(n<r&&(i[n]=i[r],i[r]=null),i[n].type="none",n++),(r=a)!==i.length&&(o=i[r].polygonIdx));while(r!==i.length);if(i.splice(n),0!==i.length&&0!==t.length){i.sort((t,i)=>t.portalHash<i.portalHash?1:-1);let r=0,a=0;for(;r!==i.length&&a!==t.length;){let n=i[r],o=t[a];n.portalHash>o.hash?r++:o.hash>n.portalHash?a++:(n.type=o.type,r++)}}}isOnBorder(t,i){return t<=0&&i<=0||t>=8192&&i>=8192}addFeatureSection(t,i,r,a){return t!==i&&(i=t,r.push({featureIndex:t,vertexStart:a.getVertexCount()}),a.clearVertexLookup()),i}sortSubarray(t,i,r,a){let n=t.slice(i,r);n.sort(a),t.splice(i,n.length,...n)}static computeEdgeHash(t,i){return(t.y===i.y&&t.x>i.x||t.y>i.y)&&([t,i]=[i,t]),BigInt(dU.computePosHash(t))<<32n|BigInt(dU.computePosHash(i))}static computePosHash(t){return((65535&t.x)<<16|65535&t.y)>>>0}}let dj=[tl(),tl(),tl(),tl(),tl(),tl(),tl()],dG=tl(),dH=tl();function dq(t){return[t[0],t[1]]}function dZ(t){return th(t[0],t[1])}class d${constructor(t,i,r=null){this.feature=t,this.metersToTile=i,this.sampler=r,this.index=0}get(){let t=this.feature.vertices[this.index],i=this.feature.vertexProps[this.index].dir,r=i[1],a=-i[0],n=(t.extent+1)*this.metersToTile,o=this.sampler?this.sampler.pointTransform(t.position):t.position;return[new tg(Math.trunc(o[0]+r*n),Math.trunc(o[1]+a*n)),new tg(Math.trunc(o[0]-r*n),Math.trunc(o[1]-a*n))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class dW{constructor(t,i,r,a,n,o){if(this.vertices=[],this.vertexProps=[],this.edges=[],this.edgeProps=[],this.id=t,this.heightRange={min:r,max:r},this.safeArea=i,this.constantHeight=r,null==this.constantHeight&&(null!=this.constantHeight||0!==a.length)){this.vertices=a,this.edges=n;for(let t=0;t<this.vertices.length;t++)this.vertices[t].index=void 0!==this.vertices[t].index?this.vertices[t].index:t;for(let t of(this.edges=this.edges.filter(t=>{var i,r;return t.a<this.vertices.length&&t.b<this.vertices.length&&((i=this.vertices[t.a].position)[0]!==(r=this.vertices[t.b].position)[0]||i[1]!==r[1])}),this.heightRange={min:1/0,max:-1/0},this.vertices))this.vertexProps.push({dir:th(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,t.height),this.heightRange.max=Math.max(this.heightRange.max,t.height);for(let t of this.edges){let i=this.vertices[t.a].position,r=this.vertices[t.b].position,a=tc(tl(),r,i),n=tp(a),o=td(tl(),a,1/n);this.edgeProps.push({vec:a,dir:o,len:n});let s=this.vertexProps[t.a].dir,l=this.vertexProps[t.b].dir;tu(s,s,o),tu(l,l,o)}for(let t of this.vertexProps)0===t.dir[0]&&0===t.dir[1]||tf(t.dir,t.dir);this.tessellate(o)}}pointElevation(t){if(null!=this.constantHeight)return this.constantHeight;let i=this.getClosestEdge(t);if(null==i)return 0;let[r,a]=i;return rG(this.vertices[this.edges[r].a].height,this.vertices[this.edges[r].b].height,a)}computeSlopeNormal(t,i){let r=this.getClosestEdge(t);if(!r)return eO(0,0,1);let a=r[0],n=this.edges[a],o=this.edgeProps[a].vec,s=eO(o[0],o[1],(this.vertices[n.b].height-this.vertices[n.a].height)*i),l=eO(s[1],-s[0],0);eY(l,l,s);let h=eL(l);return h>0?ej(l,l,1/h):eF(l,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(t){var i,r,a,n;if(0===this.edges.length)return;let o=0,s=1/0,l=0,[h,u,c,d,p,f,_]=dj;i=t.x,r=t.y,_[0]=i,_[1]=r;let m=new cl(_,null);for(let t=0;t<this.edges.length;t++){let i=this.edges[t],r=this.edgeProps[t].dir;m.dir=r;let g=this.vertices[i.a].position,y=this.vertices[i.b].position,x=m.intersectsPlane(g,this.vertexProps[i.a].dir,h),v=m.intersectsPlane(y,this.vertexProps[i.b].dir,u);if(!x||!v)continue;tc(c,u,h),tc(d,_,h);let b=t_(c,c),w=b>0?t_(d,c)/b:0,T=tL(w,0,1),E=Math.abs((w-T)*this.edgeProps[t].len);tc(p,_,g),a=r[1],n=-r[0],f[0]=a,f[1]=n;let S=E+Math.abs(t_(p,f));S<s&&(o=t,s=S,l=T)}return[o,l]}tessellate(t){let i=eP(),r=eP(),a=eP(),n=eP();for(let o=this.edges.length-1;o>=0;--o){let s=this.edges[o].a,l=this.edges[o].b,{position:h,height:u,extent:c}=this.vertices[s],{position:d,height:p,extent:f}=this.vertices[l],_=this.vertexProps[s].dir,m=this.vertexProps[l].dir;if(eF(i,h[0]/t,h[1]/t,u),eF(r,d[0]/t,d[1]/t,p),eF(a,_[1],-_[0],0),ej(a,a,c),eF(n,m[1],-m[0],0
7),ej(n,n,f),.0025000000000000005>=this.distSqLines(eO(i[0]+.5*a[0],i[1]+.5*a[1],i[2]+.5*a[2]),eO(r[0]-.5*n[0],r[1]-.5*n[1],r[2]-.5*n[2]),eO(i[0]-.5*a[0],i[1]-.5*a[1],i[2]-.5*a[2]),eO(r[0]+.5*n[0],r[1]+.5*n[1],r[2]+.5*n[2])))continue;let g=this.vertices.length,y=tu(tl(),h,d);this.vertices.push({position:td(y,y,.5),height:.5*(u+p),extent:.5*(c+f),index:.5*((void 0!==this.vertices[s].index?this.vertices[s].index:s)+(void 0!==this.vertices[l].index?this.vertices[l].index:l))});let x=tu(tl(),_,m);this.vertexProps.push({dir:tf(x,x)}),this.edges.splice(o,1),this.edgeProps.splice(o,1),this.edges.push({a:s,b:g}),this.edges.push({a:g,b:l});let v=tc(tl(),this.vertices[g].position,h),b=tp(v),w={vec:v,dir:td(tl(),v,1/b),len:b};this.edgeProps.push(w),this.edgeProps.push(w)}}distSqLines(t,i,r,a){let n=ek(eP(),i,t),o=ek(eP(),a,r),s=ek(eP(),t,r),l=eX(n,n),h=eX(n,o),u=eX(n,s),c=eX(o,o),d=eX(o,s),p=l*c-h*h;return 0===p?eq(eK(n,r,a,eX(s,o)/eX(o,o)),t):eq(eK(n,t,i,(h*d-u*c)/p),eK(o,r,a,(l*d-h*u)/p))}static serialize(t,i){var r;let a={id:t.id,heightRange:{min:t.heightRange.min,max:t.heightRange.max},safeArea:{min:{x:(r=t.safeArea).min.x,y:r.min.y},max:{x:r.max.x,y:r.max.y}}};return null!=t.constantHeight?a.constantHeight=t.constantHeight:0===t.vertices.length?(a.vertices=[],a.vertexProps=[],a.edges=[],a.edgeProps=[]):(a.vertices=t.vertices.map(t=>({position:dq(t.position),height:t.height,extent:t.extent,index:t.index})),a.vertexProps=t.vertexProps.map(t=>({dir:dq(t.dir)})),a.edges=t.edges.map(t=>({a:t.a,b:t.b})),a.edgeProps=t.edgeProps.map(t=>({vec:dq(t.vec),dir:dq(t.dir),len:t.len}))),a}static deserialize(t){var i;let r={min:new tg((i=t.safeArea).min.x,i.min.y),max:new tg(i.max.x,i.max.y)};if(null!=t.constantHeight)return new dW(t.id,r,t.constantHeight);if(!t.vertices||0===t.vertices.length){let i=Object.create(dW.prototype);return i.id=t.id,i.constantHeight=void 0,i.heightRange={min:t.heightRange.min,max:t.heightRange.max},i.safeArea=r,i.vertices=[],i.vertexProps=[],i.edges=[],i.edgeProps=[],i}let a=Object.create(dW.prototype);return a.id=t.id,a.constantHeight=void 0,a.heightRange={min:t.heightRange.min,max:t.heightRange.max},a.safeArea=r,a.vertices=t.vertices.map(t=>({position:dZ(t.position),height:t.height,extent:t.extent,index:t.index})),a.vertexProps=(t.vertexProps||[]).map(t=>({dir:dZ(t.dir)})),a.edges=(t.edges||[]).map(t=>({a:t.a,b:t.b})),a.edgeProps=(t.edgeProps||[]).map(t=>({vec:dZ(t.vec),dir:dZ(t.dir),len:t.len})),a}}class dX{constructor(t,i){this.zScale=1,this.xOffset=0,this.yOffset=0,t.equals(i)||(this.zScale=Math.pow(2,i.z-t.z),this.xOffset=(t.x*this.zScale-i.x)*8192,this.yOffset=(t.y*this.zScale-i.y)*8192)}pointTransform(t){return th(t[0]*this.zScale+this.xOffset,t[1]*this.zScale+this.yOffset)}pointTransformInPlace(t){t[0]=t[0]*this.zScale+this.xOffset,t[1]=t[1]*this.zScale+this.yOffset}constantElevation(t,i){if(null!=t.constantHeight)return this.computeBiasedHeight(t.constantHeight,i)}pointElevation(t,i,r){let a=this.constantElevation(i,r);return null!=a?a:(t.x=t.x*this.zScale+this.xOffset,t.y=t.y*this.zScale+this.yOffset,this.computeBiasedHeight(i.pointElevation(t),r))}computeBiasedHeight(t,i){return i<=0?t:t+i*tO(0,i,t>=0?t:Math.abs(.5*t))}}function dY(t,i){let r=0,a=t.length-1;for(;r<=a;){let n=r+a>>1;t[n].feature.id<i?r=n+1:a=n-1}return r<t.length&&t[r].feature.id===i?r:-1}function dK(t,i,r,a){if(!t.properties)return;let n=+t.properties[ut];if(Number.isNaN(n))return;if(i){let t=i.find(t=>t.id===n);if(t&&a)return{tileId:a,feature:t}}if(!r||0===r.length)return;let o=dY(r,n);if(!(o<0)){if(a){for(let t=o;t<r.length&&r[t].feature.id===n;t++)if(r[t].tileId.key===a.key)return r[t]}return r[o]}}function dQ(t,i){return t>i?1:t<i?-1:0}oC(dW,"ElevationFeature");class dJ{constructor(t=dQ,i=!1){this._compare=t,this._root=null,this._size=0,this._noDuplicates=!!i}rotateLeft(t){var i=t.right;i&&(t.right=i.left,i.left&&(i.left.parent=t),i.parent=t.parent),t.parent?t===t.parent.left?t.parent.left=i:t.parent.right=i:this._root=i,i&&(i.left=t),t.parent=i}rotateRight(t){var i=t.left;i&&(t.left=i.right,i.right&&(i.right.parent=t),i.parent=t.parent),t.parent?t===t.parent.left?t.parent.left=i:t.parent.right=i:this._root=i,i&&(i.right=t),t.parent=i}_splay(t){for(;t.parent;){var i=t.parent;i.parent?i.left===t&&i.parent.left===i?(this.rotateRight(i.parent),this.rotateRight(i)):i.right===t&&i.parent.right===i?(this.rotateLeft(i.parent),this.rotateLeft(i)):i.left===t&&i.parent.right===i?(this.rotateRight(i),this.rotateLeft(i)):(this.rotateLeft(i),this.rotateRight(i)):i.left===t?this.rotateRight(i):this.rotateLeft(i)}}splay(t){for(var i,r,a,n,o;t.parent;
7)(r=(i=t.parent).parent)&&r.parent?((a=r.parent).left===r?a.left=t:a.right=t,t.parent=a):(t.parent=null,this._root=t),n=t.left,o=t.right,t===i.left?(r&&(r.left===i?(i.right?(r.left=i.right,r.left.parent=r):r.left=null,i.right=r,r.parent=i):(n?(r.right=n,n.parent=r):r.right=null,t.left=r,r.parent=t)),o?(i.left=o,o.parent=i):i.left=null,t.right=i):(r&&(r.right===i?(i.left?(r.right=i.left,r.right.parent=r):r.right=null,i.left=r,r.parent=i):(o?(r.left=o,o.parent=r):r.left=null,t.right=r,r.parent=t)),n?(i.right=n,n.parent=i):i.right=null,t.left=i),i.parent=t}replace(t,i){t.parent?t===t.parent.left?t.parent.left=i:t.parent.right=i:this._root=i,i&&(i.parent=t.parent)}minNode(t=this._root){if(t)for(;t.left;)t=t.left;return t}maxNode(t=this._root){if(t)for(;t.right;)t=t.right;return t}insert(t,i){var r=this._root,a=null,n=this._compare;if(this._noDuplicates)for(;r;){if(a=r,0===n(r.key,t))return;r=0>n(r.key,t)?r.right:r.left}else for(;r;)a=r,r=0>n(r.key,t)?r.right:r.left;return r={key:t,data:i,left:null,right:null,parent:a},a?0>n(a.key,r.key)?a.right=r:a.left=r:this._root=r,this.splay(r),this._size++,r}find(t){for(var i=this._root,r=this._compare;i;){var a=r(i.key,t);if(a<0)i=i.right;else{if(!(a>0))return i;i=i.left}}return null}contains(t){for(var i=this._root,r=this._compare;i;){var a=r(t,i.key);if(0===a)return!0;i=a<0?i.left:i.right}return!1}remove(t){var i=this.find(t);if(!i)return!1;if(this.splay(i),i.left)if(i.right){var r=this.minNode(i.right);r.parent!==i&&(this.replace(r,r.right),r.right=i.right,r.right.parent=r),this.replace(i,r),r.left=i.left,r.left.parent=r}else this.replace(i,i.left);else this.replace(i,i.right);return this._size--,!0}removeNode(t){if(!t)return!1;if(this.splay(t),t.left)if(t.right){var i=this.minNode(t.right);i.parent!==t&&(this.replace(i,i.right),i.right=t.right,i.right.parent=i),this.replace(t,i),i.left=t.left,i.left.parent=i}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}erase(t){var i=this.find(t);if(i){this.splay(i);var r=i.left,a=i.right,n=null;r&&(r.parent=null,n=this.maxNode(r),this.splay(n),this._root=n),a&&(r?n.right=a:this._root=a,a.parent=n),this._size--}}pop(){var t=this._root,i=null;if(t){for(;t.left;)t=t.left;i={key:t.key,data:t.data},this.remove(t.key)}return i}next(t){var i=t;if(i)if(i.right)for(i=i.right;i&&i.left;)i=i.left;else for(i=t.parent;i&&i.right===t;)t=i,i=i.parent;return i}prev(t){var i=t;if(i)if(i.left)for(i=i.left;i&&i.right;)i=i.right;else for(i=t.parent;i&&i.left===t;)t=i,i=i.parent;return i}forEach(t){for(var i=this._root,r=[],a=!1,n=0;!a;)i?(r.push(i),i=i.left):r.length>0?(t(i=r.pop(),n++),i=i.right):a=!0;return this}range(t,i,r,a){let n=[],o=this._compare,s=this._root;for(;0!==n.length||s;)if(s)n.push(s),s=s.left;else{if(o((s=n.pop()).key,i)>0)break;if(o(s.key,t)>=0&&r.call(a,s))return this;s=s.right}return this}keys(){for(var t=this._root,i=[],r=[],a=!1;!a;)t?(i.push(t),t=t.left):i.length>0?(r.push((t=i.pop()).key),t=t.right):a=!0;return r}values(){for(var t=this._root,i=[],r=[],a=!1;!a;)t?(i.push(t),t=t.left):i.length>0?(r.push((t=i.pop()).data),t=t.right):a=!0;return r}at(t){for(var i=this._root,r=[],a=!1,n=0;!a;)if(i)r.push(i),i=i.left;else if(r.length>0){if(i=r.pop(),n===t)return i;n++,i=i.right}else a=!0;return null}load(t=[],i=[],r=!1){if(0!==this._size)throw Error("bulk-load: tree is not empty");let a=t.length;return r&&function t(i,r,a,n,o){if(a>=n)return;let s=i[a+n>>1],l=a-1,h=n+1;for(;;){do l++;while(0>o(i[l],s));do h--;while(o(i[h],s)>0);if(l>=h)break;let t=i[l];i[l]=i[h],i[h]=t,t=r[l],r[l]=r[h],r[h]=t}t(i,r,a,h,o),t(i,r,h+1,n,o)}(t,i,0,a-1,this._compare),this._root=function t(i,r,a,n,o){let s=o-n;if(s>0){let l=n+Math.floor(s/2),h={key:r[l],data:a[l],parent:i};return h.left=t(h,r,a,n,l),h.right=t(h,r,a,l+1,o),h}return null}(null,t,i,0,a),this._size=a,this}min(){var t=this.minNode(this._root);return t?t.key:null}max(){var t=this.maxNode(this._root);return t?t.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(t,i,r,a,n){return new dJ(r,n).load(t,i,a)}}let d0=(3+8881784197001252e-31)*11102230246251565e-32;function d1(t,i,r,a,n){let o,s,l,h,u=i[0],c=a[0],d=0,p=0;c>u==c>
7-u?(o=u,u=i[++d]):(o=c,c=a[++p]);let f=0;if(d<t&&p<r)for(c>u==c>-u?(s=u+o,l=o-(s-u),u=i[++d]):(s=c+o,l=o-(s-c),c=a[++p]),o=s,0!==l&&(n[f++]=l);d<t&&p<r;)c>u==c>-u?(h=(s=o+u)-o,l=o-(s-h)+(u-h),u=i[++d]):(h=(s=o+c)-o,l=o-(s-h)+(c-h),c=a[++p]),o=s,0!==l&&(n[f++]=l);for(;d<t;)h=(s=o+u)-o,l=o-(s-h)+(u-h),u=i[++d],o=s,0!==l&&(n[f++]=l);for(;p<r;)h=(s=o+c)-o,l=o-(s-h)+(c-h),c=a[++p],o=s,0!==l&&(n[f++]=l);return 0===o&&0!==f||(n[f++]=o),f}function d2(t){return new Float64Array(t)}let d3=d2(4),d4=d2(8),d5=d2(12),d6=d2(16),d8=d2(4);function d9(t,i,r){null===i?(t.inOut=!1,t.otherInOut=!0):(t.isSubject===i.isSubject?(t.inOut=!i.inOut,t.otherInOut=i.otherInOut):(t.inOut=!i.otherInOut,t.otherInOut=i.isVertical()?!i.inOut:i.inOut),i&&(t.prevInResult=!d7(i,r)||i.isVertical()?i.prevInResult:i)),t.resultTransition=d7(t,r)?function(t,i){let r,a=!t.inOut,n=!t.otherInOut;switch(i){case 0:r=a&&n;break;case 1:r=a||n;break;case 3:r=a!==n;break;case 2:r=t.isSubject?a&&!n:n&&!a}return r?1:-1}(t,r):0}function d7(t,i){switch(t.type){case 0:switch(i){case 0:return!t.otherInOut;case 1:return t.otherInOut;case 2:return t.isSubject&&t.otherInOut||!t.isSubject&&!t.otherInOut;case 3:return!0}break;case 2:return 0===i||1===i;case 3:return 2===i}return!1}class pe{constructor(t,i,r,a,n){this.left=i,this.point=t,this.otherEvent=r,this.isSubject=a??!1,this.type=n||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(t){let i=this.point,r=this.otherEvent.point;return this.left?(i[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(i[1]-t[1])>0:(r[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(r[1]-t[1])>0}isAbove(t){return!this.isBelow(t)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){let t=new pe(this.point,this.left,this.otherEvent,this.isSubject,this.type);return t.contourId=this.contourId,t.resultTransition=this.resultTransition,t.prevInResult=this.prevInResult,t.isExteriorRing=this.isExteriorRing,t.inOut=this.inOut,t.otherInOut=this.otherInOut,t}}function pt(t,i){return t[0]===i[0]&&t[1]===i[1]}function pi(t,i,r){let a=function(t,i,r,a,n,o){let s=(i-o)*(r-n),l=(t-n)*(a-o),h=s-l;if(0===s||0===l||s>0!=l>0)return h;let u=Math.abs(s+l);return Math.abs(h)>=33306690738754716e-32*u?h:-function(t,i,r,a,n,o,s){let l,h,u,c,d,p,f,_,m,g,y,x,v,b,w,T,E,S,I=t-n,A=r-n,C=i-o,M=a-o;b=I*M,f=(p=0x8000001*I)-(p-I),_=I-f,m=(p=0x8000001*M)-(p-M),w=_*(g=M-m)-(b-f*m-_*m-f*g),T=C*A,f=(p=0x8000001*C)-(p-C),_=C-f,m=(p=0x8000001*A)-(p-A),y=w-(E=_*(g=A-m)-(T-f*m-_*m-f*g)),d=w-y,d3[0]=w-(y+d)+(d-E),d=(x=b+y)-b,y=(v=b-(x-d)+(y-d))-T,d=v-y,d3[1]=v-(y+d)+(d-T),d=(S=x+y)-x,d3[2]=x-(S-d)+(y-d),d3[3]=S;let R=function(t,i){let r=i[0];for(let t=1;t<4;t++)r+=i[t];return r}(0,d3),D=22204460492503146e-32*s;if(R>=D||-R>=D||(d=t-I,l=t-(I+d)+(d-n),d=r-A,u=r-(A+d)+(d-n),d=i-C,h=i-(C+d)+(d-o),d=a-M,c=a-(M+d)+(d-o),0===l&&0===h&&0===u&&0===c)||(D=11093356479670487e-47*s+d0*Math.abs(R),(R+=I*c+M*l-(C*u+A*h))>=D||-R>=D))return R;b=l*M,f=(p=0x8000001*l)-(p-l),_=l-f,m=(p=0x8000001*M)-(p-M),w=_*(g=M-m)-(b-f*m-_*m-f*g),T=h*A,f=(p=0x8000001*h)-(p-h),_=h-f,m=(p=0x8000001*A)-(p-A),y=w-(E=_*(g=A-m)-(T-f*m-_*m-f*g)),d=w-y,d8[0]=w-(y+d)+(d-E),d=(x=b+y)-b,y=(v=b-(x-d)+(y-d))-T,d=v-y,d8[1]=v-(y+d)+(d-T),d=(S=x+y)-x,d8[2]=x-(S-d)+(y-d),d8[3]=S;let P=d1(4,d3,4,d8,d4);b=I*c,f=(p=0x8000001*I)-(p-I),_=I-f,m=(p=0x8000001*c)-(p-c),w=_*(g=c-m)-(b-f*m-_*m-f*g),T=C*u,f=(p=0x8000001*C)-(p-C),_=C-f,m=(p=0x8000001*u)-(p-u),y=w-(E=_*(g=u-m)-(T-f*m-_*m-f*g)),d=w-y,d8[0]=w-(y+d)+(d-E),d=(x=b+y)-b,y=(v=b-(x-d)+(y-d))-T,d=v-y,d8[1]=v-(y+d)+(d-T),d=(S=x+y)-x,d8[2]=x-(S-d)+(y-d),d8[3]=S;let z=d1(P,d4,4,d8,d5);b=l*c,f=(p=0x8000001*l)-(p-l),_=l-f,m=(p=0x8000001*c)-(p-c),w=_*(g=c-m)-(b-f*m-_*m-f*g),T=h*u,f=(p=0x8000001*h)-(p-h),_=h-f,m=(p=0x8000001*u)-(p-u),y=w-(E=_*(g=u-m)-(T-f*m-_*m-f*g)),d=w-y,d8[0]=w-(y+d)+(d-E),d=(x=b+y)-b,y=(v=b-(x-d)+(y-d))-T,d=v-y,d8[1]=v-(y+d)+(d-T),d=(S=x+y)-x,d8[2]=x-(S-d)+(y-d),d8[3]=S;let L=d1(z,d5,4,d8,d6);return d6[L-1]}(t,i,r,a,n,o,u)}(t[0],t[1],i[0],i[1],r[0],r[1]);return a>0?-1:+(a<0)}function pr(t,i){let r=t.point,a=i.point;return r[0]>a[0]?1:r[0]<a[0]?-1:r[1]!==a[1]?r[1]>
7a[1]?1:-1:t.left!==i.left?t.left?1:-1:0!==pi(r,t.otherEvent.point,i.otherEvent.point)?t.isBelow(i.otherEvent.point)?-1:1:!t.isSubject&&i.isSubject?1:-1}function pa(t,i,r){let a=new pe(i,!1,t,t.isSubject),n=new pe(i,!0,t.otherEvent,t.isSubject);return pt(t.point,t.otherEvent.point)&&console.warn("what is that, a collapsed segment?",t),a.contourId=n.contourId=t.contourId,pr(n,t.otherEvent)>0&&(t.otherEvent.left=!0,n.left=!1),t.otherEvent.otherEvent=n,t.otherEvent=a,r.push(n),r.push(a),r}function pn(t,i){return t[0]*i[1]-t[1]*i[0]}function po(t,i){return t[0]*i[0]+t[1]*i[1]}function ps(t,i,r){let a=function(t,i,r,a){let n=[i[0]-t[0],i[1]-t[1]],o=[a[0]-r[0],a[1]-r[1]];function s(t,i,r){return[t[0]+i*r[0],t[1]+i*r[1]]}let l=[r[0]-t[0],r[1]-t[1]],h=pn(n,o),u=h*h,c=po(n,n);if(u>0){let i=pn(l,o)/h;if(i<0||i>1)return null;let a=pn(l,n)/h;return a<0||a>1?null:0===i||1===i?[s(t,i,n)]:0===a||1===a?[s(r,a,o)]:[s(t,i,n)]}if((u=(h=pn(l,n))*h)>0)return null;let d=po(n,l)/c,p=d+po(n,o)/c,f=Math.min(d,p),_=Math.max(d,p);return f<=1&&_>=0?1===f?[s(t,f>0?f:0,n)]:0===_?[s(t,_<1?_:1,n)]:[s(t,f>0?f:0,n),s(t,_<1?_:1,n)]:null}(t.point,t.otherEvent.point,i.point,i.otherEvent.point),n=a?a.length:0;if(0===n||1===n&&(pt(t.point,i.point)||pt(t.otherEvent.point,i.otherEvent.point))||2===n&&t.isSubject===i.isSubject)return 0;if(1===n)return pt(t.point,a[0])||pt(t.otherEvent.point,a[0])||pa(t,a[0],r),pt(i.point,a[0])||pt(i.otherEvent.point,a[0])||pa(i,a[0],r),1;let o=[],s=!1,l=!1;return pt(t.point,i.point)?s=!0:1===pr(t,i)?o.push(i,t):o.push(t,i),pt(t.otherEvent.point,i.otherEvent.point)?l=!0:1===pr(t.otherEvent,i.otherEvent)?o.push(i.otherEvent,t.otherEvent):o.push(t.otherEvent,i.otherEvent),s&&l||s?(i.type=1,t.type=i.inOut===t.inOut?2:3,s&&!l&&pa(o[1].otherEvent,o[0].point,r),2):(l?pa(o[0],o[1].point,r):o[0]!==o[3].otherEvent?(pa(o[0],o[1].point,r),pa(o[1],o[2].point,r)):(pa(o[0],o[1].point,r),pa(o[3].otherEvent,o[2].point,r)),3)}function pl(t,i){if(t===i)return 0;if(0!==pi(t.point,t.otherEvent.point,i.point)||0!==pi(t.point,t.otherEvent.point,i.otherEvent.point))return pt(t.point,i.point)?t.isBelow(i.otherEvent.point)?-1:1:t.point[0]===i.point[0]?t.point[1]<i.point[1]?-1:1:1===pr(t,i)?i.isAbove(t.point)?-1:1:t.isBelow(i.point)?-1:1;if(t.isSubject!==i.isSubject)return t.isSubject?-1:1;{let r=t.point,a=i.point;if(r[0]===a[0]&&r[1]===a[1])return r=t.otherEvent.point,a=i.otherEvent.point,r[0]===a[0]&&r[1]===a[1]?0:(t.contourId??0)>(i.contourId??0)?1:-1}return 1===pr(t,i)?1:-1}class ph{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return null==this.holeOf}}let pu=Math.max,pc=Math.min,pd=0;function pp(t,i,r,a,n,o){let s,l,h,u,c,d;for(s=0,l=t.length-1;s<l;s++){if(h=t[s],u=t[s+1],c=new pe(h,!1,void 0,i),d=new pe(u,!1,c,i),c.otherEvent=d,h[0]===u[0]&&h[1]===u[1])continue;c.contourId=d.contourId=r,o||(c.isExteriorRing=!1,d.isExteriorRing=!1),pr(c,d)>0?d.left=!0:c.left=!0;let l=h[0],p=h[1];n[0]=pc(n[0],l),n[1]=pc(n[1],p),n[2]=pu(n[2],l),n[3]=pu(n[3],p),a.push(c),a.push(d)}}let pf=[];function p_(t,i,r){var a,n,o,s;let l,h,u=t,c=i;"number"==typeof t[0][0][0]&&(u=[t]),"number"==typeof i[0][0][0]&&(c=[i]);let d=(a=u,n=c,l=null,a.length*n.length==0&&(0===r?l=pf:2===r?l=a:(1===r||3===r)&&(l=0===a.length?n:a)),l);if(d)return d===pf?null:d;let p=[1/0,1/0,-1/0,-1/0],f=[1/0,1/0,-1/0,-1/0],_=function(t,i,r,a,n){let o,s,l,h,u,c,d=new aH(void 0,pr);for(l=0,h=t.length;l<h;l++)for(o=t[l],u=0,c=o.length;u<c;u++)(s=0===u)&&pd++,pp(o[u],!0,pd,d,r,s);for(l=0,h=i.length;l<h;l++)for(o=i[l],u=0,c=o.length;u<c;u++)s=0===u,2===n&&(s=!1),s&&pd++,pp(o[u],!1,pd,d,a,s);return d}(u,c,p,f,r);if(o=u,s=c,h=null,(p[0]>f[2]||f[0]>p[2]||p[1]>f[3]||f[1]>p[3])&&(0===r?h=pf:2===r?h=o:(1===r||3===r)&&(h=o.concat(s))),d=h)return d===pf?null:d;let m=function(t){let i,r,a=function(t){let i,r,a,n,o,s=[];for(r=0,a=t.length;r<a;r++)((i=t[r]).left&&i.inResult||!i.left&&i.otherEvent.inResult)&&s.push(i);let l=!1;for(;!l;)for(l=!0,r=0,a=s.length;r<a;r++)r+1<a&&1===pr(s[r],s[r+1])&&(n=s[r],s[r]=s[r+1],s[r+1]=n,l=!1);for(r=0,a=s.length;r<a;r++)(i=s[r]).otherPos=r;for(r=0,a=s.length;r<a;
7r++)(i=s[r]).left||(o=i.otherPos,i.otherPos=i.otherEvent.otherPos,i.otherEvent.otherPos=o);return s}(t),n={},o=[];for(i=0,r=a.length;i<r;i++){if(n[i])continue;let t=o.length,r=function(t,i,r){let a=new ph;if(null!=t.prevInResult){let n=t.prevInResult,o=n.outputContourId;if(n.resultTransition>0){let t=i[o];if(null!=t.holeOf){let n=t.holeOf;i[n].holeIds.push(r),a.holeOf=n,a.depth=i[o].depth}else i[o].holeIds.push(r),a.holeOf=o,a.depth=i[o].depth+1}else a.holeOf=null,a.depth=i[o].depth}else a.holeOf=null,a.depth=0;return a}(a[i],o,t),s=i=>{n[i]=!0,i<a.length&&a[i]&&(a[i].outputContourId=t)},l=i,h=i;for(r.points.push(a[i].point);s(l),s(l=a[l].otherPos),r.points.push(a[l].point),!((l=function(t,i,r,a){let n,o=t+1,s=i[t].point,l=i.length;for(o<l&&(n=i[o].point);o<l&&n[0]===s[0]&&n[1]===s[1];){if(!r[o])return o;++o<l&&(n=i[o].point)}for(o=t-1;r[o]&&o>a;)o--;return o}(l,a,n,h))==h||l>=a.length)&&a[l];);o.push(r)}return o}(function(t,i,r,a,n,o){let s,l,h,u=new dJ(pl),c=[],d=Math.min(a[2],n[2]);for(;0!==t.length;){let i=t.pop();if(c.push(i),0===o&&i.point[0]>d||2===o&&i.point[0]>a[2])break;if(i.left){l=s=u.insert(i),s=s!==(h=u.minNode())?u.prev(s):null,l=u.next(l);let r=s?s.key:null;if(d9(i,r,o),l&&2===ps(i,l.key,t)&&(d9(i,r,o),d9(l.key,i,o)),s&&2===ps(s.key,i,t)){let t=s;d9(r,(t=t!==h?u.prev(t):null)?t.key:null,o),d9(i,r,o)}}else i=i.otherEvent,l=s=u.find(i),s&&l&&(s=s!==h?u.prev(s):null,l=u.next(l),u.remove(i),l&&s&&ps(s.key,l.key,t))}return c}(_,0,0,p,f,r)),g=[];for(let t=0;t<m.length;t++){let i=m[t];if(i.isExterior()){let t=[i.points];for(let r=0;r<i.holeIds.length;r++)t.push(m[i.holeIds[r]].points);g.push(t)}}return g}function pm(t,i=1){return[t.map(t=>t.map(t=>[t.x*i,t.y*i]))]}function pg(t,i){let r=Math.floor(t)+.5;return Math.abs(t-r)<=i?Math.round(r):Math.round(t)}class py{constructor(t){this.xs=[],this.ys=[],this.ixs=[],this.iys=[],this.buckets=new Map,this.tolerance=t}canonicalize(t,i){let r=this.tolerance,a=Math.floor(t/r),n=Math.floor(i/r);for(let o=-1;o<=1;o++){let s=this.buckets.get(a+o);if(s)for(let o=-1;o<=1;o++){let l=s.get(n+o);if(l){for(let o of l)if(Math.abs(this.xs[o]-t)<=r&&Math.abs(this.ys[o]-i)<=r){let r=this.ixs[o],s=this.iys[o];return this.xs[o]===t&&this.ys[o]===i||this.store(t,i,r,s,a,n),[r,s]}}}}let o=pg(t,r),s=pg(i,r);return this.store(t,i,o,s,a,n),[o,s]}store(t,i,r,a,n,o){let s=this.xs.length;this.xs.push(t),this.ys.push(i),this.ixs.push(r),this.iys.push(a);let l=this.buckets.get(n);l||(l=new Map,this.buckets.set(n,l));let h=l.get(o);h||(h=[],l.set(o,h)),h.push(s)}}function px(t,i=1,r){let a=null!=r?new py(r):null;return t.map(t=>t.map((t,r)=>{let n=t.map(t=>{let r=t[0]*i,n=t[1]*i;if(a){let[t,i]=a.canonicalize(r,n);return new tg(t,i)}return new tg(Math.round(r),Math.round(n))});return r>0&&n.reverse(),n}))}class pv{constructor(){this.frcCoverage=new Set,this.featureTriSegments=[],this.frcPerLevel=new Map,this.frcNonRoadSegments=new l9}empty(){return 0===this.frcCoverage.size}}function pb(t,i,r){if(0===t.frcCoverage.size||0===t.featureTriSegments.length)return;let a=r.get(),n=i.uint16,o=[];t.featureTriSegments.sort((t,i)=>t.segIdx!==i.segIdx?t.segIdx-i.segIdx:null===t.frc&&null===i.frc?0:null===t.frc?-1:null===i.frc?1:i.frc-t.frc);let s=new Map,l=0,h=t.featureTriSegments[0].frc,u={vertexOffset:a[l].vertexOffset,primitiveOffset:0,vertexLength:a[l].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0},c=()=>{u.primitiveLength>0&&(s.has(h)||s.set(h,[]),s.get(h).push({...u}))};for(let i of t.featureTriSegments){i.segIdx!==l&&(c(),l=i.segIdx,h=i.frc,u={vertexOffset:a[l].vertexOffset,primitiveOffset:o.length/3,vertexLength:a[l].vertexLength,primitiveLength:0,vaos:{},sortKey:void 0}),i.frc!==h&&(c(),h=i.frc,u={...u,primitiveOffset:o.length/3,primitiveLength:0});for(let t=i.start;t<i.end;t++)o.push(n[t]);u.primitiveLength+=(i.end-i.start)/3}c();for(let t=0;t<o.length;t++)n[t]=o[t];for(let[i,r]of s)null!==i?t.frcPerLevel.set(i,new l9(r)):t.frcNonRoadSegments=new l9(r);t.featureTriSegments=[]}oC(pv,"FrcSegmentData");let pw={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 pT(t){for(let i of["class","incident_class"]){let r=t[i];if("string"!=typeof r)continue;let a=pw[r];if(void 0!==a)return a}return null}oC(class{constructor(t,i,r){this.elevationMode=i,i&&(this.elevationBufferData=new dk(t.layers,t.zoom,t.lut)),r&&(this.frcData=new pv)}isEmpty(){let t=!this.elevationBufferData||this.elevationBufferData.isEmpty(),i=!this.frcData||this.frcData.empty();return t&&i}needsUpload(){return!!this.elevationBufferData&&this.elevationBufferData.needsUpload()}trackFeatureFrc(t){if(!this.frcData)return null;let i=pT(t||{});return null!==i&&this.frcData.frcCoverage.add(i),i}recordFeatureRange(t,i,r,a){if(!this.frcData||r<=i)return;
7let n=t.bufferData.triangleSegments.get();this.frcData.featureTriSegments.push({start:3*i,end:3*r,segIdx:n.length>0?n.length-1:0,frc:a})}buildFrcSegments(t){this.frcData&&!this.frcData.empty()&&pb(this.frcData,t.bufferData.indexArray,t.bufferData.triangleSegments)}handleFeature(t,i,r,a,n,o){let s=[];if(!this.elevationMode)return!1;let l=dK(t,n,void 0,a);if(!l)return!1;{let t=this.clipPolygonsToTile(i,1);t.length>0&&s.push({polygons:t,elevationFeature:l.feature,elevationTileID:l.tileId})}let h={guardRailEnabled:o.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(t,{},a),featureIndex:r};for(let i of s)if(i.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new dU(i.elevationTileID,o.layers,o.zoom,o.lut));let r=i.elevationFeature.isTunnel(),a=0;Object.hasOwn(t.properties,ui)&&(a=+t.properties[ui]),this.elevatedStructures.addPortalCandidates(i.elevationFeature.id,i.polygons,r,i.elevationFeature,a)}null==i.elevationFeature.constantHeight&&(i.polygons=this.prepareElevatedPolygons(i.polygons,i.elevationFeature,i.elevationTileID));let n=new dX(a,i.elevationTileID);this.addElevatedGeometry(o,i.polygons,n,i.elevationFeature,.05*("hd-road-base"!==this.elevationMode),r,h)}return!0}populatePaintArrays(t,i,r,a,n,o,s){this.elevationBufferData&&this.elevationBufferData.populatePaintArrays(t,i,r,a,n,o,s)}update(t,i,r,a,n,o,s,l){this.elevationBufferData&&this.elevationBufferData.update(t,i,r,a,n,o,s,l),this.elevatedStructures&&this.elevatedStructures.update(t,i,r,a,n,o,s,l)}updateExpressions(t){this.elevationBufferData&&this.elevationBufferData.programConfigurations.updateExpressions(t),this.elevatedStructures&&(this.elevatedStructures.bridgeProgramConfigurations.updateExpressions(t),this.elevatedStructures.tunnelProgramConfigurations.updateExpressions(t))}upload(t){this.elevationBufferData&&this.elevationBufferData.upload(t),this.elevatedStructures&&this.elevatedStructures.upload(t)}destroy(){this.elevationBufferData&&this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(t,i,r,a,n,o){this.elevatedStructures&&(this.elevatedStructures.construct(t),this.elevatedStructures.populatePaintArrays(i,r,a,n,o))}addElevatedGeometry(t,i,r,a,n,o,s){let[l,h]=t.addGeometry(i,this.elevationBufferData,{elevation:a,elevationSampler:r,bias:n,index:o,featureInfo:s},this.elevatedStructures);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:l,max:h}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,l),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,h))}prepareElevatedPolygons(t,i,r){let a=1/s6(r),n=[];for(let r of t){let t=function(t,i,r=0){let a=pm(t,65536),n=[];for(;i.valid();i.next()){let[t,a]=i.get(),o=65536*t.x,s=65536*t.y,l=65536*a.x,h=65536*a.y,u=l-o,c=h-s,d=Math.hypot(u,c);if(0===d)continue;o-=u*r,s-=c*r,l+=u*r,h+=c*r;let p=Math.trunc(c/d*3),f=-Math.trunc(u/d*3);n.push([[[o,s],[l,h],[l+p,h+f],[o+p,s+f],[o,s]]])}return n.length>0&&(a=p_(a,n,2)),px(a,152587890625e-16,.001)}(r,new d$(i,a),.1);n.push(...t)}return n}clipPolygonsToTile(t,i){let r=-i,a=-i,n=8192+i,o=8192+i,s=0,l=[],h=[];for(;s<t.length;s++){let i=t[s],u=function(t){let i=new tg(1/0,1/0),r=new tg(-1/0,-1/0);for(let a of t[0])i.x>a.x&&(i.x=a.x),i.y>a.y&&(i.y=a.y),r.x<a.x&&(r.x=a.x),r.y<a.y&&(r.y=a.y);return{min:i,max:r}}(i);(u.min.x>=r&&u.max.x<=n&&u.min.y>=a&&u.max.y<=o?l:h).push(i)}if(l.length===t.length)return t;let u=[new tg(r,a),new tg(n,a),new tg(n,o),new tg(r,o),new tg(r,a)];for(let t of h)l.push(...function(t,i){let r=p_(pm(t),pm([i]),0);return null==r?[]:px(r)}(t,u));return l}},"FillHDExtension"),oC(dU,"ElevatedStructures"),oC(class{constructor(t,i){this.elevationEnabled=t,this.hasDeferredElevationFeatures=!1,i&&(this.frcData=new pv)}isEmpty(){let t=!this.elevationEnabled||void 0===this.heightRange,i=!this.frcData||this.frcData.empty();return t&&i}trackFeatureFrc(t){if(!this.frcData)return null;let i=pT(t||{});return null!==i&&this.frcData.frcCoverage.add(i),i}recordFeatureRange(t,i,r,a){if(!this.frcData||r<=i)return;let n=t.segments.get();this.frcData.featureTriSegments.push({start:3*i,end:3*r,segIdx:n.length>0?n.length-1:0,frc:a})}buildFrcSegments(t){this.frcData&&!this.frcData.empty()&&pb(this.frcData,t.indexArray,t.segments)}
7handleFeature(t,i,r,a,n,o,s,l,h,u,c){if(!this.elevationEnabled)return!1;if(!c.terrainEnabled){let d=dK(t,a,n?n.registry:void 0,r),p=null!=t.properties&&Object.hasOwn(t.properties,ut)&&!Number.isNaN(+t.properties[ut]);if(!d&&p&&o&&(!n||!n.allProvidersReady))return this.hasDeferredElevationFeatures=!0,!0;if(d){let a=d.feature,o=d.tileId;if(!d.tileId.equals(r)){let i=this.mergedFeatureCache?this.mergedFeatureCache.get(a.id):void 0;if(i)a=i,o=r;else{let i=function(t,i,r){if(!t.properties||!i||0===i.length)return[];let a=+t.properties[ut];if(Number.isNaN(a))return[];let n=dY(i,a);if(n<0)return[];let o=[];for(let t=n;t<i.length&&i[t].feature.id===a;t++){let a=i[t];(a.tileId.isChildOf(r)||r.isChildOf(a.tileId)||null!=a.feature.constantHeight)&&o.push(a)}return o}(t,n?n.registry:void 0,r);i.length>1&&(a=function(t,i){let r=i.slice().sort((t,i)=>i.tileId.z-t.tileId.z),a=new tg(1/0,1/0),n=new tg(-1/0,-1/0),o=[];for(let i of r){let r=new dX(i.tileId,t);for(let t of i.feature.vertices)o.push({position:r.pointTransform(t.position),height:t.height,extent:t.extent,index:t.index});let s=i.feature.safeArea;dG[0]=s.min.x,dG[1]=s.min.y,dH[0]=s.max.x,dH[1]=s.max.y,r.pointTransformInPlace(dG),r.pointTransformInPlace(dH),a.x=Math.min(a.x,dG[0],dH[0]),a.y=Math.min(a.y,dG[1],dH[1]),n.x=Math.max(n.x,dG[0],dH[0]),n.y=Math.max(n.y,dG[1],dH[1])}let s={min:a,max:n};if(null!=r[0].feature.constantHeight)return new dW(r[0].feature.id,s,r[0].feature.constantHeight);o.sort((t,i)=>t.index-i.index);let l=[];for(let t of o)0!==l.length&&l.at(-1).index===t.index||l.push(t);let h=[];for(let t=1;t<l.length;t++)l[t].index-l[t-1].index<=1&&h.push({a:t-1,b:t});let u=1/s6(t);return new dW(r[0].feature.id,s,void 0,l,h,u)}(r,i),o=r,this.mergedFeatureCache||(this.mergedFeatureCache=new Map),this.mergedFeatureCache.set(a.id,a))}}let p=h3(i,-1,-1,8193,8193);for(let i of this.prepareElevatedLines(p,a,o,r)){let n=c.layoutVertexArray.length;c.addLine(i,t,r,s,l,h,u);let d=new dX(r,o),p=c.showElevationIdDebug?function(t){if(0===t)return[0,0,0];let i=n5(t);return[i(),i(),i()]}(a.id):null;for(let t=n;t<c.layoutVertexArray.length;t++){let i=new tg(c.layoutVertexArray.int16[6*t]>>1,c.layoutVertexArray.int16[6*t+1]>>1),r=d.pointElevation(i,a,.05);this.updateHeightRange(r),t<c.zOffsetVertexArray.length?c.zOffsetVertexArray.float32[4*t]=r:c.zOffsetVertexArray.emplaceBack(r,0,0,0),p?t<c.elevationIdColVertexArray.length?(c.elevationIdColVertexArray.float32[3*t]=p[0],c.elevationIdColVertexArray.float32[3*t+1]=p[1],c.elevationIdColVertexArray.float32[3*t+2]=p[2]):c.elevationIdColVertexArray.emplaceBack(p[0],p[1],p[2]):c.showElevationIdDebug&&(t<c.elevationIdColVertexArray.length?(c.elevationIdColVertexArray.float32[3*t]=0,c.elevationIdColVertexArray.float32[3*t+1]=0,c.elevationIdColVertexArray.float32[3*t+2]=0):c.elevationIdColVertexArray.emplaceBack(0,0,0))}}return!0}if(p&&o&&n&&n.allProvidersReady&&n.hasCoveringTile)return!0}let d=!(!t.properties||!Object.hasOwn(t.properties,"mapbox_line_metrics"))&&t.properties.mapbox_line_metrics,p=c.layoutVertexArray.length,f=[],_=h3(i,-1,-1,8193,8193,f);for(let i=0;i<_.length;i++){let a=_[i],n=f[i],o={progress:{min:n.progress.min,max:n.progress.max},nextDir:n.nextPoint.sub(a.at(-2)).unit(),prevDir:a[1].sub(n.prevPoint).unit()};c.addLine(a,t,r,s,l,h,u,o,d&&n.parentIndex>0?n.parentIndex:null)}return c.fillNonElevatedRoadSegment(p),!0}prepareElevatedLines(t,i,r,a){if(null!=i.constantHeight)return t;let n=[],o=1/s6(a),s=r.equals(a)?null:new dX(r,a);for(let r of t)!function(t,i,r,a,n){if(t.length<2)return a.push(t);let o=[];for(;i.valid();){let[r,a]=i.get();for(let i=0;i<t.length-1;i++){let n=t[i],s=t[i+1],l=function(t,i,r,a){let n=hq(t,i,a),o=hq(t,i,r);if(Math.sign(n)===Math.sign(o))return;let s=hq(r,a,t),l=s+o-n;return Math.sign(s)!==Math.sign(l)?[s/(s-l),o/(o-n)]:void 0}(n,s,r,a);if(l){let[t]=l,r=new tg(rG(n.x,s.x,t),rG(n.y,s.y,t));o.push({t:i+t,distance:0,point:r})}}i.next()}if(0===o.length)return a.push(t);o.sort((t,i)=>t.t-i.t);let s=0,l=0,h=[];for(a.push(h);s!==t.length;){if(l===o.length){for(;s!==t.length;)0!==h.length&&h.at(-1).equals(t[s])||h.push(t[s]),s++;break}o[l].t<=s?(0!==h.length&&h.at(-1).equals(o[l].point)||h.push(o[l].point),o[l].t,l++):(0!==h.length&&h.at(-1).equals(t[s])||h.push(t[s]),s++)}}(r,new d$(i,o,s),0,n);return n}updateHeightRange(t){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,t),this.heightRange.max=Math.max(this.heightRange.max,t)):this.heightRange={min:t,max:t}}endPopulate(){this.mergedFeatureCache=void 0}},"LineHDExtension"),oC(class{constructor(){this.elevatedLayoutVertexArray=new l
7c,this.hasElevation=!1}beginFeature(t,i,r){let a=dK(t,i,void 0,r);this.currentFeatureElevation=a?a.feature:void 0}writeVertexQuad(t,i){let r=this.currentFeatureElevation?this.currentFeatureElevation.pointElevation(new tg(t,i)):0;this.hasElevation=this.hasElevation||0!==r;for(let t=0;t<4;t++)this.elevatedLayoutVertexArray.emplaceBack(r)}finalize(){this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}upload(t){this.elevatedLayoutVertexArray&&!this.elevatedLayoutVertexBuffer&&(this.elevatedLayoutVertexBuffer=t.createVertexBuffer(this.elevatedLayoutVertexArray,uh.members))}destroy(){this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy()}},"CircleHDExtension");let pE=(t,i,r,a)=>{for(let n=0;n<i;n++)t.emplaceBack(r[0],r[1],r[2],a[0],a[1],a[2])};oC(class{constructor(){this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map,this.elevationStateComplete=!1}addElevationFeatures(t){for(let i of t)this.elevationFeatureIdToIndex.set(i.id,this.elevationFeatures.length),this.elevationFeatures.push(i)}updateRoadElevation(t,i){if(this.elevationStateComplete)return;this.elevationStateComplete=!0,t.hasAnyZOffset=!1;let r=!1,a=s6(i),n=1/a,o=!1,s=!1;for(let i=0;i<t.symbolInstances.length;i++){let l=t.symbolInstances.get(i),h=eO(1,0,0),u=eO(0,1,0),{numHorizontalGlyphVertices:c,numVerticalGlyphVertices:d,numIconVertices:p,numVerticalIconVertices:f}=l,_=c>0||d>0,m=p>0,g=this.elevationFeatures[l.elevationFeatureIndex];if(g){let i=new tg(l.tileAnchorX,l.tileAnchorY),c=.075+g.pointElevation(i);l.zOffset!==c&&(r=!0,l.zOffset=c),0!==c&&(t.hasAnyZOffset=!0);let d=g.computeSlopeNormal(i,n),p=ts(e7(),eO(0,0,1),d);e0(h,h,p),e0(u,u,p),h[2]*=a,u[2]*=a,1===h[0]&&0===h[1]&&0===h[2]&&0===u[0]&&1===u[1]&&0===u[2]||(o=o||_,s=s||m)}if(_&&(pE(t.text.orientationVertexArray,c,h,u),pE(t.text.orientationVertexArray,d,h,u)),m){let{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:r}=l;i>=0&&pE(t.icon.orientationVertexArray,p,h,u),r>=0&&pE(t.icon.orientationVertexArray,f,h,u)}}o||(t.text.orientationVertexArray=void 0),s||(t.icon.orientationVertexArray=void 0),r&&(t.zOffsetBuffersNeedUpload=!0,t.zOffsetSortDirty=!0)}getElevationFeatureForPlacedSymbol(t,i,r){let a=t.symbolInstances.get(i.symbolInstanceIndices[r]).elevationFeatureIndex;if(a<this.elevationFeatures.length)return this.elevationFeatures[a]}},"SymbolHDExtension");let pS=null,pI=null,pA=null,pC=null,pM={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},pR={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},pD={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function pP(t,i,r){let a=r.json.bufferViews.length,n=r.buffers.length;i.bufferView=a,r.json.bufferViews[a]={buffer:n,byteLength:t.byteLength},r.buffers[n]=t}let pz="KHR_draco_mesh_compression",pL="EXT_meshopt_compression",pO=new TextDecoder("utf8");function pF(t,i){return new URL(t,i).href}async function pB(t,i,r,a,n){let o=await fetch(pF(t.uri,a),{signal:n}),s=await o.arrayBuffer();i.buffers[r]=s}function pk(t,i){let r=t.json.bufferViews[i];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}async function pN(t,i,r,a,n){if(t.uri){let o=pF(t.uri,a),s=await fetch(o,{signal:n}),l=await s.blob(),h=await createImageBitmap(l);i.images[r]=h}else if(void 0!==t.bufferView){let a=new Blob([pk(i,t.bufferView)],{type:t.mimeType}),n=await createImageBitmap(a);i.images[r]=n}}async function pV(t,i){let{data:r}=await i4({url:t},i);return async function(t,i=0,r,a){let n={json:null,images:[],buffers:[]};if(0x46546c67===new Uint32Array(t,i,1)[0]){let r=new Uint32Array(t,i),a=2,o=(r[a++]>>2)-3,s=r[a++]>>2;if(a++,n.json=JSON.parse(pO.decode(r.subarray(a,a+s))),(a+=s)<o){let o=r[a++],s=i+(++a<<2);n.buffers[0]=t.slice(s,s+o)}}else n.json=JSON.parse(pO.decode(new Uint8Array(t,i)));let{buffers:o,images:s,meshes:l,extensionsUsed:h,bufferViews:u}=n.json;if(o){let t=[];for(let i=0;i<o.length;i++){let s=o[i];s.uri?t.push(pB(s,n,i,r,a)):n.buffers[i]||(n.buffers[i]=null)}await Promise.all(t)}a&&a.throwIfAborted();let c=[],d=h&&h.includes(pz),p=h&&h.includes(pL);if(d&&c.push(function(){if(!pS)return null!=pI||(pI=(function(t){let i,r=null;function a(){i=new Uint8Array(r.buffer)}function n(){throw Error("Unexpected Draco error.")}return WebAssembly.instantiateStreaming(t,{a:{a:n,d:function(t,r,a){return i.copyWithin(t,r,r+a
7)},c:function(t){let n=i.length,o=Math.ceil((Math.max(t>>>0,Math.ceil(1.2*n))-n)/65536);try{return r.grow(o),a(),!0}catch(t){return!1}},b:n}}).then(t=>{let n,o,s,l,{Rb:h,Qb:u,P:c,T:d,X:p,Ja:f,La:_,Qa:m,Va:g,Wa:y,eb:x,jb:v,f:b,e:w,yb:T,zb:E,Ab:S,Bb:I,Db:A,Gb:C}=t.instance.exports;r=w;let M=(n=0,o=0,s=0,l=0,t=>{s&&(h(l),h(n),o+=s,s=n=0),n||(o+=128,n=u(o));let r=t.length+7&-8,a=n;r>=o&&(s=r,a=l=u(r));for(let r=0;r<t.length;r++)i[a+r]=t[r];return a});return a(),b(),{memory:w,_free:h,_malloc:u,Mesh:class{constructor(){this.ptr=c()}destroy(){d(this.ptr)}},Decoder:class{constructor(){this.ptr=f()}destroy(){v(this.ptr)}DecodeArrayToMesh(t,i,r){let a=M(t);return!!p(_(this.ptr,a,i,r.ptr))}GetAttributeByUniqueId(t,i){return{ptr:m(this.ptr,t.ptr,i)}}GetTrianglesUInt16Array(t,i,r){g(this.ptr,t.ptr,i,r)}GetTrianglesUInt32Array(t,i,r){y(this.ptr,t.ptr,i,r)}GetAttributeDataArrayForAllPoints(t,i,r,a,n){x(this.ptr,t.ptr,i.ptr,r,a,n)}},DT_INT8:T(),DT_UINT8:E(),DT_INT16:S(),DT_UINT16:I(),DT_UINT32:A(),DT_FLOAT32:C()}})})(fetch(iE())).then(t=>{pS=t,pI=null})),pI}()),p&&c.push(function(){var t;if(!pA)return null!=pC||(pC=(t=fetch(iS()),WebAssembly.instantiateStreaming(t,{}).then(t=>{let{sbrk:i,memory:r,meshopt_decodeVertexBuffer:a,meshopt_decodeIndexBuffer:n,meshopt_decodeIndexSequence:o,meshopt_decodeFilterOct:s,meshopt_decodeFilterQuat:l,meshopt_decodeFilterExp:h}=t.instance.exports,u={ATTRIBUTES:a,TRIANGLES:n,INDICES:o},c={OCTAHEDRAL:s,QUATERNION:l,EXPONENTIAL:h};return t.instance.exports.__wasm_call_ctors(),{decodeGltfBuffer(t,a,n,o,s,l){let h=a+3&-4,d=i(h*n),p=i(o.length),f=new Uint8Array(r.buffer);f.set(o,p);let _=u[s](d,a,n,p,o.length);if(0===_&&c[l]&&c[l](d,h,n),t.set(f.subarray(d,d+a*n)),i(d-i(0)),0!==_)throw Error(`Malformed buffer data: ${_}`)}}})).then(t=>{pA=t,pC=null})),pC}()),s)for(let t=0;t<s.length;t++)c.push(pN(s[t],n,t,r,a));if(c.length&&await Promise.all(c),a&&a.throwIfAborted(),d&&l)for(let{primitives:t}of l)for(let i of t)!function(t,i){let r=t.extensions&&t.extensions[pz];if(!r)return;let a=new pS.Decoder,n=pk(i,r.bufferView),o=new pS.Mesh;if(!a.DecodeArrayToMesh(n,n.byteLength,o))throw Error("Failed to decode Draco mesh");let s=i.json.accessors[t.indices],l=pM[s.componentType],h=s.count*l.BYTES_PER_ELEMENT,u=pS._malloc(h);for(let n of(l===Uint16Array?a.GetTrianglesUInt16Array(o,h,u):a.GetTrianglesUInt32Array(o,h,u),pP(pS.memory.buffer.slice(u,u+h),s,i),pS._free(u),Object.keys(r.attributes))){let s=a.GetAttributeByUniqueId(o,r.attributes[n]),l=i.json.accessors[t.attributes[n]],h=pR[l.componentType],u=l.count*pD[l.type]*pM[l.componentType].BYTES_PER_ELEMENT,c=pS._malloc(u);a.GetAttributeDataArrayForAllPoints(o,s,pS[h],u,c),pP(pS.memory.buffer.slice(c,c+u),l,i),pS._free(c)}a.destroy(),o.destroy(),delete t.extensions[pz]}(i,n);if(p&&l&&u)for(let t of u)!function(t,i){if(!t.extensions||!t.extensions[pL])return;let r=t.extensions[pL],a=new Uint8Array(i.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),n=new Uint8Array(r.count*r.byteStride);pA.decodeGltfBuffer(n,r.count,r.byteStride,a,r.mode,r.filter),t.buffer=i.buffers.length,t.byteOffset=0,i.buffers[t.buffer]=n.buffer,delete t.extensions[pL]}(t,n);return n}(r,0,t,i)}class pU{constructor(t,i,r,a){if(this.triangleCount=i.length/3,this.min=new tg(0,0),this.max=new tg(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===t.length)return;let[n,o]=[t[0].clone(),t[0].clone()];for(let i=1;i<t.length;++i){let r=t[i];n.x=Math.min(n.x,r.x),n.y=Math.min(n.y,r.y),o.x=Math.max(o.x,r.x),o.y=Math.max(o.y,r.y)}if(a&&(r=Math.max(r,Math.ceil(Math.max(o.x-n.x,o.y-n.y)/a))),0===r)return;this.min=n,this.max=o;let s=this.max.sub(this.min);s.x=Math.max(s.x,1),s.y=Math.max(s.y,1);let l=Math.max(s.x,s.y)/r;this.cellsX=Math.max(1,Math.ceil(s.x/l)),this.cellsY=Math.max(1,Math.ceil(s.y/l)),this.xScale=1/l,this.yScale=1/l;let h=[];for(let r=0;r<this.triangleCount;r++){let a=t[i[3*r+0]].sub(this.min),n=t[i[3*r+1]].sub(this.min),o=t[i[3*r+2]].sub(this.min),s=pj(Math.floor(Math.min(a.x,n.x,o.x)),this.xScale,this.cellsX),u=pj(Math.floor(Math.max(a.x,n.x,o.x)),this.xScale,this.cellsX),c=pj(Math.floor(Math.min(a.y,n.y,o.y)),this.yScale,this.cellsY),d=pj(Math.floor(Math.max(a.y,n.y,o.y)),this.yScale,this.cellsY),p=new tg(0,0),f=new tg(0,0),_=new tg(0,0),m=new tg(0,0);for(let t=c;t<=d;++t){p.y=f.y=t*l,_.y=m.y=(t+1)*l;for(let i=s;i<=u;++i)p.x=_.x=i*l,f.x=m.x=(i+1)*l,(hQ(a,n,o,p,f,m)||hQ(a,n,o,p,m,_))&&h.push({cellIdx:t*this.cellsX+i,triIdx:r})}}if(0===h.length)return;h.sort((t,i)=>t.cellIdx-i.cellIdx||t.triIdx-i.triIdx);let u=0;for(;u<h.length;){let t=h[u].cellIdx,i={start:this.payload.length,len:0};for(;u<h.length&&h[u].cellIdx===t;)++i.len,this.payload.push(h[u++].triIdx);this.cells[t]=i}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(t,i){if(0===this.triangleCount||0===this.cells.length||t.x>this.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;let r=pj(t.x-this.min.x,this.xScale,this.cellsX),a=pj(t.y-this.min.y,this.yScale,this.cellsY),n=this.cells[a*this.cellsX+r];if(n){this._lazyInitLookup();for(let t=0;t<n.len;t++){let r=this.payload[n.start+t],a=Math.floor(r/8),o=1<<r%8;if(!(this.lookup[a]&o)&&(this.lookup[a]|=o,i.push(r),i.length===this.triangleCount))return}}}query(t,i,r){if(0===this.triangleCount||0===this.cells.length||t.x>this.max.x||this.min.x>i.x||t.y>this.max.y||this.min.y>i.y)return;this._lazyInitLookup();let a=pj(t.x-this.min.x,this.xScale,this.cellsX),n=pj(i.x-this.min.x,this.xScale,this.cellsX),o=pj(t.y-this.min.y,this.yScale,this.cellsY),s=pj(i.y-this.min.y,this.yScale,this.cellsY);for(let t=o;t<=s;t++)for(let i=a;i<=n;
7i++){let a=this.cells[t*this.cellsX+i];if(a)for(let t=0;t<a.len;t++){let i=this.payload[a.start+t],n=Math.floor(i/8),o=1<<i%8;if(!(this.lookup[n]&o)&&(this.lookup[n]|=o,r.push(i),r.length===this.triangleCount))return}}}}function pj(t,i,r){return Math.max(0,Math.min(r-1,Math.floor(t*i)))}oC(pU,"TriangleGridIndex");let pG=lo([{name:"a_pos_3f",components:3,type:"Float32"}]),pH=lo([{name:"a_color_3f",components:3,type:"Float32"}]),pq=lo([{name:"a_color_4f",components:4,type:"Float32"}]),pZ=lo([{name:"a_uv_2f",components:2,type:"Float32"}]),p$=lo([{name:"a_normal_3f",components:3,type:"Float32"}]),pW=lo([{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"}]),pX=lo([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function pY(t,i){let r=pQ(t.projection,t.zoom,t.width,t.height),a=function(t,i,r,a,n){let o=new s0(r.lng-180*pJ,r.lat),s=new s0(r.lng+180*pJ,r.lat),l=t.project(o.lng,o.lat),h=t.project(s.lng,s.lat),u=-Math.atan2(h.y-l.y,h.x-l.x),c=s8.fromLngLat(r);c.y=tL(c.y,-1+pJ,1-pJ);let d=c.toLngLat(),p=t.project(d.lng,d.lat),f=s8.fromLngLat(d);f.x+=pJ;let _=f.toLngLat(),m=t.project(_.lng,_.lat),g=p1(m.x-p.x,m.y-p.y,u),y=s8.fromLngLat(d);y.y+=pJ;let x=y.toLngLat(),v=t.project(x.lng,x.lat),b=p1(v.x-p.x,v.y-p.y,u),w=Math.abs(g.x)/Math.abs(b.y),T=ef([]);ew(T,T,-u*(1-(n?0:a)));let E=ef([]);return ex(E,E,[1,1-(1-w)*a,1]),E[4]=-b.x/b.y*a,ew(E,E,u),eg(E,T,E),E}(t.projection,0,t.center,r,i),n=pK(t);return ex(a,a,[n,n,1]),a}function pK(t){let i=t.projection,r=pQ(t.projection,t.zoom,t.width,t.height);return Math.pow(2,p0(i,t.center)*r+(1-r)*p0(i,s0.convert(i.center)))}function pQ(t,i,r,a,n=1/0){let o=t.range;if(!o)return 0;let s=Math.log2(Math.min(n,Math.max(r,a))/1024);return tO(o[0]+s,o[1]+s,i)}let pJ=1/4e4;function p0(t,i){let r=tL(i.lat,-85.051129,85.051129),a=new s0(i.lng-180*pJ,r),n=new s0(i.lng+180*pJ,r),o=t.project(a.lng,r),s=t.project(n.lng,r),l=s8.fromLngLat(a),h=s8.fromLngLat(n),u=s.x-o.x,c=s.y-o.y,d=h.x-l.x,p=h.y-l.y;return Math.log2(Math.sqrt((d*d+p*p)/(u*u+c*c)))}function p1(t,i,r){let a=Math.cos(r),n=Math.sin(r);return{x:t*a-i*n,y:t*n+i*a}}let p2=new Float64Array([1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);function p3(t,i,r){ef(t),ew(t,t,i[2]*tA),ev(t,t,i[0]*tA),eb(t,t,i[1]*tA),ex(t,t,r),eg(t,t,p2)}function p4(t,i,r,a,n,o,s,l){let h=[r[0]-i[0],r[1]-i[1],0],u=[a[0]-i[0],a[1]-i[1],0];if(1e-12>eL(h)||1e-12>eL(u))return te(t);let c=eY([],h,u);return eW(c,c),ek(u,a,i),h[2]=(o-n)*l,u[2]=(s-n)*l,eY(h,h,u),eW(h,h),ts(t,c,h)}function p5(t,i,r=!1){let a=cN(i.zoom),n=function(t,i,r){let a=i.worldSize,n=[t[12],t[13],t[14]],o=aF(n[1]/a),s=aO(n[0]/a),l=ef([]),h=1/s2(o)*a,u=1/s2(0)*a*s4(o,i.zoom),c=1/cO(a),d=u*c;if(r){let t=pQ(i.projection,i.zoom,i.width,i.height,1024);d=c*i.projection.pixelSpaceConversion(i.center.lat,a,t)}let p=sQ(o,s);eB(p,p,ej([],eW([],p),h*d*n[2]));let f=function(t){let i=[t[0],t[1],t[2]],r=[0,1,0],a=eY([],r,i);return eY(r,i,a),0===eZ(r)&&eY(a,i,r=[0,1,0]),eW(a,a),eW(r,r),eW(i,i),[a[0],a[1],a[2],0,r[0],r[1],r[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],1]}(p);ex(l,l,[d,d,d*h]),ey(l,l,[-n[0],-n[1],-n[2]]);let _=eg([],i.globeMatrix,f);return eg(_,_,l),eg(_,_,t),_}(t,i,r);return a>0?function(t,i,r){let a=(t,i,r)=>{let a=eL(t),n=eL(i),o=cE(t,i,r);return ej(o,o,1/eL(o)*rG(a,n,r))},n=a([t[0],t[1],t[2]],[i[0],i[1],i[2]],r),o=a([t[4],t[5],t[6]],[i[4],i[5],i[6]],r),s=a([t[8],t[9],t[10]],[i[8],i[9],i[10]],r),l=cE([t[12],t[13],t[14]],[i[12],i[13],i[14]],r);return[n[0],n[1],n[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,l[0],l[1],l[2],1]}(n,function(t,i){let r=i.worldSize,a=1/s2(0)*r*s4(i.center.lat,i.zoom)/cO(r),n=1/s2(i.center.lat)*r,o=ef([]);eb(o,o,i.center.lng*tA),ev(o,o,i.center.lat*tA),ey(o,o,[0,0,sW]),ex(o,o,[a,a,a*n]);let s=i.point;return ey(o,o,[-s.x,-s.y,0]),eg(o,o,t),eg(o,i.globeMatrix,o)}(t,i),a):n}function p6(t,i,r,a){let n=cg.projectAabbCorners(a,r),o=Number.MAX_VALUE;for(let t=0;t<n.length;++t){let r=n[t];r[0]=(.5*r[0]+.5)*i.width,r[1]=(.5-.5*r[1])*i.height,r[2]<o&&(o=r[2])}if(hj(t,function(t){let i=[],r=0;for(let i=1;i<t.length;i++)(t[i][0]<t[r][0]||t[i][0]===t[r][0]&&t[i][1]<t[r][1])&&(r=i);let a,n=r,o=new Uint8Array(t.length);do{if(o[n])break;i.push(new tg(t[n][0],t[n][1])),o[n]=1,a=(n+1)%t.length;for(let i=0;i<t.length;i++){if(t[i][0]===t[a][0]&&t[i][1]===t[a][1]||t[i][0]===t[n][0]&&t[i][1]===t[n][1])continue;let r=[t[i][0]-t[n][0],t[i][1]-t[n][1]],o=[t[a][0]-t[n][0],t[a][1]-t[n][1]],s=r[0]*o[1]-r[1]*o[0];(s>
70||0===s&&r[0]*o[0]+r[1]*o[1]>=0&&r[0]*r[0]+r[1]*r[1]>o[0]*o[0]+o[1]*o[1])&&(a=i)}n=a}while(n!==r);return i.length>0&&i.push(i[0]),i}(n)))return o}let p8=[1,1,1];function p9(t,i,r,a,n,o,s,l,h,u=!1){let c=r.zoom,d=r.project(a),p=s4(a.lat,c),f=1/p;ef(t),ey(t,t,[d.x+s[0]*f,d.y+s[1]*f,s[2]]);let _=1,m=1,g=r.worldSize;if(u){if("mercator"===r.projection.name){let t=0;r.elevation&&(t=r.elevation.getAtPointOrZero(new s8(d.x/g,d.y/g),0));let i=e9([],[d.x,d.y,t,1],r.projMatrix)[3]/r.cameraToCenterDistance;_=i,m=i*s4(r.center.lat,c)}else if("globe"===r.projection.name){let i=p5(t,r),n=[0,0,0,1];e9(n,n,eg([],r.projMatrix,i));let o=n[3]/r.cameraToCenterDistance,s=cN(c),l=r.projection.pixelsPerMeter(a.lat,g)*s4(a.lat,c),h=r.projection.pixelsPerMeter(r.center.lat,g)*s4(r.center.lat,c);_=o/rG(l,s3(r.center.lat),s),m=o*p/l,_*=h,m*=h}}else _=f;ex(t,t,[_,_,m]);let y=[...t],x=i.orientation,v=[];if(p3(v,[x[0]+(n?n[0]:0),x[1]+(n?n[1]:0),x[2]+(n?n[2]:0)],o),eg(t,y,v),l&&r.elevation){let n=0,o=[];if(h&&r.elevation){n=function(t,i,r,a,n){let o=i.elevation;if(!o)return 0;let s=cg.projectAabbCorners(r,a),l=1/s2(n.lat)*i.worldSize,h=function(t,i){let r=[0,0,1],a=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(let n of a){let a=t[n.corners[0]],o=t[n.corners[1]],s=t[n.corners[2]],l=[o[0]-a[0],o[1]-a[1],i*(o[2]-a[2])],h=eY(l,l,[s[0]-a[0],s[1]-a[1],i*(s[2]-a[2])]);eW(h,h),n.dotProductWithUp=eX(h,r)}return a.sort((t,i)=>t.dotProductWithUp-i.dotProductWithUp),a[0].corners}(s,l),u=s[h[0]],c=s[h[1]],d=s[h[2]],p=s[h[3]],f=o.getAtPointOrZero(new s8(u[0]/i.worldSize,u[1]/i.worldSize),0),_=o.getAtPointOrZero(new s8(c[0]/i.worldSize,c[1]/i.worldSize),0),m=o.getAtPointOrZero(new s8(d[0]/i.worldSize,d[1]/i.worldSize),0),g=o.getAtPointOrZero(new s8(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,x=(_+m)/2;return y>x?_<m?p4(t,c,p,u,_,g,f,l):p4(t,d,u,p,m,f,g,l):f<g?p4(t,u,c,d,f,_,m,l):p4(t,p,d,c,g,m,_,l),Math.max(y,x)}(o,r,i.aabb,t,a);let s=eg([],eM([],o),v);eg(t,y,s)}else n=r.elevation.getAtPointOrZero(new s8(d.x/g,d.y/g),0);0!==n&&(t[14]+=n)}}class p7{constructor(t,i,r,a,n){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=t,this.uri=i,this.position=null!=r?new s0(r[0],r[1]):new s0(0,0),this.orientation=null!=a?a:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new cg([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,i){var r;eg(t.globalMatrix,i,t.localMatrix);let a=this.nodeOverrides.get(t.name);if(void 0!==a){if(a.orientation){let i=[];r=a.orientation,ef(i),eb(i,i,r[1]*tA),ew(i,i,r[2]*tA),ev(i,i,r[0]*tA),eg(t.globalMatrix,t.globalMatrix,i)}a.minZoom&&(t.minZoom=a.minZoom),a.maxZoom&&(t.maxZoom=a.maxZoom)}if(t.meshes)for(let i of t.meshes){let r=cg.applyTransformFast(i.aabb,t.globalMatrix);this.aabb.encapsulate(r)}if(t.children)for(let i of t.children)this._applyTransformations(i,t.globalMatrix)}computeBoundsAndApplyParent(){let t=ef([]);for(let i of(this.aabb=new cg([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.nodes))this._applyTransformations(i,t)}computeModelMatrix(t,i,r,a,n,o,s=!1){p9(this.matrix,this,t.transform,this.position,i,r,a,n,o,s)}upload(t){if(!this.uploaded){for(let i of this.nodes)fi(i,t);for(let t of this.nodes)fa(t);this.uploaded=!0}}destroy(){for(let t of this.nodes)fo(t)}}function fe(t,i,r=!1){t.uploaded||(t.gfxTexture=new uW(i,t.image,r?i.gl.R8:i.gl.RGBA8,{useMipmap:t.sampler.minFilter>=i.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function ft(t,i,r){t.indexBuffer=i.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=i.createVertexBuffer(t.vertexArray,pG.members,!1,!0),t.normalArray&&(t.normalBuffer=i.createVertexBuffer(t.normalArray,p$.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=i.createVertexBuffer(t.texcoordArray,pZ.members,!1,!0)),t.colorArray&&(t.colorBuffer=i.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?pH:pq).members,!1,!0)),t.featureArray&&(t.pbrBuffer=i.createVertexBuffer(t.featureArray,pX.members,!0)),t.segments=l9.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);let a=t.material;a.pbrMetallicRoughness.baseColorTexture&&fe(a.pbrMetallicRoughness.baseColorTexture,i),a.pbrMetallicRoughness.metallicRoughnessTexture&&fe(a.pbrMetallicRoughness.metallicRoughnessTexture,i),a.normalTexture&&fe(a.normalTexture,i),a.occlusionTexture&&fe(a.occlusionTexture,i,r),a.emissionTexture&&fe(a.emissionTexture,i)}function fi(t,i,r){if(t.meshes)for(let a of t.meshes)ft(a,i,r);if(t.lodMeshes)for(let a of t.lodMeshes)ft(a,i,r);if(t.children)for(let a of t.children)fi(a,i,r)}function fr(t){t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy()}function fa(t){if(t.meshes)for(let i of t.meshes)fr(i);if(t.lodMeshes)for(let i of t.lodMeshes)fr(i);if(t.children)for(let i of t.children)fa(i)}function fn(t){var i;t.vertexBuffer&&(t.vertexBuffer.destroy(),t.indexBuffer.destroy(),t.normalBuffer&&t.normalBuffer.destroy(),t.texcoordBuffer&&t.texcoordBuffer.destroy(),t.colorBuffer&&t.colorBuffer.destroy(),t.pbrBuffer&&t.pbrBuffer.destroy(),t.segments.destroy(),t.material&&((i=t.material).pbrMetallicRoughness.baseColorTexture&&i.pbrMetallicRoughness.baseColorTexture.gfxTexture&&i.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),i.pbrMetallicRoughness.metallicRoughnessTexture&&i.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&i.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),i.normalTexture&&i.normalTexture.gfxTexture&&i.normalTexture.gfxTexture.destroy(),i.emissionTexture&&i.emissionTexture.gfxTexture&&i.emissionTexture.gfxTexture.destroy(),i.occlusionTexture&&i.occlusionTexture.gfxTexture&&i.occlusionTexture.gfxTexture.destroy()))}function fo(t){if(t.meshes)for(let i of t.meshes)fn(i);if(t.lodMeshes)for(let i of t.lodMeshes)fn(i);if(t.footprintDebugMesh&&(t.footprintDebugMesh.vertexBuffer.destroy(),t.footprintDebugMesh.indexBuffer.destroy(),t.footprintDebugMesh.segments.destroy()),t.children)for(let i of t.children)fo(i)}function fs(t,i,r,a){return t[0]<=a[0]&&i[0]>=r[0]&&t[1]<=a[1]&&i[1]>=r[1]&&t[2]<=a[2]&&i[2]>=r[2]}let fl=[];class fh{serializeFromGltf(t,i,r,a){if(t.length<7)return;let n=0;if(109!==t[n++]||98!==t[n++]||120!==t[n++]||98!==t[n++]||118!==t[n++]||104!==t[n++]||43!==t[n++])return;let o=new DataView(t.buffer,t.byteOffset),s=o.getUint16(n,!0);if(n+=2,0===s)return;this._nodes=[];let l=0;for(let t=0;t<s;t++){let t=[i[3*l],i[3*l+1],i[3*l+2]],a=[r[3*l],r[3*l+1],r[3*l+2]];l++;let s=o.getUint16(n,!0);n+=2;let h=0,u=0;65535===s&&(h=o.getUint16(n,!0),n+=2,u=o.getUint32(n,!0),n+=4),this._nodes.push({aabbMin:t,aabbMax:a,backChild:s,indexCount:h,indexOffset:u})}let h=o.getUint32(n,!0);this._indices=a.slice(0,h)}setVertices(t){this._vertices=t}findHighestPoint(t,i){if(!this._nodes||0===this._nodes.length||!fs(this._nodes[0].aabbMin,this._nodes[0].aabbMax,t,i))return null;fl.length=0,fl.push(0);let r=-1/0;for(;fl.length>0;){let a=fl.pop(),n=this._nodes[a];if(n.aabbMax[2]<=r)continue;if(65535===n.backChild){for(let a=0;a<n.indexCount;a+=3){let o=3*this._indices[n.indexOffset+a],s=3*this._indices[n.indexOffset+a+1],l=3*this._indices[n.indexOffset+a+2];(function(t,i,r,a,n,o,s,l,h,u,c){let d,p,f,_,m,g,y=.5*(u[0]+c[0]),x=.5*(u[1]+c[1]),v=.5*(u[2]+c[2]),b=.5*(c[0]-u[0]),w=.5*(c[1]-u[1]),T=.5*(c[2]-u[2]),E=t-y,S=i-x,I=r-v,A=a-y,C=n-x,M=o-v,R=s-y,D=l-x,P=h-v,z=A-E,L=C-S,O=M-I,F=R-A,B=D-C,k=P-M,N=E-R,V=S-D,U=I-P;
7if(_=Math.min(d=I*L-S*O,p=M*L-C*O,f=P*L-D*O),m=Math.max(d,p,f),_>(g=Math.abs(O)*w+Math.abs(L)*T)||m<-g||(_=Math.min(d=I*B-S*k,p=M*B-C*k,f=P*B-D*k),m=Math.max(d,p,f),_>(g=Math.abs(k)*w+Math.abs(B)*T)||m<-g)||(_=Math.min(d=I*V-S*U,p=M*V-C*U,f=P*V-D*U),m=Math.max(d,p,f),_>(g=Math.abs(U)*w+Math.abs(V)*T)||m<-g)||(_=Math.min(d=E*O-I*z,p=A*O-M*z,f=R*O-P*z),m=Math.max(d,p,f),_>(g=Math.abs(O)*b+Math.abs(z)*T)||m<-g)||(_=Math.min(d=E*k-I*F,p=A*k-M*F,f=R*k-P*F),m=Math.max(d,p,f),_>(g=Math.abs(k)*b+Math.abs(F)*T)||m<-g)||(_=Math.min(d=E*U-I*N,p=A*U-M*N,f=R*U-P*N),m=Math.max(d,p,f),_>(g=Math.abs(U)*b+Math.abs(N)*T)||m<-g)||(_=Math.min(d=S*z-E*L,p=C*z-A*L,f=D*z-R*L),m=Math.max(d,p,f),_>(g=Math.abs(L)*b+Math.abs(z)*w)||m<-g)||(_=Math.min(d=S*F-E*B,p=C*F-A*B,f=D*F-R*B),m=Math.max(d,p,f),_>(g=Math.abs(B)*b+Math.abs(F)*w)||m<-g)||(_=Math.min(d=S*N-E*V,p=C*N-A*V,f=D*N-R*V),m=Math.max(d,p,f),_>(g=Math.abs(V)*b+Math.abs(N)*w)||m<-g)||(_=Math.min(E,A,R),m=Math.max(E,A,R),_>b||m<-b)||(_=Math.min(S,C,D),m=Math.max(S,C,D),_>w||m<-w)||(_=Math.min(I,M,P),m=Math.max(I,M,P),_>T||m<-T))return!1;let j=L*k-O*B,G=O*F-z*k,H=z*B-L*F;return g=b*Math.abs(j)+w*Math.abs(G)+T*Math.abs(H),!(Math.abs(-(j*E+G*S+H*I))>g)})(this._vertices[o],this._vertices[o+1],this._vertices[o+2],this._vertices[s],this._vertices[s+1],this._vertices[s+2],this._vertices[l],this._vertices[l+1],this._vertices[l+2],t,i)&&(r=Math.max(r,this._vertices[o+2],this._vertices[s+2],this._vertices[l+2]))}continue}let o=a+1,s=n.backChild,l=this._nodes[o],h=this._nodes[s],u=fs(l.aabbMin,l.aabbMax,t,i),c=fs(h.aabbMin,h.aabbMax,t,i);u&&c?l.aabbMax[2]<h.aabbMax[2]?(fl.push(o),fl.push(s)):(fl.push(s),fl.push(o)):u?fl.push(o):c&&fl.push(s)}return r>=0?r:null}}function fu(t,i){let r=t.json.bufferViews[i.bufferView],a=pM[i.componentType];return new a(t.buffers[r.buffer],(i.byteOffset||0)+(r.byteOffset||0),i.count*(r.byteStride&&r.byteStride!==pD[i.type]*a.BYTES_PER_ELEMENT?r.byteStride/a.BYTES_PER_ELEMENT:pD[i.type]))}function fc(t,i,r,a){let n=pM[i.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(n),s=t.json.bufferViews[i.bufferView],l=s.byteStride?s.byteStride/n.BYTES_PER_ELEMENT:pD[i.type],h=r.float32,u=h.length/r.capacity,c=i.count*l;for(let t=0,i=0;t<c;t+=l,i+=u)for(let r=0;r<u;r++)h[i+r]=a[t+r]*o}function fd(t,i,r){var a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w,T,E,S,I;let{matrix:A,rotation:C,translation:M,scale:R,mesh:D,extras:P,children:z,name:L}=t,O={};if(O.name=L,O.localMatrix=A||(a=[],n=C||[0,0,0,1],o=M||[0,0,0],s=R||[1,1,1],l=n[0],h=n[1],u=n[2],c=n[3],d=l+l,p=h+h,f=u+u,_=l*d,m=l*p,g=l*f,y=h*p,x=h*f,v=u*f,b=c*d,w=c*p,T=c*f,E=s[0],S=s[1],I=s[2],a[0]=(1-(y+v))*E,a[1]=(m+T)*E,a[2]=(g-w)*E,a[3]=0,a[4]=(m-T)*S,a[5]=(1-(_+v))*S,a[6]=(x+b)*S,a[7]=0,a[8]=(g+w)*I,a[9]=(x-b)*I,a[10]=(1-(_+y))*I,a[11]=0,a[12]=o[0],a[13]=o[1],a[14]=o[2],a[15]=1,a),O.globalMatrix=ed(O.localMatrix),void 0!==D){O.meshes=r[D];let t=O.anchor=[0,0];for(let i of O.meshes){let{min:r,max:a}=i.aabb;t[0]+=r[0]+a[0],t[1]+=r[1]+a[1]}t[0]=Math.floor(t[0]/O.meshes.length/2),t[1]=Math.floor(t[1]/O.meshes.length/2)}if(P&&(P.id&&(O.id=P.id),P.lights&&(O.lights=function(t){if(!t.length)return[];let i=function(t){let i=atob(t),r=new Uint8Array(i.length);for(let t=0;t<i.length;t++)r[t]=i.codePointAt(t);return r}(t),r=[],a=i.length/24,n=new Uint16Array(i.buffer),o=new Float32Array(i.buffer);for(let t=0;t<a;t++){let i=n[2*t*6]/30,a=n[2*t*6+1]/30,s=n[2*t*6+10]/100,l=o[6*t+1],h=o[6*t+2],u=o[6*t+3],c=o[6*t+4],d=u-l,p=c-h,f=Math.hypot(d,p);r.push({pos:[l+.5*d,h+.5*p,a],normal:[p/f,-d/f,0],width:f,height:i,depth:s,points:[l,h,u,c]})}return r}(P.lights)),P.MAPBOX_geometry_bloom&&(O.isGeometryBloom=P.MAPBOX_geometry_bloom),P.MAPBOX_zoom_min&&(O.minZoom=P.MAPBOX_zoom_min),P.MAPBOX_zoom_max&&(O.maxZoom=P.MAPBOX_zoom_max)),z){let t=[];for(let a of z)t.push(fd(i.json.nodes[a],i,r));O.children=t}if(t.extensions&&t.extensions.mbx_bvh&&(O.meshBVH=function(t,i,r){let a=i.binaryAccessor,n=i.positionMinAccessor,o=i.positionMaxAccessor,s=i.indexAccessor;if(!(Number.isInteger(a)&&Number.isInteger(n)&&Number.isInteger(o)&&Number.isInteger(s)))return null;let l=t.json.accessors;if(a>=l.length||n>=l.length||o>=l.length||s>=l.length)return null;let h=l[a],u=l[n],c=l[o],d=l[s];if(void 0===h.bufferView||void 0===u.bufferView||void 0===c.bufferView||void 0===d.bufferView)return null;let p=t.json.bufferViews;if(h.bufferView>=p.length||u.bufferView>=p.length||c.bufferView>=p.length||d.bufferView>=p.length)return null;let f=p[h.bufferView],_=p[u.bufferView],m=p[c.bufferView],g=p[d.bufferView];if(f.buffer>=t.buffers.length||_.buffer>=t.buffers.length||m.buffer>=t.buffers.length||g.buffer>=t.buffers.length)return null;let y=(t,i,r)=>t>=0&&t<=r&&i<=r-t,x=h.byteOffset||0,v=u.byteOffset||0,b=c.byteOffset||0,w=d.byteOffset||0;if(!(y(x,0,f.byteLength)&&y(v,3*u.count*4,_.byteLength)&&y(b,3*c.count*4,m.byteLength)&&y(w,4*d.count,g.byteLength)))return null;let T=new Uint8Array(t.buffers[f.buffer],(f.byteOffset||0)+x,f.byteLength-x),E=new Float32Array(t.buffers[_.buffer],(_.byteOffset||0)+v,3*u.count),S=new Float32Array(t.buffers[m.buffer],(m.byteOffset||0)+b,3*c.count),I=new Uint32Array(t.buffers[g.buffer],(g.byteOffset||0)+w,d.count),A=new fh;if(A.serializeFromGltf(T,E,S,I),void 0!==r&&t.json.meshes&&t.json.meshes[r]){let i=t.json.meshes[r].primitives[0];if(i&&void 0!==i.attributes.POSITION&&i.attributes.POSITION<l.length){let r=l[i.attributes.POSITION];if(void 0!==r.bufferView&&r.bufferView<p.length){let i=p[r.bufferView];if(i.buffer<t.buffers.length){let a=r.byteOffset||0,n=i.byteStride?i.byteStride/4:3;if(y(a,r.count*n*4,i.byteLength)){let o=(i.byteOffset||0)+a;if(3===n)A.setVertices(new Float32Array(t.buffers[i.buffer],o,3*r.count));else{let a=new Float32Array(t.buffers[i.buffer],o,r.count*n),s=new Float32Array(3*r.count);for(let t=0;t<r.count;t++)s[3*t]=a[t*n],s[3*t+1]=a[t*n+1],s[3*t+2]=a[t*n+2];A.setVertices(s)}}}}}}return A}(i,t.extensions.mbx_bvh,D)),!O.meshBVH&&O.children){for(let t of O.children)if(t.meshBVH){O.meshBVH=t.meshBVH;break}}return O}function fp(t,i){for(let r=0;r<t.length;r++)if(t[r].name===i)return r;return -1}function ff(t){let i=function(t,i){let r=[],a=WebGL2RenderingContext;if(t.json.textures)for(let n of t.json.textures){let o={magFilter:a.LINEAR,minFilter:a.NEAREST,wrapS:a.REPEAT,wrapT:a.REPEAT};void 0!==n.sampler&&Object.assign(o,t.json.samplers[n.sampler]),r.push({image:i[n.source],sampler:o,uploaded:!1})}return r}(t,t.images),r=function(t,i){let r=[];if(!t.json.meshes)return r;for(let a of t.json.meshes){let n=[];for(let r of a.primitives)n.push(function(t,i,r){let a=t.indices,n=t.attributes,o={};o.indexArray=new lR;let s=i.json.accessors[a],l=fu(i,s);o.indexArray.resizeExact(s.count/3),o.indexArray.uint16.set(l),o.vertexArray=new lg;let h=i.json.accessors[n.POSITION],u=fu(i,h);
7o.vertexArray.resizeExact(h.count),o.vertexArray.float32.set(u),o.aabb=new cg(h.min,h.max);let[c,d,p]=h.min,[f,_,m]=h.max;if(o.centroid=[.5*(c+f),.5*(d+_),.5*(p+m)],void 0!==n.COLOR_0){let t=i.json.accessors[n.COLOR_0],r=pD[t.type],a=fu(i,t);o.colorArray=3===r?new lg:new lT,o.colorArray.resizeExact(t.count),fc(i,t,o.colorArray,a)}if(void 0!==n.NORMAL){o.normalArray=new lg;let t=i.json.accessors[n.NORMAL];o.normalArray.resizeExact(t.count);let r=fu(i,t);fc(i,t,o.normalArray,r)}if(void 0!==n.TEXCOORD_0&&r.length>0){o.texcoordArray=new lk;let t=i.json.accessors[n.TEXCOORD_0];o.texcoordArray.resizeExact(t.count);let r=fu(i,t);fc(i,t,o.texcoordArray,r)}if(void 0!==n._FEATURE_ID_RGBA4444){let t=i.json.accessors[n._FEATURE_ID_RGBA4444];i.json.extensionsUsed&&i.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=fu(i,t))}void 0!==n._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(fu(i,i.json.accessors[n._FEATURE_RGBA4444]).buffer));let g=t.material;return o.material=function(t,i){let{emissiveFactor:r=[0,0,0],alphaMode:a="OPAQUE",alphaCutoff:n=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:l,doubleSided:h,name:u}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:d=1,roughnessFactor:p=1,baseColorTexture:f,metallicRoughnessTexture:_}=t.pbrMetallicRoughness||{},m=s?i[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&m){let t=s.extensions.KHR_texture_transform;m.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{name:u,pbrMetallicRoughness:{baseColorFactor:new rq(...c),metallicFactor:d,roughnessFactor:p,baseColorTexture:f?i[f.index]:void 0,metallicRoughnessTexture:_?i[_.index]:void 0},doubleSided:h,emissiveFactor:new rq(...r),alphaMode:a,alphaCutoff:n,normalTexture:o?i[o.index]:void 0,occlusionTexture:m,emissionTexture:l?i[l.index]:void 0,defined:void 0===t.defined}}(void 0!==g?i.json.materials[g]:{defined:!1},r),o}(r,t,i));r.push(n)}return r}(t,i),{scenes:a,scene:n,nodes:o}=t.json,s=a?fp(a,"Default Scene"):-1;s<0&&(s=n||0);let l=a&&a[s]?a[s].nodes||[]:[...o.keys()],h=[];for(let i of l)h.push(fd(o[i],t,r));!function(t,i,r){let a={},n=new Set;for(let o=0;o<t.length;o++){let t=r[i[o]];if(!t.extras)continue;let s=t.extras["mapbox:footprint:version"],l=t.extras["mapbox:footprint:id"];(s||l)&&n.add(o),"1.0.0"===s&&l&&(a[l]=o)}for(let o=0;o<t.length;o++){if(n.has(o))continue;let s=t[o],l=r[i[o]];if(!l.extras)continue;let h=null;s.id in a&&(h=function(t,i){let r=[],a=[],n=0,o=[];for(let s of t){n=r.length;let t=s.vertexArray.float32,l=s.indexArray.uint16;for(let a=0;a<s.vertexArray.length;a++)o[0]=t[3*a+0],o[1]=t[3*a+1],o[2]=t[3*a+2],eQ(o,o,i),r.push(new tg(o[0],o[1]));for(let t=0;t<3*s.indexArray.length;t++)a.push(l[t]+n)}if(a.length%3!=0)return null;for(let t=0;t<a.length;t+=3){let i=r[a[t+0]],n=r[a[t+1]],o=r[a[t+2]];(i.x-n.x)*(o.y-n.y)-(o.x-n.x)*(i.y-n.y)>0&&([a[t+1],a[t+2]]=[a[t+2],a[t+1]])}return{vertices:r,indices:a}}(t[a[s.id]].meshes,s.localMatrix)),h||(h=function(t){if(!t.extras||!t.extras.ground)return null;let i=t.extras.ground;if(!i||!Array.isArray(i)||0===i.length)return null;let r=i[0];if(!r||!Array.isArray(r)||0===r.length)return null;let a=[];for(let t of r){if(!Array.isArray(t)||2!==t.length)continue;let i=t[0],r=t[1];"number"==typeof i&&"number"==typeof r&&a.push(new tg(i,r))}if(a.length<3)return null;a.length>1&&a.at(-1).equals(a[0])&&a.pop();let n=0;for(let t=0;t<a.length;t++){let i=a[t],r=a[(t+1)%a.length],o=a[(t+2)%a.length];n+=(i.x-r.x)*(o.y-r.y)-(o.x-r.x)*(i.y-r.y)}n>0&&a.reverse();let o=sC(a.flatMap(t=>[t.x,t.y]),[]);return 0===o.length?null:{vertices:a,indices:o}}(l)),h&&(s.footprint=function(t){if(0===t.vertices.length||0===t.indices.length)return null;let i=new pU(t.vertices,t.indices,8,256),[r,a]=[i.min.clone(),i.max.clone()];return{vertices:t.vertices,indices:t.indices,grid:i,min:r,max:a}}(h))}if(n.size>0){let i=Array.from(n.values()).sort((t,i)=>t-i);for(let r=i.length-1;r>=0;r--)t.splice(i[r],1)}}(h,l,t.json.nodes);let u=a?fp(a,"LOD"):-1;if(u>=0){let i=a[u].nodes,n=new Map;for(let a of i){let i=fd(o[a],t,r);i.id&&n.set(i.id,i)}for(let t of h)if(t.id){let i=n.get(t.id);
7i&&i.meshes&&(t.lodMeshes=i.meshes,i.meshBVH&&(t.meshBVH=i.meshBVH))}}return h}oC(fh,"ModelBVH");let f_=lo([{name:"a_pos_3f",components:3,type:"Float32"}]),fm=lo([{name:"a_normal_3",components:3,type:"Int16"}]),fg=lo([{name:"a_centroid_3",components:3,type:"Int16"}]),fy=lo([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),fx=lo([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),fv=lo([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),fb=lo([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),fw=lo([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),fT=lo([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),fE=lo([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),fS=lo([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),fI=lo([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),fA=lo([{name:"a_centroid_pos",components:2,type:"Uint16"}]),fC=lo([{name:"a_join_normal_inside",components:3,type:"Int16"}]),fM=lo([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),fR=lo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:fD}=fE;function fP(t,i,r,a){let n=[],o=0===a?(t,i,r,a,n,o)=>{t.push(new tg(o,r+(o-i)/(a-i)*(n-r)))}:(t,i,r,a,n,o)=>{t.push(new tg(i+(o-r)/(n-r)*(a-i),o))};for(let s of t){let t=[];for(let n of s){if(n.length<=2)continue;let s=[];for(let t=0;t<n.length-1;t++){let l=n[t].x,h=n[t].y,u=n[t+1].x,c=n[t+1].y,d=0===a?l:h,p=0===a?u:c;d<i?p>i&&o(s,l,h,u,c,i):d>r?p<r&&o(s,l,h,u,c,r):s.push(n[t]),p<i&&d>=i&&o(s,l,h,u,c,i),p>r&&d<=r&&o(s,l,h,u,c,r)}let l=n.at(-1),h=0===a?l.x:l.y;h>=i&&h<=r&&s.push(l),s.length&&(l=s.at(-1),s[0].x===l.x&&s[0].y===l.y||s.push(s[0]),t.push(s))}t.length&&n.push(t)}return n}let fz=[new tg(0,0),new tg(8192,0),new tg(8192,8192),new tg(0,8192)];function fL(t,i){let r=[],a=[];if(!i||t.length<2)return[t];if(2===t.length)return hY(t[0],t[1],fz)?[t]:[];for(let i=0;i<t.length+2;i++){let n=0===i?t.at(-1):t[(i-1)%t.length],o=t[i%t.length],s=t[(i+1)%t.length],l=hY(n,o,fz),h=hY(o,s,fz),u=l||h;u&&a.push(o),u&&h||a.length>0&&(a.length>1&&r.push(a),a=[])}return a.length>1&&r.push(a),r}let fO=hN.types,fF=["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"],fB=["fill-extrusion-flood-light-ground-radius"],fk=new tg(0,1);function fN(t,i,r,a,n,o,s,l){t.emplaceBack((i<<1)+s,(r<<1)+o,(Math.floor(8192*a)<<1)+n,Math.round(l))}function fV(t,i,r){t.emplaceBack(8192*i.x,8192*i.y,+!!r)}function fU(t,i,r,a,n,o){t.emplaceBack(i.x,i.y,(r.x<<1)+a,(r.y<<1)+n,o)}function fj(t,i,r){t.emplaceBack(i.x,i.y,i.z,16384*r[0],16384*r[1],16384*r[2])}class fG{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class fH{constructor(){this.data=[]}get length(){return this.data.length}push(t){this.data.push(t)}get(t){return this.data[t]}static serialize(t,i){let r=t.data.length,a=new Uint32Array(4*r),n=[];n.length=r;for(let i=0;i<r;i++){let r=t.data[i],o=4*i;a[o]=r.vertexOffset,a[o+1]=r.vertexCount,a[o+2]=r.indexOffset,a[o+3]=r.indexCount,n[i]=r.ringIndices}return i&&i.add(a.buffer),{scalars:a,rings:n}}static deserialize(t){let{scalars:i,rings:r}=t,a=i.length/4,n=new fH,o=[];o.length=a,n.data=o;for(let t=0;t<a;t++){let a=4*t,o=new fG;o.vertexOffset=i[a],o.vertexCount=i[a+1],o.indexOffset=i[a+2],o.indexCount=i[a+3],o.ringIndices=r[t],n.data[t]=o}return n}}class fq{constructor(){this.centroidXY=new tg(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 tg(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new tg(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new tg(0,0)}span(){return new tg(this.max.x-this.min.x,this.max.y-this.min.y)}}class fZ{constructor(){this.data=[],this.buffer=null}get length(){return this.data.length}push(t){this.data.push(t)}get(t){return this.data[t]}find(t){return this.data.find(t)}[Symbol.iterator](){return this.data[Symbol.iterator]()}static serialize(t,i){let r=t.data.length,a=new Float64Array(15*r);for(let i=0;i<r;i++){let r=t.data[i],n=15*i;a[n]=r.centroidXY.x,a[n+1]=r.centroidXY.y,a[n+2]=r.min.x,a[n+3]=r.min.y,a[n+4]=r.max.x,a[n+5]=r.max.y,a[n+6]=r.groupCentroidPos.x,a[n+
77]=r.groupCentroidPos.y,a[n+8]=r.vertexArrayOffset,a[n+9]=r.vertexCount,a[n+10]=r.groundVertexArrayOffset,a[n+11]=r.groundVertexCount,a[n+12]=r.footprintSegLen,a[n+13]=r.height,a[n+14]=r.buildingId}return i&&i.add(a.buffer),{buffer:a}}static deserialize(t){let i=t.buffer,r=i.length/15,a=new fZ;a.buffer=i;let n=[];n.length=r,a.data=n;let o=0;for(let t=0;t<r;t++){let r=15*t,n=new fq;n.centroidXY=new tg(i[r],i[r+1]),n.min=new tg(i[r+2],i[r+3]),n.max=new tg(i[r+4],i[r+5]),n.groupCentroidPos=new tg(i[r+6],i[r+7]),n.vertexArrayOffset=i[r+8],n.vertexCount=i[r+9],n.groundVertexArrayOffset=i[r+10],n.groundVertexCount=i[r+11],n.footprintSegLen=i[r+12],n.height=i[r+13],n.buildingId=i[r+14],n.footprintSegIdx=o,o+=n.footprintSegLen,a.data[t]=n}return a}}class f${constructor(){this.acc=new tg(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(t,i){t.min.x===Number.MAX_VALUE&&(t.min.x=t.max.x=i.x,t.min.y=t.max.y=i.y)}appendEdge(t,i,r){this.accCount++,this.acc._add(i);let a=!!this.borders;i.x<t.min.x?(t.min.x=i.x,a=!0):i.x>t.max.x&&(t.max.x=i.x,a=!0),i.y<t.min.y?(t.min.y=i.y,a=!0):i.y>t.max.y&&(t.max.y=i.y,a=!0),((0===i.x||8192===i.x)&&i.x===r.x)!=((0===i.y||8192===i.y)&&i.y===r.y)&&this.processBorderOverlap(i,r),a&&this.checkBorderIntersection(i,r)}checkBorderIntersection(t,i){i.x<0!=t.x<0&&this.addBorderIntersection(0,rG(i.y,t.y,(0-i.x)/(t.x-i.x))),i.x>8192!=t.x>8192&&this.addBorderIntersection(1,rG(i.y,t.y,(8192-i.x)/(t.x-i.x))),i.y<0!=t.y<0&&this.addBorderIntersection(2,rG(i.x,t.x,(0-i.y)/(t.y-i.y))),i.y>8192!=t.y>8192&&this.addBorderIntersection(3,rG(i.x,t.x,(8192-i.y)/(t.y-i.y)))}addBorderIntersection(t,i){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);let r=this.borders[t];i<r[0]&&(r[0]=i),i>r[1]&&(r[1]=i)}processBorderOverlap(t,i){if(t.x===i.x){if(t.y===i.y)return;let r=+(0!==t.x);this.addBorderIntersection(r,i.y),this.addBorderIntersection(r,t.y)}else{let r=0===t.y?2:3;this.addBorderIntersection(r,i.x),this.addBorderIntersection(r,t.x)}}centroid(){return 0===this.accCount?new tg(0,0):new tg(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((t,i)=>t+ +(i[0]!==Number.MAX_VALUE),0):0}}function fW(t,i){let r=t.add(i)._unit();return Math.min(4,Math.max(-4,Math.tan(Math.acos(tL(t.x*r.x+t.y*r.y,-1,1)))))/4*32767*(t.x*i.y-t.y*i.x<0?-1:1)}let fX=[t=>t.x<0,t=>t.x>8192,t=>t.y<0,t=>t.y>8192];class fY{constructor(t){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new l_,this.indexArray=new lR,this.programConfigurations=new hS(t.layers,{zoom:t.zoom,lut:t.lut},t=>fB.includes(t)),this._segments=new l9,this.hiddenByLandmarkVertexArray=new lH,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new l9}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,i,r,a=!1){let n=t.length;if(n>2){let o,s=Math.max(0,this._segments.get().length-1),l=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{let i=t[0],r=t[1];o=fW(i.sub(t[n-1])._perp()._unit(),r.sub(i)._perp()._unit())}for(let h=0;h<n;h++){let u=h===n-1?0:h+1,c=t[h],d=t[u],p=t[u===n-1?0:u+1],f=d.sub(c)._perp()._unit(),_=fW(f,p.sub(d)._perp()._unit()),m=o;if(f0(c,d,i)||a&&f1(c,i)&&f1(d,i)){o=_;continue}let g=l.vertexLength;for(let t of(fU(this.vertexArray,c,d,1,1,m),fU(this.vertexArray,c,d,1,0,m),fU(this.vertexArray,c,d,0,1,_),fU(this.vertexArray,c,d,0,0,_),l.vertexLength+=4,function(t,i,r,a){let n=[4];if(0===a)return n;r._mult(a);let o=t.sub(r),s=i.sub(r),l=[t,i,o,s];for(let t=0;t<4;t++)for(let i of l)if(fX[t](i)){n.push(t);break}return n}(c,d,f,r)))this._segmentToGroundQuads[s].push({id:g,region:t}),this._segmentToRegionTriCounts[s][t]+=2,l.primitiveLength+=2;o=_}}}prepareBorderSegments(){if(!this.hasData())return;let t=this._segments.get(),i=t.length;for(let t=0;t<i;t++)this._segmentToGroundQuads[t].sort((t,i)=>t.region-i.region);for(let r=0;r<i;r++){let i=this._segmentToGroundQuads[r],a=t[r],n=this._segmentToRegionTriCounts[r];n.reduce((t,i)=>t+i,0);let o=0;for(let t=0;t<=4;t++){let i=n[t];if(0!==i){let r=this.regionSegments[t];r||(r=this.regionSegments[t]=new l9);let n={vertexOffset:a.vertexOffset,primitiveOffset:a.primitiveOffset+o,vertexLength:a.vertexLength,primitiveLength:i};r.get().push(n)}o+=i}for(let t=0;t<i.length;t++){let r=i[t].id;this.indexArray.emplaceBack(r,r+1,r+3),this.indexArray.emplaceBack(r,r+3,r+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(t,i,r,a,n,o,s){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,t,i,r,a,n,o,void 0,s)}upload(t){this.hasData()&&(this.vertexBuffer=t.createVertexBuffer(this.vertexArray,fS.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),null!=this.groundRadiusArray&&(this.groundRadiusBuffer=t.createVertexBuffer(this.groundRadiusArray,fI.members)))}uploadPaintProperties(t){this.hasData()&&this.programConfigurations.upload(t)}update(t,i,r,a,n,o,s,l){this.hasData()&&this.programConfigurations.updatePaintArrays(t,i,r,a,n,o,s,l)}updateHiddenByLandmark(t){this.updateHiddenByLandmarkRange(t.groundVertexArrayOffset,t.groundVertexCount,!!(0x80000000&t.flags||0x40000000&t.flags))}updateHiddenByLandmarkRange(t,i,r){if(!this.hasData())return;let a=i+t;if(0!==i){for(let i=t;i<a;++i)this.hiddenByLandmarkVertexArray.emplace(i,+!!r);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(t){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,fM.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 t=0;t<=4;t++){let i=this.regionSegments[t];i&&i.destroy()}}}}class fK{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.pixelRatio=t.pixelRatio,this.layerIds=this.layers.map(t=>t.fqid),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=new fZ,this.footprintIndices=new lR,this.footprintVertices=new ll,this.footprintSegments=new fH,this.layoutVertexArray=new lf,this.centroidVertexArray=new l1,this.wallVertexArray=new l3,this.indexArray=new lR,this.programConfigurations=new hS(t.layers,{zoom:t.zoom,lut:t.lut},t=>fF.includes(t)),this.segments=new l9,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>
7t.id),this.groundEffect=new fY(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,i){}updateAppearances(t,i,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,i,r,a){for(let{feature:n,id:o,index:s,sourceLayerIndex:l}of(this.features=[],this.hasPattern=sZ("fill-extrusion",this.layers,this.pixelRatio,i),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=s6(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1),t)){let t=this.layers[0]._featureFilter.needGeometry,h=lt(n,t);if(!this.layers[0]._featureFilter.filter(new o0(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),h,r))continue;let u={id:o,sourceLayerIndex:l,index:s,geometry:t?h.geometry:le(n,r,a),properties:n.properties,type:n.type,patterns:{}},c=this.layoutVertexArray.length,d="Polygon"===fO[u.type];if(this.hasPattern)this.features.push({featureId:n.id,feature:s$("fill-extrusion",this.layers,u,this.zoom,this.pixelRatio,i)});else if(this.wallMode)for(let t of u.geometry)for(let o of fL(t,d))this.addFeature(n.id,u,[o],s,r,{},i.availableImages,a,i.brightness);else this.addFeature(n.id,u,u.geometry,s,r,{},i.availableImages,a,i.brightness);i.featureIndex.insert(n,u.geometry,s,l,this.index,c)}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,i,r,a,n,o){for(let{featureId:t,feature:s}of this.features){let l="Polygon"===fO[s.type],{geometry:h}=s;if(this.wallMode)for(let u of h)for(let h of fL(u,l))this.addFeature(t,s,[h],s.index,i,r,a,n,o);else this.addFeature(t,s,h,s.index,i,r,a,n,o)}this._finalizeBuildingGroups(),this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,i,r,a,n,o,s){this.programConfigurations.updatePaintArrays(t,i,n,r,a,o,s,this.worldview),this.groundEffect.update(t,i,n,r,a,o,s,this.worldview)}updateExpressions(t){this.programConfigurations.updateExpressions(t),this.groundEffect.programConfigurations.updateExpressions(t)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,fD),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,fC.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,fR.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,fA.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(t,i,r,a,n,o,s,l,h){let u,c,d=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(i,{})/this.tileToMeter,p=[new tg(0,0),new tg(8192,8192)],f=l.projection,_="globe"===f.name,m=this.wallMode||"Polygon"===fO[i.type],g=new f$;g.centroidDataIndex=this.centroidData.length;let y=new fq;y.buildingId=t,i.properties&&Object.hasOwn(i.properties,"building_id")&&(y.buildingId=Number(i.properties.building_id)),g.buildingId=y.buildingId;let x=0>=this.layers[0].paint.get("fill-extrusion-base").evaluate(i,{},n),v=this.layers[0].paint.get("fill-extrusion-height").evaluate(i,{},n);if(y.height=v,y.vertexArrayOffset=this.layoutVertexArray.length,y.groundVertexArrayOffset=this.groundEffect.vertexArray.length,_&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new lv),this.wallMode){if(_)return void tX("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==r.length)return;r=[(u=function(t){let i=t[0].x===t.at(-1).x&&t[0].y===t.at(-1).y;(function(t){let i=0,r=t.length;for(let a=0;a<r;
7a++)i+=(t[(a+1)%r].x-t[a].x)*(t[(a+1)%r].y+t[a].y);return i>=0})(t)||(t=t.reverse());let r={geometry:[],joinNormals:[],indices:[]},a=[],n=[],o=[],s=t.length;for(;s>=2&&t[s-1].equals(t[s-2]);)s--;if(s<(i?3:2))return r;let l,h,u,c,d,p=0;for(;p<s-1&&t[p].equals(t[p+1]);)p++;i&&(l=t[s-2],d=t[p].sub(l)._unit()._perp());for(let r=p;r<s;r++){if((u=r===s-1?i?t[p+1]:void 0:t[r+1])&&t[r].equals(u))continue;d&&(c=d),l&&(h=l),l=t[r],d=u?u.sub(l)._unit()._perp():c;let f=(c=c||d).add(d);0===f.x&&0===f.y||f._unit();let _=f.x*d.x+f.y*d.y,m=0!==_?1/_:1/0,g=c.x*d.y-c.y*d.x>0,y="miter";"miter"===y&&m>2&&(y="bevel"),"bevel"===y&&(m>100&&(y="flipbevel"),m<2&&(y="miter"));let x=(t,i,r,s)=>{let l=new tg(t.x,t.y),h=new tg(t.x,t.y);l.x+=i.x*s,l.y+=i.y*s,h.x-=i.x*Math.max(r,1),h.y-=i.y*Math.max(r,1),o.push(i),a.push(l),n.push(h)};if("miter"===y)f._mult(m),x(l,f,0,0);else if("flipbevel"===y)x(l,f=d.mult(-1),0,0),x(l,f.mult(-1),0,0);else{let t=-Math.sqrt(m*m-1),i=g?t:0,r=g?0:t;h&&x(l,c,i,r),u&&x(l,d,i,r)}}r.geometry=[...a,...n.reverse(),a[0]],r.joinNormals=[...o,...o.reverse(),o.at(-1)];let f=r.geometry.length-1;for(let t=0;t<f/2;t++)if(t+1<f/2){let i=t,a=t+1,n=f-1-t,o=f-2-t;i=0===i?f-1:i-1,a=0===a?f-1:a-1,n=0===n?f-1:n-1,o=0===o?f-1:o-1,r.indices.push(n),r.indices.push(a),r.indices.push(i),r.indices.push(n),r.indices.push(o),r.indices.push(a)}return r}(r[0])).geometry]}let b=(t,i)=>t<(i.length-1)/2||t===i.length-1,w=this.wallMode?[r]:tb(r,500);for(let t=w.length-1;t>=0;t--){var T;let i=w[t];(0===i.length||(T=i[0]).every(t=>t.x<=0)||T.every(t=>t.x>=8192)||T.every(t=>t.y<=0)||T.every(t=>t.y>=8192))&&w.splice(t,1)}if(_)c=f5(w,p,n);else for(let t of(c=[],w))c.push({polygon:t,bounds:p});let E=m?this.edgeRadius:0,S=E>0&&this.zoom<17,I=(t,i)=>{if(0===t.length)return!1;let r=t.at(-1);return i.x===r.x&&i.y===r.y};for(let{polygon:t,bounds:i}of c){let r=0,a=0;for(let i of t)m&&!i[0].equals(i.at(-1))&&i.push(i[0]),a+=m?i.length-1:i.length;let o=this.segments.prepareSegment((m?5:4)*a,this.layoutVertexArray,this.indexArray);y.footprintSegIdx<0&&(y.footprintSegIdx=this.footprintSegments.length),y.polygonSegIdx<0&&(y.polygonSegIdx=this.polygonSegments.length);let s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},l=new fG;if(l.vertexOffset=this.footprintVertices.length,l.indexOffset=3*this.footprintIndices.length,l.ringIndices=[],m){let a=[],s=[];r=o.vertexLength;for(let r=0;r<t.length;r++){let h,c,p=t[r];p.length&&0!==r&&s.push(a.length/2);let m=[];h=p[1].sub(p[0])._perp()._unit(),l.ringIndices.push(p.length-1);for(let t=1;t<p.length;t++){let i=p[t],r=p[t===p.length-1?1:t+1],s=i.clone();if(E){c=r.sub(i)._perp()._unit();let t=h.add(c)._unit(),a=E*Math.min(4,1/(h.x*t.x+h.y*t.y));s.x+=a*t.x,s.y+=a*t.y,s.x=Math.round(s.x),s.y=Math.round(s.y),h=c}if(!x||0!==E&&!S||I(m,s)||m.push(s),fN(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),this.wallMode){let i=b(t,p);fV(this.wallVertexArray,u.joinNormals[t],!i)}o.vertexLength++,this.footprintVertices.emplaceBack(i.x,i.y),a.push(i.x,i.y),_&&fj(this.layoutVertexExtArray,f.projectTilePoint(s.x,s.y,n),f.upVector(n,s.x,s.y))}x&&(0===E||S)&&(0!==m.length&&I(m,m[0])&&m.pop(),this.groundEffect.addData(m,i,d))}let h=this.wallMode?u.indices:sC(a,s);for(let t=0;t<h.length;t+=3)this.footprintIndices.emplaceBack(l.vertexOffset+h[t+0],l.vertexOffset+h[t+1],l.vertexOffset+h[t+2]),this.indexArray.emplaceBack(r+h[t],r+h[t+2],r+h[t+1]),o.primitiveLength++;l.indexCount+=h.length,l.vertexCount+=this.footprintVertices.length-l.vertexOffset}for(let a=0;a<t.length;a++){let s,l,h,c=t[a];g.startRing(y,c[0]);let p=c.length>4&&f2(c[c.length-2],c[0],c[1]),v=E?function(t,i,r,a){let n=i.sub(t)._perp()._unit(),o=r.sub(i)._perp()._unit();return fJ(t,i,r,fQ(n,o),a)}(c[c.length-2],c[0],c[1],E):0,w=[];l=c[1].sub(c[0])._perp()._unit();let T=!0;for(let t=1,a=0;t<c.length;t++){let d=c[t-1],m=c[t],S=c[t===c.length-1?1:t+1];if(g.appendEdge(y,m,d),f0(m,d,i)){E&&(l=S.sub(m)._perp()._unit(),T=!T);continue}let A=m.sub(d)._perp(),C=A.x/(Math.abs(A.x)+Math.abs(A.y)),M=+(A.y>0),R=d.dist(m);if(a+R>32768&&(a=0),E){h=S.sub(m)._perp()._unit();let t=fJ(d,m,S,fQ(l,h),E);isNaN(t)&&(t=0);let i=m.sub(d)._unit();d=d.add(i.mult(v))._round(),m=m.add(i.mult(-t))._round(),v=t,l=h,x&&this.zoom>=17&&(I(w,d)||w.push(d),I(w,m)||w.push(m))}let D=o.vertexLength,P=c.length>4&&f2(d,m,S),z=f3(a,p,T);
7if(fN(this.layoutVertexArray,d.x,d.y,C,M,0,0,z),fN(this.layoutVertexArray,d.x,d.y,C,M,0,1,z),this.wallMode){let i=b(t-1,c),r=u.joinNormals[t-1];fV(this.wallVertexArray,r,i),fV(this.wallVertexArray,r,i)}if(a+=R,z=f3(a,P,!T),p=P,fN(this.layoutVertexArray,m.x,m.y,C,M,0,0,z),fN(this.layoutVertexArray,m.x,m.y,C,M,0,1,z),this.wallMode){let i=b(t,c),r=u.joinNormals[t];fV(this.wallVertexArray,r,i),fV(this.wallVertexArray,r,i)}if(o.vertexLength+=4,this.indexArray.emplaceBack(D+0,D+1,D+2),this.indexArray.emplaceBack(D+1,D+3,D+2),o.primitiveLength+=2,E){let a=r+(1===t?c.length-2:t-2),n=1===t?r:a+1;if(this.indexArray.emplaceBack(D+1,a,D+3),this.indexArray.emplaceBack(a,n,D+3),o.primitiveLength+=2,void 0===s&&(s=D),!f0(S,c[t],i)){let i=t===c.length-1?s:o.vertexLength;this.indexArray.emplaceBack(D+2,D+3,i),this.indexArray.emplaceBack(D+3,i+1,i),this.indexArray.emplaceBack(D+3,n,i+1),o.primitiveLength+=3}T=!T}if(_){let t=this.layoutVertexExtArray,i=f.projectTilePoint(d.x,d.y,n),r=f.projectTilePoint(m.x,m.y,n),a=f.upVector(n,d.x,d.y),o=f.upVector(n,m.x,m.y);fj(t,i,a),fj(t,i,a),fj(t,r,o),fj(t,r,o)}}m&&(r+=c.length-1),x&&E&&this.zoom>=17&&(0!==w.length&&I(w,w[0])&&w.pop(),this.groundEffect.addData(w,i,d,E>0))}this.footprintSegments.push(l),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++y.footprintSegLen,++y.polygonSegLen}if(y.vertexCount=this.layoutVertexArray.length-y.vertexArrayOffset,y.groundVertexCount=this.groundEffect.vertexArray.length-y.groundVertexArrayOffset,0!==y.vertexCount){if(y.centroidXY=g.borders?fk:this.encodeCentroid(g,y),i.properties&&Object.hasOwn(i.properties,"building_id")){let t=y.buildingId,i=this.buildingGroups.get(t);i||(i={accX:0,accY:0,accCount:0,mergedMin:new tg(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new tg(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(t,i)),i.accX+=g.acc.x,i.accY+=g.acc.y,i.accCount+=g.accCount,i.mergedMin.x=Math.min(i.mergedMin.x,y.min.x),i.mergedMin.y=Math.min(i.mergedMin.y,y.min.y),i.mergedMax.x=Math.max(i.mergedMax.x,y.max.x),i.mergedMax.y=Math.max(i.mergedMax.y,y.max.y),i.partIndices.push(this.centroidData.length)}if(this.centroidData.push(y),g.borders){this.featuresOnBorder.push(g);let t=this.featuresOnBorder.length-1;for(let i=0;i<g.borders.length;i++)g.borders[i][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[i].push(t)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,i,a,o,s,n,h,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(i,a,o,s,n,h,this.worldview),this.maxHeight=Math.max(this.maxHeight,v)}}_finalizeBuildingGroups(){for(let[,t]of this.buildingGroups){if(0===t.partIndices.length)continue;let i=new f$;i.acc=new tg(t.accX,t.accY),i.accCount=t.accCount;let r=new fq;r.min=t.mergedMin,r.max=t.mergedMax;let a=this.encodeCentroid(i,r),n=i.centroid();for(let i of t.partIndices){let r=this.centroidData.get(i);r.centroidXY.x===fk.x&&r.centroidXY.y===fk.y||(r.centroidXY=a),r.min=t.mergedMin,r.max=t.mergedMax,r.groupCentroidPos=n}}this.buildingGroups.clear()}sortBorders(){for(let t=0;t<this.borderFeatureIndices.length;t++)this.borderFeatureIndices[t].sort((i,r)=>this.featuresOnBorder[i].borders[t][0]-this.featuresOnBorder[r].borders[t][0])}splitToSubtiles(){let t=[];for(let i=0;i<this.centroidData.length;i++){let r=this.centroidData.get(i),a=+(r.min.y+r.max.y>8192),n=2*a+(r.min.x+r.max.x>8192^a);for(let a=0;a<r.polygonSegLen;a++){let o=r.polygonSegIdx+a;t.push({centroidIdx:i,subtile:n,polygonSegmentIdx:o,triangleSegmentIdx:this.polygonSegments[o].triangleSegIdx})}}let i=new lR;t.sort((t,i)=>t.triangleSegmentIdx===i.triangleSegmentIdx?t.subtile-i.subtile:t.triangleSegmentIdx-i.triangleSegmentIdx);let r=0,a=0,n=0;
7for(let i of t){if(i.triangleSegmentIdx!==r)break;n++}let o=t.length;for(;a!==t.length;){r=t[a].triangleSegmentIdx;let s=0,l=a,h=a;for(let i=l;i<n&&t[i].subtile===s;i++)h++;for(;l!==n;){let a=t[l];s=a.subtile;let o=this.centroidData.get(a.centroidIdx).min.clone(),u=this.centroidData.get(a.centroidIdx).max.clone(),c={vertexOffset:this.segments.segments[r].vertexOffset,primitiveOffset:i.length,vertexLength:this.segments.segments[r].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let r=l;r<h;r++){let a=t[r],n=this.polygonSegments[a.polygonSegmentIdx],s=this.centroidData.get(a.centroidIdx).min,l=this.centroidData.get(a.centroidIdx).max,h=this.indexArray.uint16;for(let t=n.triangleArrayOffset;t<n.triangleArrayOffset+n.triangleCount;t++)i.emplaceBack(h[3*t],h[3*t+1],h[3*t+2]);c.primitiveLength+=n.triangleCount,o.x=Math.min(o.x,s.x),o.y=Math.min(o.y,s.y),u.x=Math.max(u.x,l.x),u.y=Math.max(u.y,l.y)}c.primitiveLength>0&&this.triangleSubSegments.push({segment:c,min:o,max:u}),l=h;for(let i=l;i<n&&t[i].subtile===t[l].subtile;i++)h++}a=n;for(let i=a;i<o&&t[i].triangleSegmentIdx===t[a].triangleSegmentIdx;i++)n++}i._trim(),this.indexArray=i}getVisibleSegments(t,i,r){let a,n=new l9;if(this.wallMode){for(let t of this.triangleSubSegments)n.segments.push(t.segment);return n}let o=0,s=0,l=1<<t.canonical.z;if(i){let r=i.getMinMaxForTile(t);r&&(o=r.min,s=r.max)}s+=this.maxHeight;let h=t.toUnwrapped(),u=[h.canonical.x/l+h.wrap,h.canonical.y/l],c=[(h.canonical.x+1)/l+h.wrap,(h.canonical.y+1)/l],d=(t,i,r)=>[rG(t[0],i[0],r[0]),rG(t[1],i[1],r[1])],p=[],f=[];for(let t of this.triangleSubSegments){p[0]=t.min.x/8192,p[1]=t.min.y/8192,f[0]=t.max.x/8192,f[1]=t.max.y/8192;let i=d(u,c,p),l=d(u,c,f);if(0===new cg([i[0],i[1],o],[l[0],l[1],s]).intersectsPrecise(r)){a&&(n.segments.push(a),a=void 0);continue}let h=t.segment;a&&a.vertexOffset!==h.vertexOffset&&(n.segments.push(a),a=void 0),a?(a.vertexLength+=h.vertexLength,a.primitiveLength+=h.primitiveLength):a={vertexOffset:h.vertexOffset,primitiveLength:h.primitiveLength,vertexLength:h.vertexLength,primitiveOffset:h.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&n.segments.push(a),n}encodeCentroid(t,i){let r=t.centroid(),a=i.span(),n=Math.min(7,Math.round(a.x*this.tileToMeter/10)),o=Math.min(6,Math.round(a.y*this.tileToMeter/10));return new tg(tL(r.x,1,8191)<<3|n,tL(r.y,1,8191)<<3|o)}encodeBorderCentroid(t){if(!t.borders)return new tg(0,0);let i=t.borders,r=Number.MAX_VALUE;if(i[0][0]!==r||i[1][0]!==r){let t=+(i[0][0]===r);return new tg(6|65528*(i[0][0]===r),(i[t][0]+i[t][1])/2<<3|6)}{let t=i[2][0]!==r?2:3;return new tg((i[t][0]+i[t][1])/2<<3|6,6|65528*(i[2][0]===r))}}showCentroid(t){let i=this.centroidData.get(t.centroidDataIndex);if(i.flags&=0x80000000,0!==i.groupCentroidPos.x||0!==i.groupCentroidPos.y){let t=i.span(),r=Math.min(7,Math.round(t.x*this.tileToMeter/10)),a=Math.min(6,Math.round(t.y*this.tileToMeter/10));i.centroidXY=new tg(tL(i.groupCentroidPos.x,1,8191)<<3|r,tL(i.groupCentroidPos.y,1,8191)<<3|a)}else i.centroidXY=new tg(0,0);this.writeCentroidToBuffer(i)}writeCentroidToBuffer(t){this.groundEffect.updateHiddenByLandmark(t);let i=t.vertexArrayOffset,r=t.vertexCount+t.vertexArrayOffset,a=-0x40000000&t.flags?fk:t.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(i);if(this.centroidVertexArray.geta_centroid_pos1(i)!==a.y||n!==a.x){for(let t=i;t<r;++t)this.centroidVertexArray.emplace(t,a.x,a.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){for(let t of(this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length),this.centroidData))this.writeCentroidToBuffer(t)}updateReplacement(t,i,r){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let a=i.getReplacementRegionsForTile(t.toUnwrapped());if(dw(this.activeReplacements,a))return;if(this.activeReplacements=a,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(let t of this.centroidData)t.flags&=0x3fffffff;let n=[];for(let i of this.activeReplacements){if(i.order<r)continue;let a=Math.max(1,Math.pow(2,i.footprintTileId.canonical.z-t.canonical.z));if(i.footprint.buildingIds)for(let t of this.centroidData)0x80000000&t.flags||0x40000000&t.flags||i.min.x>t.max.x||t.min.x>i.max.x||i.min.y>t.max.y||t.min.y>i.max.y||i.footprint.buildingIds.has(t.buildingId)&&(t.flags|=0!==i.clipMask?-0x40000000:0x80000000);else for(let r of this.centroidData)if(!(0x80000000&r.flags||0x40000000&r.flags||i.min.x>r.max.x||r.min.x>i.max.x||i.min.y>r.max.y||r.min.y>i.max.y))for(let o=0;o<r.footprintSegLen;o++){let s=this.footprintSegments.get(r.footprintSegIdx+o);if(n.length=0,function(t,i,r,a,n,o){let s=Math.pow(2,a.z-n.z);for(let l=0;l<r;l++){let r=t.int16[2*(l+i)+0],h=t.int16[2*(l+i)+1];r=(r+8192*n.x)*s-8192*a.x,h=(h+8192*n.y)*s-8192*a.y,o.push(new tg(r,h))}}(this.footprintVertices,s.vertexOffset,s.vertexCount,i.footprintTileId.canonical,t.canonical,n),dE(i.footprint,n,this.footprintIndices.uint16,s.indexOffset,s.indexCount,-s.vertexOffset,
7-a)){r.flags|=0!==i.clipMask?-0x40000000:0x80000000;break}}}for(let t of this.centroidData)this.writeCentroidToBuffer(t);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(t,i,r){let a=!1;for(let n=0;n<r.footprintSegLen;n++){let o=this.footprintSegments.get(r.footprintSegIdx+n),s=0;for(let r of o.ringIndices){for(let n=s,l=r+s-1;n<r+s;l=n++){let r=this.footprintVertices.int16[2*(n+o.vertexOffset)+0],s=this.footprintVertices.int16[2*(n+o.vertexOffset)+1],h=this.footprintVertices.int16[2*(l+o.vertexOffset)+1];s>i!=h>i&&t<(this.footprintVertices.int16[2*(l+o.vertexOffset)+0]-r)*(i-s)/(h-s)+r&&(a=!a)}s=r}}return a}getHeightAtTileCoord(t,i){let r=-1/0,a=!0,n=4*(t+8192)*8192+(i+8192);if(Object.hasOwn(this.partLookup,n)){let t=this.partLookup[n];return t?{height:t.height,hidden:!!(0x80000000&t.flags)}:void 0}let o=this.centroidData.buffer,s=this.centroidData.length;for(let l=0;l<s;l++){let s=15*l;if(t>o[s+4]||o[s+2]>t||i>o[s+5]||o[s+3]>i)continue;let h=o[s+13];if(h<=r)continue;let u=this.centroidData.get(l);this.footprintContainsPoint(t,i,u)&&(r=h,this.partLookup[n]=u,a=!!(0x80000000&u.flags))}if(r!==-1/0)return{height:r,hidden:a};this.partLookup[n]=void 0}}function fQ(t,i){let r=t.add(i)._unit();return t.x*r.x+t.y*r.y}function fJ(t,i,r,a,n){let o=Math.sqrt(1-a*a);return Math.min(t.dist(i)/3,i.dist(r)/3,n*o/a)}function f0(t,i,r){return t.x<r[0].x&&i.x<r[0].x||t.x>r[1].x&&i.x>r[1].x||t.y<r[0].y&&i.y<r[0].y||t.y>r[1].y&&i.y>r[1].y}function f1(t,i){return t.x<i[0].x||t.x>i[1].x||t.y<i[0].y||t.y>i[1].y}function f2(t,i,r){if(t.x<0||t.x>=8192||i.x<0||i.x>=8192||r.x<0||r.x>=8192)return!1;let a=r.sub(i),n=a.perp(),o=t.sub(i);return(a.x*o.x+a.y*o.y)/Math.sqrt((a.x*a.x+a.y*a.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function f3(t,i,r){let a=i?2|t:-3&t;return r?1|a:-2&a}function f4(){let t=Math.tan(Math.PI/32);return 6371008.8*Math.sqrt(1+2*t*t)-6371008.8}function f5(t,i,r){let a=1<<r.z,n=aO(r.x/a),o=aO((r.x+1)/a);return function(t,i,r,a,n=0,o){let s=[];if(!t.length||!r||!a)return s;let l=(t,i)=>{for(let r of t)s.push({polygon:r,bounds:i})},h=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(a)),c=h-u,d=[];for(let t=0;t<Math.abs(c);t++)d.push(c>0?0:1);for(let t=0;t<Math.min(h,u);t++)d.push(0),d.push(1);let p=t;if(p=fP(p,i[0].y-n,i[1].y+n,1),!(p=fP(p,i[0].x-n,i[1].x+n,0)).length)return s;let f=[];for(d.length?f.push({polygons:p,bounds:i,depth:0}):l(p,i);f.length;){let t=f.pop(),i=t.depth,r=d[i],a=t.bounds[0],s=t.bounds[1],h=0===r?a.x:a.y,u=0===r?s.x:s.y,c=o?o(r,h,u):.5*(h+u),p=fP(t.polygons,h-n,c+n,r),_=fP(t.polygons,c-n,u+n,r);if(p.length){let t=[a,new tg(0===r?c:s.x,1===r?c:s.y)];d.length>i+1?f.push({polygons:p,bounds:t,depth:i+1}):l(p,t)}if(_.length){let t=[new tg(0===r?c:a.x,1===r?c:a.y),s];d.length>i+1?f.push({polygons:_,bounds:t,depth:i+1}):l(_,t)}}return s}(t,i,Math.ceil((o-n)/11.25),Math.ceil((aF(r.y/a)-aF((r.y+1)/a))/11.25),1,(t,i,n)=>{if(0===t)return .5*(i+n);{let t=aF((r.y+i/8192)/a);return(aL(.5*(aF((r.y+n/8192)/a)+t))*a-r.y)*8192}})}oC(fK,"FillExtrusionBucket",{omit:["layers","features"]}),oC(fq,"PartData"),oC(fZ,"PartDataArray"),oC(fH,"FootprintSegmentArray"),oC(f$,"BorderCentroidData"),oC(fY,"GroundEffect");class f6{constructor(t){this.module=t,this.memoryStack=this.module.malloc(4096),this.memoryStackNextFree=this.memoryStack}createIntArray(t){let i=this.memoryStackNextFree;return this.memoryStackNextFree+=t.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>4096?-1:(new Int32Array(this.module.heap32.buffer,i,t.length).set(t),i)}createFloatArray(t){let i=this.memoryStackNextFree;return this.memoryStackNextFree+=t.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>4096?-1:(new Float32Array(this.module.heapF32.buffer,i,t.length).set(t),i)}readStringBuffer(t){let i="";for(;0!==this.module.heapU8[t];)i+=String.fromCharCode(this.module.heapU8[t]),++t;return i}setStyle(t){let i=t.normalScale;this.module.setStyle(i[0],i[1],i[2],t.tileToMeters)}setAOOptions(t,i){this.module.setAOOptions(+!!t,i)}setMetricOptions(t,i){this.module.setMetricOptions(+!!t,i)}setStructuralOptions(t){this.module.setStructuralOptions(+!!t)}setFacadeOptions(t,i){this.module.setFacadeOptions(t,+!!i)}setFauxFacadeOptions(t,i,r){this.module.setFauxFacadeOptions(+!!t,+!!i,r)}setFacadeClassifierOptions(t){this.module.setFacadeClassifierOptions(t)}generateMesh(t,i){for(let i of(this.memoryStackNextFree=this.memoryStack,t)){let t=this.createIntArray(i.ringIndices),r=this.createFloatArray(i.coordinates);if(-1===t||-1===r)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(i.id,i.sourceId,i.minHeight,i.height,i.roofType,r,t,i.ringIndices.length-1)}for(let t of i){let i;i=t.entrances?JSON.parse(t.entrances):[];let r=this.createFloatArray(i),a=this.createFloatArray(t.coordinates);if(-1===r||-1===a)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(t.sourceId,t.crossPerc,t.distanceToRoad,r,i.length,a,t.co
7ordinates.length)}if(!this.module.generateMesh()){let t=this.module.getLastError();return this.readStringBuffer(t)}let r=this.module.getMeshCount(),a=Array(r);for(let t=0;t<r;t++){let i=this.module.getPositionsPtr(t),r=this.module.getPositionsLength(t),n=new Float32Array(this.module.heapF32.buffer,i,r),o=this.module.getNormalsPtr(t),s=this.module.getNormalsLength(t),l=new Float32Array(this.module.heapF32.buffer,o,s),h=this.module.getAOPtr(t),u=this.module.getAOLength(t),c=new Float32Array(this.module.heapF32.buffer,h,u),d=this.module.getUVPtr(t),p=this.module.getUVLength(t),f=new Float32Array(this.module.heapF32.buffer,d,p),_=this.module.getFauxFacadePtr(t),m=this.module.getFauxFacadeLength(t),g=new Uint8Array(this.module.heapU8.buffer,_,m),y=this.module.getIndicesPtr(t),x=this.module.getIndicesLength(t),v=new Int16Array(this.module.heap16.buffer,y,x),b=this.module.getBuildingPart(t);a[t]={positions:n,normals:l,ao:c,uv:f,isFauxFacade:g,indices:v,buildingPart:b}}let n=this.module.getRingCount(),o=[];for(let t=0;t<n;t++){let i=this.module.getRingPtr(t),r=this.module.getRingLength(t),a=new Float32Array(this.module.heapF32.buffer,i,r);o.push(a)}return{meshes:a,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:o}}}let f8=hN.types,f9=null,f7=null,_e=null;class _t{constructor(){this.layoutVertexArray=new lg,this.layoutAttenuationArray=new lT,this.layoutColorArray=new lS,this.indexArray=new lR,this.indexArrayForConflation=new lR,this.segmentsBucket=new l9}}class _i{constructor(t){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new l9,this.entranceBloom=new _t,this.layoutVertexArray=new lg,this.layoutVertexArray.reserve(66560),this.layoutNormalArray=new lh,this.layoutNormalArray.reserve(66560),this.layoutCentroidArray=new lh,this.layoutCentroidArray.reserve(66560),this.layoutColorArray=new lS,this.layoutColorArray.reserve(66560),this.layoutFloodLightDataArray=new lG,this.layoutFloodLightDataArray.reserve(66560),this.layoutAOArray=new lH,this.layoutAOArray.reserve(66560),this.indexArray=new lR,this.indexArray.reserve(66560),this.indexArrayForConflation=new lR,this.segmentsBucket=new l9,this.entranceBloom=new _t,t&&(this.layoutFacadePaintArray=new lS,this.layoutFacadeDataArray=new lx,this.layoutFacadeVerticalRangeArray=new lS)}reserve(t,i,r){this.layoutVertexArray.reserveForAdditional(t),this.layoutCentroidArray.reserveForAdditional(t),this.layoutFloodLightDataArray.reserveForAdditional(t),this.layoutNormalArray.reserveForAdditional(t),this.layoutAOArray.reserveForAdditional(t),this.layoutColorArray.reserveForAdditional(t),this.indexArray.reserveForAdditional(i),r&&(this.layoutFacadePaintArray.reserveForAdditional(t),this.layoutFacadeDataArray.reserveForAdditional(t),this.layoutFacadeVerticalRangeArray.reserveForAdditional(t))}}class _r{constructor(t){this.requiresHDRuntime=!0,this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new lk,this.footprintsIndices=new lV,this.footprintsMin=new tg(1/0,1/0),this.footprintsMax=new tg(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new _i(!1),this.buildingWithFacade=new _i(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=t.index,this.hasPattern=!1,this.worldview=t.worldview,this.lut=t.lut,this.programConfigurations=new hS(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.projection=t.projection,this.groundEffect=new fY(t),this.groundEffect.groundRadiusArray=new lc,this.hasAppearances=null}updateFootprints(t,i){let r=new pU([],[],1),a={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};i.push({footprint:a,id:t})}updateAppearances(t,i,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,i,r,a){if(!_e)return;let n=s6(r);this.tileToMeter=n,this.brightness=i.brightness,_e.setStyle({normalScale:[1,-1,n],tileToMeters:n}),_e.setAOOptions(!1,.3),_e.setMetricOptions(!1,16),_e.setStructuralOptions(!0),_e.setFacadeClassifierOptions(3);let o=new Map,s=new Map,l=0;for(let{feature:i}of t){if("LineString"!==f8[i.type]){o.set(i.id,i.properties.source_id);continue}let t=this.layers[0]._featureFilter.needGeometry;if(t&&!this.layers[0]._featureFilter.filter(new o0(this.zoom),i,r))continue;let n=lt(i,t);if(!t&&!this.layers[0]._featureFilter.filter(new o0(this.zoom),n,r))continue;let h=t?n.geometry:le(i,r,a),u=[];for(let t of h)for(let i of t)u.push(i.x),u.push(i.y);let c={coordinates:u,crossPerc:i.properties.cross_perc,distanceToRoad:i.properties.distance_to_road,entrances:i.properties.entrances,sourceId:0},d=i.properties.source_id,p=s.get(d);p||(p=[],s.set(d,p)),p.push(c),++l}this.maxHeight=0;let h=[],u=new Set,c=t=>{null!=t&&u.add(t)},d=(t,i)=>{null!=t&&h.push({buildingId:t,footprintIndex:i})},p=64*(t.length-l),f=p/2;for(let{feature:h,id:_,index:m,sourceLayerIndex:g}of(this.buildingWithFacade.reserve(p,f,!0),this.buildingWithoutFacade.reserve(2*p,2*f,!1),this.footprintsIndices.reserve(16*(t.length-l)),this.footprintsVertices.reserve(8*(t.length-l)),t)){if("LineString"===f8[h.type])continue;let t=this.layers[0]._featureFilter.needGeometry;if(t&&!this.layers[0]._featureFilter.filter(new o0(this.zoom),h,r))continue;let l=null;if(h.properties&&Object.hasOwn(h.properties,"building_id")&&(l=Number(h.properties.building_id),u.has(l)))continue;let p=lt(h,t);
7if(!t&&!this.layers[0]._featureFilter.filter(new o0(this.zoom),p,r))continue;let f=t?p.geometry:le(h,r,a),y=tb(f,500),x=!1;for(let t of y)if(1!==t.length){x=!0;break}if(x||!function(t,i){for(let r of t)for(let t of r)if(t.x<-163||t.x>8355||t.y<-i||t.y>8355)return!1;return!0}(f,163)){c(l);continue}let v=this.layers[0],b=function(t){switch(t){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 Error(`Unknown roof shape: ${t}`)}}(v.layout.get("building-roof-shape").evaluate(h,{},r)),w=v.layout.get("building-base").evaluate(h,{},r),T=v.layout.get("building-height").evaluate(h,{},r),E=v.layout.get("building-flood-light-ground-radius").evaluate(h,{},r),S=v.paint.get("building-ambient-occlusion-intensity"),I=E/this.tileToMeter;h.properties["building-part"]="roof";let A=v.paint.get("building-color").evaluate(h,{},this.canonical).toPremultipliedRenderColor(this.lut),C=v.paint.get("building-emissive-strength").evaluate(h,{},this.canonical);h.properties["building-part"]="wall";let M=v.paint.get("building-color").evaluate(h,{},this.canonical).toPremultipliedRenderColor(this.lut),R=v.paint.get("building-emissive-strength").evaluate(h,{},this.canonical);h.properties["building-part"]="window";let D=v.paint.get("building-color").evaluate(h,{},this.canonical).toPremultipliedRenderColor(this.lut),P=v.paint.get("building-emissive-strength").evaluate(h,{},this.canonical);h.properties["building-part"]="door";let z=v.paint.get("building-color").evaluate(h,{},this.canonical).toPremultipliedRenderColor(this.lut),L=v.paint.get("building-emissive-strength").evaluate(h,{},this.canonical),O=v.layout.get("building-flood-light-wall-radius").evaluate(h,{},r),F=(O=tL(O,0,2048))/2048*32767,B=o.get(_),k=s.get(B)||[],N=0!==k.length&&v.layout.get("building-facade").evaluate(h,{},r);_e.setFacadeOptions(4,!0),_e.setFauxFacadeOptions(N,!1,1);let V=0,U=0,j=0,G=0,H=0,q=0,Z=0,$=0,W=0,X=0,Y=0;if(N){let t=Math.round(v.layout.get("building-facade-floors").evaluate(h,{},r));if(0===w){t=Math.max(1,t-(k.length>0));let i=4;if(T>100){let t=[10,13,15];i=t[h.id?h.id%t.length:0]}else T<=10&&(i=3);_e.setFacadeOptions(i,!0),H=(T<15?1.3:1.61803)*i/n}else H=w/n;H=Math.min(H,q=T/n),j=v.layout.get("building-facade-unit-width").evaluate(h,{},r)/n,G=(q-H)/t,_e.setFauxFacadeOptions(!0,!0,j);let i=v.layout.get("building-facade-window").evaluate(h,{},r);V=i[0],U=i[1],Z=Math.floor(65535*Math.min(1,H/8192)),$=Math.floor(65535*Math.min(1,q/8192)),W=Math.floor(255*V)<<8|Math.floor(255*U),X=Math.floor(65535*Math.min(1,j/8192)),Y=Math.floor(65535*Math.min(1,G/8192))}let K=Array(y.length),Q={x:1/0,y:1/0},J={x:-1/0,y:-1/0},ee={x:0,y:0},et=0;for(let t=0;t<y.length;t++){let i=y[t];if(i.length>0){let r=[],a=Array(i.length+1);a[0]=0;for(let t=0;t<i.length;t++){let n=i[t];for(let t=0;t<n.length;t++){let i=n[n.length-t-1];Q.x=Math.min(Q.x,i.x),Q.y=Math.min(Q.y,i.y),J.x=Math.max(J.x,i.x),J.y=Math.max(J.y,i.y),ee.x+=i.x,ee.y+=i.y,et++,r.push(i.x),r.push(i.y)}a[t+1]=r.length}K[t]={id:h.id?h.id:0,height:T,minHeight:w,sourceId:0,roofType:b,coordinates:r,ringIndices:a}}}ee.x/=et||1,ee.y/=et||1;let ei=_e.generateMesh(K,k);if("string"==typeof ei){tX(`Unable to generate building ${h.id}: ${ei}`),c(l);continue}if(0===ei.meshes.length||0===ei.modifiedPolygonRings.length){c(l);continue}let er=N?this.buildingWithFacade:this.buildingWithoutFacade,ea=0;for(let t of ei.meshes)ea+=t.positions.length/3;let en=er.segmentsBucket.prepareSegment(ea,er.layoutVertexArray,er.indexArray),eo=[],es=null,el=0,eh=-1,eu=er.layoutVertexArray.length,ec=eu+ea;er.layoutVertexArray.resize(ec),er.layoutCentroidArray.resize(ec),er.layoutNormalArray.resize(ec),er.layoutAOArray.resize(ec),er.layoutColorArray.resize(ec),er.layoutFloodLightDataArray.resize(ec),N&&(er.layoutFacadePaintArray.resize(ec),er.layoutFacadeDataArray.resize(ec),er.layoutFacadeVerticalRangeArray.resize(ec));let ed=er.indexArray.length,ep=0,ef=eu;for(let t of ei.meshes){let i,r;if(1===t.buildingPart)i=A,r=C;else if(0===t.buildingPart)i=M,r=R;else if(2===t.buildingPart)i=D,r=P;else{if(3!==t.buildingPart)continue;i=z,r=L}if(r=tL(r,0,1),3===t.buildingPart){let i=[];for(let r=0;r<t.positions.length;r+=12){let a=t.positions[r+0],n=t.positions[r+1],o=t.positions[r+3],s=t.positions[r+4],l=t.positions[r+2],h=t.positions[r+8]-l,u=o-a,c=s-n,d=Math.hypot(u,c);i.push({pos:[a+.5*u,n+.5*c,l],normal:[c/d,-u/d,0],width:d,height:h,depth:1,points:[a,n,o,s]})}let r=er.entranceBloom.segmentsBucket.prepareSegment(10*i.length,er.entranceBloom.layoutVertexArray,er.entranceBloom.indexArray),a=er.entranceBloom.layoutVertexArray.length;el=er.entranceBloom.indexArray.length,function(t,i,r,a,n){r.reserve(r.length+4*t.length),a.reserve(a.length+10*t.length),n.reserve(n.length+10*t.length);let o=a.length;for(let s of t){let t=Math.min(10,Math.max(4,1.3*s.height))*i,l=[-s.normal[1],s.normal[0],0],h=Math.min(.29,.1*s.width/s.depth),u=s.width-2*s.depth*i*(h+.01),c=eG([],s.pos,l,u/2),d=eG([],s.pos,l,-u/2),p=[c[0],c[
71],c[2]+s.height],f=[d[0],d[1],d[2]+s.height],_=eG([],s.normal,l,h);ej(_,_,t);let m=eG([],s.normal,l,-h);ej(m,m,t),eB(_,c,_),eB(m,d,m),c[2]+=.1,d[2]+=.1,a.emplaceBack(_[0],_[1],_[2]),a.emplaceBack(m[0],m[1],m[2]),a.emplaceBack(c[0],c[1],c[2]),a.emplaceBack(d[0],d[1],d[2]),a.emplaceBack(p[0],p[1],p[2]),a.emplaceBack(f[0],f[1],f[2]),a.emplaceBack(c[0],c[1],c[2]),a.emplaceBack(d[0],d[1],d[2]),a.emplaceBack(_[0],_[1],_[2]),a.emplaceBack(m[0],m[1],m[2]);let g=u/t/2;n.emplaceBack(-g-h,-1,g,.8),n.emplaceBack(g+h,-1,g,.8),n.emplaceBack(-g,0,g,1.3),n.emplaceBack(g,0,g,1.3),n.emplaceBack(g+h,-.8,g,.7),n.emplaceBack(g+h,-.8,g,.7),n.emplaceBack(0,0,g,1.3),n.emplaceBack(0,0,g,1.3),n.emplaceBack(g+h,-1.2,g,.8),n.emplaceBack(g+h,-1.2,g,.8),r.emplaceBack(6+o,4+o,8+o),r.emplaceBack(7+o,9+o,5+o),r.emplaceBack(0+o,1+o,2+o),r.emplaceBack(1+o,3+o,2+o),o+=10}}(i,.5/this.tileToMeter,er.entranceBloom.indexArray,er.entranceBloom.layoutVertexArray,er.entranceBloom.layoutAttenuationArray);let n=er.entranceBloom.layoutVertexArray.length-a;eh=er.entranceBloom.indexArray.length-el;for(let t=0;t<n;t++)er.entranceBloom.layoutColorArray.emplaceBack(255*z.r<<8|255*z.g,255*z.b<<8|51*L);r.vertexLength+=n,r.primitiveLength+=eh,es={part:t.buildingPart,vertexOffset:a,vertexLength:n}}er.layoutVertexArray.float32.set(t.positions,3*ef);let a=t.positions.length/3;for(let n=0;n<a;++n){let a=3*n;ep=Math.max(ep,t.positions[a+2]);let o=32767*t.normals[a+1],s=32767*t.normals[a+2],l=3*(ef+n);er.layoutNormalArray.int16[l]=32767*t.normals[a],er.layoutNormalArray.int16[l+1]=o,er.layoutNormalArray.int16[l+2]=s;let h=t.ao[n];er.layoutAOArray.uint8[ef+n]=255*h;let u=1+(h-1)*S,c=255*i.b*u<<8|255*r;er.layoutColorArray.uint16[2*(ef+n)]=255*i.r*u<<8|255*i.g*u,er.layoutColorArray.uint16[2*(ef+n)+1]=c}let n=Math.min(8191,Math.max(0,Math.floor(ee.x))),o=Math.min(8191,Math.max(0,Math.floor(ee.y))),s=Math.floor(T),l=4*n+Math.min(3,Math.round((J.x-Q.x)*this.tileToMeter/20)),h=4*o+Math.min(3,Math.round((J.y-Q.y)*this.tileToMeter/20));for(let t=0;t<a;++t){let i=3*(ef+t);er.layoutCentroidArray.int16[i]=l,er.layoutCentroidArray.int16[i+1]=h,er.layoutCentroidArray.int16[i+2]=s}if(er.layoutFloodLightDataArray.int16.fill(0===t.buildingPart?F:0,ef,ef+a),N){let i=255*D.r<<8|255*D.g,r=255*D.b<<8|255*P;for(let t=0;t<a;++t){let a=2*(ef+t);er.layoutFacadePaintArray.uint16[a]=i,er.layoutFacadePaintArray.uint16[a+1]=r}for(let i=0;i<a;++i)if(t.isFauxFacade[i]){let r=Math.min(65535,Math.floor(t.uv[2*i]*ei.outerRingLength));er.layoutFacadeDataArray.emplace(ef+i,1|r,W,X,Y),er.layoutFacadeVerticalRangeArray.emplace(ef+i,Z,$)}else er.layoutFacadeDataArray.emplace(ef+i,0,0,0,0),er.layoutFacadeVerticalRangeArray.emplace(ef+i,0,0)}let u=en.vertexLength,c=t.indices.length/3,d=er.indexArray.length;er.indexArray.resize(d+c);for(let i=0;i<c;++i){let r=3*i,a=3*d+r;er.indexArray.uint16[a]=u+t.indices[r],er.indexArray.uint16[a+1]=u+t.indices[r+1],er.indexArray.uint16[a+2]=u+t.indices[r+2]}1!==t.buildingPart&&0!==t.buildingPart&&2!==t.buildingPart&&3!==t.buildingPart||eo.push({part:t.buildingPart,vertexOffset:ef,vertexLength:t.positions.length/3}),ef+=a,en.vertexLength+=a,en.primitiveLength+=t.indices.length/3}this.maxHeight=Math.max(this.maxHeight,ep);let e_=er.indexArray.length-ed,em=this.footprintsIndices.length,eg=this.footprintsVertices.length,ey=[],ex=new tg(1/0,1/0),ev=new tg(-1/0,-1/0),eb=this.groundEffect.vertexArray.length;for(let t of ei.modifiedPolygonRings){let i=[],r=new tg(1/0,1/0),a=new tg(-1/0,-1/0);for(let n=0;n<t.length;n+=2){let o=t.length-n-2;r.x=Math.min(r.x,t[o]),r.y=Math.min(r.y,t[o+1]),a.x=Math.max(a.x,t[o]),a.y=Math.max(a.y,t[o+1]);let s=new tg(t[o],t[o+1]);i.push(s),ey.push(s.x,s.y),this.footprintsVertices.emplaceBack(s.x,s.y)}ex.x=Math.min(ex.x,r.x),ex.y=Math.min(ex.y,r.y),ev.x=Math.max(ev.x,a.x),ev.y=Math.max(ev.y,a.y),this.groundEffect.addData(i,[r,a],I)}let ew=this.groundEffect.vertexArray.length-eb;this.groundEffect.groundRadiusArray.reserveForAdditional(ew);for(let t=0;t<ew;t++)this.groundEffect.groundRadiusArray.emplaceBack(E);(Q.x<0||J.x>8192||Q.y<0||J.y>8192)&&this.featuresOnBorder.push({featureId:h.id,footprintIndex:this.footprints.length});{let t=sC(ey,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+t.length),this.footprintsIndices.uint16.set(t,em),this.buildingIds.add(null!=l?l:h.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,ex.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,ex.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,ev.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,ev.y);let i={footprintVertexOffset:eg,footprintVertexLength:this.footprintsVertices.length-eg,footprintIndexOffset:em,footprintIndexLength:this.footprintsIndices.length-em,min:ex,max:ev,hiddenFlags:0,indicesOffset:ed,indicesLength:e_,bloomIndicesOffset:el,bloomIndicesLength:eh,groundEffectVertexOffset:eb,groundEffectVertexLength:ew,hasFauxFacade:N,height:ep,promoteId:_,feature:p,parts:eo,buildingBloom:es},r=this.footprints.length;void 0!==h.id&&this.featureFootprintLookup.set(h.id,r),d(l,r),this.footprints.push(i)}this.programConfigurations.populatePaintArrays(er.layoutVertexArray.length,h,m,{},i.availableImages,r,i.brightness),this.groundEffect.addPaintPropertiesData(h,m,{},i.availableImages,r,i.brightness),i.featureIndex.insert(h,f,m,g,this.index,eu)}
7h.forEach(({buildingId:t,footprintIndex:i})=>{u.has(t)&&(this.footprints[i].hiddenFlags|=4)});let _=new Set;this.buildingIds.forEach((t,i,r)=>{u.has(t)||_.add(t)}),this.buildingIds=_,this.groundEffect.prepareBorderSegments()}update(t,i,r,a,n,o,s){this.programConfigurations.updatePaintArrays(t,i,n,r,a,o,s),this.groundEffect.update(t,i,n,r,a,o,s),this.evaluate(this.layers[0],t),this.colorBufferUploaded=!1}updateExpressions(t){this.programConfigurations.updateExpressions(t),this.groundEffect.programConfigurations.updateExpressions(t)}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){let i=i=>{i.layoutVertexBuffer=t.createVertexBuffer(i.layoutVertexArray,f_.members),i.layoutNormalBuffer=t.createVertexBuffer(i.layoutNormalArray,fm.members),i.layoutCentroidBuffer=t.createVertexBuffer(i.layoutCentroidArray,fg.members),i.layoutFloodLightDataBuffer=t.createVertexBuffer(i.layoutFloodLightDataArray,fT.members),i.layoutFacadeDataArray&&i.layoutFacadeDataArray.length&&(i.layoutFacadeDataBuffer=t.createVertexBuffer(i.layoutFacadeDataArray,fv.members)),i.layoutFacadeVerticalRangeArray&&i.layoutFacadeVerticalRangeArray.length&&(i.layoutFacadeVerticalRangeBuffer=t.createVertexBuffer(i.layoutFacadeVerticalRangeArray,fb.members)),i.entranceBloom.layoutVertexArray.length&&(i.entranceBloom.layoutVertexBuffer=t.createVertexBuffer(i.entranceBloom.layoutVertexArray,f_.members),i.entranceBloom.layoutAttenuationBuffer=t.createVertexBuffer(i.entranceBloom.layoutAttenuationArray,fw.members)),this.uploadUpdatedColorBuffer(t),this.uploadUpdatedIndexBuffer(t)};this.uploaded||(i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){let t=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()))};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(t,i,r=!0){let a=!1,n=r?i:0,o=0|(r?-1:~i);for(let i of(0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length),t)){let t=this.footprints[i],r=t.hiddenFlags&o|n;t.hiddenFlags!==r&&(t.hiddenFlags=r,a=!0,this.groundEffect.updateHiddenByLandmarkRange(t.groundEffectVertexOffset,t.groundEffectVertexLength,0!==t.hiddenFlags))}return a&&(this.indexArrayForConflationUploaded=!1),a}uploadUpdatedIndexBuffer(t){if(this.groundEffect.uploadHiddenByLandmark(t),this.indexArrayForConflationUploaded)return;let i=t=>{0!==t.indexArray.length&&(t.indexArrayForConflation.resize(t.indexArray.length),t.indexArrayForConflation.uint16.set(t.indexArray.uint16),t.entranceBloom.indexArrayForConflation.resize(t.entranceBloom.indexArray.length),t.entranceBloom.indexArrayForConflation.uint16.set(t.entranceBloom.indexArray.uint16))};for(let t of(i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.footprints)){let i=t.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,r=t.indicesOffset+t.indicesLength;if(0!==t.hiddenFlags){for(let a=t.indicesOffset;a<r;a++)i.indexArrayForConflation.uint16[3*a+0]=0,i.indexArrayForConflation.uint16[3*a+1]=0,i.indexArrayForConflation.uint16[3*a+2]=0;let a=t.bloomIndicesOffset+t.bloomIndicesLength;for(let r=t.bloomIndicesOffset;r<a;r++)i.entranceBloom.indexArrayForConflation.uint16[3*r+0]=0,i.entranceBloom.indexArrayForConflation.uint16[3*r+1]=0,i.entranceBloom.indexArrayForConflation.uint16[3*r+2]=0}}let r=i=>{0!==i.indexArray.length&&(i.indexBuffer?i.indexBuffer.updateData(i.indexArrayForConflation):i.indexBuffer=t.createIndexBuffer(i.indexArrayForConflation,!0),i.entranceBloom.indexBuffer?i.entranceBloom.indexBuffer.updateData(i.entranceBloom.indexArrayForConflation):i.entranceBloom.indexBuffer=t.createIndexBuffer(i.entranceBloom.indexArrayForConflation,!0))};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(t){let i=i=>{i.layoutColorBuffer?i.layoutColorBuffer.updateData(i.layoutColorArray):i.layoutColorBuffer=t.createVertexBuffer(i.layoutColorArray,fy.members,!0),i.layoutFacadePaintArray&&(i.layoutFacadePaintBuffer?i.layoutFacadePaintBuffer.updateData(i.layoutFacadePaintArray):i.layoutFacadePaintBuffer=t.createVertexBuffer(i.layoutFacadePaintArray,fx.members,!0)),i.entranceBloom.layoutColorBuffer?i.entranceBloom.layoutColorBuffer.updateData(i.entranceBloom.layoutColorArray):i.entranceBloom.layoutColorBuffer=t.createVertexBuffer(i.entranceBloom.layoutColorArray,fy.members,!0)};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(t,i){let r=t.paint.get("building-ambient-occlusion-intensity");for(let a of this.footprints){if(4&a.hiddenFlags)continue;let n=i[a.promoteId],o=a.feature;o.properties["building-part"]="roof";let s=t.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),l=t.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="wall";let h=t.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),u=t.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="window";
7let c=t.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),d=t.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="door";let p=t.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),f=t.paint.get("building-emissive-strength").evaluate(o,n,this.canonical),_=a.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(let t of a.parts){let i,n=s;1===t.part?(n=s,i=l):0===t.part?(n=h,i=u):2===t.part?(n=c,i=d):3===t.part&&(n=p,i=f),i=tL(i,0,1);for(let o=0;o<t.vertexLength;o++){let s=t.vertexOffset+o,l=1+(_.layoutAOArray.uint8[s]/255-1)*r;_.layoutColorArray.emplace(s,n.r*l*255<<8|n.g*l*255,n.b*l*255<<8|255*i),a.hasFauxFacade&&_.layoutFacadePaintArray.emplace(s,255*c.r<<8|255*c.g,255*c.b<<8|255*d)}}let m=a.buildingBloom;if(m)for(let t=0;t<m.vertexLength;t++)_.entranceBloom.layoutColorArray.emplace(m.vertexOffset+t,255*p.r<<8|255*p.g,255*p.b<<8|51*f)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(t,i,r){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let a=i.getReplacementRegionsForTile(t.toUnwrapped());if(dw(this.activeReplacements,a))return;for(let t of(this.activeReplacements=a,this.footprints))t.hiddenFlags&=-2;let n=[];for(let i of this.activeReplacements){if(i.order<r)continue;let a=Math.max(1,Math.pow(2,i.footprintTileId.canonical.z-t.canonical.z));for(let r of this.footprints)r.min.x>i.max.x||r.max.x<i.min.x||r.min.y>i.max.y||r.max.y<i.min.y||(n.length=0,function(t,i,r,a,n,o){let s=Math.pow(2,a.z-n.z);for(let l=0;l<r;l++){let r=t.float32[2*(l+i)+0],h=t.float32[2*(l+i)+1];r=(r+8192*n.x)*s-8192*a.x,h=(h+8192*n.y)*s-8192*a.y,o.push(new tg(r,h))}}(this.footprintsVertices,r.footprintVertexOffset,r.footprintVertexLength,i.footprintTileId.canonical,t.canonical,n),dE(i.footprint,n,this.footprintsIndices.uint16,r.footprintIndexOffset,r.footprintIndexLength,0,-a)&&(r.hiddenFlags|=1))}for(let t of(0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length),this.footprints))this.groundEffect.updateHiddenByLandmarkRange(t.groundEffectVertexOffset,t.groundEffectVertexLength,0!==t.hiddenFlags);this.indexArrayForConflationUploaded=!1}getFootprint(t){if(void 0!==t.id){let i=this.featureFootprintLookup.get(t.id);return this.footprints[i]}return null}getHeightAtTileCoord(t,i){let r=-1/0,a=!0,n=4*(t+8192)*8192+(i+8192);if(Object.hasOwn(this.footprintLookup,n)){let t=this.footprintLookup[n];return t?{height:t.height,hidden:0!==t.hiddenFlags}:void 0}let o=new tg(t,i);for(let s of this.footprints)t>s.max.x||s.min.x>t||i>s.max.y||s.min.y>i||s.height<=r||function(t,i,r){for(let a=0;a<r.length;a+=3){let n=r[a],o=r[a+1],s=r[a+2],l=i[2*n+0],h=i[2*n+1],u=i[2*o+0],c=i[2*o+1],d=i[2*s+0],p=i[2*s+1],f=(l-d)*(t.y-p)-(h-p)*(t.x-d),_=(u-l)*(t.y-h)-(c-h)*(t.x-l);if(f<0!=_<0&&0!==f&&0!==_)continue;let m=(d-u)*(t.y-c)-(p-c)*(t.x-u);if(0===m||m<0==f+_<=0)return!0}return!1}(o,this.footprintsVertices.float32.subarray(2*s.footprintVertexOffset,2*(s.footprintVertexOffset+s.footprintVertexLength)),this.footprintsIndices.uint16.subarray(s.footprintIndexOffset,s.footprintIndexOffset+s.footprintIndexLength))&&(r=s.height,this.footprintLookup[n]=s,a=0!==s.hiddenFlags);if(r!==-1/0)return{height:r,hidden:a};this.footprintLookup[n]=void 0}}oC(_r,"BuildingBucket",{omit:["layers"]}),oC(_i,"BuildingGeometry"),oC(_t,"BuildingBloomGeometry");let _a="hd_road_coverage";oC(class{constructor(t=0,i=[]){this.frcMask=t,this.rings=i}hasGeometry(){return this.rings.length>0&&this.rings[0].length>0}},"FrcCoveragePolygon");class _n{static calculate(t,i,r){let a=new Set,n=new Map,o=new Set,s=new Set;for(let r of Object.values(t))for(let[t,l]of Object.entries(r.floors)){o.add(t),l.isDefault&&s.add(t),l.conflicts&&n.set(t,l.conflicts);let r=t===i,h=l.connections&&i&&l.connections.has(i);(r||h)&&a.add(t)}let l=t=>{let i=n.get(t)||new Set;for(let r of a)if((n.get(r)||new Set).has(t)||i.has(r))return!0;return!1};if(r)for(let t of r)o.has(t)&&(l(t)||a.add(t));for(let t of s)a.has(t)||l(t)||a.add(t);return a}}async function _o(){}function _s(t,i,r){let a=i.paint.get(t).value;return"constant"===a.kind?a.value:r.programConfigurations.get(i.id).getMaxValue(t)}function _l(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function _h(t,i,r,a,n){if(!i[0]&&!i[1])return t;let o=tg.convert(i)._mult(n);"viewport"===r&&o._rotate(-a);let s=[];for(let i=0;i<t.length;i++)s.push(t[i].sub(o));return s}function _u(t,i,r,a){let n=tg.convert(t)._mult(a);return"viewport"===i&&n._rotate(-r),n}let _c=ec(),_d=(t,i,r,a,n,o)=>{let s,l=t.transform,h="globe"===l.projection.name;if("map"===o.paint.get("circle-pitch-alignment"))if(h){let t=cF(l.zoom,i.canonical)*l._pixelsPerMercatorPixel;s=Float32Array.from([t,0,0,t])}else s=l.calculatePixelsToTileUnitsMatrix(r);else s=new Float32Array([l.pixelsToGLUnits[0],0,0,l.pixelsToGLUnits[1]]);let u={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(l.projection),u_matrix:t.translatePosMatrix(i.projMatrix,r,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:is.devicePixelRatio,u_extrude_scale:s,u_inv_rot_matrix:_c,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(h){u.u_inv_rot_matrix=a,u.u_merc_center=n,u.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],u.u_zoom_transition=cN(l.zoom);let t=8192*n[0],r=8192*n[1];u.u_up_dir=l.projection.upVector(new cQ(0,0,0),t,r)}return u},_p=t=>{let i=[];return"map"===t.paint.get("circle-pitch-alignment")&&i.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&i.push("SCALE_WITH_MAP"),i};function _f(t,i,r,a,n,o,s,l,h){if(o&&t.queryGeometry.isAboveHorizon)return!1;o&&(h*=t.pixelToTileUnitsFactor);let u=t.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(let p of i)for(let i of p){var d;let p=i.add(l),f=n&&r.elevation?r.elevation.exaggeration()*n.getElevationAt(p.x,p.y,!0):0,_=r.projection.projectTilePoint(p.x,p.y,u);if(f>0){let t=r.projection.upVector(u,p.x,p.y);_.x+=t[0]*c*f,_.y+=t[1]*c*f,_.z+=t[2]*c*f}let m=o?p:function(t,i,r,a){let n=e9([],[t,i,r,1],a);return new tg(n[0]/n[3],n[1]/n[3])}(_.x,_.y,_.z,a),g=o?t.tilespaceRays.map(t=>(function(t,i){let r=eP();return __[2]=i,t.intersectsPlane(__,_m,r),new tg(r[0],r[1])})(t,f)):t.queryGeometry.screenGeometry,y=e9([],[_.x,_.y,_.z,1],a);if(!s&&o?h*=y[3]/r.cameraToCenterDistance:s&&!o&&(h*=r.cameraToCenterDistance/y[3]),o){let t=aF((i.y/8192+u.y)/(1<<u.z));h/=r.projection.pixelsPerMeter(t,1)/(1/s2(t))}if(d=h,hW(g,m)||hZ(m,g,d))return!0}return!1}let __=eO(0,0,0),_m=eO(0,0,1);class _g extends uc{}function _y(t){let i={},r=t.resolution||256,a=t.clips?t.clips.length:1,n=t.image||new h7({width:r,height:a}),o=t.lut||null,s=(r,a,s)=>{i[t.evaluationKey]=s;let l=t.expression.evaluate(i),h=l?l.toNonPremultipliedRenderColor(o):null;h&&(n.data[r+a+0]=Math.floor(255*h.r),n.data[r+a+1]=Math.floor(255*h.g),n.data[r+a+2]=Math.floor(255*h.b),n.data[r+a+3]=Math.floor(255*h.a))};if(t.clips)for(let i=0,n=0;i<a;++i,n+=4*r)for(let a=0,o=0;a<r;a++,o+=4){let l=a/(r-1),{start:h,end:u}=t.clips[i];s(n,o,rG(h,u,l))}else for(let t=0,i=0;t<r;t++,i+=4)s(0,i,t/(r-1));return n}oC(_g,"HeatmapBucket",{omit:["layers"]});class _x{constructor(t){this.zoom=t.zoom,this.layers=t.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>
7t.id),this.footprints=[],this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,i){for(let r of this.footprints)i.push({footprint:r,id:t})}updateAppearances(t,i,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,i,r,a){let n=[];for(let{feature:o,id:s,index:l,sourceLayerIndex:h}of t){let t=this.layers[0]._featureFilter.needGeometry,u=lt(o,t);if(!this.layers[0]._featureFilter.filter(new o0(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),u,r))continue;let c={id:s,properties:o.properties,type:o.type,sourceLayerIndex:h,index:l,geometry:t?u.geometry:le(o,r,a),patterns:{}};n.push(c)}for(let a of n){let{geometry:n,index:o,sourceLayerIndex:s}=a;this.addFeature(a,n,o,r,{},i.availableImages,i.brightness),i.featureIndex.insert(t[o].feature,n,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,i,r,a,n,o,s){}destroy(){}addFeature(t,i,r,a,n,o=[],s){for(let t of tb(i,2)){let i=[],r=[],a=[],n=new tg(1/0,1/0),o=new tg(-1/0,-1/0);for(let s of t)if(0!==s.length){s!==t[0]&&a.push(r.length/2);for(let t=0;t<s.length;t++)r.push(s[t].x),r.push(s[t].y),i.push(s[t]),n.x=Math.min(n.x,s[t].x),n.y=Math.min(n.y,s[t].y),o.x=Math.max(o.x,s[t].x),o.y=Math.max(o.y,s[t].y)}let s=sC(r,a),l=new pU(i,s,8,256);this.footprints.push({vertices:i,indices:s,grid:l,min:n,max:o})}}}function _v(t,i){return t.x*i.x+t.y*i.y}function _b(t,i){if(1===t.length){let r,a=0,n=i[a++];for(;!r||n.equals(r);)if(!(r=i[a++]))return 1/0;for(;a<i.length;a++){let o=i[a],s=t[0],l=r.sub(n),h=o.sub(n),u=s.sub(n),c=_v(l,l),d=_v(l,h),p=_v(h,h),f=_v(u,l),_=_v(u,h),m=c*p-d*d,g=(p*f-d*_)/m,y=(c*_-d*f)/m,x=n.z*(1-g-y)+r.z*g+o.z*y;if(isFinite(x))return x}return 1/0}{let t=1/0;for(let r of i)t=Math.min(t,r.z);return t}}function _w(t,i,r){let a=1/0;hG(r,i)&&(a=_b(r,i[0]));for(let n=0;n<i.length;n++){let o=i[n],s=t[n];for(let t=0;t<o.length-1;t++){let i=o[t],n=[i,o[t+1],s[t+1],s[t],i];hj(r,n)&&(a=Math.min(a,_b(r,n)))}}return a!==1/0&&a}function _T(t,i,r,a,n,o,s,l,h,u,c){return"globe"===t.projection.name?function(t,i,r,a,n,o,s,l,h,u,c){let d=[],p=[],f=t.projection.upVectorScale(c,t.center.lat,t.worldSize).metersToTile,_=[0,0,0,1],m=[0,0,0,1],g=(t,i,r,a)=>{t[0]=i,t[1]=r,t[2]=a,t[3]=1},y=f4();for(let x of(r>0&&(r+=y),a+=y,i)){let i=[],y=[];for(let d of x){let p=d.x+n.x,x=d.y+n.y,v=t.projection.projectTilePoint(p,x,c),b=t.projection.upVector(c,d.x,d.y),w=r,T=a;if(s){let t=_E(p,x,r,a,s,l,h,u);w+=t.base,T+=t.top}0!==r?g(_,v.x+b[0]*f*w,v.y+b[1]*f*w,v.z+b[2]*f*w):g(_,v.x,v.y,v.z),g(m,v.x+b[0]*f*T,v.y+b[1]*f*T,v.z+b[2]*f*T),eQ(_,_,o),eQ(m,m,o),i.push(new hJ(_[0],_[1],_[2])),y.push(new hJ(m[0],m[1],m[2]))}d.push(i),p.push(y)}return[d,p]}(t,i,r,a,n,o,s,l,h,u,c):s?function(t,i,r,a,n,o,s,l,h){let u=[],c=[],d=[0,0,0,1];for(let p of t){let t=[],f=[];for(let u of p){let c=u.x+a.x,p=u.y+a.y,_=_E(c,p,i,r,o,s,l,h);d[0]=c,d[1]=p,d[2]=_.base,d[3]=1,e9(d,d,n),d[3]=Math.max(d[3],1e-5);let m=new hJ(d[0]/d[3],d[1]/d[3],d[2]/d[3]);d[0]=c,d[1]=p,d[2]=_.top,d[3]=1,e9(d,d,n),d[3]=Math.max(d[3],1e-5);let g=new hJ(d[0]/d[3],d[1]/d[3],d[2]/d[3]);t.push(m),f.push(g)}u.push(t),c.push(f)}return[u,c]}(i,r,a,n,o,s,l,h,u):function(t,i,r,a,n){let o=[],s=[],l=n[8]*i,h=n[9]*i,u=n[10]*i,c=n[11]*i,d=n[8]*r,p=n[9]*r,f=n[10]*r,_=n[11]*r;for(let i of t){let t=[],r=[];for(let o of i){let i=o.x+a.x,s=o.y+a.y,m=n[0]*i+n[4]*s+n[12],g=n[1]*i+n[5]*s+n[13],y=n[2]*i+n[6]*s+n[14],x=n[3]*i+n[7]*s+n[15],v=m+l,b=g+h,w=y+u,T=Math.max(x+c,1e-5),E=m+d,S=g+p,I=y+f,A=Math.max(x+_,1e-5);t.push(new hJ(v/T,b/T,w/T)),r.push(new hJ(E/A,S/A,I/A))}o.push(t),s.push(r)}return[o,s]}(i,r,a,n,o)}function _E(t,i,r,a,n,o,s,l){let h=s*n.getElevationAt(t,i,!0,!0),u=0!==o[0],c=u?0===o[1]?s*(o[0]/7-450):s*function(t,i,r){var a,n;let o=Math.floor(i[0]/8),s=Math.floor(i[1]/8),l=10*(i[0]-8*o),h=10*(i[1]-8*s),u=t.getElevationAt(o,s,!0,!0),c=t.getMeterToDEM(r),d=Math.floor(.5*(l*c-1)),p=Math.floor(.5*(h*c-1)),f=t.tileCoordToPixel(o,s),_=2*d+1,m=2*p+1,g=(a=f.x-d,n=f.y-p,[t.getElevationAtPixel(a,n,!0),t.getElevationAtPixel(a+m,n,!0),t.getElevationAtPixel(a,n+m,!0),t.getElevationAtPixel(a+_,n+m,!0)]),y=Math.abs(g[0]-g[1]),x=Math.abs(g[2]-g[3]);return u+Math.max(Math.min(.25,.5*c*(y+x)/_)*l,Math.min(.25,.5*c*(Math.abs(g[0]-g[2])+Math.abs(g[1]-g[3]))/m)*h)}(n,o,l):h;return{base:h+(0===r?-1:r),top:u?Math.max(c+a,h+r+2):h+a}}function _S(t,i,r){return i*(8192/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ
7)))}oC(_x,"ClipBucket",{omit:["layers"]});let _I=(t,i,r,a,n,o,s,l,h,u)=>{let c=t.transform,d=c.calculatePixelsToTileUnitsMatrix(i),p="none"===r.paint.get("line-trim-color-use-theme").constantOr("default"),f=c.pitch<15?rG(.07,.7,tL((14-c.zoom)/5,0,1)):.07;return{u_matrix:_M(t,i,r,a),u_pixels_to_tile_units:d,u_device_pixel_ratio:o,u_width_scale:s,u_floor_width_scale:l,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:_D(r)&&i.lineAtlasTexture?i.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:_C(i,t.transform),u_alpha_discard_threshold:0,u_trim_offset:h,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(p?null:r.lut).toArray01(),u_zbias_factor:f,u_tile_to_meter:s6(i.tileID.canonical,0),u_ground_shadow_factor:u,u_opacity_multiplier:1}},_A=(t,i,r,a,n,o,s,l,h,u)=>{let c=t.transform,d=c.pitch<15?rG(.07,.7,tL((14-c.zoom)/5,0,1)):.07,p="none"===r.paint.get("line-trim-color-use-theme").constantOr("default");return{u_matrix:_M(t,i,r,a),u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(i),u_device_pixel_ratio:n,u_width_scale:o,u_floor_width_scale:s,u_image:0,u_tile_units_to_pixels:_C(i,c),u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(p?null:r.lut).toArray01(),u_zbias_factor:d,u_tile_to_meter:s6(i.tileID.canonical,0),u_ground_shadow_factor:h,u_pattern_transition:u,u_opacity_multiplier:1}};function _C(t,i){return 1/_S(t,1,i.tileZoom)}function _M(t,i,r,a){return t.translatePosMatrix(a||i.tileID.projMatrix,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}let _R=t=>{let i=[];_D(t)&&i.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&i.push("RENDER_LINE_GRADIENT"),"multiply"===t.paint.get("line-blend-mode")&&i.push("LINE_BLEND_MULTIPLY"),"additive"===t.paint.get("line-blend-mode")&&i.push("LINE_BLEND_ADDITIVE");let r=t.paint.get("line-trim-offset");0===r[0]&&0===r[1]||i.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&i.push("RENDER_LINE_BORDER");let a="none"===t.layout.get("line-join").constantOr("miter"),n=!!t.paint.get("line-pattern").constantOr(1);return a&&n&&i.push("LINE_JOIN_NONE"),i};function _D(t){let i=t.paint.get("line-dasharray").value;return"constant"!==i.kind||i.value}let _P=()=>z||(z={layout:D||(D=new sa({"line-cap":new se(sn.layout_line["line-cap"]),"line-join":new se(sn.layout_line["line-join"]),"line-miter-limit":new o7(sn.layout_line["line-miter-limit"]),"line-round-limit":new o7(sn.layout_line["line-round-limit"]),"line-sort-key":new se(sn.layout_line["line-sort-key"]),"line-z-offset":new se(sn.layout_line["line-z-offset"]),"line-elevation-reference":new o7(sn.layout_line["line-elevation-reference"]),"line-cross-slope":new o7(sn.layout_line["line-cross-slope"]),visibility:new o7(sn.layout_line.visibility),"line-width-unit":new o7(sn.layout_line["line-width-unit"]),"line-elevation-ground-scale":new se(sn.layout_line["line-elevation-ground-scale"])})),paint:P||(P=new sa({"line-opacity":new se(sn.paint_line["line-opacity"]),"line-color":new se(sn.paint_line["line-color"]),"line-translate":new o7(sn.paint_line["line-translate"]),"line-translate-anchor":new o7(sn.paint_line["line-translate-anchor"]),"line-width":new se(sn.paint_line["line-width"]),"line-gap-width":new se(sn.paint_line["line-gap-width"]),"line-offset":new se(sn.paint_line["line-offset"]),"line-blur":new se(sn.paint_line["line-blur"]),"line-dasharray":new se(sn.paint_line["line-dasharray"]),"line-pattern":new se(sn.paint_line["line-pattern"]),"line-pattern-cross-fade":new o7(sn.paint_line["line-pattern-cross-fade"]),"line-gradient":new st(sn.paint_line["line-gradient"]),"line-trim-offset":new o7(sn.paint_line["line-trim-offset"]),"line-trim-fade-range":new o7(sn.paint_line["line-trim-fade-range"]),"line-trim-color":new o7(sn.paint_line["line-trim-color"]),"line-emissive-strength":new se(sn.paint_line["line-emissive-strength"]),"line-border-width":new se(sn.paint_line["line-border-width"]),"line-border-color":new se(sn.paint_line["line-border-color"]),"line-occlusion-opacity":new o7(sn.paint_line["line-occlusion-opacity"]),"line-blend-mode":new o7(sn.paint_line["line-blend-mode"]),"line-blend-additive-clamp":new o7(sn.paint_line["line-blend-additive-clamp"]),"line-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}
vendor: 6,848 bytes, line 7
7),"line-gradient-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))});class _z extends se{possiblyEvaluate(t,i){return i=new o0(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,transition:i.transition,worldview:i.worldview}),super.possiblyEvaluate(t,i)}evaluate(t,i,r,a){return i={...i,zoom:Math.floor(i.zoom)},super.evaluate(t,i,r,a)}}function _L(t,i){return i.replace(/{([^{}]+)}/g,(i,r)=>r in t?String(t[r]):"")}class _O{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:rJ,this.defaultValue=t}evaluate(t){if(t.formattedSection){let i=this.defaultValue.property.overrides;if(i&&i.hasOverride(t.formattedSection))return i.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}oC(_O,"FormatSectionOverride",{omit:["defaultValue"]});let _F=()=>B||(B={layout:O||(O=new sa({"symbol-placement":new o7(sn.layout_symbol["symbol-placement"]),"symbol-spacing":new o7(sn.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new o7(sn.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new se(sn.layout_symbol["symbol-sort-key"]),"symbol-z-order":new o7(sn.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new o7(sn.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new o7(sn.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new o7(sn.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new o7(sn.layout_symbol["icon-ignore-placement"]),"icon-optional":new o7(sn.layout_symbol["icon-optional"]),"icon-rotation-alignment":new o7(sn.layout_symbol["icon-rotation-alignment"]),"icon-size":new se(sn.layout_symbol["icon-size"]),"icon-size-scale-range":new o7(sn.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new se(sn.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new se(sn.layout_symbol["icon-text-fit-padding"]),"icon-image":new se(sn.layout_symbol["icon-image"]),"icon-image-use-theme":new o7({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new se(sn.layout_symbol["icon-rotate"]),"icon-padding":new o7(sn.layout_symbol["icon-padding"]),"icon-keep-upright":new o7(sn.layout_symbol["icon-keep-upright"]),"icon-offset":new se(sn.layout_symbol["icon-offset"]),"icon-anchor":new se(sn.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new o7(sn.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new o7(sn.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new o7(sn.layout_symbol["text-rotation-alignment"]),"text-field":new se(sn.layout_symbol["text-field"]),"text-font":new se(sn.layout_symbol["text-font"]),"text-size":new se(sn.layout_symbol["text-size"]),"text-size-scale-range":new o7(sn.layout_symbol["text-size-scale-range"]),"text-max-width":new se(sn.layout_symbol["text-max-width"]),"text-line-height":new se(sn.layout_symbol["text-line-height"]),"text-letter-spacing":new se(sn.layout_symbol["text-letter-spacing"]),"text-justify":new se(sn.layout_symbol["text-justify"]),"text-radial-offset":new se(sn.layout_symbol["text-radial-offset"]),"text-variable-anchor":new o7(sn.layout_symbol["text-variable-anchor"]),"text-anchor":new se(sn.layout_symbol["text-anchor"]),"text-max-angle":new o7(sn.layout_symbol["text-max-angle"]),"text-writing-mode":new o7(sn.layout_symbol["text-writing-mode"]),"text-rotate":new se(sn.layout_symbol["text-rotate"]),"text-padding":new o7(sn.layout_symbol["text-padding"]),"text-keep-upright":new o7(sn.layout_symbol["text-keep-upright"]),"text-transform":new se(sn.layout_symbol["text-transform"]),"text-offset":new se(sn.layout_symbol["text-offset"]),"text-allow-overlap":new o7(sn.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new o7(sn.layout_symbol["text-ignore-placement"]),"text-optional":new o7(sn.layout_symbol["text-optional"]),visibility:new o7(sn.layout_symbol.visibility)})),paint:F||(F=new sa({"icon-opacity":new se(sn.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new se(sn.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new se(sn.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new se(sn.paint_symbol["text-emissive-strength"]),"icon-color":new se(sn.paint_symbol["icon-color"]),"icon-halo-color":new se(sn.paint_symbol["icon-halo-color"]),"icon-halo-width":new se(sn.paint_symbol["icon-halo-width"]),"icon-halo-blur":new se(sn.paint_symbol["icon-halo-blur"]),"icon-translate":new o7(sn.paint_symbol["icon-translate"]),"icon-translate-anchor":new o7(sn.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new o7(sn.paint_symbol["icon-image-cross-fade"]),"text-opacity":new se(sn.paint_symbol["text-opacity"]),"text-occlusion-opacity":new se(sn.paint_symbol["text-occlusion-opacity"]),"text-color":new se(sn.paint_symbol["text-color"],{runtimeType:r3,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new se(sn.paint_symbol["text-halo-color"]),"text-halo-width":new se(sn.paint_symbol["text-halo-width"]),"text-halo-blur":new se(sn.paint_symbol["text-halo-blur"]),"text-translate":new o7(sn.paint_symbol["text-translate"]),"text-translate-anchor":new o7(sn.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new o7(sn.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new o7(sn.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new o7(sn.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new o7(sn.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new se(sn.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))});class _B extends sI{constructor(t,i,r,a){super(t,_F(),i,r,a,t.layout?t.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=ef([]),this.hasOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}_handleSpecialPaintPropertyUpdate(t){"icon-occlusion-opacity"!==t&&"text-occlusion-opacity"!==t||(this.hasOcclusionOpacityProperties=!0)}recalculate(t,i){super.recalculate(t,i),this.appearances&&this.appearances.forEac
7h(r=>{r.recalculate(t,i,this.iconImageUseTheme)}),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));let r=this.layout.get("text-writing-mode");if(r){let t=[];for(let i of r)t.includes(i)||t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(t,i,r,a){return this._saturation===t&&this._contrast===i&&this._brightnessMin===r&&this._brightnessMax===a||(this._colorAdjustmentMatrix=function(t,i,r,a){t=it(t),i=ie(i);let n=ec(),o=t/3,s=1-2*o,l=.5-.5*i,h=a-r;return eg(n,[h,0,0,0,0,h,0,0,0,0,h,0,r,r,r,1],[i,0,0,0,0,i,0,0,0,0,i,0,l,l,l,1]),eg(n,n,[s,o,o,0,o,s,o,0,o,o,s,0,0,0,0,1]),n}(t,i,r,a),this._saturation=t,this._contrast=i,this._brightnessMin=r,this._brightnessMax=a),this._colorAdjustmentMatrix}getValueAndResolveTokens(t,i,r,a){let n=this.layout.get(t).evaluate(i,{},r,a),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||ov(o.value)||!n?n:_L(i.properties,n)}getAppearanceValueAndResolveTokens(t,i,r,a,n){let o=t.getLayoutProperty(i);if(!o)return;let s=o.evaluate(r,{},a,n),l=t.getUnevaluatedLayoutProperties()._values[i];return l.isDataDriven()||ov(l.value)||!s||"string"!=typeof s?s:_L(r.properties,s)}createBucket(t){return new dB(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(let t of _F().paint.overridableProperties){if(!_B.hasPaintOverride(this.layout,t))continue;let i=this.paint.get(t),r=new ox(new _O(i),i.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme")),a=null;a="constant"===i.value.kind||"source"===i.value.kind?new ow("source",r):new oT("composite",r,i.value.zoomStops,i.value.interpolationType),this.paint._values[t]=new o8(i.property,a,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&_B.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,i){let r=t.get("text-field"),a=_F().paint.properties[i],n=!1,o=t=>{for(let i of t)if(a.overrides&&a.overrides.hasOverride(i))return void(n=!0)};if("constant"===r.value.kind&&r.value.value instanceof al)o(r.value.value.sections);else if("source"===r.value.kind){let t=i=>{n||(i instanceof a_&&ap(i.value)===r8?o(i.value.sections):i instanceof ax?o(i.sections):i.eachChild(t))},i=r.value;i._styleExpression&&t(i._styleExpression.expression)}return n}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,i,r){return{config:new hE(this,{zoom:i,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}mayUse(t){return"HD"===t&&sA(this,"symbol-elevation-reference",t=>"hd-road-markup"===t)}prepare(){return this.mayUse("HD")?_o():Promise.resolve()}}class _k extends sI{constructor(t,i,r,a){super(t,{layout:V||(V=new sa({visibility:new o7(sn.layout_raster.visibility)})),paint:U||(U=new sa({"raster-opacity":new o7(sn.paint_raster["raster-opacity"]),"raster-color":new st(sn.paint_raster["raster-color"]),"raster-color-mix":new o7(sn.paint_raster["raster-color-mix"]),"raster-color-range":new o7(sn.paint_raster["raster-color-range"]),"raster-hue-rotate":new o7(sn.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new o7(sn.paint_raster["raster-brightness-min"]),"raster-brightness-max":new o7(sn.paint_raster["raster-brightness-max"]),"raster-saturation":new o7(sn.paint_raster["raster-saturation"]),"raster-contrast":new o7(sn.paint_raster["raster-contrast"]),"raster-resampling":new o7(sn.paint_raster["raster-resampling"]),"raster-fade-duration":new o7(sn.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new o7(sn.paint_raster["raster-emissive-strength"]),"raster-array-band":new o7(sn.paint_raster["raster-array-band"]),"raster-elevation":new o7(sn.paint_raster["raster-elevation"]),"raster-elevation-reference":new o7(sn.paint_raster["raster-elevation-reference"]),"raster-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),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(t){let i=t?t._source:null;return(!i||"image"!==i.type&&"video"!==i.type&&"canvas"!==i.type||!i.onNorthPole&&!i.onSouthPole)&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(t){"raster-color"!==t&&"raster-color-range"!==t||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}
7updateColorRamp(t){if(!this.hasColorMap()||!this._curRampRange)return;let i=this._transitionablePaint._values["raster-color"].value.expression,[r,a]=t||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(a)||r===this._curRampRange[0]&&a===this._curRampRange[1]||(this.colorRamp=_y({expression:i,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:a}],resolution:1024}),this.colorRampTexture=null,this._curRampRange=[r,a])}is3D(t){return this.paint.get("raster-elevation")>0}}class _N extends sI{constructor(t,i,r,a){super(t,{layout:j||(j=new sa({visibility:new o7(sn["layout_raster-particle"].visibility)})),paint:G||(G=new sa({"raster-particle-array-band":new o7(sn["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new o7(sn["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new st(sn["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new o7(sn["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new o7(sn["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new o7(sn["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new o7(sn["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new o7(sn["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._updateColorRamp(),this.lastInvalidatedAt=is.now()}mayUse(t){return"HD"===t}_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(t){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"none"!==this.visibility}isDraped(t){return!1}_handleSpecialPaintPropertyUpdate(t){"raster-particle-color"!==t&&"raster-particle-max-speed"!==t||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===t&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;let t=this._transitionablePaint._values["raster-particle-color"].value.expression,i=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=_y({expression:t,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:i}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=is.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class _V extends sI{constructor(t,i){super(t,{},i,null),this.implementation=t,t.slot&&(this.slot=t.slot)}is3D(t){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(t){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}function _U(t,i,r){let a=[0,0,1],n=te([]);return ti(n,n,r?-(t*tA)+Math.PI:t*tA),tt(n,n,-(i*tA)),e0(a,a,n),eW(a,a)}class _j{constructor(t,i){this.feature=t,this.instancedDataOffset=i,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class _G{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new lU,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(t){let i=16*t,r=this.instancedDataArray.float32,a=Math.floor(r[i+2]),n=1.05*(r[i+2]-a);return a/=100,[r[i]%1*1.05,r[i+1]%1*1.05,n,a]}tileCoordinatesForInstance(t){let i=16*t,r=this.instancedDataArray.float32,a=r[i+0];return new tg(Math.trunc(a=a>8192?a-8192:a),Math.trunc(r[i+1]))}translationForInstance(t){let i=16*t,r=this.instancedDataArray.float32;return[r[i+4],r[i+5],r[i+6]]}rotationScaleForInstance(t){let i=16*t,r=this.instancedDataArray.float32;
7return[r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]]}transformForInstance(t){let i=16*t,r=this.instancedDataArray.float32;return[r[i+7],r[i+8],r[i+9],r[i+4],r[i+10],r[i+11],r[i+12],r[i+5],r[i+13],r[i+14],r[i+15],r[i+6],0,0,0,1]}}class _H{constructor(t){this.requiresStandardRuntime=!0,this.zoom=t.zoom,this.canonical=t.canonical,this.overscaledZ=this.canonical.z+Math.log2(t.overscaling),this.layers=t.layers,this.layerIds=this.layers.map(t=>t.fqid),this.projection=t.projection,this.index=t.index,this.worldview=t.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=t.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(t,i){}updateAppearances(t,i,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(t,i,r,a){this.tileToMeter=s6(r);let n=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);let o="hd-road-markup"===this.layers[0].paint.get("model-elevation-reference")?i.elevationFeatures:void 0;for(let{feature:s,id:l,index:h,sourceLayerIndex:u}of t){let t=null!=l?l:s.properties&&Object.hasOwn(s.properties,"id")?s.properties.id:void 0,c=lt(s,n);if(!this.layers[0]._featureFilter.filter(new o0(this.zoom,{worldview:this.worldview,activeFloors:i.activeFloors}),c,r))continue;let d={id:t,sourceLayerIndex:u,index:h,geometry:n?c.geometry:le(s,r,a),properties:s.properties,type:s.type,patterns:{}},p=this.addFeature(d,d.geometry,c,o,r);p&&i.featureIndex.insert(s,d.geometry,h,u,this.index,this.instancesPerModel[p].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){let t=this.layers[0].modelManager,i=this.layers[0].scope,r=0;for(let a of this.modelUris){let n=t.getModel(a,i);if(!n)continue;let o=this.instancesPerModel[a];o&&(r=Math.max(Math.min(8192,Math.max((.5*eH(n.aabb.max,n.aabb.min)*o.maxScale+o.maxXYTranslationDistance)/this.tileToMeter,256)),r))}return r}update(t,i,r,a){for(let i in this.instancesPerModel){let r=this.instancesPerModel[i];for(let i in t)Object.hasOwn(r.idToFeaturesIndex,i)&&(this.evaluate(r.features[r.idToFeaturesIndex[i]],t[i],r,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(let i in this.instancesPerModel){let r=this.instancesPerModel[i];for(let i of r.features){let a=this.layers[0],n=i.feature,o=this.canonical,s=a.paint.get("model-rotation").evaluate(n,{},o),l=a.paint.get("model-scale").evaluate(n,{},o),h=a.paint.get("model-translation").evaluate(n,{},o);e2(i.rotation,s)&&e2(i.scale,l)&&e2(i.translation,h)||(this.evaluate(i,i.featureStates,r,!0),t=!0)}}return t}updateReplacement(t,i,r,a){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;let n=i.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(dw(this.activeReplacements,n))return!1;this.activeReplacements=n;let o=!1;for(let i in this.instancesPerModel){let n=this.instancesPerModel[i],s=n.instancedDataArray;for(let i of n.features){let n=i.instancedDataOffset,l=i.instancedDataCount;for(let i=0;i<l;i++){let l=16*(i+n),h=s.float32[l+0],u=h>8192,c=Math.floor(h=u?h-8192:h),d=Math.floor(s.float32[l+1]),p=!1;for(let i of this.activeReplacements)if(!dg(i,r,1,a)&&!(i.min.x>c||c>i.max.x||i.min.y>d||d>i.max.y)&&(p=dI(dS(c,d,t.canonical,i.footprintTileId.canonical),i.footprint)))break;s.float32[l]=p?h+8192:h,o=o||p!==u}}}return o}isEmpty(){for(let t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(let i in this.instancesPerModel){let r=this.instancesPerModel[i];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=t.createVertexBuffer(r.
7instancedDataArray,pW.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(t){for(let t in this.instancesPerModel){let i=this.instancesPerModel[t];0!==i.instancedDataArray.length&&i.instancedDataBuffer&&i.instancedDataBuffer.destroy()}let i=this.layers[0].modelManager;if(t&&i&&this.modelUris&&this.modelsRequested)for(let t of this.modelUris)i.removeModel(t,"",!0)}addFeature(t,i,r,a,n){let o,s=this.layers[0],l=s.layout.get("model-id"),h=s.layout.get("model-allow-density-reduction"),u=l.evaluate(r,{},this.canonical);if(!u)return tX(`modelId is not evaluated for layer ${s.id} and it is not going to get rendered.`),u;!u.includes("://")&&!this.styleDefinedModelURLs[u]||this.modelUris.includes(u)||this.modelUris.push(u),this.instancesPerModel[u]||(this.instancesPerModel[u]=new _G);let c=this.instancesPerModel[u],d=c.instancedDataArray,p=new _j(r,d.length);if(a){let i=dK(t,a,void 0,n);o=i?i.feature:void 0}for(let t of i)for(let i of t){if(i.x<0||i.x>=8192||i.y<0||i.y>=8192)continue;if(0!==this.lookupDim&&h){let t=(this.lookupDim-1)/8192,r=this.lookupDim*(i.y*t|0)+i.x*t|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1}}this.instanceCount++;let t=d.length;if(d.resize(t+1),a){c.instancesRoadElevation||(c.instancesRoadElevation=[]);let t=o?o.pointElevation(new tg(i.x,i.y)):0;c.instancesRoadElevation.push(t)}c.instancesEvaluatedElevation.push(0),d.float32[16*t]=i.x,d.float32[16*t+1]=i.y}return p.instancedDataCount=c.instancedDataArray.length-p.instancedDataOffset,p.instancedDataCount>0&&(t.id&&(c.idToFeaturesIndex[t.id]=c.features.length),c.features.push(p),this.evaluate(p,{},c,!1)),u}getModelUris(){return this.modelUris}evaluate(t,i,r,a){let n=this.layers[0],o=t.feature,s=this.canonical,l=t.rotation=n.paint.get("model-rotation").evaluate(o,i,s),h=t.scale=n.paint.get("model-scale").evaluate(o,i,s),u=t.translation=n.paint.get("model-translation").evaluate(o,i,s),{r:c,g:d,b:p}=n.paint.get("model-color").evaluate(o,i,s),f=n.paint.get("model-color-mix-intensity").evaluate(o,i,s),_=[];this.maxVerticalOffset<u[2]&&(this.maxVerticalOffset=u[2]);let m=u[0]*u[0]+u[1]*u[1],g=m>0?Math.sqrt(m):0;r.maxScale=Math.max(Math.max(r.maxScale,h[0]),Math.max(h[1],h[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,g),this.maxScale=Math.max(Math.max(this.maxScale,h[0]),Math.max(h[1],h[2])),p3(_,l,h);let y=Math.round(100*f)+p/1.05;for(let i=0;i<t.instancedDataCount;++i){let n=t.instancedDataOffset+i,o=16*n,l=r.instancedDataArray.float32,h=0;a&&(h=l[o+6]-r.instancesEvaluatedElevation[n]);let p=0|l[o+1];l[o]=(0|l[o])+c/1.05,l[o+1]=p+d/1.05,l[o+2]=y,l[o+3]=1/(s.z>10?this.tileToMeter:s6(s,p)),l[o+4]=u[0],l[o+5]=u[1],l[o+6]=u[2]+(r.instancesRoadElevation?r.instancesRoadElevation[n]:0)+h,l[o+7]=_[0],l[o+8]=_[1],l[o+9]=_[2],l[o+10]=_[4],l[o+11]=_[5],l[o+12]=_[6],l[o+13]=_[8],l[o+14]=_[9],l[o+15]=_[10],r.instancesEvaluatedElevation[n]=u[2]}}}oC(_H,"ModelBucket",{omit:["layers"]}),oC(_G,"PerModelAttributes"),oC(_j,"ModelFeature");class _q{isDataAvailableAtPoint(t){let i=this._source();if(this.isUsingMockSource()||!i||t.y<0||t.y>1)return!1;let r=i.getSource().maxzoom,a=1<<r,n=Math.floor(t.x),o=Math.floor((t.x-n)*a),s=Math.floor(t.y*a),l=this.findDEMTileFor(new c0(r,n,r,o,s));return!(!l||!l.dem)}getAtPointOrZero(t,i=0){return this.getAtPoint(t,i)||0}getAtPoint(t,i,r=!0){if(this.isUsingMockSource())return null;null==i&&(i=null);let a=this._source();if(!a||t.y<0||t.y>1)return i;let n=a.getSource().maxzoom,o=1<<n,s=Math.floor(t.x),l=t.x-s,h=new c0(n,s,n,Math.floor(l*o),Math.floor(t.y*o)),u=this.findDEMTileFor(h);if(!u||!u.dem)return i;let c=u.dem,d=1<<u.tileID.canonical.z,p=(l*d-u.tileID.canonical.x)*c.dim,f=(t.y*d-u.tileID.canonical.y)*c.dim,_=Math.floor(p),m=Math.floor(f);return(r?this.exaggeration():1)*rG(rG(c.get(_,m),c.get(_,m+1),f-m),rG(c.get(_+1,m),c.get(_+1,m+1),f-m),p-_)}static getAtTileOffset(t,i,r,a){let n=1<<t.canonical.z;return a?a.pointElevation(i):r?r.getAtPointOrZero(new s8(t.wrap+(t.canonical.x+i.x/8192)/n,(t.canonical.y+i.y/8192)/n)):0}static getAtTileOffsetFunc(t,i,r,a){return(n,o,s)=>{let l=this.getAtTileOffset(t,n,o,s),h=a.upVector(t.canonical,n.x,n.y);return ej(h,h,l*a.upVectorScale(t.canonical,i,r).metersToTile),h}}getForTilePoints(t,i,r,a){if(this.isUsingMockSource())return!1;let n=_Z.create(this,t,a);return!!n&&(i.forEach(t=>{t[2]=this.exaggeration()*n.getElevationAt(t[0],t[1],r,!0)}),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;let i=this.findDEMTileFor(t);if(!i||!i.dem)return null;let r=i.dem.tree,a=i.tileID,n=1<<t.canonical.z-a.canonical.z,o=t.canonical.x/n-a.canonical.x,s=t.canonical.y/n-a.canonical.y,l=0;for(let i=0;i<t.canonical.z-a.canonical.z&&!r.leaves[l];i++){let t=2*Math.floor(s*=2)+Math.floor(o*=2);l=r.childOffsets[l]+t,o%=1,s%=1}return{min:this.exaggeration()*r.minimums[l],max:this.exaggeration()*r.maximums[l]}}getMinElevationBelowMSL(){throw Error("Pure virtual method called.")}raycast(t,i,r){throw Error("Pure virtual method called.")}pointCoordinate(t){throw Error("Pure virtual method called.")}_source(){throw Error("Pure virtual method called.")}isUsingMockSource(){throw Error("Pure virtual method called.")}exaggeration(){throw Error("Pure virtual method called.")}findDEMTileFor(t){throw Error("Pure virtual method called.")}get visibleDemTiles(){throw Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){let t=this.visibleDemTiles;if(0===t.length)return null;let i=!1,r=Number.MAX_VALUE,a=5e-324;for(let n of t){let t=this.getMinMaxForTile(n.tileID);
7t&&(r=Math.min(r,t.min),a=Math.max(a,t.max),i=!0)}return i?{min:r,max:a}:null}}class _Z{constructor(t,i,r){this._demTile=t,this._dem=this._demTile.dem,this._scale=i,this._offset=r}static create(t,i,r){let a=r||t.findDEMTileFor(i);if(!a||!a.dem)return;let n=a.dem,o=a.tileID,s=1<<i.canonical.z-o.canonical.z;return new _Z(a,n.dim/8192/s,[(i.canonical.x/s-o.canonical.x)*n.dim,(i.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(t,i){let r=i*this._scale+this._offset[1];return new tg(Math.floor(t*this._scale+this._offset[0]),Math.floor(r))}getElevationAt(t,i,r,a){let n=t*this._scale+this._offset[0],o=i*this._scale+this._offset[1],s=Math.floor(n),l=Math.floor(o),h=this._dem;return a=!!a,r?rG(rG(h.get(s,l,a),h.get(s,l+1,a),o-l),rG(h.get(s+1,l,a),h.get(s+1,l+1,a),o-l),n-s):h.get(s,l,a)}getElevationAtPixel(t,i,r){return this._dem.get(t,i,!!r)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*(1/s2(t))*this._dem.stride}}let _$=new Float32Array(262144),_W=new Uint8Array(262144),_X=[0,0,0],_Y=[0,0,0],_K=["","wall","door","roof","window","lamp","logo"];class _Q{constructor(t){this.node=t,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:t.id,geometry:[],properties:{height:function t(i){let r=0;if(i.meshes)for(let t of i.meshes)r=Math.max(r,t.aabb.max[2]);if(i.children)for(let a of i.children)r=Math.max(r,t(a));return r}(t)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new cg([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0,i=new cg([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(let r of this.node.meshes)this.node.lightMeshIndex!==t&&(r.transformedAabb=cg.applyTransformFast(r.aabb,this.node.globalMatrix),i.encapsulate(r.transformedAabb)),t++;this.aabb=i}return this.aabb}}class _J{constructor(t,i,r,a,n,o,s,l){for(let h of(this.requiresStandardRuntime=!0,this.id=r,this.layers=t,this.layerIds=this.layers.map(t=>t.fqid),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,a&&(this.modelTraits|=4),n&&(this.modelTraits|=8),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=l,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[],i))this.nodesInfo.push(new _Q(h)),function t(i,r,a){if(i.meshes)for(let t of i.meshes){if(t.aabb.min[0]===1/0)continue;let n=cg.applyTransform(t.aabb,i.globalMatrix);a.insert(r,n.min[0],n.min[1],n.max[0],n.max[1])}if(i.children)for(let n of i.children)t(n,r,a)}(h,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(t,i){for(let r of this.getNodesInfo()){let a=r.node;a.footprint&&i.push({footprint:a.footprint,id:t})}}updateAppearances(t,i,r,a){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(t){let i=0!==Object.keys(t).length;if(i&&!this.stateDependentLayers.length)return;let r=i?this.stateDependentLayers:this.layers;if(!ty(t,this.states))for(let i of r)this.evaluate(i,t);this.states=structuredClone(t)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;let i=this.getNodesInfo();for(let r of i){let i=r.node;this.uploaded?this.updatePbrBuffer(i):fi(i,t,!0)}for(let t of i)fa(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let i=!1;if(!t.meshes)return i;for(let r of t.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),i=!0);if(t.lodMeshes)for(let r of t.lodMeshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),i=!0);return i}needsReEvaluation(t,i,r){let a=t.transform.projectionOptions,n=t.style.getBrightness(),o=this.brightness!==n;if(!this.uploaded||this.dirty||a.name!==this.projection.name||_0(r.paint.get("model-color").value,o)||_0(r.paint.get("model-color-mix-intensity").value,o)||_0(r.paint.get("model-roughness").value,o)||_0(r.paint.get("model-emissive-strength").value,o)||_0(r.paint.get("model-height-based-emissive-strength-multiplier").value,o)){for(let t of(this.projection=a,this.brightness=n,this.getNodesInfo()))t.state=null;return!0}return!1}evaluateTransform(t,i){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;let r=this.getNodesInfo(),a=this.id.canonical;for(let t of r){let r=t.feature;t.evaluatedTranslation=i.paint.get("model-translation").evaluate(r,{},a),t.evaluatedScale=i.paint.get("model-scale").evaluate(r,{},a)}}
7evaluate(t,i){for(let r of this.getNodesInfo()){if(!r.node.meshes)continue;let a=r.feature,n=i&&i[a.id];if(ty(n,r.state))continue;r.state=structuredClone(n);let o=r.node.meshes&&r.node.meshes[0].featureData,s=r.evaluatedColor[2],l=r.evaluatedRMEA[2],h=this.id.canonical;if(r.hasTranslucentParts=!1,o){for(let i=0;i<_K.length;i++){let o=_K[i];o.length&&(a.properties.part=o);let s=t.paint.get("model-color").evaluate(a,n,h).toPremultipliedRenderColor(null),l=t.paint.get("model-color-mix-intensity").evaluate(a,n,h);r.evaluatedColor[i]=[s.r,s.g,s.b,l],r.evaluatedRMEA[i][0]=t.paint.get("model-roughness").evaluate(a,n,h),r.evaluatedRMEA[i][2]=t.paint.get("model-emissive-strength").evaluate(a,n,h),r.evaluatedRMEA[i][3]=s.a,r.emissionHeightBasedParams[i]=t.paint.get("model-height-based-emissive-strength-multiplier").evaluate(a,n,h),!r.hasTranslucentParts&&s.a<1&&(r.hasTranslucentParts=!0)}delete a.properties.part,function(t,i,r){let a=t.node,n=8&r,o=16*!n,s=16*!!n;for(let r=0;r<a.meshes.length;r++)a.lights&&a.lightMeshIndex===r||_2(a.meshes[r],t,o,s,i);if(a.lodMeshes)for(let i of a.lodMeshes)_2(i,t,o,s,!1)}(r,s!==r.evaluatedColor[2]||l!==r.evaluatedRMEA[2],this.modelTraits)}else r.evaluatedRMEA[0][2]=t.paint.get("model-emissive-strength").evaluate(a,n,h);r.evaluatedTranslation=t.paint.get("model-translation").evaluate(a,n,h),r.evaluatedScale=t.paint.get("model-scale").evaluate(a,n,h),this.updatePbrBuffer(r.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(t,i,r,a){let n=t.findDEMTileFor(r);if(n&&(n.tileID.canonical!==this.terrainTile||i!==this.terrainExaggeration)){if(n.dem&&n.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=n.tileID.overscaledZ;let i=_Z.create(t,r,n);if(!i)return;for(let n of(4&this.modelTraits&&this.updateDEM(t,i,r,a),this.getNodesInfo())){let t=n.node;if(!t.footprint||!t.footprint.vertices||!t.footprint.vertices.length)continue;let r=t.footprint.vertices,a=i.getElevationAt(r[0].x,r[0].y,!0,!0);for(let t=1;t<r.length;t++)a=Math.min(a,i.getElevationAt(r[t].x,r[t].y,!0,!0));t.elevation=a}}this.terrainTile=n.tileID.canonical,this.terrainExaggeration=i}}updateDEM(t,i,r,a){let n=i._dem._modifiedForSources[a];if(void 0===n&&(i._dem._modifiedForSources[a]=[],n=i._dem._modifiedForSources[a]),n.includes(r.canonical))return;let o=i._dem.dim;n.push(r.canonical);let s=!1;for(let t of this.getNodesInfo()){let r=t.node;if(!r.footprint||!r.footprint.grid)continue;let a=r.footprint.grid,n=i.tileCoordToPixel(a.min.x,a.min.y),l=i.tileCoordToPixel(a.max.x,a.max.y),h=Math.min(Math.min(o-l.y,n.x),Math.min(n.y,o-l.x));if(h<0)continue;let u=tL(h,2,5),c=Math.max(0,n.x-u),d=Math.max(0,n.y-u),p=Math.min(l.x+u,o-1),f=Math.min(l.y+u,o-1);for(let t=d;t<=f;++t)for(let i=c;i<=p;++i)_W[t*o+i]=255;let _=0,m=0;for(let t=0;t<a.cellsY;++t)for(let r=0;r<a.cellsX;++r){if(!a.cells[t*a.cellsX+r])continue;let n=i.tileCoordToPixel(a.min.x+r/a.xScale,a.min.y+t/a.yScale),s=i.tileCoordToPixel(a.min.x+(r+1)/a.xScale,a.min.y+(t+1)/a.yScale);for(let t=n.y;t<=Math.min(s.y+1,o-1);++t)for(let r=n.x;r<=Math.min(s.x+1,o-1);++r)255===_W[t*o+r]&&(_W[t*o+r]=0,_+=i.getElevationAtPixel(r,t),m++)}let g=_/m;c=Math.max(1,n.x-u),d=Math.max(1,n.y-u),p=Math.min(l.x+u,o-2),f=Math.min(l.y+u,o-2),s=!0;for(let t=d;t<=f;++t)for(let r=c;r<=p;++r)0===_W[t*o+r]&&(_$[t*o+r]=i._dem.set(r,t,g));for(let t=1;t<u;++t){c=Math.max(1,n.x-t),d=Math.max(1,n.y-t),p=Math.min(l.x+t,o-2),f=Math.min(l.y+t,o-2);for(let r=d;r<=f;++r)for(let a=c;a<=p;++a){let n=r*o+a;if(255===_W[n]){let s=0,l=0,h=-1,c=-1;for(let i=-1;i<=1;++i)for(let n=-1;n<=1;++n){let u=(r+i)*o+a+n;if(_W[u]>=t)continue;let d=_$[u],p=Math.abs(d);p>l&&(s=d,l=p,h=n,c=i)}if(l>.1){let o=1-(t+.5*Math.abs(h*c))/u,l=i._dem.get(a,r)+s*o,d=i._dem.get(a+h,r+c),p=i._dem.get(a-h,r-c,!0);(l-d)*(l-p)>0&&(l=(d+p)/2),_$[n]=i._dem.set(a,r,l),_W[n]=t}}}}}s&&(i._demTile.needsDEMTextureUpload=!0,i._dem._timestamp=is.now())}setFilter(t){this.filter=t?sh(t):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(t=>this.filter.filter(new o0(this.id.overscaledZ,{worldview:this.worldview}),t.feature,this.id.canonical)):this.nodesInfo}destroy(){for(let t of this.getNodesInfo())fa(t.node),fo(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,i){if(i.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=i.updateTime;let r=i.getReplacementRegionsForTile(t.toUnwrapped());for(let t of this.getNodesInfo()){let i=t.node.footprint;t.hiddenByReplacement=!!i&&!r.some(t=>t.footprint===i)}}
7getHeightAtTileCoord(t,i){let r=[0,0,0],a=ef([]);for(let n of this.getNodesInfo()){let o=n.node.meshes[0],s=o.transformedAabb;if(t<s.min[0]||i<s.min[1]||t>s.max[0]||i>s.max[1])continue;if(!0===n.node.hidden)return{height:1/0,maxHeight:n.feature.properties.height,hidden:!1,verticalScale:n.evaluatedScale[2]};if(em(a,n.node.globalMatrix),r[0]=t,r[1]=i,r[2]=0,eQ(r,r,a),n.node.meshBVH){let t=r[0],i=r[1];_X[0]=t-1,_X[1]=i-1,_X[2]=-1e3,_Y[0]=t+1,_Y[1]=i+1,_Y[2]=1e3;let a=n.node.meshBVH.findHighestPoint(_X,_Y);if(null!==a)return{height:a,maxHeight:n.feature.properties.height,hidden:n.hiddenByReplacement,verticalScale:n.evaluatedScale[2]};continue}let l=(r[0]-o.aabb.min[0])/(o.aabb.max[0]-o.aabb.min[0])*64|0,h=64*Math.min(63,(r[1]-o.aabb.min[1])/(o.aabb.max[1]-o.aabb.min[1])*64|0)+Math.min(63,l),u=o.heightmap[h];if(u<0&&n.node.footprint){let r=[];if(n.node.footprint.grid.query(new tg(t,i),new tg(t,i),r),r.length>0)return{height:void 0,maxHeight:n.feature.properties.height,hidden:n.hiddenByReplacement,verticalScale:n.evaluatedScale[2]};continue}if(n.hiddenByReplacement)return;return{height:u,maxHeight:n.feature.properties.height,hidden:!1,verticalScale:n.evaluatedScale[2]}}}}function _0(t,i){return t instanceof ow&&!t.isLightConstant&&i}let _1=new Float64Array(10*_K.length);function _2(t,i,r,a,n){if(!t.featureData)return;let o=t.featureArray=new lj;o.reserveExact(t.featureData.length),function(t,i,r){let a=r-i;for(let r=0;r<_K.length;r++){let n=t.evaluatedRMEA[r],o=t.evaluatedColor[r],s=t.emissionHeightBasedParams[r],l=tL(s[0],0,1),h=tL(s[1],0,1),u=65535,c=0,d=1,p=1;if(l!==h&&0!==a){let t=tL(s[2],0,1),r=tL(s[3],0,1),n=a*(h-l);c=1/n,d=-(i+a*l)/n,p=Math.pow(10,tL(s[4],-1,1)),u=255*t<<8|255*r}let f=10*r;_1[f]=255*o[0],_1[f+1]=255*o[1],_1[f+2]=255*o[2],_1[f+3]=o[3],_1[f+4]=Math.floor(255*n[3]),_1[f+5]=Math.min(Math.round(.5*tL(n[2],0,2)*255),255)<<8|15*n[0]<<4|15*n[1],_1[f+6]=u,_1[f+7]=c,_1[f+8]=d,_1[f+9]=p}}(i,t.aabb.min[2],t.aabb.max[2]);let s=i.node,l=n&&!!s.lights;for(let i of t.featureData){let t=i>>r&65535,n=i>>a&15,h=n<8?n:0,u=10*h,c=(61440&t|(61440&t)>>4)>>8,d=(3840&t|(3840&t)>>4)>>4,p=240&t|(240&t)>>4,f=(15&t|(15&t)<<4)/255,_=_1[u+3];_>0&&(c=rG(c,_1[u],_),d=rG(d,_1[u+1],_),p=rG(p,_1[u+2],_)),c*=f,d*=f,p*=f;let m=c<<8|d,g=p<<8|_1[u+4],y=_1[u+5],x=_1[u+6],v=_1[u+7],b=_1[u+8],w=_1[u+9];if(o.emplaceBack(m,g,y,x,v,b,w),l&&2===h){l=!1;let t=10*s.lights.length,i=new lj;i.reserveExact(t);for(let r=0;r<t;r++)i.emplaceBack(m,g,y,x,v,b,w);s.meshes[s.lightMeshIndex].featureArray=i}}}oC(_J,"Tiled3dModelBucket",{omit:["layers"]}),oC(_Q,"Tiled3dModelFeature");let _3=["id","tile","layer","source","sourceLayer","state"];class _4{constructor(t,i,r,a,n){this.type="Feature",this._vectorTileFeature=t,this._z=i,this._x=r,this._y=a,this.properties=t?t.properties:{},this.id=n}clone(){let t=new _4(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(t.state={...this.state}),this.layer&&(t.layer={...this.layer}),this.source&&(t.source=this.source),this.sourceLayer&&(t.sourceLayer=this.sourceLayer),t}get geometry(){return void 0===this._geometry&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){let t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(let i of _3)void 0!==this[i]&&(t[i]=this[i]);return t}}class _5 extends _4{constructor(t,i){super(t._vectorTileFeature,t._z,t._x,t._y,t.id),t.state&&(this.state={...t.state}),this.target=i.target,this.namespace=i.namespace,i.properties&&(this.properties=i.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=t.source,this.sourceLayer=t.sourceLayer,this.layer=t.layer)}toJSON(){let t=super.toJSON();return t.target=this.target,t.namespace=this.namespace,t}}class _6 extends rB{constructor(t,i,r,a){super(),this.id=t,this.type="model",this.models=[],this._options=i,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}async loadGLTFFromURI(t,i){return pV((await this.map._requestManager.transformRequest(t,iX.Model,i)).url,
7i)}async loadModel(t,i,r){try{let a=await this.loadGLTFFromURI(i.uri,r);if(r.aborted)return;let n=this._modelsInfo.get(t);if(!n)return;let o=ff(a),s=n.modelSpec,l=new p7(t,s.uri,s.position,s.orientation,o);_6.applyModelSpecification(l,s),l.computeBoundsAndApplyParent(),this.models.push(l),n.model=l}catch(a){if(r.aborted)return;this.fire(new rL(Error(`Could not load model ${t} from ${i.uri}`,{cause:a})))}}async load(){this._abortController||(this._abortController=new AbortController);let t=this._abortController.signal,i=[];for(let r in this._options.models){let a=this._options.models[r],n=this._modelsInfo.get(r);if(n&&n.model){n.modelSpec=a;let t=n.model;t.position=null!=a.position?new s0(a.position[0],a.position[1]):new s0(0,0),t.orientation=null!=a.orientation?a.orientation:[0,0,0],_6.applyModelSpecification(t,a),t.computeBoundsAndApplyParent(),this.models.push(t)}else n?n.modelSpec=a:(this._modelsInfo.set(r,{modelSpec:a,model:null}),i.push(this.loadModel(r,a,t)))}0!==i.length?(await Promise.allSettled(i),t.aborted||this.fire(new rz("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new rz("data",{dataType:"source",sourceDataType:"metadata"}))}static arrayFromColorSpecification(t){if(void 0===t)return;if(Array.isArray(t))return[t[0],t[1],t[2]];let i=rq.parse(t);return i?[i.r,i.g,i.b]:void 0}static applyModelSpecification(t,i){if(i.nodeOverrides&&_6.convertNodeOverrides(t,i.nodeOverrides),i.materialOverrides&&_6.convertMaterialOverrides(t,i.materialOverrides),i.nodeOverrideNames&&(t.nodeOverrideNames=[...i.nodeOverrideNames]),i.materialOverrideNames&&(t.materialOverrideNames=[...i.materialOverrideNames]),i.featureProperties&&(t.featureProperties=i.featureProperties),i.lightOverrides){let r=i.lightOverrides,a=_6.arrayFromColorSpecification(r["light-ambient-color"]),n=_6.arrayFromColorSpecification(r["light-directional-color"]);t.lightOverrides={ambientIntensity:r["light-ambient-intensity"],ambientColor:a,directionalIntensity:r["light-directional-intensity"],directionalColor:n}}else t.lightOverrides=void 0}static convertNodeOverrides(t,i){if(Array.isArray(i)&&i.every(t=>"string"==typeof t))for(let r of(t.nodeOverrideNames=[],i))t.nodeOverrideNames.push(r);else Object.entries(i).forEach(([i,r])=>{let a={orientation:[0,0,0],minZoom:void 0,maxZoom:void 0};if(Object.hasOwn(r,"orientation")){let t=r.orientation;t&&(a.orientation=t)}Object.hasOwn(r,"minzoom")&&(a.minZoom=r.minzoom),Object.hasOwn(r,"maxzoom")&&(a.maxZoom=r.maxzoom),t.nodeOverrides.set(i,a)})}static convertMaterialOverrides(t,i){if(Array.isArray(i)&&i.every(t=>"string"==typeof t))for(let r of(t.materialOverrideNames=[],i))t.materialOverrideNames.push(r);else Object.entries(i).forEach(([i,r])=>{let a=r["model-color"],n={color:void 0!==a?new rq(a[0],a[1],a[2]):new rq(1,1,1),colorMix:0,emissionStrength:0,opacity:1},o=r["model-color-mix-intensity"];void 0!==o&&(n.colorMix=o);let s=r["model-emissive-strength"];void 0!==s&&(n.emissionStrength=s);let l=r["model-opacity"];void 0!==l&&(n.opacity=l),t.materialOverrides.set(i,n)})}onAdd(t){this.map=t,this.load()}hasTransition(){return!1}loaded(){if(0===this._modelsInfo.size)return!0;for(let t of this._modelsInfo.values())if(null==t.model)return!1;return!0}getModels(){return this.models}loadTile(t,i){}serialize(){return this._options}setProperty(t,i){return!1}reload(){this.cancelModelRequests();let t=sy(this.id,this.scope);this.map.style.clearSource(t),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(t){this.cancelModelRequests()}setModels(t){this.models=[];let i=new Map;for(let r in t){let a=t[r],n=this._modelsInfo.get(r);n&&n.modelSpec.uri===a.uri&&i.set(r,n)}if(this._modelsInfo.size!==i.size)for(let[t,r]of(this.cancelModelRequests(),i))r.model||i.delete(t);this._modelsInfo=i,this._options.models=t,this.load()}}function _8(t,i,r,a){let n=1<<t.z;i.lat=aF((a/8192+t.y)/n),i.lng=aO((r/8192+t.x)/n)}let _9={circle:class extends sI{constructor(t,i,r,a){super(t,{layout:g||(g=new sa({"circle-sort-key":new se(sn.layout_circle["circle-sort-key"]),"circle-elevation-reference":new o7(sn.layout_circle["circle-elevation-reference"]),visibility:new o7(sn.layout_circle.visibility)})),paint:y||(y=new sa({"circle-radius":new se(sn.paint_circle["circle-radius"]),"circle-color":new se(sn.paint_circle["circle-color"]),"circle-blur":new se(sn.paint_circle["circle-blur"]),"circle-opacity":new se(sn.paint_circle["circle-opacity"]),"circle-translate":new o7(sn.paint_circle["circle-translate"]),"circle-translate-anchor":new o7(sn.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new o7(sn.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new o7(sn.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new se(sn.paint_circle["circle-stroke-width"]),"circle-stroke-color":new se(sn.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new se(sn.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new o7(sn.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a)}createBucket(t){return new uc(t)}queryRadius(t){return _s("circle-radius",this,t)+_s("circle-stroke-width",this,t)+_l(this.paint.get("circle-translate"))}queryIntersectsFeature(t,i,r,a,n,o,s,l){let h=_u(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(i,r)+this.paint.get("circle-stroke-width").evaluate(i,r);return _f(t,a,o,s,l,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,u)}getProgramIds(){return["circle"]}getDefaultProgramParams(t,i,r){let a=_p(this);return{config:new hE(this,{zoom:i,lut:r}),defines:a,overrideFog:!1}}
vendor: 5,853 bytes, line 7
7is3D(t){return!t&&!!this.layout&&"none"!==this.layout.get("circle-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("circle-elevation-reference")}mayUse(t){return"HD"===t&&sA(this,"circle-elevation-reference",t=>"hd-road-markup"===t)}prepare(){return this.mayUse("HD")?_o():Promise.resolve()}},heatmap:class extends sI{createBucket(t){return new _g(t)}constructor(t,i,r,a){super(t,{layout:x||(x=new sa({visibility:new o7(sn.layout_heatmap.visibility)})),paint:v||(v=new sa({"heatmap-radius":new se(sn.paint_heatmap["heatmap-radius"]),"heatmap-weight":new se(sn.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new o7(sn.paint_heatmap["heatmap-intensity"]),"heatmap-color":new st(sn.paint_heatmap["heatmap-color"]),"heatmap-opacity":new o7(sn.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=_y({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(t){return _s("heatmap-radius",this,t)}queryIntersectsFeature(t,i,r,a,n,o,s,l){let h=this.paint.get("heatmap-radius").evaluate(i,r);return _f(t,a,o,s,l,!0,!0,new tg(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(t,i,r){return"heatmap"===t?{config:new hE(this,{zoom:i,lut:r}),overrideFog:!1}:{}}},hillshade:class extends sI{constructor(t,i,r,a){super(t,{layout:b||(b=new sa({visibility:new o7(sn.layout_hillshade.visibility)})),paint:w||(w=new sa({"hillshade-illumination-direction":new o7(sn.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new o7(sn.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new o7(sn.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new o7(sn.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new o7(sn.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new o7(sn.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new o7(sn.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a)}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(t,i,r){return{overrideFog:!1}}},fill:class extends sI{constructor(t,i,r,a){super(t,{layout:T||(T=new sa({"fill-sort-key":new se(sn.layout_fill["fill-sort-key"]),visibility:new o7(sn.layout_fill.visibility),"fill-elevation-reference":new o7(sn.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new se(sn.layout_fill["fill-construct-bridge-guard-rail"])})),paint:E||(E=new sa({"fill-antialias":new o7(sn.paint_fill["fill-antialias"]),"fill-opacity":new se(sn.paint_fill["fill-opacity"]),"fill-color":new se(sn.paint_fill["fill-color"]),"fill-outline-color":new se(sn.paint_fill["fill-outline-color"]),"fill-translate":new o7(sn.paint_fill["fill-translate"]),"fill-translate-anchor":new o7(sn.paint_fill["fill-translate-anchor"]),"fill-pattern":new se(sn.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new o7(sn.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new o7(sn.paint_fill["fill-emissive-strength"]),"fill-z-offset":new se(sn.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new se(sn.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new se(sn.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a)}getProgramIds(){let t=this.paint.get("fill-pattern"),i=t&&t.constantOr(1),r=[i?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(i&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(t,i,r){return{config:new hE(this,{zoom:i,lut:r}),overrideFog:!1}}recalculate(t,i){super.recalculate(t,i);let r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new hD(t)}queryRadius(){return _l(this.paint.get("fill-translate"))}queryIntersectsFeature(t,i,r,a,n,o){return!t.queryGeometry.isAboveHorizon&&hG(_h(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a)}isTileClipped(){return 0===this.paint.get("fill-z-offset").constantOr(1)}is3D(t){if(0!==this.paint.get("fill-z-offset").constantOr(1))return!0;
7let i=this.layout&&"none"!==this.layout.get("fill-elevation-reference");return null!=t?i&&!t:i}hasElevation(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}mayUse(t){return"HD"===t&&sA(this,"fill-elevation-reference",t=>"none"!==t)}prepare(){return this.mayUse("HD")?_o():Promise.resolve()}hasShadowPass(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}},"fill-extrusion":class extends sI{constructor(t,i,r,a){super(t,{layout:A||(A=new sa({visibility:new o7(sn["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new o7(sn["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new o7(sn["layout_fill-extrusion"]["source-max-zoom"])})),paint:C||(C=new sa({"fill-extrusion-opacity":new o7(sn["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new se(sn["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new o7(sn["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new o7(sn["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new se(sn["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new o7(sn["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new se(sn["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new se(sn["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new o7(sn["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new o7(sn["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new o7(sn["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new o7(sn["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new o7(sn["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new o7(sn["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new o7(sn["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new o7(sn["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new o7(sn["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new o7(sn["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new se(sn["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new se(sn["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new o7(sn["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new o7(sn["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new o7(sn["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new o7(sn["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new o7(sn["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new se(sn["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new se(sn["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new o7(sn["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(t){return new fK(t)}queryRadius(){return _l(this.paint.get("fill-extrusion-translate"))}is3D(t){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(t,i,r,a,n,o,s,l,h){let u=_u(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(i,r),d=this.paint.get("fill-extrusion-base").evaluate(i,r),p=[0,0],f=l&&o.elevation,_=o.elevation?o.elevation.exaggeration():1,m=t.tile.getBucket(this);if(m instanceof fK){let t=m.centroidData.find(t=>h>=t.vertexArrayOffset&&h<t.vertexArrayOffset+t.vertexCount);if(t&&0x40000000&t.flags)return!1;if(f){let t=m.centroidVertexArray,i=h+1;i<t.length&&(p[0]=t.geta_centroid_pos0(i),p[1]=t.geta_centroid_pos1(i))}}if(0===p[0]&&1===p[1])return!1;"globe"===o.projection.name&&(a=f5([a],[new tg(0,0),new tg(8192,8192)],t.tileID.canonical).map(t=>t.polygon).flat());let[g,y]=_T(o,a,d,c,u,s,f?l:null,p,_,o.center.lat,t.tileID.canonical),x=t.queryGeometry;return _w(g,y,x.isPointQuery()?x.screenBounds:x.screenGeometry)}},building:class extends sI{constructor(t,i,r,a){super(t,{layout:M||(M=new sa({visibility:new o7(sn.layout_building.visibility),"building-facade":new se(sn.layout_building["building-facade"]),"building-facade-floors":new se(sn.layout_building["building-facade-floors"]),"building-facade-unit-width":new se(sn.layout_building["building-facade-unit-width"]),"building-facade-window":new se(sn.layout_building["building-facade-window"]),"building-roof-shape":new se(sn.layout_building["building-roof-shape"]),"building-height":new se(sn.layout_building["building-height"]),"building-base":new se(sn.layout_building["building-base"]),"building-flood-light-wall-radius":new se(sn.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new se(sn.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new se(sn.layout_building["building-flip-roof-orientation"])})),paint:R||(R=new sa({"building-opacity":new o7(sn.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new o7(sn.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new o7(sn.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new o7(sn.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new o7(sn.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new o7(sn.paint_building["building-vertical-scale"]),"building-cast-shadows":new o7(sn.paint_building["building-cast-shadows"]),"building-color":new se(sn.paint_building["building-color"]),"building-emissive-strength":new se(sn.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new o7(sn.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new o7(sn.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new o7(sn.paint_building["building-front-cutoff"]),"building-flood-light-color":new o7(sn.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new o7(sn.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new o7(sn.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}mayUse(t){return"HD"===t}prepare(){return async function(){return tJ(self)&&null==_e&&null==f7?null!=f9?f9:f9=(function(t){let i,r,a,n,o;function s(){i=new Uint8Array(o.buffer),r=new Int16Array(o.buffer),a=new Int32Array(o.buffer),n=new Float32Array(o.buffer)}function l(){throw Error("Unexpected BuildingGen error.")}let h=()=>{},u={a:{a:l,f:function(t){let r=i.length,a=Math.ceil((Math.max(t>>>0,Math.ceil(1.2*r))-r)/65536);try{return o.grow(a),s(),!0}catch(t){return!1}},g:l,b:h,c:h,d:h,e:h}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,u):t.then(t=>t.arrayBuffer()).then(t=>WebAssembly.instantiate(t,u))).then(t=>{let l=t.instance.exports;return(0,l.g)(),o=l.f,s(),new f6({setStyle:l.h,setAOOptions:l.i,setMetricOptions:l.j,setStructuralOptions:l.k,setFacadeOptions:l.l,setFauxFacadeOptions:l.m,setFacadeClassifierOptions:l.n,addFeature:l.o,addFacade:l.p,generateMesh:l.q,getLastError:l.r,getOuterRingLength:l.s,getMeshCount:l.t,getPositionsPtr:l.u,getPositionsLength:l.v,getNormalsPtr:l.w,getNormalsLength:l.x,getAOPtr:l.y,getAOLength:l.z,getUVPtr:l.A,getUVLength:l.B,getFauxFacadePtr:l.C,getFauxFacadeLength:l.D,getIndicesPtr:l.E,getIndicesLength:l.F,getBuildingPart:l.G,getRingCount:l.H,getRingPtr:l.I,getRingLength:l.J,malloc:l.K,free:l.L,heapU8:i,heap16:r,heap32:a,heapF32:n})})})(fetch(iI())).then(t=>{f9=null,_e=t}).catch(t=>{tX("Could not load building-gen"),f9=null,f7=t}):null}()}createBucket(t){return new _r(t)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(t){return!0}queryRadius(t){return 0}queryIntersectsFeature(t,i,r,a,n,o,s,l,h,u){let c=this.layout.get("building-height").evaluate(i,r),d=this.layout.get("building-base").evaluate(i,r),p=t.tile.getBucket(this).getFootprint(i);if(p){if(0!==p.hiddenFlags)return!1;c=p.height}let[f,_]=_T(o,a,d,c,new tg(0,0),s,null,[0,0],1,o.center.lat,t.tileID.canonical),m=t.queryGeometry;return _w(f,_,m.isPointQuery()?m.screenBounds:m.screenGeometry)}},line:class extends sI{constructor(t,i,r,a){let n=_P();super(t,n,i,r,a),n.layout&&(this.layout=new o9(n.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1,this.lineBlendFbos=null,this.lineBlendDensityReadback=null}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){let t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof nx,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}
7else"line-gradient-use-theme"===t&&(this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER)}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(t,i){super.recalculate(t,i),this.paint._values["line-floorwidth"]=(L||((L=new _z(_P().paint.properties["line-width"].specification)).useIntegerZoom=!0),L).possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new uo(t)}getProgramIds(){let t=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return"default"!==this.paint.get("line-blend-mode")&&t.push("lineBlendComposite"),t}getDefaultProgramParams(t,i,r){if("lineBlendComposite"===t)return{};let a=_R(this);return{config:new hE(this,{zoom:i,lut:r}),defines:a,overrideFog:!1}}queryRadius(t){var i,r;return i=_s("line-width",this,t),((r=_s("line-gap-width",this,t))>0?r+2*i:i)/2+Math.abs(_s("line-offset",this,t))+_l(this.paint.get("line-translate"))}queryIntersectsFeature(t,i,r,a,n,o){var s,l;if(t.queryGeometry.isAboveHorizon)return!1;let h=_h(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),u=t.pixelToTileUnitsFactor/2*(s=this.paint.get("line-width").evaluate(i,r),(l=this.paint.get("line-gap-width").evaluate(i,r))>0?l+2*s:s),c=this.paint.get("line-offset").evaluate(i,r);return c&&(a=function(t,i){let r=[],a=new tg(0,0);for(let n=0;n<t.length;n++){let o=t[n],s=[];for(let t=0;t<o.length;t++){let r=o[t],n=o[t+1],l=0===t?a:r.sub(o[t-1])._unit()._perp(),h=t===o.length-1?a:n.sub(r)._unit()._perp(),u=l._add(h)._unit();u._mult(1/(u.x*h.x+u.y*h.y)),s.push(u._mult(i)._add(r))}r.push(s)}return r}(a,c*t.pixelToTileUnitsFactor)),function(t,i,r){for(let a=0;a<i.length;a++){let n=i[a];if(t.length>=3){for(let i=0;i<n.length;i++)if(hW(t,n[i]))return!0}if(function(t,i,r){if(t.length>1){if(hH(t,i))return!0;for(let a=0;a<i.length;a++)if(hZ(i[a],t,r))return!0}for(let a=0;a<t.length;a++)if(hZ(t[a],i,r))return!0;return!1}(t,n,r))return!0}return!1}(h,a,u)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(t){return!this.hasElevatedBuckets||this.layout&&"hd-road-markup"===this.layout.get("line-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("line-elevation-reference")}mayUse(t){return"HD"===t&&sA(this,"line-elevation-reference",t=>"hd-road-markup"===t)}prepare(){return this.mayUse("HD")?_o():Promise.resolve()}hasOffscreenPass(){return"default"!==this.paint.get("line-blend-mode")&&0!==this.paint.get("line-opacity").constantOr(1)&&0!==this.paint.get("line-width").constantOr(1)&&"none"!==this.visibility}resize(){this._destroyLineBlendFbo()}onRemove(t){this._destroyLineBlendFbo(t.painter&&t.painter.context&&t.painter.context.gl||void 0)}_clear(){this._destroyLineBlendFbo()}_destroyLineBlendFbo(t){this.lineBlendFbos&&(this.lineBlendFbos.destroy(),this.lineBlendFbos=null),t&&this.lineBlendDensityReadback&&this.lineBlendDensityReadback.destroy(t),this.lineBlendDensityReadback=null}},symbol:_B,background:class extends sI{constructor(t,i,r,a){super(t,{layout:k||(k=new sa({visibility:new o7(sn.layout_background.visibility)})),paint:N||(N=new sa({"background-pitch-alignment":new o7(sn.paint_background["background-pitch-alignment"]),"background-color":new o7(sn.paint_background["background-color"]),"background-pattern":new o7(sn.paint_background["background-pattern"]),"background-opacity":new o7(sn.paint_background["background-opacity"]),"background-emissive-strength":new o7(sn.paint_background["background-emissive-strength"]),"background-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(t,i,r){return{overrideFog:!1}}is3D(t){return"viewport"===this.paint.get("background-pitch-alignment")}},raster:_k,"raster-particle":_N,sky:class extends sI{constructor(t,i,r,a){super(t,{layout:H||(H=new sa({visibility:new o7(sn.layout_sky.visibility)})),paint:q||(q=new sa({"sky-type":new o7(sn.paint_sky["sky-type"]),"sky-atmosphere-sun":new o7(sn.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new o7(sn.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new o7(sn.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new o7(sn.paint_sky["sky-gradient-radius"]),"sky-gradient":new st(sn.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new o7(sn.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new o7(sn.paint_sky["sky-atmosphere-color"]),"sky-opacity":new o7(sn.paint_sky["sky-opacity"]),"sky-gradient-use
7-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this._updateColorRamp()}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=_y({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){let i=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==i.azimuthal||this._lightPosition.polar!==i.polar}return!1}getCenter(t,i){if("atmosphere"===this.paint.get("sky-type")){let r=this.paint.get("sky-atmosphere-sun"),a=!r,n=t.style.light,o=n.properties.get("position");return a&&"viewport"===n.properties.get("anchor")&&tX("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),a?_U(o.azimuthal,90-o.polar,i):_U(r[0],90-r[1],i)}let r=this.paint.get("sky-gradient-center");return _U(r[0],90-r[1],i)}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){let t=this.paint.get("sky-type");return"atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}},slot:class extends sI{constructor(t,i,r,a){super(t,{paint:Z||(Z=new sa({}))},i,null)}},model:class extends sI{constructor(t,i,r,a){super(t,{layout:$||($=new sa({visibility:new o7(sn.layout_model.visibility),"model-id":new se(sn.layout_model["model-id"]),"model-allow-density-reduction":new o7(sn.layout_model["model-allow-density-reduction"])})),paint:W||(W=new sa({"model-opacity":new se(sn.paint_model["model-opacity"]),"model-rotation":new se(sn.paint_model["model-rotation"]),"model-scale":new se(sn.paint_model["model-scale"]),"model-translation":new se(sn.paint_model["model-translation"]),"model-color":new se(sn.paint_model["model-color"]),"model-color-mix-intensity":new se(sn.paint_model["model-color-mix-intensity"]),"model-type":new o7(sn.paint_model["model-type"]),"model-cast-shadows":new o7(sn.paint_model["model-cast-shadows"]),"model-receive-shadows":new o7(sn.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new o7(sn.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new se(sn.paint_model["model-emissive-strength"]),"model-roughness":new se(sn.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new se(sn.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new o7(sn.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new o7(sn.paint_model["model-front-cutoff"]),"model-elevation-reference":new o7(sn.paint_model["model-elevation-reference"]),"model-line-cutout-mode":new o7(sn.paint_model["model-line-cutout-mode"]),"model-color-use-theme":new se({type:"string",default:"default","property-type":"data-driven"})}))},i,r,a),this.layer=t,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}mayUse(t){return"Standard"===t}prepare(){return async function(){return Promise.resolve()}()}createBucket(t){return new _H(t)}getProgramIds(){return["model"]}is3D(t){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(t){return 8191*(t instanceof _J)}queryRenderedFeatures(t,i,r){let a=i.getSource();if(!(a&&a instanceof _6))return{};let n={};n[this.id]=[];let o=n[this.id],s=0;for(let n of a.models){let a=i.getFeatureState(this.sourceLayer,n.id),l={type:"Unknown",id:n.id,properties:n.featureProperties},h=this.paint.get("model-rotation").evaluate(l,a),u=this.paint.get("model-scale").evaluate(l,a),c=this.paint.get("model-translation").evaluate(l,a),d=this.paint.get("model-elevation-reference"),p=[];p9(p,n,r,n.position,h,u,c,"ground"===d,"ground"===d,!1),"globe"===r.projection.name&&(p=p5(p,r));let f=eg([],r.projMatrix,p),_=p6(t.isPointQuery()?t.screenBounds:t.screenGeometry,r,f,n.aabb);if(null!=_){let t=new _4(void 0,0,0,0,n.id);t.layer=this.layer,t.properties=structuredClone(n.featureProperties),t.properties.layer=this.id,t.properties.uri=n.uri,t.properties.orientation=n.orientation,t.sourceLayer=this.sourceLayer,t.geometry={type:"Point",coordinates:[n.position.lng,n.position.lat]},t.state=a,t.source=this.source,o.push({featureIndex:s,feature:t,intersectionZ:_})}++s}return n}queryIntersectsFeature(t,i,r,a,n,o,s,l,h,u){if(!this.modelManager)return!1;let c=this.modelManager,d=t.tile.getBucket(this);if(!(d&&d instanceof _H))return!1;for(let r in d.instancesPerModel){let a=d.instancesPerModel[r],n=void 0!==i.id?i.id:i.properties&&Object.hasOwn(i.properties,"id")?i.properties.id:void 0;if(Object.hasOwn(a.idToFeaturesIndex,n)){let i=a.features[a.idToFeaturesIndex[n]],s=c.getModel(r,u||this.scope);if(!s)return!1;let l=[],h=new s0(0,0),p=d.canonical,f=Number.MAX_VALUE;for(let r=0;r<i.instancedDataCount;++r){let n=16*(i.instancedDataOffset+r),u=a.instancedDataArray.float32,c=[u[n+4],u[n+5],u[n+6]];_8(p,h,Math.floor(u[n]),Math.floor(u[n+1])),p9(l,s,o,h,i.rotation,i.scale,c,!1,!1,
vendor: 1,493 bytes, line 7
7!1),"globe"===o.projection.name&&(l=p5(l,o));let d=eg([],o.projMatrix,l),_=t.queryGeometry,m=p6(_.isPointQuery()?_.screenBounds:_.screenGeometry,o,d,s.aabb);null!=m&&(f=Math.min(m,f))}return f!==Number.MAX_VALUE&&f}}return!1}_handleOverridablePaintPropertyUpdate(t,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven()||"model-color"!==t&&"model-color-mix-intensity"!==t&&"model-rotation"!==t&&"model-scale"!==t&&"model-translation"!==t&&"model-emissive-strength"!==t)}_isPropertyZoomDependent(t){let i=this._transitionablePaint._values[t];return null!=i&&null!=i.value&&null!=i.value.expression&&i.value.expression instanceof oT}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends sI{constructor(t,i,r,a){super(t,{layout:S||(S=new sa({"clip-layer-types":new o7(sn.layout_clip["clip-layer-types"]),"clip-layer-scope":new o7(sn.layout_clip["clip-layer-scope"]),visibility:new o7(sn.layout_clip.visibility)})),paint:I||(I=new sa({}))},i,r,a)}recalculate(t,i){super.recalculate(t,i)}createBucket(t){return new _x(t)}is3D(t){return!0}}};function _7(t,i,r,a){return"custom"===t.type?new _V(t,i):new _9[t.type](t,i,r,a)}class me{constructor(t){this._layer=t,this._filterDependencies=void 0}invalidateFilter(){this._filterDependencies=void 0}get _filterDeps(){return void 0===this._filterDependencies&&(this._filterDependencies=this._computeFilterDepen
7dencies()),this._filterDependencies}_computeFilterDependencies(){let t=this._layer;if(!t.type||"custom"===t.type||"background"===t.type||"sky"===t.type||"slot"===t.type)return null;let i=ob(t.filter,sn[`filter_${t.type}`]);return"error"===i.result?null:{configDependencies:i.value.configDependencies,isIndoorDependent:i.value.isIndoorDependent}}hasConfigDependency(t){let{_unevaluatedLayout:i,_transitionablePaint:r}=this._layer;if(i&&i.configDependencies.has(t)||r&&r.configDependencies.has(t))return!0;let a=this._filterDeps;return!!a&&a.configDependencies.has(t)}get isConfigDependent(){let{_unevaluatedLayout:t,_transitionablePaint:i}=this._layer;if(t&&0!==t.configDependencies.size||i&&0!==i.configDependencies.size)return!0;let r=this._filterDeps;return!!r&&0!==r.configDependencies.size}get isIndoorDependent(){let{_unevaluatedLayout:t,_transitionablePaint:i}=this._layer;if(t&&t.isIndoorDependent()||i&&i.isIndoorDependent())return!0;let r=this._filterDeps;return!!r&&r.isIndoorDependent}}let mt=new rq(0,0,0);function mi(t,i){let r=[],a=t[`stretch_${i}`],n=null;for(let t=0;t<a.length;t++)null===n?n=0===r.length?a[0]:r.at(-1)[1]+a[t]:(r.push([n,n+a[t]]),n=null);t[`stretch_${i}_areas`]=r}function mr(t,i){let r,a={};for(;r=t.nextField(i);)1===r?a.left=t.readVarint():2===r?a.width=t.readVarint():3===r?a.top=t.readVarint():4===r&&(a.height=t.readVarint());return a}function ma(t,i){let r,a={};for(;r=t.nextField(i);)1===r?(a.group=function(t,i){let r,a={opacity:255,children:[]};for(;r=t.nextField(i);)1===r?a.transform=mn(t,t.readVarint()+t.pos):2===r?a.opacity=t.readVarint():5===r?a.clip_path_idx=t.readVarint():6===r?a.mask_idx=t.readVarint():7===r&&a.children.push(ma(t,t.readVarint()+t.pos));return a}(t,t.readVarint()+t.pos),a.node="group"):2===r&&(a.path=function(t,i){let r,a={paint_order:1,commands:[],step:1,diffs:[],rule:1};for(;r=t.nextField(i);)1===r?a.fill=function(t,i){let r,a={rgb_color:mt,paint:"rgb_color",opacity:255};for(;r=t.nextField(i);)1===r?(a.rgb_color=mo(t.readVarint()),a.paint="rgb_color"):2===r?(a.linear_gradient_idx=t.readVarint(),a.paint="linear_gradient_idx"):3===r?(a.radial_gradient_idx=t.readVarint(),a.paint="radial_gradient_idx"):5===r&&(a.opacity=t.readVarint());return a}(t,t.readVarint()+t.pos):2===r?a.stroke=function(t,i){let r,a={rgb_color:mt,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1};for(;r=t.nextField(i);)1===r?(a.rgb_color=mo(t.readVarint()),a.paint="rgb_color"):2===r?(a.linear_gradient_idx=t.readVarint(),a.paint="linear_gradient_idx"):3===r?(a.radial_gradient_idx=t.readVarint(),a.paint="radial_gradient_idx"):5===r?t.readPackedFloat(a.dasharray):6===r?a.dashoffset=t.readFloat():7===r?a.miterlimit=t.readFloat():8===r?a.opacity=t.readVarint():9===r?a.width=t.readFloat():10===r?a.linecap=t.readVarint():11===r&&(a.linejoin=t.readVarint());return a}(t,t.readVarint()+t.pos):3===r?a.paint_order=t.readVarint():5===r?t.readPackedVarint(a.commands):6===r?a.step=t.readFloat():7===r?t.readPackedSVarint(a.diffs):8===r&&(a.rule=t.readVarint());return a}(t,t.readVarint()+t.pos),a.node="path");return a}function mn(t,i){let r,a={sx:1,ky:0,kx:0,sy:1,tx:0,ty:0};for(;r=t.nextField(i);)1===r?a.sx=t.readFloat():2===r?a.ky=t.readFloat():3===r?a.kx=t.readFloat():4===r?a.sy=t.readFloat():5===r?a.tx=t.readFloat():6===r&&(a.ty=t.readFloat());return a}function mo(t){return new rq((t>>16&255)/255,(t>>8&255)/255,(255&t)/255,1)}function ms(t,i){let r,a={offset:0,opacity:255,rgb_color:mt};for(;r=t.nextField(i);)1===r?a.offset=t.readFloat():2===r?a.opacity=t.readVarint():3===r&&(a.rgb_color=mo(t.readVarint()));return a}class ml{static calculate(t={},i=[]){let r=new Map,a=new Map;if(0===Object.keys(t).length)return r;for(let[n,o]of(i.forEach(t=>{a.set(t.name,t.rgb_color||new rq(0,0,0))}),Object.entries(t)))a.has(n)?r.set(a.get(n).toString(),o):console.warn(`Ignoring unknown image variable "${n}"`);return r}}function mh(t,i=255,r){let a=r.get(t.toString())||t;return 255===i?a.toString():new rq(a.r,a.g,a.b,a.a*i/255).toString()}let mu=[],mc=0;function md(t,i){if(mc>=mu.length){let r=io()?new OffscreenCanvas(t,i).getContext("2d",{willReadFrequently:!0}):document.createElement("canvas").getContext("2d",{willReadFrequently:!0});mu.push(r)}let r=mu[mc++];return r.canvas.width=t,r.canvas.height=i,r}function mp(t,i,r,a,n){for(let o of a.children)(function t(i,r,a,n,o){var s;n.group?(i.save(),function(i,r,a,n,o){var s,l;let h=null!=n.mask_idx?a.masks[n.mask_idx]:null,u=null!=n.clip_path_idx?a.clip_paths[n.clip_path_idx]:null;if(n.transform&&(r=mx(n.transform).preMultiplySelf(r)),s=null!=u,l=null!=h,255===n.opacity&&!s&&!l)return mp(i,r,a,n,o);
7let c=md(i.canvas.width,i.canvas.height);mp(c,r,a,n,o),u&&function t(i,r,a,n){let o=md(i.canvas.width,i.canvas.height);(function i(r,a,n,o){let s=o.transform?mx(o.transform).preMultiplySelf(a):a,l=md(r.canvas.width,r.canvas.height);for(let t of o.children)if(t.group)i(l,s,n,t.group);else if(t.path){let i=t.path,r=new Path2D;r.addPath(mb(i),s),l.fill(r,m_(i))}let h=null!=o.clip_path_idx?n.clip_paths[o.clip_path_idx]:null;h&&t(l,s,n,h),r.globalCompositeOperation="source-over",r.drawImage(l.canvas,0,0),mc--})(o,r,a,n),i.globalCompositeOperation="destination-in",i.drawImage(o.canvas,0,0),mc--}(c,r,a,u),h&&function i(r,a,n,o,s){if(0===o.children.length)return;let l=null!=o.mask_idx?n.masks[o.mask_idx]:null;l&&i(r,a,n,l,s);let h=r.canvas.width,u=r.canvas.height,c=md(h,u),d=o.width,p=o.height,f=o.left,_=o.top,m=new Path2D,g=new Path2D;for(let i of(g.rect(f,_,d,p),m.addPath(g,a),c.clip(m),o.children))t(c,a,n,i,s);let y=c.getImageData(0,0,h,u),x=y.data;if(1===o.mask_type)for(let t=0;t<x.length;t+=4)x[t+3]=x[t+3]/255*(.2126*x[t]+.7152*x[t+1]+.0722*x[t+2]);c.putImageData(y,0,0),r.globalCompositeOperation="destination-in",r.drawImage(c.canvas,0,0),mc--}(c,r,a,h,o),i.globalAlpha=n.opacity/255,i.drawImage(c.canvas,0,0),mc--}(i,r,a,n.group,o),i.restore()):n.path&&(i.save(),s=n.path,i.setTransform(r),1===s.paint_order?(mf(i,a,s,o),mm(i,a,s,o)):(mm(i,a,s,o),mf(i,a,s,o)),i.restore())})(t,i,r,o,n)}function mf(t,i,r,a){let n=r.fill;if(!n)return;let o=n.opacity/255;switch(t.save(),t.beginPath(),mv(r,t),n.paint){case"rgb_color":t.fillStyle=mh(n.rgb_color,n.opacity,a);break;case"linear_gradient_idx":{let r=i.linear_gradients[n.linear_gradient_idx];r.transform&&t.setTransform(mx(r.transform).preMultiplySelf(t.getTransform())),t.fillStyle=mg(t,r,o,a);break}case"radial_gradient_idx":{let r=i.radial_gradients[n.radial_gradient_idx];r.transform&&t.setTransform(mx(r.transform).preMultiplySelf(t.getTransform())),t.fillStyle=my(t,r,o,a)}}t.fill(m_(r)),t.restore()}function m_(t){return 1===t.rule?"nonzero":2===t.rule?"evenodd":void 0}function mm(t,i,r,a){let n=r.stroke;if(!n)return;let o=mb(r);t.lineWidth=n.width,t.miterLimit=n.miterlimit,t.setLineDash(n.dasharray),t.lineDashOffset=n.dashoffset;let s=n.opacity/255;switch(n.paint){case"rgb_color":t.strokeStyle=mh(n.rgb_color,n.opacity,a);break;case"linear_gradient_idx":t.strokeStyle=mg(t,i.linear_gradients[n.linear_gradient_idx],s,a,!0);break;case"radial_gradient_idx":t.strokeStyle=my(t,i.radial_gradients[n.radial_gradient_idx],s,a,!0)}switch(n.linejoin){case 2:case 1:t.lineJoin="miter";break;case 3:t.lineJoin="round";break;case 4:t.lineJoin="bevel"}switch(n.linecap){case 1:t.lineCap="butt";break;case 2:t.lineCap="round";break;case 3:t.lineCap="square"}t.stroke(o)}function mg(t,i,r,a,n=!1){if(1===i.stops.length){let t=i.stops[0];return mh(t.rgb_color,t.opacity*r,a)}let{x1:o,y1:s,x2:l,y2:h}=i,u=new DOMPoint(o,s),c=new DOMPoint(l,h);if(n){let t=mx(i.transform);u=t.transformPoint(u),c=t.transformPoint(c)}let d=t.createLinearGradient(u.x,u.y,c.x,c.y);for(let t of i.stops)d.addColorStop(t.offset,mh(t.rgb_color,t.opacity*r,a));return d}function my(t,i,r,a,n=!1){if(1===i.stops.length){let t=i.stops[0];return mh(t.rgb_color,t.opacity*r,a)}let o=mx(i.transform),{fx:s,fy:l,fr:h,cx:u,cy:c,r:d}=i,p=new DOMPoint(s,l),f=new DOMPoint(u,c),_=h,m=d;if(n){p=o.transformPoint(p),f=o.transformPoint(f);let t=(o.a+o.d)/2;_=h*t,m=i.r*t}let g=t.createRadialGradient(p.x,p.y,_,f.x,f.y,m);for(let t of i.stops)g.addColorStop(t.offset,mh(t.rgb_color,t.opacity*r,a));return g}function mx(t){return t?new DOMMatrix([t.sx,t.ky,t.kx,t.sy,t.tx,t.ty]):new DOMMatrix}function mv(t,i){let r=t.step,a=t.diffs[0]*r,n=t.diffs[1]*r;i.moveTo(a,n);for(let o=0,s=2;o<t.commands.length;o++)switch(t.commands[o]){case 1:a+=t.diffs[s++]*r,n+=t.diffs[s++]*r,i.moveTo(a,n);break;case 2:a+=t.diffs[s++]*r,n+=t.diffs[s++]*r,i.lineTo(a,n);break;case 3:{let o=a+t.diffs[s++]*r,l=n+t.diffs[s++]*r;a=o+t.diffs[s++]*r,n=l+t.diffs[s++]*r,i.quadraticCurveTo(o,l,a,n);break}case 4:{let o=a+t.diffs[s++]*r,l=n+t.diffs[s++]*r,h=o+t.diffs[s++]*r,u=l+t.diffs[s++]*r;a=h+t.diffs[s++]*r,n=u+t.diffs[s++]*r,i.bezierCurveTo(o,l,h,u,a,n);break}case 5:i.closePath()}return i}function mb(t){return mv(t,new Path2D)}class mw{constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;let i=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,i),i}put(t,i){this.cache.has(t)?this.cache.delete(t):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(t,i)}delete(t){this.cache.delete(t)}}oC(mw,"LRUCache");class mT{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(t){return new h7(t,t.data)}getFromCache(t,i,r){return this.cacheMap.has(r)||this.cacheMap.set(r,new mw(150)),this.cacheMap.get(r).get(sy(t.toString(),i))}setInCache(t,i,r,a){this.cacheDependenciesMap.has(a)||this.cacheDependenciesMap.set(a,new Map),this.cacheMap.has(a)||this.cacheMap.set(a,new mw(150));let n=this.cacheDependenciesMap.get(a),o=sy(t.id.toString(),r);n.get(o)||n.set(o,new Set);let s=this.cacheMap.get(a),l=t.toString();n.get(o).add(l),s.put(sy(t.toString(),r),i)}removeImagesFromCacheByIds(t,i,r=0){if(!this.cacheMap.has(r)||!this.cacheDependenciesMap.has(r))return;let a=this.cacheMap.get(r),n=this.cacheDependenciesMap.get(r);for(let r of t){let t=sy(r.toString(),i);if(n.has(t)){for(let i of n.get(t))a.delete(i);n.delete(t)}}}rasterize(t,i,r,a){let n=this.getFromCache(t,r,a);if(n)return n.clone();let o=function(t,i){let r=ml.calculate(i.params,t.metadata?t.metadata.variables:[]),a=t.usvg_tree,n=a.width,o=a.height,s=Math.max(1,Math.round(n*i.sx)),l=Math.max(1,Math.round(o*i.sy)),h=new DOMMatrix([s/n,0,0,l/o,0,0]),u=md(s,l);mp(u,h,a,a,r);let c=u.getImageData(0,0,s,l);return mc--,c}(i.icon,t),s=mT._getImage(o);return this.setInCache(t,s,r,a),s.clone()}}class mE extends rB{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new uJ,this.dirty=!0,this.spriteFormat=t,this.imageRasterizer=new mT}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.imageVersions.set(t,new Map),this.patterns.set(t,new Map),this.atlasImage.set(t,new h7({width:1,height:1}))}removeScope(t){this.loaded.delete(t),this.imageProviders.delete(t),this.images.delete(t),this.updatedImages.delete(t),this.callbackDispatchedThisFrame.delete(t),this.imageVersions.delete(t),this.patterns.delete(t),this.atlasImage.delete(t);let i=this.atlasTexture.get(t);i&&(i.destroy(),this.atlasTexture.delete(t))}addImageProvider(t,i){this.imageProviders.has(i)||this.imageProviders.set(i,new Map),this.imageProviders.get(i).set(t.id,t)}removeImageProvider(t,i){this.imageProviders.has(i)&&this.imageProviders.get(i).delete(t)}getPendingImageProviders(){let t=[];for(let i of this.imageProviders.values())for(let r of i.values())r.hasPendingRequests()&&t.push(r);return t}isLoaded(){for(let t of this.loaded.keys())if(!this.loaded.get(t))return!1;return!0}setLoaded(t,i){if(this.loaded.get(i)!==t&&(this.loaded.set(i,t),t)){for(let{ids:t,callback:r}of this.requestors)this._notify(t,i,r);this.requestors=[]}}hasImage(t,i){return!!this.getImage(t,i)}getImage(t,i){return this.images.get(i).get(t.toString())}
7addImage(t,i,r){if(this._validate(t,r)){this.images.get(i).set(t.toString(),r);let a=this.imageVersions.get(i),n=a.get(t.toString())||0;a.set(t.toString(),n+1)}}_validate(t,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new rL(Error(`Image "${t.name}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new rL(Error(`Image "${t.name}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new rL(Error(`Image "${t.name}" has invalid "content" value`))),r=!1),r}_validateStretch(t,i){if(!t)return!0;let r=0;for(let a of t){if(a[0]<r||a[1]<a[0]||i<a[1])return!1;r=a[1]}return!0}_validateContent(t,i){return!t||4===t.length&&(!!i.usvg||!(t[0]<0)&&!(i.data.width<t[0])&&!(t[1]<0)&&!(i.data.height<t[1])&&!(t[2]<0)&&!(i.data.width<t[2])&&!(t[3]<0)&&!(i.data.height<t[3]))&&!(t[2]<t[0]||t[3]<t[1])}updateImage(t,i,r){r.version=this.images.get(i).get(t.toString()).version+1,this.images.get(i).set(t.toString(),r),this.updatedImages.get(i).add(t);let a=this.imageVersions.get(i),n=a.get(t.toString())||0;a.set(t.toString(),n+1),this.removeFromImageRasterizerCache(t,i)}clearUpdatedImages(t){this.updatedImages.get(t).clear()}removeFromImageRasterizerCache(t,i){"raster"!==this.spriteFormat&&this.imageRasterizer.removeImagesFromCacheByIds([t],i)}removeImage(t,i){let r=this.images.get(i),a=r.get(t.toString());r.delete(t.toString());let n=this.imageVersions.get(i),o=n.get(t.toString())||0;n.set(t.toString(),o+1),this.patterns.get(i).delete(t.toString()),this.removeFromImageRasterizerCache(t,i),a.userImage&&a.userImage.onRemove&&a.userImage.onRemove()}listImages(t){return Array.from(this.images.get(t).keys()).map(t=>rk.from(t))}getImageVersions(t){return this.imageVersions.get(t)||new Map}getImages(t,i,r){let a=[],n=[],o=this.imageProviders.get(i);for(let r of t){if(!r.iconsetId){a.push(r);continue}let t=o.get(r.iconsetId);t&&(this.getImage(r,i)?n.push(r):t.addPendingRequest(r))}if(0===a.length)return void this._notify(n,i,r);let s=!0,l=!!this.loaded.get(i),h=this.images.get(i);if(!l)for(let t of a)h.has(t.toString())||(s=!1);l||s?this._notify(a,i,r):this.requestors.push({ids:a,scope:i,callback:r})}rasterizeImages(t,i){let r=new Map,{iconTasks:a,patternTasks:n,scope:o}=t;for(let t of[a,n])for(let[i,a]of t.entries()){let t=this.getImage(a.id,o);t&&r.set(i,{image:t,imageVariant:a})}i(null,this._rasterizeImages(o,r))}_rasterizeImages(t,i){let r=new Map;for(let[a,{image:n,imageVariant:o}]of i.entries())r.set(a,this.imageRasterizer.rasterize(o,n,t,0));return r}getUpdatedImages(t){return this.updatedImages.get(t)||new Set}_notify(t,i,r){let a=this.images.get(i),n=new Map;for(let i of t){if(!a.get(i.toString())){if(i.iconsetId)continue;this.fire(new rz("styleimagemissing",{id:i.name}))}let t=a.get(i.toString());if(!t){tX(`Image "${i.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}let r={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:!!(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(r,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),n.set(rk.toString(i),r)}r(null,{images:n,versions:this.getImageVersions(i)})}getPixelSize(t){let{width:i,height:r}=this.atlasImage.get(t);return{width:i,height:r}}getPattern(t,i,r){let a=t.toString(),n=this.patterns.get(i),o=n.get(a),s=this.getImage(t,i);if(!s)return null;if(o){if(o.position.version===s.version)return o.position;o.position.version=s.version}else{if(s.usvg&&!s.data){let n=this.getPatternInFlightId(a,i);if(this.patternsInFlight.has(n))return null;this.patternsInFlight.add(n);let o=new ah(t).scaleSelf(is.devicePixelRatio),l=new Map([[o.toString(),{image:s,imageVariant:o}]]),h=this._rasterizeImages(i,l);return this.storePatternImage(o,i,s,r,h),null}this.storePattern(t,i,s)}return this._updatePatternAtlas(i,r),n.get(a).position}getPatternInFlightId(t,i){return sy(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(t,i,r,a,n){let o=t.toString(),s=n?n.get(o):void 0;s&&(r.data=s,this.storePattern(t.id,i,r),this._updatePatternAtlas(i,a),this.patternsInFlight.delete(this.getPatternInFlightId(t.id.toString(),i)))}storePattern(t,i,r){let a={w:r.data.width+4,h:r.data.height+4,x:0,y:0},n=new uK(a,r,2);this.patterns.get(i).set(t.toString(),{bin:a,position:n})}destroyAtlasTextures(){for(let t of this.atlasTexture.values())t&&t.destroy();this.atlasTexture.clear()}bind(t,i){let r=t.gl,a=this.atlasTexture.get(i);a?this.dirty&&(a.update(this.atlasImage.get(i)),this.dirty=!1):(a=new uW(t,this.atlasImage.get(i),r.RGBA8),this.atlasTexture.set(i,a)),a.bind(r.LINEAR,r.CLAMP_TO_EDGE)}_updatePatternAtlas(t,i){let r=this.patterns.get(t),{w:a,h:n}=uV(Array.from(r.values()).map(({bin:t})=>t)),o=this.atlasImage.get(t);o.resize({width:a||1,height:n||1});let s=this.images.get(t);for(let[t,{bin:a,position:n}]of r.entries()){let r=n.padding,l=a.x+r,h=a.y+r,u=s.get(t).data,c=u.width,d=u.height;r=r>1?r-1:r,h7.copy(u,o,{x:0,y:0},{x:l,y:h},{width:c,height:d},i),h7.copy(u,o,{x:0,y:d-r},{x:l,y:h-r},{width:c,height:r},i),h7.copy(u,o,{x:0,y:0},{x:l,y:h+d},{width:c,height:r},i),h7.copy(u,o,{x:c-r,y:0},{x:l-r,y:h},{width:r,height:d},i),h7.copy(u,o,{x:0,y:0},{x:l+c,y:h},{width:r,height:d},i),h7.copy(u,o,{x:c-r,y:d-r},{x:l-r,y:h-r},{width:r,height:r},i),h7.copy(u,o,{x:0,y:d-r},{x:l+c,y:h-r},{width:r,height:r},i),h7.copy(u,o,{x:0,y:0},{x:l+c,y:h+d},{width:r,height:r},i),h7.copy(u,o,{x:c-r,y:0},{x:l-r,y:h+d},{width:r,height:r},i)}this.dirty=!0}beginFrame(){for(let t of this.images.keys())this.callbackDispatchedThisFrame.set(t,new Set);this.imageAtlasCache.beginFrame()}dispatchRenderCallbacks(t,i){let r=this.images.get(i);for(let a of t){if(this.callbackDispatchedThisFrame.get(i).has(a.toString()))continue;this.callbackDispatchedThisFrame.get(i).add(a.toString());let t=r.get(a.toString());(function(t){let{userImage:i}=t;return!!(i&&i.render&&i.render())&&(t.data.replace(new Uint8Array(i.data.buffer)),!0)})(t)&&this.updateImage(a,i,t)}}}class mS{constructor(t,i,r,a){this.message=(t?`${t}: `:"")+r,a&&(this.identifier=a),null!=i&&i.__line__&&(this.line=i.__line__)}}class mI extends mS{}function mA(t){let i=t.value,r=t.valueSpec,a=t.style,n=t.styleSpec,o=t.key,s=t.arrayElementValidator||mY;if(!Array.isArray(i))return[new mS(o,i,`array expected, ${ab(i)} found`)];if(r.length&&i.length!==r.length)return[new mS(o,i,`array length ${r.length} expected, length ${i.length} found`)];if(r["min-length"]&&i.length<r["min-length"])return[new mS(o,i,`array length at least ${r["min-length"]} expected, length ${i.length} found`)];let l={type:r.value,values:r.values,minimum:r.minimum,maximum:r.maximum,function:void 0};n.$version<7&&(l.function=r.function),aw(r.value)&&(l=r.value);let h=[];for(let t=0;t<i.length;t++)h=h.concat(s({array:i,arrayIndex:t,value:i[t],valueSpec:l,style:a,styleSpec:n,key:`${o}[${t}]`},!0));return h}function mC(t){let i=t.key,r=t.value,a=t.valueSpec;if(!aE(r))return[new mS(i,r,`number expected, ${ab(r)} found`)];if(r!=r)return[new mS(i,r,"number expected, NaN found")];if("minimum"in a){let n=a.minimum;if(Array.isArray(a.minimum)&&(n=a.minimum[t.arrayIndex]),r<n)return[new mS(i,r,`${r} is less than the minimum value ${n}`)]}if("maximum"in a){let n=a.maximum;if(Array.isArray(a.maximum)&&(n=a.maximum[t.arrayIndex]),r>n)return[new mS(i,r,`${r} is greater than the maximum value ${n}`)]}return[]}function mM(t){let i=t.key,r=t.value;if(!aw(r))return[new mS(i,r,`object expected, ${ab(r)} found`)];let a=t.valueSpec,n=so(r.type),o,s,l,h={},u="categorical"!==n&&void 0===r.property,c=function(t){let i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&aw(i[0][0])}(r),d=mK({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===n)return[new mS(t.key,t.value,'identity function may not have a "stops" property')];let i=[],r=t.value;return i=i.concat(mA({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:p})),Array.isArray(r)&&0===r.length&&i.push(new mS(t.key,r,"array must have at least one stop")),i},default:function(t){return mY({key:t.key,value:t.value,valueSpec:a,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===n&&u&&d.push(new mS(t.key,t.value,'missing required property "property"')),"identity"===n||r.stops||d.push(new mS(t.key,t.value,'missing required property "stops"')),"exponential"===n&&a.expression&&!oc(a)&&d.push(new mS(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(u||ol(a)?u&&!ou(a)&&d.push(new mS(t.key,t.value,"zoom functions not supported")):d.push(new mS(t.key,t.value,"property functions not supported"))),("categorical"===n||c)&&void 0===r.property&&d.push(new mS(t.key,t.value,'"property" property is required')),d;function p(t){let i=[],r=t.value,n=t.key;if(!Array.isArray(r))return[new mS(n,r,`array expected, ${ab(r)} found`)];if(2!==r.length)return[new mS(n,r,`array length 2 expected, length ${r.length} found`)];
7if(c){if(!aw(r[0]))return[new mS(n,r,`object expected, ${ab(r[0])} found`)];let a=r[0];if(void 0===a.zoom)return[new mS(n,r,"object stop key must have zoom")];if(void 0===a.value)return[new mS(n,r,"object stop key must have value")];let o=so(a.zoom);if("number"!=typeof o)return[new mS(n,a.zoom,"stop zoom values must be numbers")];if(l&&l>o)return[new mS(n,a.zoom,"stop zoom values must appear in ascending order")];o!==l&&(l=o,s=void 0,h={}),i=i.concat(mK({key:`${n}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:mC,value:f}}))}else i=i.concat(f({key:`${n}[0]`,value:r[0],style:t.style,styleSpec:t.styleSpec},r));return ov(ss(r[1]))?i.concat([new mS(`${n}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(mY({key:`${n}[1]`,value:r[1],valueSpec:a,style:t.style,styleSpec:t.styleSpec}))}function f(t,i){let r=ab(t.value),l=so(t.value),u=null!==t.value?t.value:i;if(o){if(r!==o)return[new mS(t.key,u,`${r} stop domain type must match previous stop domain type ${o}`)]}else o=r;if("number"!==r&&"string"!==r&&"boolean"!==r&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new mS(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==r&&"categorical"!==n){let i=`number expected, ${r} found`;return ol(a)&&void 0===n&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new mS(t.key,u,i)]}return"categorical"!==n||"number"!==r||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===r&&"number"==typeof l&&"number"==typeof s&&void 0!==s&&l<s?[new mS(t.key,u,"stop domain values must appear in ascending order")]:(s=l,"categorical"===n&&l in h?[new mS(t.key,u,"stop domain values must be unique")]:(h[l]=!0,[])):[new mS(t.key,u,`integer expected, found ${String(l)}`)]}}function mR(t){let i=("property"===t.expressionContext?oE:ob)(ss(t.value),t.valueSpec);if("error"===i.result)return i.value.map(i=>new mS(`${t.key}${i.key}`,t.value,i.message));let r=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new mS(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!ns(r))return[new mS(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return function t(i,r){let a=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(r.valueSpec&&r.valueSpec.expression)for(let t of r.valueSpec.expression.parameters)a.delete(t);if(0===a.size)return[];let n=[];return i instanceof aR&&a.has(i.name)?[new mS(r.key,r.value,`["${i.name}"] expression is not supported in a filter for a ${r.object.type} layer with id: ${r.object.id}`)]:(i.eachChild(i=>{n.push(...t(i,r))}),n)}(r,t);if("appearance"===t.expressionContext)return function t(i,r){if(r.valueSpec&&r.valueSpec.expression)for(let t of r.valueSpec.expression.parameters)mP.delete(t);if(0===mP.size)return[];let a=[];if(i instanceof aR){let t=mD.has(i.name)?"feature":i.name;if(mP.has(t))return[new mS(r.key,r.value,`["${i.name}"] is not an allowed parameter`)]}return i.eachChild(i=>{a.push(...t(i,r))}),a}(r,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!nh(r,["zoom","feature-state"]))return[new mS(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!no(r))return[new mS(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}let mD=new Set(["get","has","properties","geometry-type","id"]),mP=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 mz(t){let i=t.key,r=t.value,a=t.valueSpec,n=[];return Array.isArray(a.values)?a.values.includes(so(r))||n.push(new mS(i,r,`expected one of [${a.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(a.values).includes(so(r))||n.push(new mS(i,r,`expected one of [${Object.keys(a.values).join(", ")}], ${JSON.stringify(r)} found`)),n}function mL(t){if(sl(ss(t.value))){let i=t.layerType||"fill";return mR({...t,expressionContext:"filter",valueSpec:t.styleSpec[`filter_${i}`]})}return function t(i){let r=i.value,a=i.key;if(!Array.isArray(r))return[new mS(a,r,`array expected, ${ab(r)} found`)];if(r.length<1)return[new mS(a,r,"filter array must have at least 1 element")];let n=i.styleSpec,o=mz({key:`${a}[0]`,value:r[0],valueSpec:n.filter_operator}),s=()=>{r.length>=2&&(aT(r[1])||o.push(new mS(`${a}[1]`,r[1],`string expected, ${ab(r[1])} found`)));for(let t=2;t<r.length;t++)"$type"===so(r[1])?o=o.concat(mz({key:`${a}[${t}]`,value:r[t],valueSpec:n.geometry_type})):aT(r[t])||aE(r[t])||aS(r[t])||o.push(new mS(`${a}[${t}]`,r[t],`string, number, or boolean expected, ${ab(r[t])} found.`))};switch(so(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===so(r[1])&&o.push(new mS(a,r,`"$type" cannot be use with operator "${r[0]}"`)),3!==r.length&&o.push(new mS(a,r,`filter array for operator "${r[0]}" must have 3 elements`)),s();break;case"==":case"!=":3!==r.length&&o.push(new mS(a,r,`filter array for operator "${r[0]}" must have 3 elements`)),s();break;case"in":case"!in":s();break;case"any":case"all":case"none":for(let n=1;n<r.length;n++)o=o.concat(t({key:`${a}[${n}]`,value:r[n],style:i.style,styleSpec:i.styleSpec}));break;case"has":case"!has":2!==r.length?o.push(new mS(a,r,`filter array for "${r[0]}" operator must have 2 elements`)):aT(r[1])||o.push(new mS(`${a}[1]`,r[1],`string expected, ${ab(r[1])} found`))}return o}(t)}
7let mO=/^{([^}]+)}$/;function mF(t,i){let r,a=t.key,n=t.style,o=t.layer,s=t.styleSpec,l=t.value,h=t.objectKey,u=s[`${i}_${t.layerType}`];if(!u)return[];let c=h.match(oo);if(c&&u[c[1]])return ov(ss(l))?[].concat(mY({key:a,value:l,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:n,styleSpec:s,expressionContext:"property",propertyType:i,propertyKey:h})):mY({key:a,value:l,valueSpec:{type:"string"},style:n,styleSpec:s});let d=h.match(on);if("paint"===i&&d&&u[d[1]]&&u[d[1]].transition)return mY({key:a,value:l,valueSpec:s.transition,style:n,styleSpec:s});let p=t.valueSpec||u[h];if(!p)return[new mI(a,l,`unknown property "${h}"`)];if(aT(l)&&ol(p)&&!p.tokens&&(r=mO.exec(l))){let t=`\`{ "type": "identity", "property": ${r?JSON.stringify(r[1]):'"_"'} }\``;return[new mS(a,l,`"${h}" does not support interpolation syntax 8Use an identity property function instead: ${t}.`)]}let f=[];if("symbol"===t.layerType)"text-field"!==h||!n||n.glyphs||n.imports||f.push(new mS(a,l,'use of "text-field" requires a style "glyphs" property')),"text-font"===h&&od(ss(l))&&"identity"===so(l.type)&&f.push(new mS(a,l,'"text-font" does not support identity functions'));else if("model"===t.layerType&&"paint"===i&&o&&o.layout&&Object.hasOwn(o.layout,"model-id")&&ol(p)&&(oh(p)||ou(p))){let t=oE(ss(l),p).value,i="expression"in t&&t.expression||"_styleExpression"in t&&t._styleExpression&&t._styleExpression.expression;i&&!nh(i,["measure-light"])&&("model-emissive-strength"===h&&no(i)&&ns(i)||f.push(new mS(a,l,`${h} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return f.concat(mY({key:t.key,value:l,valueSpec:p,style:n,styleSpec:s,expressionContext:"property",propertyType:i,propertyKey:h}))}function mB(t){return mF(t,"paint")}function mk(t){return mF(t,"layout")}function mN(t){let i=[],r=t.value,a=t.key,n=t.style,o=t.styleSpec;if(!aw(r))return[new mS(a,r,"object expected")];r.type||r.ref||i.push(new mS(a,r,'either "type" or "ref" is required'));let s=so(r.type),l=so(r.ref);if(r.id){let o=so(r.id);for(let s=0;s<t.arrayIndex;s++){let t=n.layers[s];so(t.id)===o&&i.push(new mS(a,r.id,`duplicate layer id "${o}", previously used at line ${t.id.__line__}`))}}if("ref"in r){let t;["type","source","source-layer","filter","layout"].forEach(t=>{t in r&&i.push(new mS(a,r[t],`"${t}" is prohibited for ref layers`))}),n.layers.forEach(i=>{so(i.id)===l&&(t=i)}),t?t.ref?i.push(new mS(a,r.ref,"ref cannot reference another ref layer")):s=so(t.type):"string"==typeof l&&i.push(new mS(a,r.ref,`ref layer "${l}" not found`))}else if("background"!==s&&"sky"!==s&&"slot"!==s)if(r.source)if(aT(r.source)){let t=n.sources&&Object.hasOwn(n.sources,r.source)?n.sources[r.source]:void 0,o=t&&so(t.type);t?"vector"===o&&"raster"===s?i.push(new mS(a,r.source,`layer "${r.id}" requires a raster source`)):"raster"===o&&"raster"!==s?i.push(new mS(a,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==o||r["source-layer"]?"raster-dem"===o&&"hillshade"!==s?i.push(new mS(a,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==o||["raster","raster-particle"].includes(s)?"line"===s&&r.paint&&r.paint["line-gradient"]&&"geojson"===o&&!t.lineMetrics?i.push(new mS(a,r,`layer "${r.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"line"===s&&r.paint&&r.paint["line-trim-offset"]&&"geojson"===o&&!t.lineMetrics?i.push(new mS(a,r,`layer "${r.id}" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===s&&"raster-array"!==o&&i.push(new mS(a,r.source,`layer "${r.id}" requires a 'raster-array' source.`)):i.push(new mS(a,r.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new mS(a,r,`layer "${r.id}" must specify a "source-layer"`)):i.push(new mS(a,r.source,`source "${r.source}" not found`))}else i.push(new mS(`${a}.source`,r.source,'"source" must be a string'));else i.push(new mS(a,r,'missing required property "source"'));
8return i=i.concat(mK({key:a,value:r,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>mY({key:`${a}.type`,value:r.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:t=>mL({layerType:s,...t}),layout:t=>mK({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>mk({layerType:s,...t})}}),paint:t=>mK({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>mB({layerType:s,layer:r,...t})}}),appearances(t){let i=mA({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>(function(t){let{key:i,layer:r,layerType:a}=t,n=so(t.value),o=so(n.name),s=so(n.condition),l=mK({key:i,value:n,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>(function(t){let i=[];return i.push(...mR({key:t.key,value:t.object.condition,valueSpec:sn.appearance.condition,expressionContext:"appearance"})),i})({...t}),properties:t=>(function(t){let i=[],{styleSpec:r,layer:a,layerType:n}=t,o=r[`paint_${n}`],s=r[`layout_${n}`],l=t.object[t.objectKey];for(let r in l){let h=r in o?"paint":r in s?"layout":void 0;if(!h){i.push(new mS(t.key,r,`unknown property "${r}" for layer type "${n}"`));continue}let u={...t,key:`${t.key}.${r}`,objectKey:r,layer:a,layerType:n,value:l[r],valueSpec:"paint"===h?o[r]:s[r]};i.push(...mF(u,h))}return i})({layer:r,layerType:a,...t})}});return"hidden"!==o&&void 0===s&&l.push(new mS(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l})({layerType:s,layer:r,...t})}),a=Array.isArray(t.value)?t.value:[],n=new Set;return a.forEach((a,o)=>{let s=so(a.name);if(s)if(n.has(s)){let a=so(r.id);i.push(new mS(t.key,s,`Duplicated appearance name "${s}" for layer "${a}"`))}else n.add(s)}),i}}}))}function mV({key:t,value:i}){return aT(i)?[]:[new mS(t,i,`string expected, ${ab(i)} found`)]}let mU={promoteId:function t({key:i,value:r}){if(aT(r))return mV({key:i,value:r});if(Array.isArray(r)){let t=[],a=ob(ss(r));return"error"===a.result?a.value.forEach(r=>{t.push(new mS(`${i}${r.key}`,null,`${r.message}`))}):nh(a.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"])||t.push(new mS(`${i}`,null,"promoteId expression should be only feature dependent")),t}if(!aw(r))return[new mS(i,r,`string, expression or object expected, "${ab(r)}" found`)];let a=[];for(let n in r)a.push(...t({key:`${i}.${n}`,value:r[n]}));return a}};function mj(t){let i=t.value,r=t.key,a=t.styleSpec,n=t.style;if(!aw(i))return[new mS(r,i,`object expected, ${ab(i)} found`)];if(!("type"in i))return[new mS(r,i,'"type" is required')];let o=so(i.type),s=[];switch(["vector","raster","raster-dem","raster-array"].includes(o)&&("url"in i||"tiles"in i||s.push(new mI(r,i,'Either "url" or "tiles" is required.'))),o){case"vector":case"raster":case"raster-dem":case"raster-array":return s.concat(mK({key:r,value:i,valueSpec:a[`source_${o.replace("-","_")}`],style:t.style,styleSpec:a,objectElementValidators:mU}));case"geojson":if(s=mK({key:r,value:i,valueSpec:a.source_geojson,style:n,styleSpec:a,objectElementValidators:mU}),"cluster"in i&&"clusterProperties"in i){if(!aw(i.clusterProperties))return[new mS(`${r}.clusterProperties`,i,`object expected, ${ab(i)} found`)];for(let t in i.clusterProperties){let a=i.clusterProperties[t];if(!Array.isArray(a))return[new mS(`${r}.clusterProperties.${t}`,a,"array expected")];let[n,o]=a,l="string"==typeof n?[n,["accumulated"],["get",t]]:n;s.push(...mR({key:`${r}.${t}.map`,value:o,expressionContext:"cluster-map"})),s.push(...mR({key:`${r}.${t}.reduce`,value:l,expressionContext:"cluster-reduce"}))}}return s;case"video":return mK({key:r,value:i,valueSpec:a.source_video,style:n,styleSpec:a});case"image":return mK({key:r,value:i,valueSpec:a.source_image,style:n,styleSpec:a});case"canvas":return[new mS(r,null,"Please use runtime APIs to add canvas sources, rather than
8including them in stylesheets.","source.canvas")];default:var l;return mz({key:`${r}.type`,value:i.type,valueSpec:{values:(l=a).source.reduce((t,i)=>{let r=l[i];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values||{}))),t},[])}})}}function mG(t,i){let r=!t.includes("://");try{return new URL(t,r&&i?"http://example.com":void 0),!0}catch(t){return!1}}function mH(t){let i=t.value;return i?aT(i)?mG(i,!0)?[]:[new mS(t.key,i,`invalid url "${i}"`)]:[new mS(t.key,i,`string expected, "${ab(i)}" found`)]:[]}function mq(t){let i=t.value,r=t.styleSpec,a=r.light,n=t.style;if(void 0===i)return[];if(!aw(i))return[new mS("light",i,`object expected, ${ab(i)} found`)];let o=[];for(let t in i){let s=t.match(on),l=t.match(oo);o=o.concat(l&&a[l[1]]?mY({key:t,value:i[t],valueSpec:{type:"string"},style:n,styleSpec:r}):s&&a[s[1]]&&a[s[1]].transition?mY({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):a[t]?mY({key:t,value:i[t],valueSpec:a[t],style:n,styleSpec:r}):[new mS(t,i[t],`unknown property "${t}"`)])}return o}function mZ(t){let i=t.value;if(!i)return[];let r=t.key;if(!aw(i))return[new mS(r,i,`object expected, ${ab(i)} found`)];let a=[],n=t.styleSpec,o=n["light-3d"],s=t.style,l=t.style.lights;for(let t of["type","id"])if(!(t in i))return a.concat([new mS(r,i,`missing property "${t}"`)]);if(!aT(i.type))return a.concat([new mS(`${r}.type`,i.type,"string expected")]);if(l)for(let n=0;n<t.arrayIndex;n++){let t=so(i.type),o=l[n];so(o.type)===t&&a.push(new mS(r,i.id,`duplicate light type "${i.type}", previously defined at line ${o.id.__line__}`))}let h=`properties_light_${i.type}`;if(!(h in n))return a.concat([new mS(`${r}.type`,i,`Invalid light type ${i.type}`)]);let u=n[h];for(let r in i)if("properties"===r){let o=i[r];if(!aw(o))return a.concat([new mS("properties",o,`object expected, ${ab(o)} found`)]);for(let l in o){let h=l.match(on),c=l.match(oo);a=a.concat(c&&u[c[1]]?mY({key:r,value:o[l],valueSpec:{type:"string"},style:s,styleSpec:n}):h&&u[h[1]]&&u[h[1]].transition?mY({key:r,value:i[r],valueSpec:n.transition,style:s,styleSpec:n}):u[l]?mY({key:l,value:o[l],valueSpec:u[l],style:s,styleSpec:n}):[new mI(t.key,o[l],`unknown property "${l}"`)])}}else a=a.concat(o[r]?mY({key:r,value:i[r],valueSpec:o[r],style:s,styleSpec:n}):[new mI(r,i[r],`unknown property "${r}"`)]);return a}function m$(t){let i=t.value,r=t.key,a=t.style,n=t.styleSpec,o=n.terrain;if(null==i)return[];if(!aw(i))return[new mS("terrain",i,`object expected, ${ab(i)} found`)];let s=[];for(let t in i){let r=t.match(on),l=t.match(oo);s=s.concat(l&&o[l[1]]?mY({key:t,value:i[t],valueSpec:{type:"string"},style:a,styleSpec:n}):r&&o[r[1]]&&o[r[1]].transition?mY({key:t,value:i[t],valueSpec:n.transition,style:a,styleSpec:n}):o[t]?mY({key:t,value:i[t],valueSpec:o[t],style:a,styleSpec:n}):[new mI(t,i[t],`unknown property "${t}"`)])}if(i.source)if(aT(i.source)){let t=a.sources&&Object.hasOwn(a.sources,i.source)?a.sources[i.source]:void 0,n=t&&so(t.type);t?"raster-dem"!==n&&s.push(new mS(`${r}.source`,i.source,`terrain cannot be used with a source of type ${n}, it only be used with a "raster-dem" source type`)):s.push(new mS(`${r}.source`,i.source,`source "${i.source}" not found`))}else s.push(new mS(`${r}.source`,i.source,"source must be a string"));else s.push(new mS(r,i,'terrain is missing required property "source"'));return s}function mW(t){let i=t.value,r=t.style,a=t.styleSpec,n=a.fog;if(void 0===i)return[];if(!aw(i))return[new mS("fog",i,`object expected, ${ab(i)} found`)];let o=[];for(let t in i){let s=t.match(on),l=t.match(oo);o=o.concat(l&&n[l[1]]?mY({key:t,value:i[t],valueSpec:{type:"string"},style:r,styleSpec:a}):s&&n[s[1]]&&n[s[1]].transition?mY({key:t,value:i[t],valueSpec:a.transition,style:r,styleSpec:a}):n[t]?mY({key:t,value:i[t],valueSpec:n[t],style:r,styleSpec:a}):[new mI(t,i[t],`unknown property "${t}"`)])}return o}let mX={"*":()=>[],array:mA,boolean:function(t){let i=t.value,r=t.key;return aS(i)?[]:[new mS(r,i,`boolean expected, ${ab(i)} found`)]},number:mC,color:function({key:t,value:i}){return aT(i)?void 0===rq.parse(so(i))?[new mS(t,i,`color expected, "${i}" found`)]:[]:[new mS(t,i,`color expected, ${ab(i)} found`)]},enum:mz,filter:mL,function:mM,layer:mN,object:mK,source:mj,model:mH,light:mq,"light-3d":mZ,terrain:m$,fog:mW,string:mV,formatted:function(t){return 0===mV(t).length?[]:mR(t)},resolvedImage:function(t){return 0===mV(t).length?[]:mR(t)},projection:function(t){let i=t.value,r=t.styleSpec,a=r.projection,n=t.style;if(aw(i)){let t=[];for(let o in i)t=t.concat(mY({key:o,value:i[o],valueSpec:a[o],style:n,styleSpec:r}));return t}return aT(i)?[]:[new mS("projection",i,`object or string expected, ${ab(i)} found`)]},import:function(t){let i=t.key,{value:r,styleSpec:a}=t;if(!aw(r))return[new mS(i,r,"import must be an object")];let{data:n,...o}=r;Object.defineProperty(o,"__line__",{value:r.__line__,enumerable:!1});let s=mK({...t,value:o,valueSpec:a.import});return""===so(o.id)&&s.push(new mS(`${t.key}.id`,o,"import id can't be an empty string")),"__proto__"===so(o.id)&&s.push(new mS(`${t.key}.id`,o,'import id can\'t be "__proto__"')),n&&(s=s.concat(mJ(n,a,{key:`${t.key}.data`}))),s},iconset:function(t){let i=t.value,r=t.key,a=t.styleSpec,n=t.style;if(!aw(i))return[new mS(r,i,"object expected")];if(!i.type)return[new mS(r,i,'"type" is required')];let o=so(i.type),s=[];
8if(s=s.concat(mK({key:r,value:i,valueSpec:a[`iconset_${o}`],style:n,styleSpec:a})),!("source"!==o||!i.source)){let t=n.sources&&Object.hasOwn(n.sources,i.source)?n.sources[i.source]:void 0,a=t&&so(t.type);t?"raster-array"!==a&&s.push(new mS(r,i.source,`iconset cannot be used with a source of type ${String(a)}, it only be used with a "raster-array" source type`)):s.push(new mS(r,i.source,`source "${i.source}" not found`))}return s},option:function(t){let i=t.styleSpec,r=t.value,a=aw(r)&&!0===so(r.array)||!aw(r)?void 0:so(r.type);return mK({...t,valueSpec:i.option,objectElementValidators:a?{default:t=>Array.isArray(t.value)?mY({...t,valueSpec:{...t.valueSpec,type:a}}):mY(t)}:void 0})}};function mY(t,i=!1){let r=t.value,a=t.valueSpec,n=t.styleSpec;if(a.expression){if(od(so(r)))return mM(t);if(ov(ss(r)))return mR(t)}if(a.type&&mX[a.type]){let r=mX[a.type](t);return!0===i&&r.length>0&&Array.isArray(t.value)?mR(t):r}return mK({...t,valueSpec:a.type?n[a.type]:a})}function mK(t){let i=t.key,r=t.value,a=t.valueSpec||{},n=t.objectElementValidators||{},o=t.style,s=t.styleSpec;if(!aw(r))return[new mS(i,r,`object expected, ${ab(r)} found`)];let l=[];for(let t in r){let h;if(!Object.hasOwn(r,t))continue;let u=t.split(".")[0],c=Object.hasOwn(a,u),d=Object.hasOwn(a,"*"),p=c?a[u]:d?a["*"]:void 0;Object.hasOwn(n,u)?h=n[u]:c?h=mY:Object.hasOwn(n,"*")?h=n["*"]:d&&(h=mY),h?l=l.concat(h({key:(i?`${i}.`:i)+t,value:r[t],valueSpec:p,style:o,styleSpec:s,object:r,objectKey:t},r)):l.push(new mI(i,r[t],`unknown property "${t}"`))}for(let t in a){if(!Object.hasOwn(a,t)||Object.hasOwn(n,t))continue;let o=a[t];!o.required||void 0!==o.default||Object.hasOwn(r,t)&&void 0!==r[t]||l.push(new mS(i,r,`missing required property "${t}"`))}return l}function mQ({key:t,value:i}){let r=mV({key:t,value:i});return r.length||(i.includes("{fontstack}")||r.push(new mS(t,i,'"glyphs" url must include a "{fontstack}" token')),i.includes("{range}")||r.push(new mS(t,i,'"glyphs" url must include a "{range}" token'))),r}function mJ(t,i=sn,r={}){return mK({key:r.key||"",value:t,valueSpec:{...i.$root,"*":{type:"*"}},styleSpec:i,style:t,objectElementValidators:{glyphs:mQ}})}function m0(t,i=sn){return gr(mJ(t,i))}let m1=t=>gr(mj(t)),m2=t=>gr(mq(t)),m3=t=>gr(mZ(t)),m4=t=>gr(m$(t)),m5=t=>gr(mW(t)),m6=t=>gr(function(t){let i=t.value,r=t.style,a=t.styleSpec,n=a.snow;if(void 0===i)return[];if(!aw(i))return[new mS("snow",i,`object expected, ${ab(i)} found`)];let o=[];for(let t in i){let s=t.match(on);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?mY({key:t,value:i[t],valueSpec:a.transition,style:r,styleSpec:a}):n[t]?mY({key:t,value:i[t],valueSpec:n[t],style:r,styleSpec:a}):[new mI(t,i[t],`unknown property "${t}"`)])}return o}(t)),m8=t=>gr(function(t){let i=t.value,r=t.style,a=t.styleSpec,n=a.rain;if(void 0===i)return[];if(!aw(i))return[new mS("rain",i,`object expected, ${ab(i)} found`)];let o=[];for(let t in i){let s=t.match(on);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?mY({key:t,value:i[t],valueSpec:a.transition,style:r,styleSpec:a}):n[t]?mY({key:t,value:i[t],valueSpec:n[t],style:r,styleSpec:a}):[new mI(t,i[t],`unknown property "${t}"`)])}return o}(t)),m9=t=>gr(mN(t)),m7=t=>gr(mL(t)),ge=t=>gr(mB(t)),gt=t=>gr(mk(t)),gi=t=>gr(mH(t));function gr(t){return t.slice().sort((t,i)=>t.line&&i.line?t.line-i.line:0)}function ga(t,i){let r=!1;if(i&&i.length)for(let a of i)a instanceof mI?tX(a.message):(t.fire(new rL(Error(a.message))),r=!0);return r}let gn=sn.light;class go extends rB{constructor(t,i="flat"){super(),this._transitionable=new o3(X||(X=new sa({anchor:new o7(gn.anchor),position:new sr(gn.position),color:new o7(gn.color),intensity:new o7(gn.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,i,r={}){this._validate(m2,t,r)||(this._transitionable.setTransitionOrValue(t),this.id=i)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r){return(!r||!1!==r.validate)&&ga(this,t.call(m0,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:sn}))}}let gs=sn.terrain,gl=class extends rB{constructor(t,i,r,a,n){super(),this.scope=r,this._transitionable=new o3(new sa({source:new o7(gs.source),exaggeration:new o7(gs.exaggeration)}),r,a),this._transitionable.setTransitionOrValue(t,a),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=n}get(){return this._transitionable.serialize()}set(t,i){this._transitionable.setTransitionOrValue(t,i)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new o0(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;let t=this._transitionable._values.exaggeration;if(!t)return null;let i=t.value.expression;if(!i)return null;let r=-1,a=-1,n=1;for(let t of i.zoomStops)(n=i.evaluate(new o0(t,{worldview:this.worldview})))>.01?(r=t,a=-1):a=t;return n<.01&&r>0&&a>r?[r,a]:null}isZoomDependent(){let t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof oT}};function gh(t,i){let r=t?t.terrain:null;return!!r&&(!i||!!i.projection.requiresDraping||!r.isZoomDependent()||r.getExaggeration(i.zoom)>0)}function gu(t,i,r){let a=tO(45,65,r),[n,o]=t.range,s=1-Math.min(1,Math.exp(-((i-n)/(o-n)*6)));return s*=s*s,(s=Math.min(1,1.00747*s))*a*t.alpha}function gc(t,i,r,a,n){return gu(t,eL(eQ([],[i,r,a],n.mercatorFogMatrix)),n.pitch)}function gd(t,i,r,a,n,o,s){let l=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let t of[[r,a,0],[n,a,0],[n,o,0],[r,o,0]]){let r=eL(eQ([],t,i));l=Math.min(l,r),h=Math.max(h,r)}return[gu(t,l,s.pitch),gu(t,h,s.pitch)]}let gp=sn.fog;class gf extends rB{constructor(t,i,r,a){super();let n=new sa({range:new o7(gp.range),color:new o7(gp.color),"color-use-theme":new o7({type:"string","property-type":"data-constant",default:"default"}),"high-color":new o7(gp["high-color"]),"high-color-use-theme":new o7({type:"string","property-type":"data-constant",default:"default"}),"space-color":new o7(gp["space-color"]),"space-color-use-theme":new o7({type:"string","property-type":"data-constant",default:"default"}
8),"horizon-blend":new o7(gp["horizon-blend"]),"star-intensity":new o7(gp["star-intensity"]),"vertical-range":new o7(gp["vertical-range"])});this._transitionable=new o3(n,r,a),this.set(t,a),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new o9(n),this.scope=r}get state(){let t=this._transform,i="globe"===t.projection.name,r=cN(t.zoom),a=this.properties.get("range"),n=.5/Math.tan(.5*t._fov),o=[a[0]+n,a[1]+n];return{range:i?[rG(2,o[0],r),rG(4.5,o[1],r)]:o,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(m5,t,r))return;let a={...t};for(let t of Object.keys(gp))void 0===a[t]&&(a[t]=gp[t].default);this._options=a,this._transitionable.setTransitionOrValue(this._options,i)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;let i=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:tO(45,65,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,r){let a=s8.fromLngLat(i),n=r.elevation?r.elevation.getAtPointOrZero(a):0;return gc(t,a.x,a.y,n,r)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];let i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return gd(this.state,i,0,0,8192,8192,this._transform)}getOpacityForBounds(t,i,r,a,n){return this._transform.projection.supportsFog?gd(this.state,t,i,r,a,n,this._transform):[1,1]}getRangeForProjection(){return this._transform.projection.supportsFog?this.state.range:[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;for(let i of[4,5,6,7]){let r,a=t.points[i];if(a[2]>=0)r=a;else{let n=t.points[i-4];r=rX(n,a,n[2]/(n[2]-a[2]))}if(gc(this.state,r[0],r[1],0,this._transform)>=.05)return!0}return!1}updateConfig(t){this._transitionable.setTransitionOrValue(this._options,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r){return(!r||!1!==r.validate)&&ga(this,t.call(m0,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:sn}))}}let g_,gm,gg=class extends rB{constructor(t,i,r,a){super();let n=g_||(g_=new sa({density:new o7(sn.snow.density),intensity:new o7(sn.snow.intensity),color:new o7(sn.snow.color),opacity:new o7(sn.snow.opacity),vignette:new o7(sn.snow.vignette),"vignette-color":new o7(sn.snow["vignette-color"]),"center-thinning":new o7(sn.snow["center-thinning"]),direction:new o7(sn.snow.direction),"flake-size":new o7(sn.snow["flake-size"])}));this._transitionable=new o3(n,r,a),this.set(t,a),this._transitioning=this._transitionable.untransitioned(),this.properties=new o9(n),this.scope=r}get state(){let t=this.properties.get("opacity"),i=this.properties.get("color"),r=this.properties.get("direction"),a=r[0]*tA,n=-Math.max(r[1]*tA,.01),o=[Math.cos(a)*Math.cos(n),Math.sin(a)*Math.cos(n),Math.sin(n)],s=this.properties.get("vignette"),l=this.properties.get("vignette-color"),h=new rq(l.r,l.g,l.b,s);return{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new rq(i.r,i.g,i.b,i.a*t),direction:o,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:h}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(m6,t,r))return;let a={...t},n=sn.snow;for(let t of Object.keys(n))void 0===a[t]&&(a[t]=n[t].default);this._options=a,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(t){this._transitionable.setTransitionOrValue(this._options,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r){return(!r||!1!==r.validate)&&ga(this,t.call(m0,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:sn}))}},gy=class extends rB{constructor(t,i,r,a){super();let n=gm||(gm=new sa({density:new o7(sn.rain.density),intensity:new o7(sn.rain.intensity),color:new o7(sn.rain.color),opacity:new o7(sn.rain.opacity),vignette:new o7(sn.rain.vignette),"vignette-color":new o7(sn.rain["vignette-color"]),"center-thinning":new o7(sn.rain["center-thinning"]),direction:new o7(sn.rain.direction),"droplet-size":new o7(sn.rain["droplet-size"]),"distortion-strength":new o7(sn.rain["distortion-strength"])}));this._transitionable=new o3(n,r,a),this.set(t,a),this._transitioning=this._transitionable.untransitioned(),this.properties=new o9(n),this.scope=r}get state(){let t=this.properties.get("opacity"),i=this.properties.get("color"),r=this.properties.get("direction"),a=r[0]*tA,n=-Math.max(r[1]*tA,.01),o=[Math.cos(a)*Math.cos(n),Math.sin(a)*Math.cos(n),Math.sin(n)],s=this.properties.get("vignette-color"),l=new rq(s.r,s.g,s.b,this.properties.get("vignette"));return{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new rq(i.r,i.g,i.b,i.a*t),direction:o,centerThinning:this.properties.get("center-thinning"),droplet
8Size:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(m8,t,r))return;let a={...t},n=sn.rain;for(let t of Object.keys(n))void 0===a[t]&&(a[t]=n[t].default);this._options=a,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(t){this._transitionable.setTransitionOrValue(this._options,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r){return(!r||!1!==r.validate)&&ga(this,t.call(m0,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:sn}))}};class gx{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(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=()=>{}}}class gv{constructor(){this.tasks=new Map,tG(["process"],this),this.invoker=new gx(this.process),this.nextId=0}add(t,i){let r=this.nextId++,a=function({type:t,renderSourceType:i,zoom:r}){r=r||0;let a=1===i;return"message"===t?0:"maybePrepare"!==t||a?"parseTile"!==t||a?"parseTile"===t&&a?300-r:"maybePrepare"===t&&a?400-r:500:200-r:100-r}(i);return 0===a?(t(),null):(this.tasks.set(r,{fn:t,metadata:i,priority:a,id:r}),this.invoker.trigger(),{cancel:()=>{this.tasks.delete(r)}})}process(){{let t=this.pick();if(!t)return;this.tasks.delete(t.id),this.tasks.size>0&&this.invoker.trigger(),t.fn()}}pick(){let t=null,i=1/0;for(let r of this.tasks.values())r.priority<i&&(i=r.priority,t=r);return t}remove(){this.tasks.clear(),this.invoker.remove()}}let gb={type:"message"},gw={workerUrl:"",workerClass:null,workerParams:void 0},gT="mapboxgl_preloaded_worker_pool";class gE{constructor(t){this.active={},this.name=t}acquire(t,i=gE.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<i;){var r;let i=(r=`${this.name||""}WorkerPool: ${t}-${this.workers.length}`,null!=gw.workerClass?new gw.workerClass:new self.Worker(gw.workerUrl,{name:r,...gw.workerParams}));this.workers.push(i)}return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.workers&&0===this.numActive()&&(this.workers.forEach(t=>{t.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[gT]}numActive(){return Object.keys(this.active).length}}gE.workerCount=2;class gS{constructor(t,i,r="Worker",a=gE.workerCount){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=tN++;let n=this.workerPool.acquire(this.id,a);for(let t=0;t<n.length;t++){let a=new gS.Actor(n[t],i,this.id);a.name=`${r} ${t}`,this.actors.push(a)}this.ready=!1,this.send("checkIfReady",null).then(()=>{this.ready=!0}).catch(()=>{})}send(t,i,r){return Promise.all(this.actors.map(a=>a.send(t,i,r)))}broadcast(t,i){for(let r of this.actors)r.notify(t,i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(t=>{t.remove()}),this.actors=[],this.workerPool.release(this.id)}}gS.Actor=class{constructor(t,i,r){this.target=t,this.parent=i,this.mapId=r,this.pendingResponses=new Map,tG(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new gv}send(t,i,r){let{signal:a,targetMapId:n,metadata:o}=r||{},s=Math.round(1e18*Math.random()).toString(36).substring(0,10),l=new Set;return a&&a.aborted?Promise.reject(a.reason):(this.target.postMessage({id:s,type:t,targetMapId:n,sourceMapId:this.mapId,data:oP(i,l)},[...l]),new Promise((t,i)=>{let r={resolve:t,reject:i,metadata:o||gb};if(a){let t=()=>{this.pendingResponses.delete(s),i(a.reason)};a.addEventListener("abort",t,{once:!0}),r.detach=()=>a.removeEventListener("abort",t)}this.pendingResponses.set(s,r)}))}notify(t,i,r){let{targetMapId:a}=r||{},n=new Set;this.target.postMessage({type:t,targetMapId:a,sourceMapId:this.mapId,data:oP(i,n)},[...n])}sendCancelable(t,i,r,a){let n=new AbortController;return this.send(t,i,{...r,signal:n.signal}).then(t=>a(null,t)).catch(t=>{"AbortError"!==t.name&&a(t)}),n}getWorkerSourceActor(t){return{scheduler:this.scheduler,send:(i,r,a)=>this.send(i,r,{...a,targetMapId:t}),notify:(i,r)=>{this.notify(i,r,{targetMapId:t})},sendCancelable:(i,r,a,n)=>this.sendCancelable(i,r,{...a,targetMapId:t},n)}}receive(t){let i=t.data;if(!i)return;let r=i.id;if(!i.targetMapId||this.mapId===i.targetMapId)if(tJ(self)){let t=this.pendingResponses.get(r);this.scheduler.add(()=>{this.processTask(r,i)},t&&t.metadata||gb)}else this.processTask(r,i)}async processTask(t,i){if("<response>
8"===i.type){let r=this.pendingResponses.get(t);if(this.pendingResponses.delete(t),r){r.detach&&r.detach();try{i.error?r.reject(oz(i.error)):r.resolve(oz(i.data))}catch(t){r.reject(t)}}return}let r=new Set,a=oz(i.data);try{let n;if(this.parent[i.type])n=await this.parent[i.type](i.sourceMapId,a);else{if(!this.parent.getWorkerSource)throw Error(`Could not find function ${i.type}`);{let t=i.type.split("."),{source:r,scope:o}=a,s=this.parent.getWorkerSource(i.sourceMapId,{type:t[0],source:r,scope:o,uid:0});n=await s[t[1]](a)}}if(!t)return;this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:null,data:oP(n,r)},[...r])}catch(i){this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:oP(i),data:null},[])}}remove(){for(let t of this.pendingResponses.values())t.detach&&t.detach(),t.reject(new DOMException("Actor removed","AbortError"));this.pendingResponses.clear(),this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}};class gI extends rB{constructor(t,i,r,a){super(),this.scope=r,this._options=t,this.properties=new o9(i),this._transitionable=new o3(i,r,a),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(t){this._transitionable.setTransitionOrValue(this._options.properties,t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(t,i){this._options=t,this._transitionable.setTransitionOrValue(t.properties,i)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}let gA=()=>Y||(Y=new sa({color:new o7(sn.properties_light_ambient.color),"color-use-theme":new o7({type:"string",default:"default","property-type":"data-constant"}),intensity:new o7(sn.properties_light_ambient.intensity)})),gC=()=>K||(K=new sa({direction:new si(sn.properties_light_directional.direction),color:new o7(sn.properties_light_directional.color),"color-use-theme":new o7({type:"string",default:"default","property-type":"data-constant"}),intensity:new o7(sn.properties_light_directional.intensity),"cast-shadows":new o7(sn.properties_light_directional["cast-shadows"]),"shadow-quality":new o7(sn.properties_light_directional["shadow-quality"]),"shadow-intensity":new o7(sn.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new o7(sn.properties_light_directional["shadow-draw-before-layer"])})),gM=(t,i,r,a,n,o,s,l,h,u=[0,0,1])=>({u_matrix:t,u_normal_matrix:i,u_opacity:r,u_faux_facade_ao_intensity:a,u_camera_pos:n,u_tile_to_meter:o,u_facade_emissive_chance:s,u_flood_light_color:l,u_flood_light_intensity:h,u_front_cutoff_params:u}),gR=t=>({u_matrix:t}),gD=t=>({u_matrix:t});class gP{constructor(t,i,r){this.enable=t,this.mode=i,this.frontFace=r}}gP.disabled=new gP(!1,1029,2305),gP.backCCW=new gP(!0,1029,2305),gP.backCW=new gP(!0,1029,2304),gP.frontCW=new gP(!0,1028,2304),gP.frontCCW=new gP(!0,1028,2305);class gz{constructor(t,i,r){this.func=t,this.mask=i,this.range=r}}gz.ReadOnly=!1,gz.ReadWrite=!0,gz.disabled=new gz(519,gz.ReadOnly,[0,1]);class gL{constructor(t=0,i=0,r=0,a=0){if(isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0||isNaN(a)||a<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=i,this.left=r,this.right=a}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=rG(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=rG(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=rG(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=rG(t.right,i.right,r)),this}getCenter(t,i){return new tg(tL((this.left+t-this.right)/2,0,t),tL((this.top+i-this.bottom)/2,0,i))}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new gL(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function gO(t,i){let r=t4(t,3);eM(t,i),t5(t,3,r)}function gF(t,i){let r=te([]);return tr(r,r,-i),tt(r,r,-t),r}function gB(t,i){let r=[t[0],t[1],0],a=[i[0],i[1],0];if(eL(r)>=1e-15){let t=eW([],r);ej(a,t,eX(a,t)),i[0]=a[0],i[1]=a[1]}let n=eY([],i,t);
8if(1e-15>eL(n))return null;let o=Math.atan2(-n[1],n[0]);return gF(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),o)}class gk{constructor(t,i){this.position=t,this.orientation=i}get position(){return this._position}set position(t){if(t){let i=t instanceof s8?t:new s8(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=tF(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i,r){if(this.orientation=null,!this.position)return;let a=this.position,n=r||(this._elevation?this._elevation.getAtPointOrZero(s8.fromLngLat(t)):0),o=s8.fromLngLat(t,n),s=[o.x-a.x,o.y-a.y,o.z-a.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=gB(s,i)}setPitchBearing(t,i){this.orientation=gF(t*tA,-i*tA)}}class gN{constructor(t,i){this._transform=ef([]),this.orientation=i,this.position=t}get mercatorPosition(){let t=this.position;return new s8(t[0],t[1],t[2])}get position(){let t=t4(this._transform,3);return[t[0],t[1],t[2]]}set position(t){t&&t5(this._transform,3,[t[0],t[1],t[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||te([]),t&&gO(this._transform,this._orientation)}getPitchBearing(){let t=this.forward(),i=this.right();return{bearing:Math.atan2(-i[1],i[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,i){this._orientation=gF(t,i),gO(this._transform,this._orientation)}forward(){let t=t4(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){let t=t4(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){let t=t4(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){let r=new Float64Array(16);return em(r,this.getWorldToCamera(t,i)),r}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,r){let a=this.position;ej(a,a,-t);let n=new Float64Array(16);return eE(n,[r,r,r]),ey(n,n,a),n[10]*=i,n}getWorldToCamera(t,i){var r;let a=new Float64Array(16),n=new Float64Array(4),o=this.position;return n[0]=-(r=this._orientation)[0],n[1]=-r[1],n[2]=-r[2],n[3]=r[3],ej(o,o,-t),eM(a,n),ey(a,a,o),a[1]*=-1,a[5]*=-1,a[9]*=-1,a[13]*=-1,a[8]*=i,a[9]*=i,a[10]*=i,a[11]*=i,a}getCameraToClipPerspective(t,i,r,a){let n=new Float64Array(16);return eR(n,t,i,r,a),n}getCameraToClipOrthographic(t,i,r,a,n,o){let s=new Float64Array(16);return eD(s,t,i,r,a,n,o),s}getDistanceToElevation(t,i=!1){let r=0===t?0:t/s2(i?aF(this.position[1]):this.position[1]),a=this.forward();return(r-this.position[2])/a[2]}clone(){return new gN([...this.position],[...this.orientation])}}let gV=Math.tan(85*Math.PI/180);function gU(t,i,r,a,n,o,s){let l=ec();if(r)if("globe"===o.name){let t=function(t,i){let{x:r,y:a}=t.point,n=cB(r,a,t.worldSize/t._pixelsPerMercatorPixel,0,0);return eg(n,n,cL(cT(i)))}(n,i);eg(l,l,t)}else{let t=en([],s);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],a||ew(l,l,n.angle)}else eg(l,n.labelPlaneMatrix,t);return l}function gj(t,i,r,a,n,o,s){let l=gU(t,i,r,a,n,o,s);return"globe"===o.name&&r||(l[2]=l[6]=l[10]=l[14]=0),l}function gG(t,i,r,a,n,o,s){if(r){if("globe"===o.name){let l=gU(t,i,r,a,n,o,s);return em(l,l),eg(l,t,l),l}{let i=ed(t),[r,o,l,h]=s,[u,c,d,p,f,_,m,g]=i;return i[0]=r*u+o*f,i[1]=r*c+o*_,i[2]=r*d+o*m,i[3]=r*p+o*g,i[4]=l*u+h*f,i[5]=l*c+h*_,i[6]=l*d+h*m,i[7]=l*p+h*g,a||ew(i,i,-n.angle),i}}return n.glCoordMatrix}function gH(t,i,r,a){let n=[t,i,r,1];r?e9(n,n,a):g0(n,n,a);let o=n[3];return n[0]/=o,n[1]/=o,n[2]/=o,n}function gq(t,i){return Math.min(.5+t/i*.5,1.5)}function gZ(t,i,r,a,n,o,s,l,h,u,c=1){let d=r.transform,p=a?t.textSizeData:t.iconSizeData,f=uk(p,r.transform.zoom,c),_="globe"===d.projection.name,m=[256/r.width*2+1,256/r.height*2+1],g=a?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let y=null;_&&(y=a?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);let x=t.lineVertexArray,v=a?t.text.placedSymbolArray:t.icon.placedSymbolArray,b=r.transform.width/r.transform.height,w,T=!1;for(let c=0;c<v.length;c++){let _=v.get(c),{numGlyphs:E,writingMode:S}=_;if(S!==uL.vertical||T||w===uL.horizontal||(T=!0),w=S,(_.hidden||S===uL.vertical)&&!T){gJ(E,g);continue}T=!1;let I=new tg(_.tileAnchorX,_.tileAnchorY),A="road"===t.elevationType,C=!!d.elevation||A,{x:M,y:R,z:D}=d.projection.projectTilePoint(I.x,I.y,u.canonical),P=null;if(C){let i=A&&t.hdExt?t.hdExt.getElevationFeatureForPlacedSymbol(t,a?t.text:t.icon,
8c):null;P={getElevation:h,elevation:d.elevation,elevationFeature:i};let[r,n,o]=h(I,d.elevation,i);M+=r,R+=n,D+=o}let z=[M,R,D,1];if(e9(z,z,i),!function(t,i){let r=t[0]/t[3],a=t[1]/t[3];return r>=-i[0]&&r<=i[0]&&a>=-i[1]&&a<=i[1]}(z,m)){gJ(E,g);continue}let L=z[3],O=gq(r.transform.getCameraToCenterDistance(d.projection),L),F=uB(p,f,_),B=s?F/O:F*O,k=gH(M,R,D,n);if(k[3]<=0){gJ(E,g);continue}let N={},V=Math.cos(t.layers[0].layout.get("text-max-angle")*tA),U=s?null:P,j=gX(_,B,!1,l,i,n,o,t.glyphOffsetArray,x,g,y,k,I,N,b,U,d.projection,u,s,V);T=j.useVertical,U&&j.needsFlipping&&(N={}),(j.notEnoughRoom||T||j.needsFlipping&&gX(_,B,!0,l,i,n,o,t.glyphOffsetArray,x,g,y,k,I,N,b,U,d.projection,u,s,V).notEnoughRoom)&&gJ(E,g)}a?(t.text.dynamicLayoutVertexBuffer.updateData(g),y&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(y)):(t.icon.dynamicLayoutVertexBuffer.updateData(g),y&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(y))}function g$(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g){let{lineStartIndex:y,glyphStartIndex:x,segment:v}=l,b=x+l.numGlyphs,w=y+l.lineLength,T=i.getoffsetX(x),E=i.getoffsetX(b-1),S=gQ(t*T,r,a,n,o,s,v,y,w,h,u,c,d,p,!0,f,_,m,g);if(!S)return null;let I=gQ(t*E,r,a,n,o,s,v,y,w,h,u,c,d,p,!0,f,_,m,g);return I?{first:S,last:I}:null}function gW(t,i,r,a){return t===uL.horizontal&&Math.abs(a)>Math.abs(r)?{useVertical:!0}:t===uL.vertical?a>0?{needsFlipping:!0}:null:0!==i&&(0===r||Math.abs(a/r)>gV)?1===i?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function gX(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v){let b=i/24,w=t.lineOffsetX*b,T=t.lineOffsetY*b,{lineStartIndex:E,glyphStartIndex:S,numGlyphs:I,segment:A,writingMode:C,flipState:M}=t,R=E+t.lineLength,D=t=>{if(c){let[i,r,a]=t.up,n=u.length;dz(c,n+0,i,r,a),dz(c,n+1,i,r,a),dz(c,n+2,i,r,a),dz(c,n+3,i,r,a)}let[i,r,a]=t.point;dL(u,i,r,a,t.angle)};if(I>1){let i=g$(b,l,w,T,r,d,p,t,h,o,f,m,!1,g,y,x,v);if(!i)return{notEnoughRoom:!0};if(a&&!r){let[r,a,n]=i.first.point,[o,l,h]=i.last.point;[r,a]=gH(r,a,n,s),[o,l]=gH(o,l,h,s);let u=gW(C,M,(o-r)*_,l-a);if(t.flipState=u&&u.needsFlipping?1:2,u)return u}D(i.first);for(let t=S+1;t<S+I-1;t++){let i=gQ(b*l.getoffsetX(t),w,T,r,d,p,A,E,R,h,o,f,m,!1,!1,g,y,x,v);if(!i)return u.length-=4*(t-S),{notEnoughRoom:!0};D(i)}D(i.last)}else{if(a&&!r){let i=gH(p.x,p.y,0,n),r=E+A+1,a=new tg(h.getx(r),h.gety(r)),o=gH(a.x,a.y,0,n),s=o[3]>0?o:gK(p,a,i,1,n,void 0,g,y.canonical),l=gW(C,M,(s[0]-i[0])*_,s[1]-i[1]);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}let i=gQ(b*l.getoffsetX(S),w,T,r,d,p,A,E,R,h,o,f,m,!1,!1,g,y,x,v);if(!i)return{notEnoughRoom:!0};D(i)}return{}}function gY(t,i,r,a,n){let{x:o,y:s,z:l}=a.projectTilePoint(t.x,t.y,i);if(!n)return gH(o,s,l,r);let[h,u,c]=n.getElevation(t,n.elevation,n.elevationFeature);return gH(o+h,s+u,l+c,r)}function gK(t,i,r,a,n,o,s,l){let h=gY(t.sub(i)._unit()._add(t),l,n,s,o);return ek(h,r,h),eW(h,h),eG(h,r,h,a)}function gQ(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x){let v=a?t-i:t+i,b=v>0?1:-1,w=0;a&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=l+s+(b>0?0:1)|0,E=n,S=n,I=0,A=0,C=Math.abs(v),M=[],R=[],D=o,P=D,z=e1([]),L=()=>gK(P,D,S,C-I+1,c,p,m,g.canonical);for(;I+A<=C;){if((T+=b)<l||T>=h)return null;if(S=E,P=D,M.push(S),f&&R.push(P),D=new tg(u.getx(T),u.gety(T)),!(E=d[T])){let t=gY(D,g.canonical,c,m,p);E=t[3]>0?d[T]=t:L()}I+=A;let t=ek([],E,S),i=eH(S,E);if(r&&i>0&&A>0&&eX(z,t)/(A*i)<x)return null;A=i,z=t}_&&p&&(d[T]&&(E=L(),A=eH(S,E),z=ek([],E,S)),d[T]=E);let O=(C-I)/A,F=D.sub(P)._mult(O)._add(P),B=eG([],S,z,O),k=[0,0,1],N=z[0],V=z[1];if(y&&(0!==(k=m.upVector(g.canonical,F.x,F.y))[0]||0!==k[1]||1!==k[2])){let t=[k[2],0,-k[0]],i=eY([],k,t);eW(t,t),eW(i,i),N=eX(z,t),V=eX(z,i)}if(r){let t=eY([],k,z);eW(t,t),eG(B,B,t,r*b)}let U=w+Math.atan2(V,N);return M.push(B),f&&R.push(F),{point:B,angle:U,path:M,tilePath:R,up:k}}function gJ(t,i){let r=i.length,a=r+4*t;i.resize(a),i.float32.fill(-1/0,4*r,4*a)}function g0(t,i,r){let a=i[0],n=i[1];return t[0]=r[0]*a+r[4]*n+r[12],t[1]=r[1]*a+r[5]*n+r[13],t[3]=r[3]*a+r[7]*n+r[15],t}class g1{constructor(t,i,r,a,n,o,s){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=r??0,this._maxPitch=a??60,this.setProjection(o),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new s0(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 gL,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new gN,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1,this.mercatorMatrix=new Float64Array(16),this.mercatorFogMatrix=new Float32Array(16),this.invProjMatrix=new Float64Array(16),this._expandedFarZProjMatrixBuf=new Float64Array(16),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf,this.starsProjMatrix=new Float32Array(16),this.skyboxMatrix=new Float32Array(16),this._mat4Scratch=new Float64Array(16),this.alignedProjMatrix=new Float64Array(16),this.labelPlaneMatr
8ix=new Float32Array(16),this.glCoordMatrix=new Float32Array(16),this.pixelMatrix=new Float64Array(16),this.pixelMatrixInverse=new Float64Array(16)}clone(){let t=new g1(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.mercatorFromTransition=this.mercatorFromTransition,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._nearClipOffset=this._nearClipOffset,t._averageElevation=this._averageElevation,t._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t._allowWorldUnderZoom=this._allowWorldUnderZoom,t}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(t){this._nearClipOffset=t,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(t,i=!1){let r=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForE
8xaggeration;(null==this._seaLevelZoom||r)&&this._updateCameraOnTerrain(),(t||r)&&this._constrainCamera(i),this._calcMatrices()}getProjection(){return tk(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};let i=this.projection?this.getProjection():void 0;this.projection=df(this.projectionOptions);let r=!ty(i,this.getProjection());return r&&this._calcMatrices(),this.mercatorFromTransition=!1,r}setOrthographicProjectionAtLowPitch(t){return this._orthographicProjectionAtLowPitch!==t&&(this._orthographicProjectionAtLowPitch=t,this._calcMatrices(),!0)}setMercatorFromTransition(){let t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=df({name:"mercator"});let i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){let t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get cameraWorldSize(){let t=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return 1/s2(this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new tg(this.width,this.height)}get bearing(){return tF(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(t){let i=-t*Math.PI/180;if(this.angle===i)return;this._unmodified=!1,this.angle=i,this._calcMatrices();let r=Math.sin(this.angle),a=Math.cos(this.angle);this.rotationMatrix=[a,r,-r,a]}get pitch(){return this._pitch/Math.PI*180}set pitch(t){let i=tL(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t*tA,this._calcMatrices())}get fovX(){return this._fov}get fovY(){let t=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/t)}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){let i=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==i&&(this._unmodified=!1,this._setZoom(i),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(t){this._tileCoverLift!==t&&(this._tileCoverLift=t)}_updateCameraOnTerrain(){let t=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),-1/0):-1/0,i=this.elevation&&t===-1/0&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>
80&&this._centerAltitudeValidForExaggeration;if(!this._elevation||t===-1/0&&(!i||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);let r=this._elevation;i||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&r.exaggeration()&&this._centerAltitudeValidForExaggeration!==r.exaggeration()?this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*r.exaggeration():this._centerAltitude=t||0,this._centerAltitudeValidForExaggeration=r.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(void 0===this._centerAltitudeValidForExaggeration)return;let t=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(t)}sampleAverageElevation(){if(!this._elevation)return 0;let t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop(),a=0,n=0;for(let o=0;o<i.length;o++){let s=new tg(i[o][0]*this.width,r+i[o][1]*(this.height-r)),l=t.pointCoordinate(s);if(!l)continue;let h=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);a+=l[3]*h,n+=h}return 0===n?NaN:a/n}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;let t=this._seaLevelZoom,i=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),r=this.pixelsPerMeter/this.worldSize*i,a=Math.max(this._mercatorZfromZoom(t)-r,this._mercatorZfromZoom(this._maxZoom));this._setZoom(this._zoomFromMercatorZ(a))}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}equals(t){let i=this.elevation,r=t.elevation,a=null!=i!=(null!=r)||i&&r&&i.exaggeration()!==r.exaggeration();return this.width===t.width&&this.height===t.height&&this.center.lng===t.center.lng&&this.center.lat===t.center.lat&&this.zoom===t.zoom&&this.bearing===t.bearing&&this.pitch===t.pitch&&this.fov===t.fov&&this.projection.name===t.projection.name&&this._edgeInsets.equals(t.padding)&&!a}computeZoomRelativeTo(t){let i,r=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));i=t.z<this._camera.position[2]?[r.x,r.y,r.z]:[t.x,t.y,t.z];let a=eL(ek([],this._camera.position,i));return tL(this._zoomFromMercatorZ(a),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){var i,r;if(!this.height||!t.position&&!t.orientation)return;this._updateCameraState();let a=!1;if(t.orientation&&((i=t.orientation)[0]!==(r=this._camera.orientation)[0]||i[1]!==r[1]||i[2]!==r[2]||i[3]!==r[3])&&(a=this._setCameraOrientation(t.orientation)),t.position){let i=[t.position.x,t.position.y,t.position.z];e2(i,this._camera.position)||(this._setCameraPosition(i),a=!0)}a&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();let t=this._camera.position,i=new gk;return i.position=new s8(t[0],t[1],t[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this.renderWorldCopies,i}_setCameraOrientation(t){var i,r,a,n;if(i=t[0],r=t[1],!Math.sqrt(i*i+r*r+(a=t[2])*a+(n=t[3])*n))return!1;e8(t,t);let o=e0([],[0,0,-1],t),s=e0([],[0,-1,0],t);if(s[2]<0)return!1;let l=gB(o,s);return!!l&&(this._camera.orientation=l,!0)}_setCameraPosition(t){let i=this.zoomScale(this.minZoom)*this.tileSize,r=this.zoomScale(this.maxZoom)*this.tileSize,a=this.cameraToCenterDistance;t[2]=tL(t[2],a/r,a/i),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,i,r){this._unmodified=!1,this._edgeInsets.interpolate(t,i,r),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){return Math.max(0,(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize)))}getVisibleUnwrappedCoordinates(t){let i=[new cJ(0,t)];if(this.renderWorldCopies){let r=this.pointCoordinate(new tg(0,0)),a=this.pointCoordinate(new tg(this.width,0)),n=this.pointCoordinate(new tg(this.width,this.height)),o=this.pointCoordinate(new tg(0,this.height)),s=Math.floor(Math.min(r.x,a.x,n.x,o.x)),l=Math.floor(Math.max(r.x,a.x,n.x,o.x));for(let r=s-1;r<=l+1;r++)0!==r&&i.push(new cJ(r,t))}return i}isLODDisabled(t){return(!t||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}
8extendTileCover(t,i,r,a){let n=[],o=null!=r,s=!o;if(s&&this.zoom<i||o&&0===r[0]&&0===r[1])return n;let l=new Set,h=(t,i,r,a,o)=>{let s=c1(i,t,r,a,o);l.has(s)||(n.push(new c0(t,i,r,a,o)),l.add(s))};for(let n=0;n<t.length;n++){let l=t[n];if(s&&l.canonical.z!==i||o&&void 0!==a&&a>l.canonical.z)continue;let u=l.canonical,c=l.overscaledZ,d=l.wrap,p=1<<u.z,f=u.x+1<p,_=u.x>0,m=u.y+1<p,g=u.y>0,y=l.wrap-!_,x=l.wrap+ +!f,v=_?u.x-1:p-1,b=f?u.x+1:0;if(o)r[0]<0?(h(c,x,u.z,b,u.y),r[1]<0&&m&&(h(c,d,u.z,u.x,u.y+1),h(c,x,u.z,b,u.y+1)),r[1]>0&&g&&(h(c,d,u.z,u.x,u.y-1),h(c,x,u.z,b,u.y-1))):r[0]>0?(h(c,y,u.z,v,u.y),r[1]<0&&m&&(h(c,d,u.z,u.x,u.y+1),h(c,y,u.z,v,u.y+1)),r[1]>0&&g&&(h(c,d,u.z,u.x,u.y-1),h(c,y,u.z,v,u.y-1))):r[1]<0&&m?h(c,d,u.z,u.x,u.y+1):g&&h(c,d,u.z,u.x,u.y-1);else{let t=l.visibleQuadrants;1&t&&(h(c,y,u.z,v,u.y),g&&(h(c,d,u.z,u.x,u.y-1),h(c,y,u.z,v,u.y-1))),2&t&&(h(c,x,u.z,b,u.y),g&&(h(c,d,u.z,u.x,u.y-1),h(c,x,u.z,b,u.y-1))),4&t&&(h(c,y,u.z,v,u.y),m&&(h(c,d,u.z,u.x,u.y+1),h(c,y,u.z,v,u.y+1))),8&t&&(h(c,x,u.z,b,u.y),m&&(h(c,d,u.z,u.x,u.y+1),h(c,x,u.z,b,u.y+1)))}}let u=[];for(let t of n)n.some(i=>t.isChildOf(i))||u.push(t);if(n=u.filter(r=>!t.some(t=>!!(r.overscaledZ<i&&t.isChildOf(r))||r.equals(t)||r.isChildOf(t))),s){let t=1<<i,r="globe"===this.projection.name?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),a=[t*r.x,t*r.y];n=n.filter(t=>{let i=t.canonical.x+.5-a[0],r=t.canonical.y+.5-a[1];return i*i+r*r<16})}return n}extendTileCoverToNearPlane(t,i,r){let a=[],n=new Set;for(let i of t)n.add(i.key);let o=(t,i,r,o,s)=>{let l=c1(i,t,r,o,s);n.has(l)||(a.push(new c0(t,i,r,o,s)),n.add(l))},s=t.reduce((t,i)=>Math.max(t,i.overscaledZ),r),l=1<<r,h=[new tg(0,0),new tg(8192,0),new tg(8192,8192),new tg(0,8192)],u=new tg(0,0),c=new tg(0,0),d=(t,i)=>{let a=Math.floor(t[0]),n=Math.floor(t[1]),d=(t[0]-a)*8192,p=(t[1]-n)*8192,f=Math.floor(i[0]),_=Math.floor(i[1]),m=(i[0]-f)*8192,g=(i[1]-_)*8192;for(let t=-1;t<=1;t++){let i=a+t;if(!(i<0||i>=l)){u.x=d-8192*t,c.x=m-(i-f)*8192;for(let t=-1;t<=1;t++){let a=n+t;u.y=p-8192*t,c.y=g-(a-_)*8192,hY(u,c,h)&&o(s,0,r,i,a)}}}},p=i.points,f=p[3],_=p[2],m=this._projectToGround(f,p[7]),g=this._projectToGround(_,p[6]);return d(f,m),d(_,g),a}_projectToGround(t,i){return eK(eP(),t,i,t[2]/(t[2]-i[2]))}_projectToZ(t,i,r){let a=t[2]-i[2];return 1e-6>Math.abs(a)?ez(t):eK(eP(),t,i,(t[2]-r)/a)}extendTileCoverForTunnels(t,i,r,a){if(r<18)return[];let n=i.points,o=n[0],s=n[1],l=n[4],h=n[5];if(l[2]>=0&&h[2]>=0||o[2]<=0||s[2]<=0)return[];let u=l[2]<0?this._projectToZ(o,l,0):l,c=h[2]<0?this._projectToZ(s,h,0):h,d=-a,p=l[2]<d?this._projectToZ(o,l,d):l,f=h[2]<d?this._projectToZ(s,h,d):h,_=this._findExtensionTilesInQuad(t,r,[f,p,c,u],[.5*(u[0]+c[0]),.5*(u[1]+c[1])]);return _.length>3&&(_.length=3),_}_findExtensionTilesInQuad(t,i,r,a){let n=[],o=new Set;for(let i of t)o.add(i.key);let s=t.reduce((t,i)=>Math.max(t,i.overscaledZ),i),l=1<<i,h=[new tg(r[0][0],r[0][1]),new tg(r[1][0],r[1][1]),new tg(r[3][0],r[3][1]),new tg(r[2][0],r[2][1]),new tg(r[0][0],r[0][1])],u=r[0][0],c=r[1][0],d=r[2][0],p=r[3][0],f=r[0][1],_=r[1][1],m=r[2][1],g=r[3][1],y=Math.max(0,Math.floor(Math.min(u,c,d,p))),x=Math.min(l-1,Math.ceil(Math.max(u,c,d,p))-1),v=Math.max(0,Math.floor(Math.min(f,_,m,g))),b=Math.min(l-1,Math.ceil(Math.max(f,_,m,g))-1);for(let t=v;t<=b;t++)for(let r=y;r<=x;r++){if(!hX(h,r,t,r+1,t+1))continue;let a=c1(0,s,i,r,t);o.has(a)||(n.push(new c0(s,0,i,r,t)),o.add(a))}let w=a[0],T=a[1];return n.sort((t,i)=>{let r=t.canonical.x+.5-w,a=t.canonical.y+.5-T,n=i.canonical.x+.5-w,o=i.canonical.y+.5-T;return r*r+a*a-(n*n+o*o)||t.canonical.x-i.canonical.x||t.canonical.y-i.canonical.y}),n}coveringTiles(t){let i,r=this.coveringZoomLevel(t),a=r,n=this.elevation&&this.elevation.exaggeration(),o=n&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&r<t.minzoom)return[];void 0!==t.maxzoom&&r>t.maxzoom&&(r=t.maxzoom);let l=this.locationCoordinate(this.center),h=this.center.lat,u=1<<r,c=[u*l.x,u*l.y,0],d="globe"===this.projection.name,p=!d,f=cm.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r,p),_=d?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),m=u*(1/s2(this.center.lat)),g=this._camera.position[2]/(1/s2(this.center.lat)),y=[u*_.x,u*_.y,g*(p?1:m)],x=d||n,v=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),b=this.isLODDisabled(!0)?r:0;if(this._elevation&&t.isTerrainDEM)i=1e4*this._elevation.exaggeration();else if(this._elevation){let t=this._elevation.getMinMaxForVisibleTiles();i=t?t.max:this._centerAltitude}else i=this._centerAltitude;let w=t.isTerrainDEM?-i:this._elevation?this._elevation.getMinElevationBelowMSL():0,T=this.projection.isReprojectedInTileSpace?pK(this):1,E=t=>{let i=1/4e4,r=new s8(t.x+i,t.y,t.z),a=new s8(t.x,t.y+i,t.z),n=t.toLngLat(),o=r.toLngLat(),s=a.toLngLat(),l=this.locationCoordinate(n),h=this.locationCoordinate(o),u=this.locationCoordinate(s);return Math.sqrt(Math.hypot(h.x-l.x,h.y-l.y)*Math.hypot(u.x-l.x,u.y-l.y))*T/i},S=t=>{let r=i;return{aabb:c4(this,u,0,0,0,t,w,r,this.projection),zoom:0,x:0,y:0,minZ:w,maxZ:r,wrap:t,fullyVisible:!1}},I=[],A=[],C=r,M=t.reparseOverscaled?a:r,R=(g-this._centerAltitude)*m,D=t=>{if(!this._elevation||!t.tileID||!s)return;let i=this._elevation.getMinMaxForTile(t.tileID),r=t.aabb;i?(r.min[2]=i.min,r.max[2]=i.max,r.center[2]=(r.min[2]+r.max[2])/2):(t.shouldSplit=z(t),t.shouldSplit||(r.min[2]=r.max[2]=r.center[2]=this._centerAltitude))},P=(t,i)=>{if(.707*i<t)return 1;let r=i/t;return r/(1.4144271570014144+(Math.pow(1.1,r-1.4144271570014144+1)-1)/(1.1-1)-1)},z=t=>{if(t.zoom<b)return!0;
8if(t.zoom===C)return!1;if(null!=t.shouldSplit)return t.shouldSplit;let i=t.aabb.distanceX(y),r=t.aabb.distanceY(y),n=R,l=1;if(d){n=t.aabb.distanceZ(y);let i=Math.pow(2,t.zoom),r=Math.min(Math.max(h,aF((t.y+1)/i)),aF(t.y/i)),a=s2(r)/s2(h);if(l=r===h?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,a/this._mercatorScaleRatio),this.zoom<=5&&t.zoom===C-1&&a>=.9)return!0}else if(o&&(n=t.aabb.distanceZ(y)*m),this.projection.isReprojectedInTileSpace&&a<=5){let i=Math.pow(2,t.zoom),r=E(new s8((t.x+.5)/i,(t.y+.5)/i));l=r>.85?1:r}if(!s&&!d){let a=Math.sqrt(i*i+r*r+n*n),o=(1<<C-t.zoom)*v*l;return o*=P(Math.max(n,R),a),a<o}let u=Number.MAX_VALUE,p=0,f=t.aabb.getCorners(),_=[0,0,0];for(let t of f){ek(_,t,y),d||(o?_[2]*=m:_[2]=R);let i=eX(_,this._camera.forward());i<u&&(u=i,p=Math.abs(_[2]))}let g=(1<<C-t.zoom)*v*l;if(g*=P(Math.max(p,R),u),u<g)return!0;let x=t.aabb.closestPoint(c);return x[0]===c[0]&&x[1]===c[1]};if(this.renderWorldCopies)for(let t=1;t<=3;t++)I.push(S(-t)),I.push(S(t));for(I.push(S(0));I.length>0;){let i=I.pop(),a=i.x,n=i.y,l=i.fullyVisible,h=()=>"globe"===this.projection.name&&(0===i.y||i.y===(1<<i.zoom)-1);if(!l){let t=x?i.aabb.intersects(f):i.aabb.intersectsFlat(f);if(0===t&&h()&&(t=cA(this,u,new cQ(i.zoom,a,n),!0).intersects(f)),0===t)continue;l=2===t}if(i.zoom===C||!z(i)){let o=i.zoom===C?M:i.zoom;if(t.minzoom&&t.minzoom>o)continue;let s=0;if(!l){let r=x?i.aabb.intersectsPrecise(f):i.aabb.intersectsPreciseFlat(f);if(0===r&&h()&&(r=cA(this,u,new cQ(i.zoom,a,n),!0).intersectsPrecise(f)),0===r)continue;if(t.calculateQuadrantVisibility)if(f.containsPoint(i.aabb.center))s=15;else for(let t=0;t<4;t++)0!==i.aabb.quadrant(t).intersects(f)&&(s|=1<<t)}let d=c[0]-(.5+a+(i.wrap<<i.zoom))*(1<<r-i.zoom),p=c[1]-.5-n,_=i.tileID?i.tileID:new c0(o,i.wrap,i.zoom,a,n);t.calculateQuadrantVisibility&&(_.visibleQuadrants=s),A.push({tileID:_,distanceSq:d*d+p*p});continue}for(let t=0;t<4;t++){let r=(a<<1)+t%2,h=(n<<1)+(t>>1),c={aabb:s?i.aabb.quadrant(t):c4(this,u,i.zoom+1,r,h,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:r,y:h,wrap:i.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};o&&!d&&(c.tileID=new c0(i.zoom+1===C?M:i.zoom+1,i.wrap,i.zoom+1,r,h),D(c)),I.push(c)}}if(this.fogCullDistSq){let r=this.fogCullDistSq,a=this.horizonLineFromTop();A=A.filter(n=>{var o,s;let l=[0,0,0,1],h=[8192,8192,0,1],u=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e9(l,l,u),e9(h,h,u);let c=function(t,i){let r=0;for(let a=0;a<2;++a)t[a]>0&&(r+=(t[a]-0)*(t[a]-0)),i[a]<0&&(r+=(0-i[a])*(0-i[a]));return r}(((o=[])[0]=Math.min(l[0],h[0]),o[1]=Math.min(l[1],h[1]),o[2]=Math.min(l[2],h[2]),o[3]=Math.min(l[3],h[3]),o),((s=[])[0]=Math.max(l[0],h[0]),s[1]=Math.max(l[1],h[1]),s[2]=Math.max(l[2],h[2]),s[3]=Math.max(l[3],h[3]),s));if(0===c)return!0;let d=!1,p=this._elevation;if(p&&c>r&&0!==a){let r,o=this.calculateProjMatrix(n.tileID.toUnwrapped());t.isTerrainDEM||(r=p.getMinMaxForTile(n.tileID)),r||(r={min:w,max:i});let s=tR[Math.round((this.rotation+45+360)%360/90)%4],l=[8192*s[0],8192*s[1],r.max];eQ(l,l,o),d=(1-l[1])*this.height*.5<a}return c<r||d})}return A.sort((t,i)=>t.distanceSq-i.distanceSq).map(t=>t.tileID)}resize(t,i){this.width=t,this.height=i,this.pixelsToGLUnits=[2/t,-2/i],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log2(t)}project(t){let i=tL(t.lat,-85.051129,85.051129),r=this.projection.project(t.lng,i);return new tg(r.x*this.worldSize,r.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/(1/s2(this.center.lat))/this.worldSize}setLocationAtPoint(t,i){let r,a,n=this.centerPoint;if("globe"===this.projection.name){let t=this.worldSize;r=(i.x-n.x)/t,a=(i.y-n.y)/t}else{let t=this.pointCoordinate(i),o=this.pointCoordinate(n);r=t.x-o.x,a=t.y-o.y}let o=this.locationCoordinate(t);this.setLocation(new s8(o.x-r,o.y-a))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t,i){return this.projection.locationPoint(this,t,i)}locationPoint3D(t,i){return this.projection.locationPoint(this,t,i,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t,i){return this.coordinateLocation(this.pointCoordinate3D(t,i))}locationCoordinate(t,i){let r=i?i/s2(t.lat):void 0,a=this.projection.project(t.lng,t.lat);return new s8(a.x,a.y,r)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(t,i){let r=null!=i?i:this._centerAltitude,a=[t.x,t.y,0,1],n=[t.x,t.y,1,1];e9(a,a,this.pixelMatrixInverse),e9(n,n,this.pixelMatrixInverse);let o=n[3];e6(a,a,1/a[3]),e6(n,n,1/o);let s=a[2],l=n[2];return{p0:a,p1:n,t:s===l?0:(r-s)/(l-s)}}screenPointToMercatorRay(t){let i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e9(i,i,this.pixelMatrixInverse),e9(r,r,this.pixelMatrixInverse),e6(i,i,1/i[3]),e6(r,r,1/r[3]),i[2]=i[2]/s2(this._center.lat)*this.worldSize,r[2]=r[2]/s2(this._center.lat)*this.worldSize,e6(i,i,1/this.worldSize),e6(r,r,1/this.worldSize),new ch([i[0],i[1],i[2]],eW([],ek([],r,i)))}rayIntersectionCoordinate(t){let{p0:i,p1:r,t:a}=t,n=i[2]/s2(this._center.lat),o=r[2]/s2(this._center.lat);return new s8(rG(i[0],r[0],a)/this.worldSize,rG(i[1],r[1],a)/this.worldSize,rG(n,o,a))}pointCoordinate(t,i=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,i)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let r=this.projection.pointCoordinate3D(this,t.x,t.y);if(r)return new s8(r[0],r[1],r[2]);let a=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t,i);let o=.02*n,s=t.clone();for(let t=0;t<10&&n-a>o;t++){s.y=rG(a,n,.66);let t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(n=s.y,r=t):a=s.y}return r?new s8(r[0],r[1],r[2]):this.pointCoordinate(t)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=6)return!this.isPointAboveHorizon(t);let i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){let r=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,a=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e9(a,a,this.pixelMatrix),a[3]>0?new tg(a[0]/a[3],a[1]/a[3]):new tg(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){let{top:t,left:i}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,a=this.width-this._edgeInsets.right,n=this.pointLocation3D(new tg(i,t)),o=this.pointLocation3D(new tg(a,t)),s=this.pointLocation3D(new tg(a,r)),l=this.pointLocation3D(new tg(i,r)),h=Math.min(n.lng,o.lng,s.lng,l.lng),u=Math.max(n.lng,o.lng,s.lng,l.lng),c=Math.min(n.lat,o.lat,s.lat,l.lat),d=Math.max(n.lat,o.lat,s.lat,l.lat),p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,_=(t,i,r,a,n)=>
8{let o=(t+r)/2,s=(i+a)/2,l=new tg(o,s),{lng:m,lat:g}=this.pointLocation3D(l),y=Math.max(0,h-m,c-g,m-u,g-d);h=Math.min(h,m),u=Math.max(u,m),c=Math.min(c,g),d=Math.max(d,g),(n<f||y>p)&&(_(t,i,o,s,n+1),_(o,s,r,a,n+1))};if(_(i,t,a,t,1),_(a,t,a,r,1),_(a,r,i,r,1),_(i,r,i,t,1),"globe"===this.projection.name){let[t,i]=function(t){let i=ef(new Float64Array(16));eg(i,t.pixelMatrix,t.globeMatrix);let r=[0,sY,0],a=[0,sW,0];return eQ(r,r,i),eQ(a,a,i),[r[0]>0&&r[0]<=t.width&&r[1]>0&&r[1]<=t.height&&!cZ(t,new s0(t.center.lat,90)),a[0]>0&&a[0]<=t.width&&a[1]>0&&a[1]<=t.height&&!cZ(t,new s0(t.center.lat,-90))]}(this);t?(d=90,u=180,h=-180):i&&(c=-90,u=180,h=-180)}return new s1(new s0(h,c),new s0(u,d))}_getBoundsRectangular(t,i){let{top:r,left:a}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,s=new tg(a,r),l=new tg(o,r),h=new tg(o,n),u=new tg(a,n),c=this.pointCoordinate(s,t),d=this.pointCoordinate(l,t),p=this.pointCoordinate(h,i),f=this.pointCoordinate(u,i),_=(t,i)=>(i.y-t.y)/(i.x-t.x);return c.y>1&&d.y>=0?c=new s8((1-f.y)/_(f,c)+f.x,1):c.y<0&&d.y<=1&&(c=new s8(-f.y/_(f,c)+f.x,0)),d.y>1&&c.y>
8=0?d=new s8((1-p.y)/_(p,d)+p.x,1):d.y<0&&c.y<=1&&(d=new s8(-p.y/_(p,d)+p.x,0)),(new s1).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){let t=this.elevation;if(!t.visibleDemTiles.length||t.isUsingMockSource())return this._getBoundsRectangular(0,0);let i=t.visibleDemTiles.reduce((t,i)=>{if(i.dem){let r=i.dem.tree;t.min=Math.min(t.min,r.minimums[0]),t.max=Math.max(t.max,r.maximums[0])}return t},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(i.min*t.exaggeration(),i.max*t.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(t=!0){let i=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,r=this.height/2-i*(1-this._horizonShift);return t?Math.max(0,r):r}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-85.051129,this.maxLat=85.051129,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=az(this.minLng)*this.tileSize,this.worldMaxX=az(this.maxLng)*this.tileSize,this.worldMinY=aL(this.maxLat)*this.tileSize,this.worldMaxY=aL(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(t,i){return this.projection.createTileMatrix(this,i,t)}calculateDistanceTileData(t){let i=t.key,r=this._distanceTileDataCache;if(r[i])return r[i];let a=t.canonical,n=1/this.height,o=this.cameraWorldSize,s=o/this.zoomScale(a.z),l=(a.x+Math.pow(2,a.z)*t.wrap)*s,h=a.y*s,u=this.point;u.x*=o/this.worldSize,u.y*=o/this.worldSize;let c=this.angle,d=Math.sin(-c),p=-Math.cos(-c);return r[i]={bearing:[d,p],center:[(u.x-l)*n,(u.y-h)*n],scale:s/8192*n},r[i]}calculateFogTileMatrix(t){let i=t.key,r=this._fogTileMatrixCache;if(r[i])return r[i];let a=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return eg(a,this.worldToFogMatrix,a),r[i]=new Float32Array(a),r[i]}calculateProjMatrix(t,i=!1,r=!1){let a,n=t.key;if((a=r?this._expandedProjMatrixCache:i?this._alignedProjMatrixCache:this._projMatrixCache)[n])return a[n];let o=this.calculatePosMatrix(t,this.worldSize);return eg(o,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:r?this.expandedFarZProjMatrix:i?this.alignedProjMatrix:this.projMatrix,o),a[n]=new Float32Array(o),a[n]}calculatePixelsToTileUnitsMatrix(t){let i=t.tileID.key,r=this._pixelsToTileUnitsCache;if(r[i])return r[i];let a=function(t,i){let{scale:r}=t.tileTransform,a=8192*r/(t.tileSize*Math.pow(2,i.zoom-t.tileID.overscaledZ+t.tileID.canonical.z)),n=i.inverseAdjustmentMatrix;return new Float32Array([n[0]*a,n[1]*a,n[2]*a,n[3]*a])}(t,this);return r[i]=a,r[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){let t=1/this.worldSize,i=eE([],[t,t,t]);return eg(i,i,this.globeMatrix),i}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;let t=this._elevation;this._updateCameraState();let i=1/s2(this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),a=this._camera.forward(),n=1/s2(this._center.lat);r[2]/=n,a[2]/=n,eW(a,a);let o=t.raycast(r,a,t.exaggeration());if(o){let t=eG([],r,a,o),i=new s8(t[0],t[1],t[2]/s2(aF(t[1]))),s=(i.z+eL([i.x-r[0],i.y-r[1],i.z-r[2]*n]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(s),this._centerAltitude=i.toAltitude(),this._center=this.coordinateLocation(i),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(t=!1){if(!this._elevation)return;let i=this._elevation,r=1/s2(this._center.lat)*this.worldSize,a=this._computeCameraPosition(r),n=i.getAtPointOrZero(new s8(...a)),o=this.pixelsPerMeter/this.worldSize*n,s=this._minimumHeightOverTerrain(),l=a[2]-o;if(l<=s)if(l<0||t){let t=this.locationCoordinate(this._center,this._centerAltitude),i=[a[0],a[1],t.z-
8a[2]],r=eL(i);i[2]-=(s-l)/this._pixelsPerMercatorPixel;let n=eL(i);if(0===n)return;ej(i,i,r/n*this._pixelsPerMercatorPixel),this._camera.position=[a[0],a[1],t.z*this._pixelsPerMercatorPixel-i[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){let i=this.center;return i.lat=tL(i.lat,this.minLat,this.maxLat),!this.maxBounds&&(this.renderWorldCopies||t)||(i.lng=tL(i.lng,this.minLng,this.maxLng)),this.center=i,void(this._constraining=!1)}let i=this._unmodified,{x:r,y:a}=this.point,n=0,o=r,s=a,l=this.width/2,h=this.height/2,u=this.worldMinY*this.scale,c=this.worldMaxY*this.scale;if(a-h<u&&(s=u+h),a+h>c&&(s=c-h),c-u<this.height&&(n=Math.max(n,this.height/(c-u)),s=(c+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){let t=this.worldMinX*this.scale,i=this.worldMaxX*this.scale,a=this.worldSize/2-(t+i)/2;(o=(r+a+this.worldSize)%this.worldSize-a)-l<t&&(o=t+l),o+l>i&&(o=i-l),i-t<this.width&&(n=Math.max(n,this.width/(i-t)),o=(i+t)/2)}o===r&&s===a||this._allowWorldUnderZoom||(this.center=this.unproject(new tg(o,s))),n&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(n)),this._constrainCamera(),this._unmodified=i,this._constraining=!1}_minZoomForBounds(){let t=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(t=Math.max(t,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),t}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){let t;if(!this.height)return;let i=this.centerOffset,r="globe"===this.projection.name,a=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=1/s2(this.center.lat)/(1/s2(45)));let n=pQ(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,n),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;let o="meters"===this.projection.zAxisUnit?a:1,s=this._camera.getWorldToCamera(this.worldSize,o),l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=-(2*i.x)/this.width,l[9]=2*i.y/this.height,this.isOrthographic){let r=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),a=r*this.aspect,n=-a,o=-r;a-=i.x,n-=i.x,r+=i.y,o+=i.y,((t,i,r,a)=>{for(let n=0;n<16;n++)t[n]=rG(i[n],r[n],a)})(t=this._camera.getCameraToClipOrthographic(n,a,o,r,this._nearZ+this._nearClipOffset,this._farZ),t,l,ir(this.pitch>=15?1:this.pitch/15))}else t=l;let h=eg([],l,s),u=eg([],t,s);if(this.projection.isReprojectedInTileSpace){let t=this.locationCoordinate(this.center);ef(this._mat4Scratch);let i=this._mat4Scratch;ey(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),eg(i,i,pY(this)),ey(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),eg(u,u,i),eg(h,h,i),this.inverseAdjustmentMatrix=function(t){let i=pY(t,!0);return en([],[i[0],i[1],i[4],i[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(ex(this.mercatorMatrix,u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,em(this.invProjMatrix,this.projMatrix),r){let t=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);t[8]=-(2*i.x)/this.width,t[9]=2*i.y/this.height,eg(this._expandedFarZProjMatrixBuf,t,s),this.expandedFarZProjMatrix=this._expandedFarZProjMatrixBuf}else this.expandedFarZProjMatrix=this.projMatrix;em(this._mat4Scratch,t),this.frustumCorners=cu.fromInvProjectionMatrix(this._mat4Scratch,this.horizonLineFromTop(),this.height),this.cameraFrustum=cm.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!r),eE(this.skyboxMatrix,[1,-1,1]),ev(this.skyboxMatrix,this.skyboxMatrix,this._pitch),ew(this.skyboxMatrix,this.skyboxMatrix,this.angle),eR(this.starsProjMatrix,this._fov,this.width/this.height,this._nearZ,this._farZ);let c=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;ep(this._mat4Scratch,this.starsProjMatrix),this._mat4Scratch[8]=-(2*i.x)/this.width,this._mat4Scratch[9]=2*(i.y+c)/this.height,eg(this.skyboxMatrix,this._mat4Scratch,this.skyboxMatrix);let d=this.point,p=d.x,f=d.y,_=this.width%2/2,m=this.height%2/2,g=Math.cos(this.angle),y=Math.sin(this.angle),x=p-Math.round(p)+g*_+y*m,v=f-Math.round(f)+g*m+y*_;if(ep(this.alignedProjMatrix,u),ey(this.alignedProjMatrix,this.alignedProjMatrix,[x>.5?x-1:x,v>
8.5?v-1:v,0]),eE(this.labelPlaneMatrix,[this.width/2,-this.height/2,1]),ey(this.labelPlaneMatrix,this.labelPlaneMatrix,[1,-1,0]),eE(this.glCoordMatrix,[1,-1,1]),ey(this.glCoordMatrix,this.glCoordMatrix,[-1,-1,0]),ex(this.glCoordMatrix,this.glCoordMatrix,[2/this.width,2/this.height,1]),eg(this.pixelMatrix,this.labelPlaneMatrix,h),this._calcFogMatrices(),this._distanceTileDataCache={},!em(this.pixelMatrixInverse,this.pixelMatrix))throw Error("failed to invert matrix");if("globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(t){let{x:i,y:r}=t.point,{lng:a,lat:n}=t._center;return cB(i,r,t.worldSize,a,n)}(this);let t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=eQ(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=this.pixelMatrixInverse;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};let t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,r=this._camera.position,a=1/this.height/this._pixelsPerMercatorPixel,n=[t,t,i];ej(n,n,a),ej(r,r,-1),eN(r,r,n),eT(this.mercatorFogMatrix,r),ex(this.mercatorFogMatrix,this.mercatorFogMatrix,n),this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,a)}_computeCameraPosition(t){let i=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,r=this._camera.forward(),a=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*i-t/this.worldSize*this._centerAltitude;return[a.x/this.worldSize-r[0]*n,a.y/this.worldSize-r[1]*n,t/this.worldSize*this._centerAltitude-r[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){let i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],a=t[2],n=1;this.projection.wrap&&(this.center=this.center.wrap()),a>0&&(n=Math.min((i-r)/a,1)),this._camera.position=eG([],this._camera.position,t,n),this._updateStateFromCamera()}_updateStateFromCamera(){let t=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:a}=this._camera.getPitchBearing(),n=this._centerAltitude/s2(this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(this._maxPitch*tA),s=Math.max((t[2]-n)/Math.cos(r),o),l=this._zoomFromMercatorZ(s);eG(t,t,i,s),this._pitch=tL(r,this.minPitch*tA,this.maxPitch*tA),this.angle=tF(a,-Math.PI,Math.PI),this._setZoom(tL(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new s8(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){let t=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,t)*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,r=6,a=0,n=1/0;for(;r-i>1e-6&&r>i;){let o=i+.5*(r-i),s=this.tileSize*Math.pow(2,o),l=this.getCameraToCenterDistance(this.projection,o,s),h=this.scaleZoom(l/(Math.max(0,t)*this.tileSize)),u=Math.abs(o-h);u<n&&(n=u,a=o),o<h?i=o:r=o}return a}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(tX("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,i){let r=Math.min(t.x,i.x),a=Math.max(t.x,i.x),n=Math.min(t.y,i.y),o=Math.max(t.y,i.y);if(n<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;let s=[new tg(r,n),new tg(a,o),new tg(r,o),new tg(a,n)],l=this.renderWorldCopies?-3:0,h=this.renderWorldCopies?4:1;for(let t of s){let i=this.pointRayIntersection(t);if(i.t<0)return!0;let r=this.rayIntersectionCoordinate(i);if(r.x<l||r.y<0||r.x>h||r.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+this.fovAboveCenter*tC>88||this.anyCornerOffEdge(new tg(0,0),new tg(this.width,this.height))}zoomDeltaToMovement(t,i){let r=eL(ek([],this._camera.position,t)),a=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(a)}getCameraPoint(){if("globe"===this.projection.name){let t=function([t,i,r],a){let n=[t,i,r,1];e9(n,n,a);let o=n[3]=Math.max(n[3],1e-6);return n[0]/=o,n[1]/=o,n[2]/=o,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new tg(t[0],t[1])}{let t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new tg(0,t))}}getCameraToCenterDistance(t,i=this.zoom,r=this.worldSize){let a=pQ(t,i,this.width,this.height,1024),n=t.pixelSpaceConversion(this.center.lat,r,a),o=.5/Math.tan(.5*this._fov)*this.height*n;return this.isOrthographic&&(o=rG(1,o,ir(this.pitch>=15?1:this.pitch/15))),o}getWorldToCameraMatrix(){let t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&eg(t,t,this.globeMatrix),t}getFrustum(t){return cm.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}let g2=(t,i)=>{if(i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};let r=t.transform,a=r.pitch,n=r.isLODDisabled(!1)?60:30;if(a<n-15)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};let o=r._farZ-r._nearZ,s=i*r.height*1.3,l=Math.pow(2,.85*Math.max(r._zoom-t.minCutoffZoom,0)),h=1.4*r.cameraToCenterDistance*l,u=tO(n-15,n,a),c=rG(r._farZ+s,h,u),d=Math.min(s,c-r._nearZ);return{shouldRenderCutoff:u>0,uniformValues:{u_cutoff_params:[r._nearZ,r._farZ,(c-r._nearZ)/o,(c-d-r._nearZ)/o]}}};class g3{constructor(t,i,r,a,n,o){this.test=t,this.ref=i,this.mask=r,this.fail=a,this.depthFail=n,this.pass=o}}g3.disabled=new g3({func:519,mask:0},0,0,7680,7680,7680);let g4=new Float32Array(16);function g5(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b){let w=i.context,T=w.gl,E=i.transform,S=i.transform.zoom,I=[],A=t.translate,C=t.translateAnchor,M=t.edgeRadius,R=g2(i,t.cutoffFadeRange);"clear"===c?(I.push("CLEAR_SUBPASS"),v&&(I.push("CLEAR_FROM_TEXTURE"),w.activeTexture.set(T.TEXTURE0),v.bind(T.LINEAR,T.CLAMP_TO_EDGE))):"sdf"===c?I.push("SDF_SUBPASS"):"emissive"===c&&(I.push("USE_MRT1"),w.activeTexture.set(T.TEXTURE0),v.bind(T.LINEAR,T.CLAMP_TO_EDGE)),y&&I.push("HAS_CENTROID"),R.shouldRenderCutoff&&I.push("RENDER_CUTOFF");let D=(t,r,n,c,x)=>{let b=I;null!=r.groundRadiusBuffer&&(b=I.concat("HAS_ATTRIBUTE_a_flood_light_ground_radiu
8s"));let T=r.programConfigurations.get(a.id),E=i.isTileAffectedByFog(t),A=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:T,defines:b,overrideFog:E}),C={u_matrix:c,u_opacity:d,u_ao_pass:+!!u,u_meter_to_tile:x,u_ao:[p,f*x],u_flood_light_intensity:_,u_flood_light_color:m,u_attenuation:g,u_edge_radius:S>=17?0:M*x,u_fb:0,u_fb_size:v?v.size[0]:0,u_dynamic_offset:1},D=[];y&&D.push(r.hiddenByLandmarkVertexBuffer),null!=r.groundRadiusBuffer&&D.push(r.groundRadiusBuffer),i.uploadCommonUniforms(w,A,t.toUnwrapped(),null,R),A.draw(i,w.gl.TRIANGLES,o,s,l,h,C,a.id,r.vertexBuffer,r.indexBuffer,n,a.paint,S,T,D)};for(let t of n){let n=r.getTile(t),o=n.getBucket(a);if(!o||o.projection.name!==E.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;let s=o.groundEffect,l=1/o.tileToMeter;{let r=i.translatePosMatrix(t.projMatrix,n,A,C),a=s.getDefaultSegment();D(t,s,a,r,l)}if(x)for(let o=0;o<4;o++){let s,h,u=c2[o](t),c=r.getTile(u);if(!c)continue;let d=c.getBucket(a);if(!d||d.projection.name!==E.projection.name||!d.groundEffect||d.groundEffect&&!d.groundEffect.hasData())continue;let p=d.groundEffect;0===o?(s=[-8192,0,0],h=1):1===o?(s=[8192,0,0],h=0):2===o?(s=[0,-8192,0],h=3):(s=[0,8192,0],h=2);let f=p.regionSegments[h];f&&(ey(g4,t.projMatrix,s),D(t,p,f,i.translatePosMatrix(g4,n,A,C),l))}}}class g6{constructor(t,i,r,a){this.blendFunction=t,this.blendColor=i.toNonPremultipliedRenderColor(null),this.mask=r,this.blendEquation=a}}function g8(t,i,r=0){let a=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,t.transform.tileZoom)/a,o=n*(i.tileID.canonical.x+i.tileID.wrap*a),s=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/_S(i,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s],u_pattern_transition:r}}g6.Replace=[1,0,1,0],g6.disabled=new g6(g6.Replace,rq.transparent,[!1,!1,!1,!1]),g6.unblended=new g6(g6.Replace,rq.transparent,[!0,!0,!0,!0]),g6.alphaBlended=new g6([1,771,1,771],rq.transparent,[!0,!0,!0,!0]),g6.alphaBlendedNonPremultiplied=new g6([770,771,770,771],rq.transparent,[!0,!0,!0,!0]),g6.multiply=new g6([774,0,774,0],rq.transparent,[!0,!0,!0,!0]),g6.multiplyAccumulateAlpha=new g6([774,0,1,771],rq.transparent,[!0,!0,!0,!0]),g6.additive=new g6([1,1,1,1],rq.transparent,[!0,!0,!0,!0]),g6.additiveAlphaWeighted=new g6([770,1,773,1],rq.transparent,[!0,!0,!0,!0]),g6.additiveAlphaWeightedUnboundedAlpha=new g6([770,1,1,1],rq.transparent,[!0,!0,!0,!0]);let g9={terrain:0,flat:1},g7=ec(),ye=[0,0,0],yt=(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x=[0,0,1],v=!1)=>{let b=ye,w=0,T=ye;if(!v){let t=i.style.light,r=t.properties.get("position");if(b=[r.x,r.y,r.z],"viewport"===t.properties.get("anchor")){let t=eo();eu(t,-i.transform.angle),eJ(b,b,t)}let a=t.properties.get("color").toPremultipliedRenderColor(null);w=t.properties.get("intensity"),T=[a.r,a.g,a.b]}let E=i.transform,S={u_matrix:t,u_lightpos:b,u_lightintensity:w,u_lightcolor:T,u_vertical_gradient:+r,u_opacity:a,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:g7,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:g9[u],u_base_type:g9[c],u_ao:n,u_edge_radius:o,u_width_scale:s,u_flood_light_color:_,u_vertical_scale:m,u_flood_light_intensity:g,u_ground_shadow_factor:y,u_front_cutoff_params:x};return"globe"===E.projection.name&&(S.u_tile_id=[l.canonical.x,l.canonical.y,1<<l.canonical.z],S.u_zoom_transition=d,S.u_inv_rot_matrix=f,S.u_merc_center=p,S.u_up_dir=E.projection.upVector(new cQ(0,0,0),8192*p[0],8192*p[1]),S.u_height_lift=h),S},yi=(t,i,r,a,n,o)=>({u_matrix:t,u_edge_radius:i,u_width_scale:r,u_vertical_scale:a,u_height_type:g9[n],u_base_type:g9[o]}),yr=(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x=!1)=>{let v=yt(t,i,r,a,n,o,s,l,u,c,d,p,f,_,m,g,1,[0,0,0],[0,0,1],x),b={u_height_factor:-Math.pow(2,l.overscaledZ)/h.tileSize/8};return Object.assign(v,g8(i,h,y),b)};function ya(t){let i=t.properties.get("direction"),r=tQ(i.x,i.y,i.z);r[2]=tL(r[2],0,75);let a=tK([r[0],r[1],r[2]]);return eO(a.x,a.y,a.z)}function yn(t,i,r){let a="none"===i.properties.get("color-use-theme"),n=i.properties.get("color"),o=i.properties.get("intensity"),s=i.properties.get("direction"),l=[s.x,s.y,s.z],h="none"===r.properties.get("color-use-theme"),u=r.properties.get("color"),c=r.properties.get("intensity"),d=Math.max(eX([0,0,1],l),0),p=[0,0,0];ej(p,u.toPremultipliedRenderColor(h?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),c);let f=[0,0,0];return ej(f,n.toPremultipliedRenderColor(a?null:t.getLut(r.scope)).toArray01Linear().slice(0,3),d*o),t8([p[0]>0?p[0]/(p[0]+f[0]):0,p[1]>0?p[1]/(p[1]+f[1]):0,p[2]>0?p[2]/(p[2]+f[2]):0])}let yo=new Float32Array(ef([])),ys=[0,0,0],yl=(t,i,r,a,n,o,s,l,h,u,c,d,p,f=[0,0,0],_,m,g,y=1,x=!1)=>{let v=ys,b=0,w=ys;if(!x){let t=n.style.light,i=t.properties.get("position");if(v=[-i.x,-i.y,i.z],"viewport"===t.properties.get("anchor")){let t=eo();eu(t,-n.transform.angle),eJ(v,v,t)}let r=t.properties.get("color").toNonPremultipliedRenderColor(null);b=t.properties.get("intensity"),w=[r.r,r.g,r.b]}let T="MASK"===c.alphaMode,E=p.paint.get("model-ambient-occlusion-intensity"),S=p.paint.get("model-color").constantOr(rq.white).toNonPremultipliedRenderColor(null);return S.a=p.paint.get("model-color-mix-intensity").constantOr(0),g&&(S.r=g[0],S.g=g[1],S.b=g[2],S.a=g[3]),m&&(S.r=m.color.r,S.g=m.color.g,S.b=m.color.b,S.a=m.colorMix,d=m.emissionStrength,o*=m.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:r,u_node_matrix:a||yo,u_lightpos:v,u_lightintensity:b,u_lightcolor:w,u_c
8amera_pos:f,u_opacity:o,u_baseTextureIsAlpha:0,u_alphaMask:+T,u_alphaCutoff:c.alphaCutoff,u_baseColorFactor:s.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:h,u_roughnessFactor:u,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:S.toArray01(),u_aoIntensity:E,u_emissive_strength:d,u_occlusionTextureTransform:_||[0,0,0,0],u_dithered_discard_threshold:y}},yh=(t,i=yo,r=yo)=>({u_matrix:t,u_instance:i,u_node_matrix:r}),yu=(t,i,r=1)=>({u_matrix:t,u_color:i,u_overlay:0,u_overlay_scale:r}),yc=new Float64Array(16),yd=new Float64Array(16),yp=new Float64Array(16),yf=new Float64Array(16),y_=new Float64Array(16),ym=new Float64Array(16),yg=new Float64Array(16),yy=[0,0,0],yx=new Float32Array(16),yv=[0,0,0],yb=[0,0,0],yw=[];function yT(t,i,r){let a=r.cameraWorldSizeForFog/r.worldSize;return ex(t,r.worldToFogMatrix,[a,a,1]),eg(t,t,i),t}function yE(t,i,r,a){return ey(t,i,r),e2(a,p8)||ex(t,t,a),t}function yS(t,i,r,a,n){let o=r.material,s=a.context,{baseColorTexture:l,metallicRoughnessTexture:h}=o.pbrMetallicRoughness,{normalTexture:u,occlusionTexture:c,emissionTexture:d}=o;function p(i,r,a){if(i&&(t.push(r),s.activeTexture.set(s.gl.TEXTURE0+a),i.gfxTexture)){let{minFilter:t,magFilter:r,wrapS:a,wrapT:n}=i.sampler;i.gfxTexture.bindExtraParam(t,r,a,n)}}p(l,"HAS_TEXTURE_u_baseColorTexture",5),p(h,"HAS_TEXTURE_u_metallicRoughnessTexture",6),p(u,"HAS_TEXTURE_u_normalTexture",7),p(c,"HAS_TEXTURE_u_occlusionTexture",8),p(d,"HAS_TEXTURE_u_emissionTexture",9),n&&(n.texture||(n.texture=new uX(a.context,n.image,[n.image.height,n.image.height,n.image.height],s.gl.RGBA8)),s.activeTexture.set(s.gl.TEXTURE0+10),n.texture&&n.texture.bind(s.gl.LINEAR,s.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),r.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(r.texcoordBuffer)),r.colorBuffer&&(t.push(12===r.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(r.colorBuffer)),r.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(r.normalBuffer)),r.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(r.pbrBuffer)),"OPAQUE"!==o.alphaMode&&"MASK"!==o.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),o.defined||t.push("DIFFUSE_SHADED");let f=a.shadowRenderer;f&&(t.push("RENDER_SHADOWS"),f.useNormalOffset&&t.push("NORMAL_OFFSET"))}function yI(t,i,r,a,n,o){let s=t.modelOpacity,l=i.context,h=new gz(i.context.gl.LEQUAL,t.isLightMesh?gz.ReadOnly:gz.ReadWrite,i.depthRangeFor3D),u=i.transform,c=t.mesh,d=c.material,p=d.pbrMetallicRoughness,f=i.style.fog;"pixels"===i.transform.projection.zAxisUnit?yc.set(t.nodeModelMatrix):eg(yc,a.zScaleMatrix,t.nodeModelMatrix),eg(yc,a.negCameraPosMatrix,yc),em(yd,yc),e_(yd,yd
8);let _="none"===r.paint.get("model-color-use-theme").constantOr("default"),m=r.paint.get("model-emissive-strength").constantOr(0),g={defines:[]},y=[],x=i.shadowRenderer;x&&(x.useNormalOffset=!1),yS(g.defines,y,c,i,_?null:r.lut);let v=null;if(f&&(v=yT(yp,t.nodeModelMatrix,i.transform),"globe"!==u.projection.name)){let t=c.aabb.min,i=c.aabb.max,[r,a]=f.getOpacityForBounds(v,t[0],t[1],i[0],i[1]);g.overrideFog=r>=.05||a>=.05}let b=g2(i,r.paint.get("model-cutoff-fade-range"));b.shouldRenderCutoff&&g.defines.push("RENDER_CUTOFF");let w=i.getOrCreateProgram("model",g),T=yl(t.worldViewProjection,yc,yd,null,i,s,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,m,r,void 0,void 0,t.materialOverride,t.modelColor,1,w.fixedDefines.includes("LIGHTING_3D_MODE"));i.uploadCommonUniforms(l,w,null,v,b,t.lightOverrides),"shadow"!==i.renderPass&&x&&x.setupShadowsFromMatrix(t.nodeModelMatrix,w),w.draw(i,l.gl.TRIANGLES,h,n,o,c.material.doubleSided?gP.disabled:gP.backCCW,T,r.id,c.vertexBuffer,c.indexBuffer,c.segments,r.paint,i.transform.zoom,void 0,y)}function yA(t,i){return t.style._importedAsBasemap?"basemap":i.scope}function yC(t,i,r,a,n,o,s,l,h,u,c){let d=t.transform,p=!!i.isGeometryBloom&&i.isGeometryBloom;if(void 0!==i.minZoom&&t.transform.zoom<i.minZoom||void 0!==i.maxZoom&&t.transform.zoom>i.maxZoom||p&&"shadow"===t.renderPass)return;let f="globe"===d.projection.name?p5(r,d):[...r];eg(f,f,i.globalMatrix);let _=eg([],a,f);if(i.meshes)for(let t of i.meshes){let a=l.get(t.material.name);if(a&&a.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){s.push({mesh:t,depth:0,modelIndex:n,worldViewProjection:_,nodeModelMatrix:f,isLightMesh:p,materialOverride:a,modelOpacity:h,modelColor:u,lightOverrides:c,node:i,modelMatrix:r});continue}let m=eQ([],t.centroid,_);!d.isOrthographic&&m[2]<=0||o.push({mesh:t,depth:m[2],modelIndex:n,worldViewProjection:_,nodeModelMatrix:f,isLightMesh:p,materialOverride:a,modelOpacity:h,modelColor:u,lightOverrides:c,node:i,modelMatrix:r})}if(i.children)for(let d of i.children)yC(t,d,r,a,n,o,s,l,h,u,c)}function yM(t,i,r,a,n){let o=r.shadowRenderer;if(!o)return;let s=o.getShadowPassDepthMode(),l=yh(n||o.calculateShadowPassMatrixFromMatrix(i));r.getOrCreateProgram("modelDepth").draw(r,r.context.gl.TRIANGLES,s,g3.disabled,g6.disabled,gP.disabled,l,a.id,t.vertexBuffer,t.indexBuffer,t.segments,a.paint,r.transform.zoom,void 0,void 0)}function yR(t,i,r,a){let n=function(t,i){let r;if(i.footprintDebugMesh)return i.footprintDebugMesh;if(!i.footprint)return null;let a=t.context,n=i.footprint.vertices,o=i.footprint.indices,s=new ll;for(let t of(s.reserve(n.length),n))s.emplaceBack(t.x,t.y);let l=new lR;l.reserve(o.length);for(let t=0;t<o.length;t+=3)l.emplaceBack(o[t],o[t+1],o[t+2]);let h=a.createVertexBuffer(s,cs.members),u=a.createIndexBuffer(l),c=l9.simpleSegment(0,0,n.length,o.length),d=i.id||i.name||"footprint",p=parseInt(d,10),f=ia(r=isNaN(p)?function(t){let i=0;for(let r=0;r<t.length;r++)i=(i<<5)-i+t.charCodeAt(r)|0;return i}(d):p);return i.footprintDebugMesh={vertexBuffer:h,indexBuffer:u,segments:c,color:new rq(f,ia(r+1),ia(r+2),.5)},i.footprintDebugMesh}(t,r);if(!n)return;let o=t.context,s=o.gl,l=t.getOrCreateProgram("debug"),h=n.color,u=gz.disabled;o.activeTexture.set(s.TEXTURE0),t.emptyTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),l.draw(t,s.TRIANGLES,u,g3.disabled,g6.alphaBlended,gP.disabled,yu(a,h.toPremultipliedRenderColor(null)),"$debug",n.vertexBuffer,n.indexBuffer,n.segments)}function yD(t,i,r,a,n){let o=!1;for(let r of a)1!==r.modelOpacity&&(yI(r,t,i,n[r.modelIndex],g3.disabled,g6.disabled),o=!0);for(let r of a)yI(r,t,i,n[r.modelIndex],1!==r.modelOpacity?t.stencilModeFor3D():g3.disabled,t.colorModeForRenderPass());o&&t.resetStencilClippingMasks();let s=g6.additive;for(let a of r)yI(a,t,i,n[a.modelIndex],g3.disabled,a.isLightMesh?s:t.colorModeForRenderPass())}let yP={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new cg([0,0,0],[8192,8192,0])};var yz="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat 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);}\n#endif",yL="\n#ifdef DUAL_SOURCE_BLENDING\nlayout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;\n#elif defined(FLOAT_RENDER_TARGET)\nlayout(location=0) out highp vec4 glFragColor;\n#else\nlayout(location=0) out vec4 glFragColor;\n#endif\n#ifdef USE_MRT1\nlayout(location=1) out vec4 out_Target1;\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nconst float DITHER_THRESHOLDS[16]=float[16](\n1.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
8/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0\n);vec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}float cutoutGroundRoofOpacity(vec4 groundRoof) {\n#ifdef INDICATOR_CUTOUT\nfloat 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);\n#else\nreturn 1.0;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 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);}",yO="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat 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;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat 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;\n#else\nreturn vec3(0.0);\n#endif\n}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);}\n#endif\nvec2 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(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}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);
8return (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);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)\n{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",yF="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",yB="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(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;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform 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) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 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;\n#else\nfloat 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);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 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;\n#else\nfloat 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);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
8\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 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);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform 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;\n#ifdef DEPTH_D24\nfloat 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);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{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;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_
8size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(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\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_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))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint 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) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=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;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp 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));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif",yk="#ifdef FOG\nuniform 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);}\n#endif",yN="#ifdef FOG\nuniform 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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp vec3 ray_dir=mix(\nmix(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;}
8vec3 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);}\n#endif",yV="\n#ifdef LIGHTING_3D_MODE\nuniform 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);}\n#endif",yU="#ifdef RASTER_ARRAY\nuniform 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);}
8vec2 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)\n);}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)\n);}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);}\n#endif",yj="#ifdef RENDER_SHADOWS\nuniform 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];}\n#endif",yG="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);\n#endif\nreturn 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;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 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);\n#else\nlight_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);\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}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)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";
8let yH=/#include\s+"([^"]+)"/g,yq=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,yZ=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,y$=new Set(["ifdef","ifndef","elif","if","defined"]),yW=new Set;y4(yz,yW),y4(yO,yW),y4(yL,yW);let yX={"_prelude_fog.vertex.glsl":yk,"_prelude_terrain.vertex.glsl":yB,"_prelude_shadow.vertex.glsl":yj,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};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++) { \nif (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; \n}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 { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst 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;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{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;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{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);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":yN,"_prelude_shadow.fragment.glsl":yG,"_prelude_lighting.glsl":yV,"_prelude_raster_array.glsl":yU},yY={},yK="precision highp float;",yQ="precision mediump float;",yJ="\n#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)\n#extension GL_EXT_blend_func_extended : require\n#endif",y0={preludeTerrain:y6("",yB),preludeFog:y6(yN,yk),preludeShadow:y6(yG,yj),preludeRasterArray:y6(yU,""),preludeLighting:y6(yV,yV),preludePrecisionQualifiers:y6(yQ,yK),prelude:y6(yL,yO),preludeExtensions:y6(yJ,"")},y1=[yJ,yQ,yz,y0.prelude.fragmentSource].join("\n"),y2=[yK,yz,y0.prelude.vertexSource].join("\n");var y3={background:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;
8\n#ifdef FEATURE_CUTOUT\nvec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nfloat 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);\n#else\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifndef FEATURE_CUTOUT\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\n}'),backgroundPattern:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),circle:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 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 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform 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;\n#ifdef PROJECTION_GLOBE_VIEW\nin 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;\n#endif\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*v
8iew_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) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}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);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 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;\n#ifdef PROJECTION_GLOBE_VIEW\nsurface_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);\n#else \nsurface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);\n#endif\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat 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;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(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);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:y6("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:y6('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat 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);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
8\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin 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;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 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;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:y6("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;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_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:y6("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"\nin 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;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout 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);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 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);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.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:y6("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(\nmix(-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(\n0.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:y6("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"\nin ivec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_pos_3;\n#endif\nout 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;
8\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);\n#endif\n}'),fill:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat 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);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(opacity*u_opacity_multiplier);\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\nglFragColor=out_color;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform lowp float u_opacity_multiplier;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 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();\n#endif\nv_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;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat 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);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat 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);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\nglFragColor=out_color*(alpha*opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
8\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin ivec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;uniform lowp float u_opacity_multiplier;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 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();\n#endif\nv_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;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),fillOutlinePattern:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 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);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat 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);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
8\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform 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;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat 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);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 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();\n#endif\nv_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;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillPattern:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;uniform lowp float u_opacity_multiplier;\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 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);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 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;\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(opacity*u_opacity_multiplier);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
8\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform 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;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp uvec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump uvec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\nvec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat 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);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 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();\n#endif\nv_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;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),lineBlendComposite:y6("uniform highp sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;uniform highp float u_max_density;in vec2 v_pos;\n#define ADDITIVE 1\nvoid 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);}\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_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:y6("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:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radiu
8s;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat 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;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat 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);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat 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);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_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;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,h);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4
vendor: 9,873 bytes, line 8
8);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;\n#endif\nuniform 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;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin 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;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nuniform highp float u_vertical_scale;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\nout vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=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));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool 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;\n#else\nh=t > 0.0 ? height : base;\n#endif\npos=vec3(pos_nx.xy,h);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat 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);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec2 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);}}\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);\n#endif\n#ifdef RENDER_CUTOFF\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (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);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_FRONT_CUTOFF\nv_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);}\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 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;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_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);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=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*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat 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;\n#ifdef TERRAIN\ntop_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);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat 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;\n#endif\nv_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);\n#else\nv_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;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat 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;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 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);\n#endif\n#endif\n}'),fillExtrusionPattern:
8y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting
vendor: 8,254 bytes, line 8
8.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 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);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 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;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat 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;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,height);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform 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;\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin 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;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool 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);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat 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);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 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;\n#endif\nfloat 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\n? pos_nx.xy\n: 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;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat 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;\n#ifdef TERRAIN\ntop_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);\n#endif\nv_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]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),hillshadePrepare:
8y6("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(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.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:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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;\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),line:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform 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;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nin float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform highp float u_floor_width_scale;in vec2 v_tex;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 v_elevation_id_col;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec3 v_uv;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nuniform 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;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\nfloat linearstep(float edge0,float edge1,float x) {return
8clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat dist=length(v_normal)*v_width2_dilute.x;float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nANTIALIASING*=8.0;\n#endif\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nblur=mix(blur,0.0,stub_side);\n#endif\nfloat 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;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\npxStep=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;\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=ANTIALIASING/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp 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;\n#ifdef RENDER_LINE_GRADIENT\ngradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);\n#endif\nhighp 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;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nfloat edge2=border_width*u_width_scale+ANTIALIASING;float alpha2=smoothstep(edge2-pxStep,edge2+pxStep,delta);if (alpha2 < 1.) {if (border_color.a==0.0) {\n#ifndef RENDER_LINE_GRADIENT\nfloat 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);}\n#else\nout_color.rgb*=(0.6+0.4*alpha2);\n#endif\n} else {out_color=mix(border_color*trim_alpha,out_color,alpha2);}out_color*=v_width2_dilute.w;}\n#endif\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat 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;\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*diluted_opacity*u_opacity_multiplier);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nfloat z=0.0;\n#ifdef ELEVATED_ROADS\nz=v_road_z_offset;\n#endif\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,z);\n#endif\n#ifdef LINE_BLEND_ADDITIVE\n{float cov=alpha*diluted_opacity;glFragColor=vec4(cov > 0.0 ? out_color.rgb/cov : vec3(0.0),cov);}\n#else\n#ifdef LINE_BLEND_MULTIPLY\nglFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);\n#else\nglFragColor=out_color;\n#endif\n#endif\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef DEBUG_ELEVATION_ID\nglFragColor=vec4(v_elevation_id_col,1.0);\n#endif\nif (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"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH) || defined(VARIABLE_LINE_EMISSIVE_STRENGTH)\nin vec4 a_z_offset_width;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nin vec3 a_elevation_id_col;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nout vec3 v_elevation_id_col;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nin highp vec3 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform 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;\n#ifdef RENDER_LINE_CURVE\nuniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;\n#endif\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;
8float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out vec2 v_tile_pos;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nout float stub_side;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform highp float u_floor_width_scale;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nout highp vec3 v_uv;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump uvec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\n#ifdef RENDER_LINE_CURVE\nvec3 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=t*t;float t3=t2*t;return 0.5*(\n2.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\n);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(\n(-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\n);}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;}\n#endif\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump uvec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\n#ifdef VARIABLE_LINE_EMISSIVE_STRENGTH\nemissive_strength=a_z_offset_width.w;\n#endif\nfloat a_z_offset=u_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset+=a_z_offset_width.x;\n#endif\n#ifdef DEBUG_ELEVATION_ID\nv_elevation_id_col=a_elevation_id_col;\n#endif\nhighp float line_progress=0.0;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nline_progress=a_packed[2];\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nANTIALIASING*=8.0;\n#endif\n#endif\nvec2 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;\n#ifdef RENDER_LINE_CURVE\nCurveResult 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;\n#endif\ngapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;float symmetric_outset=0.0;\n#ifdef VARIABLE_LINE_WIDTH\nfloat 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 >
8 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;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\nfloat 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;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_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);\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat 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);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat 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;\n#else\nfloat 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;\n#endif\n#endif\nv_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);\n#else\nv_tile_pos=pos+offset2*u_pixels_to_tile_units;gl_Position=u_matrix*vec4(v_tile_pos,0.0,1.0);\n#endif\n#endif\n#ifndef ELEVATED\n#ifndef VARIABLE_LINE_WIDTH\n#ifndef RENDER_TO_TEXTURE\nfloat 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\n{\n#ifdef RENDER_LINE_BORDER\nfloat 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);\n#endif\n}}\n#endif\n#endif\nv_tile_pos=(v_tile_pos+extrude)/EXTENT;\n#ifdef ELEVATED_ROADS\ngl_Position=gl_Position+projected_extrude;\n#else\ngl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 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();\n#endif\nv_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;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat 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));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];\n#ifdef RENDER_LINE_GRADIENT\nhighp 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);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nvec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y);\n#endif\nv_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);\n#ifdef VARIABLE_LINE_WIDTH\nv_width2_dilute.x=symmetric_outset;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow
vendor: 12,103 bytes, line 8
8.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform 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;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 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);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 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;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp 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);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp 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);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity*u_opacity_multiplier);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\n#endif\nglFragColor=color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin ivec2 a_pos_normal;in uvec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec4 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform 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;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump uvec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump uvec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump uvec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat 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;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_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;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat 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);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat 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;\n#else\nfloat 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;\n#endif\n#endif\ngl_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);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 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();\n#endif\nv_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;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat 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));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_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);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:
8y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform 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;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform 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;\n#ifndef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_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\n);\n#else\nvalue=mix(\nraTexture2D_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\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;
vendor: 5,542 bytes, line 8
8\n#else\ncolor=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);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=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);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 rgb=color.rgb;rgb=vec3(\ndot(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);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp 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));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform 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;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;\n#endif\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;in uvec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT);\n#endif\nglobe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nvec4 world_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 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]); \nfloat tiles=u_grid_matrix[0][2];if (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;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;\n#endif\nvec4 merc_world_pos=vec4(0.0); \nv_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);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat ele=0.0;vec2 decodedPos=vec2(a_pos);\n#ifdef ELEVATION_REFERENCE_GROUND\nvec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;\n#else\nuv=vec2(a_texture_pos)/8192.0;\n#endif\nworld_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);\n#ifdef FOG\nv_fog_pos=fog_position(decodedPos);\n#endif\n#endif\nfloat w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;\n#endif\nv_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;\n#ifdef ELEVATED\nfloat 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);\n#endif\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),symbol:
8y6('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;\n#ifdef RENDER_TEXT_AND_SYMBOL\nuniform sampler2D u_texture_icon;\n#endif\nuniform 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;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin 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;\n#ifdef LIGHTING_3D_MODE\nin lowp float v_emissive_strength;\n#endif\nvoid 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;\n#ifdef LIGHTING_3D_MODE\nemissive_strength=v_emissive_strength;\n#endif\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity*u_opacity_multiplier;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\nvec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\nif (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 {\n#ifdef ICON_TRANSITION\nvec4 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);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n}out_color*=opacity*fade_opacity*u_opacity_multiplier;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,0.0);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define USING_APPEARANCE 1.0\nin ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin ivec4 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin uvec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\n#endif\nuniform 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;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_inv_matrix;\n#endif\nuniform 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;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_up_vector;\n#endif\n#ifdef RENDER_TEXT_AND_SYMBOL\nuniform vec2 u_texsize_icon;\n#endif\nuniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform 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;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#ifndef MAX_UBO_SIZE_VEC4\n#define MAX_UBO_SIZE_VEC4 1024u\n#endif\n#define SPP_HEADER_SIZE_VEC4 3u\n#define DWORDS_PER_VEC4 4u\nstruct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;float zoomFactor;bool hasAppearanceZoomStops;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform 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_fill_color_zoom_factor;uniform highp float u_spp_halo_color_zoom_factor;uniform highp float u_spp_opacity_zoom_factor;uniform highp float u_spp_halo_width_zoom_factor;uniform highp float u_spp_halo_blur_zoom_factor;uniform highp float u_spp_emissive_strength_zoom_factor;uniform highp float u_spp_occlusion_opacity_zoom_factor;uniform highp float u_spp_z_offset_zoom_factor;uniform highp float u_spp_translate_zoom_factor;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;\n#ifdef LIGHTING_3D_MODE\nout lowp float v_emissive_strength;\n#endif\nPropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint appearanceZoomStopsMask,uint offsetDwords,float zoomFactor) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;type.zoomFactor=zoomFactor;type.hasAppearanceZoomStops=(appearanceZoomStopsMask & (1u << propertyIndex)) !=0u;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask =u_spp_header.header[0][0];uint zoomMask =u_spp_header.header[0][1];uint zoomDependentMask =zoomMask & 0xFFFFu;uint appearanceZoomStopsMask =zoomMask >> 16u;header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color =getPropertyType(0u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[0][3],u_spp_fill_color_zoom_factor);header.halo_np_color =getPropertyType(1u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][0],u_spp_halo_color_zoom_factor);header.opacity =getPropertyType(2u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][1],u_spp_opacity_zoom_factor);header.halo_width =getPropertyType(3u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][2],u_spp_halo_width_zoom_factor);header.halo_blur =getPropertyType(4u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[1][3],u_spp_halo_blur_zoom_factor);header.emissive_strength=getPropertyType(5u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][0],u_spp_emissive_strength_zoom_factor);header.occlusion_opacity=getPropertyType(6u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][1],u_spp_occlusion_opacity_zoom_factor);header.z_offset =getPropertyType(7u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][2],u_spp_z_offset_zoom_factor);header.translate =getPropertyType(8u,dataDrivenMask,zoomDependentMask,appearanceZoomStopsMask,u_spp_header.header[2][3],u_spp_translate_zoom_factor);return header;}float appearanceZoomStopsFactor(float zm,float zM) {if (zm==zM) {return u_spp_zoom_fraction >=zm ? 1.0 : 0.0;}return clamp((u_spp_zoom_fraction-zm)/(zM-zm),0.0,1.0);}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x :\n(index==1u) ? v.y :\n(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);}uint readUint(uvec4 slot,uint offset) {return uvec4At(slot,offset % DWORDS_PER_VEC4);}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {float t=propertyType.zoomFactor;if (propertyType.hasAppearanceZoomStops) {vec4 zoomRange=readVec4(blockOffsetVec4,propertyType.offsetDwords+4u);t=appearanceZoomStopsFactor(zoomRange.x,zoomRange.y);}color=unpack_mix_color(color,t);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {float t=propertyType.zoomFactor;if (propertyType.hasAppearanceZoomStops) {vec4 zoomRange=readVec4(blockOffsetVec4,propertyType.offsetDwords+4u);t=appearanceZoomStopsFactor(zoomRange.x,zoomRange.y);}return mix(slot.xy,slot.zw,t);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);float t=propertyType.hasAppearanceZoomStops\n? appearanceZoomStopsFactor(readFloat(slot,propertyType.offsetDwords+2u),readFloat(slot,propertyType.offsetDwords+3u))\n: propertyType.zoomFactor;value=unpack_mix_vec2(packedValues,t);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color =header.fill_np_color.isDataDriven ? readColorProperty(header.fill_np_color,sizeVec4) : u_spp_fill_np_color;props.halo_np_color =header.halo_np_color.isDataDriven ? readColorProperty(header.halo_np_color,sizeVec4) : u_spp_halo_np_color;props.opacity =header.opacity.isDataDriven ? readFloatProperty(header.opacity,sizeVec4) : u_spp_opacity;props.halo_width =header.halo_width.isDataDriven ? readFloatProperty(header.halo_width,sizeVec4) : u_spp_halo_width;props.halo_blur =header.halo_blur.isDataDriven ? readFloatProperty(header.halo_blur,sizeVec4) : u_spp_halo_blur;props.emissive_strength =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset =header.z_offset.isDataDriven ? readFloatProperty(header.z_offset,sizeVec4) : u_spp_z_offset;props.translate =header.translate.isDataDriven ? readVec2Property(header.translate,sizeVec4) : vec2(0.0);return props;}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;\n#ifdef LIGHTING_3D_MODE\nv_emissive_strength=paint_properties.emissive_strength;\n#endif\nlowp 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);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset
8;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_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;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 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 ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.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;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 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); \n#endif\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat 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));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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;\n#else\n#ifdef ELEVATED_ROADS\nvec3 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;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(\nu_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\n);
8gl_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;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=vec2(a_texb)/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 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();\n#endif\nv_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;\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nin vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat 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;\n#else\nfloat 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));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat 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;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 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.);\n#endif\n}'),terrainDepth:y6("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform 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:y6('#include "_prelude_fog.fragment.glsl"\nin 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(\ncos_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
8nd-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;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',yF),skyboxGradient:y6('#include "_prelude_fog.fragment.glsl"\nin 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));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',yF),skyboxCapture:y6
vendor: 3,689 bytes, line 8
8("\nin 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;\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;
8v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nuniform float u_far_z_cutoff;in vec2 v_pos0;\n#ifndef FOG\nuniform 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;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp vec3 ray_dir=mix(\nmix(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);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat 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);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat 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;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin ivec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat 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);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 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);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:y6('#include "_prelude_fog.fragment.glsl"\nuniform 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;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_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) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp 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 ?\nPI-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);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_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;
8vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat 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);\n#else\nvec3 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);\n#endif\n}',"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(\nmix(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(\nmix(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:y6("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{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;}","\nin 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:y6("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin 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;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 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 y4(t,i){for(let r of t.split("\n")){if("#"!==(r=r.trimStart())[0]||!r.includes("if")||r.startsWith("#endif"))continue;let t=r.match(yZ);if(t)for(let r of t)y$.has(r)||i.add(r)}}function y5(t){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(t)}function y6(t,i){let r=new Set,a=[],n=[];t=t.replace(yH,(t,i)=>(n.push(i),"")),i=i.replace(yH,(t,i)=>(a.push(i),""));let o=new Set(yW);for(let r of(y4(t,o),y4(i,o),[...a,...n]))yY[r]||(yY[r]=new Set,y4(yX[r],yY[r])),o=new Set([...o,...yY[r]]);return{fragmentSource:t=t.replace(yq,(t,i,a,n,o)=>(r.add(o),"define"===i?` 9#ifndef HAS_UNIFORM_u_${o} 10${y5(n)?"flat ":""}in ${a} ${n} ${o}; 11#else 12uniform ${a} ${n} u_${o}; 13#endif 14`:"initialize"===i?` 15#ifdef HAS_UNIFORM_u_${o} 16 ${a} ${n} ${o} = u_${o}; 17#endif 18`:"define-attribute"===i?` 19#ifdef HAS_ATTRIBUTE_a_${o} 20 in ${a} ${n} ${o}; 21#endif 22`:"initialize-attribute"===i?"":void 0)),vertexSource:i=i.replace(yq,(t,i,a,n,o)=>{let s=`MATERIAL_ATTRIBUTE_OFFSET_${o}`,l="float"===n?"vec2":n,h=`GET_ATTRIBUTE_${l}(a_${o}, materialInfo, ${s})`,u=o.includes("color")?"color":l;return"define-attribute-vertex-shader-only"===i?` 23#ifdef HAS_ATTRIBUTE_a_${o} 24in ${a} ${n} a_${o}; 25#endif 26`:r.has(o)?"define"===i?` 27#ifndef HAS_UNIFORM_u_${o} 28uniform lowp float u_${o}_t; 29 #if !defined(${s}) 30 in ${a} ${l} a_${o}; 31 #endif 32${y5(n)?"flat ":""}out ${a} ${n} ${o}; 33#else 34uniform ${a} ${n} u_${o}; 35#endif 36`:"initialize"===i?"vec4"===u||"uvec4"===u?` 37#ifndef HAS_UNIFORM_u_${o} 38 ${o} = a_${o}; 39#else 40 ${a} ${n} ${o} = u_${o}; 41#endif 42`:` 43#if !defined(HAS_UNIFORM_u_${o}) 44 #ifdef ${s} 45 ${o} = unpack_mix_${u}(${h}, u_${o}_t); 46 #else 47 ${o} = unpack_mix_${u}(a_${o}, u_${o}_t); 48 #endif 49#else 50 ${a} ${n} ${o} = u_${o}; 51#endif 52`:"define-attribute"===i?` 53#ifdef HAS_ATTRIBUTE_a_${o} 54 in ${a} ${n} a_${o}; 55 out ${a} ${n} ${o}; 56#endif 57`:"initialize-attribute"===i?` 58#ifdef HAS_ATTRIBUTE_a_${o} 59 ${o} = a_${o}; 60#endif 61`:void 0:"define"===i?` 62#ifndef HAS_UNIFORM_u_${o} 63uniform lowp float u_${o}_t; 64 #if !defined(${s}) 65 in ${a} ${l} a_${o}; 66 #endif 67#else 68uniform ${a} ${n} u_${o}; 69#endif 70`:"define-instanced"===i?"mat4"===u?` 71#ifdef INSTANCED_ARRAYS 72in vec4 a_${o}0; 73in vec4 a_${o}1; 74in vec4 a_${o}2; 75in vec4 a_${o}3; 76#else 77uniform ${a} ${n} u_${o}; 78#endif 79`:` 80#ifdef INSTANCED_ARRAYS 81in ${a} ${l} a_${o}; 82#else 83uniform ${a} ${n} u_${o}; 84#endif 85`:"initialize-attribute-custom"===i?` 86#ifdef HAS_ATTRIBUTE_a_${o} 87 ${a} ${n} ${o} = a_${o}; 88#endif 89`:"vec4"===u||"uvec4"===u?` 90#ifndef HAS_UNIFORM_u_${o} 91 #ifdef ${s} 92 ${a} ${n} ${o} = ${h}; 93 #else 94 ${a} ${n} ${o} = a_${o}; 95 #endif 96#else 97 ${a} ${n} ${o} = u_${o}; 98#endif 99`:` 100#ifndef HAS_UNIFORM_u_${o} 101 #ifdef ${s} 102 ${a} ${n} ${o} = unpack_mix_${u}(${h}, u_${o}_t); 103 #else 104 ${a} ${n} ${o} = unpack_mix_${u}(a_${o}, u_${o}_t); 105 #endif 106#else 107 ${a} ${n} ${o} = u_${o}; 108#endif 109`}),usedDefines:o,vertexIncludes:a,fragmentIncludes:n}}var y8={model:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting
vendor: 14,187 bytes, line 109
109.glsl"\nuniform float u_opacity;\n#ifdef DITHERED_DISCARD\nuniform float u_dithered_discard_threshold;\n#endif\n#ifndef LIGHTING_3D_MODE\nuniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;\n#endif\nuniform 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;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nin highp float v_cutout_factor;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{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;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 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)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 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;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\ntexColor=vec4(unpremultiplyColor(texColor),1.0);\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp 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;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp 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;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp 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));\n#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 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);\n#endif\nreturn 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;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst 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)\n{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)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{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)\n{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)\n{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)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{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)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 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)\n{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;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst 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);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir;vec3 lightColor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#else\nlightDir=u_lightpos;lightColor=u_lightcolor;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat 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;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));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);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef DITHERED_DISCARD\nif (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;}}\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\napply_feature_cutout_dither(gl_FragCoord,v_cutout_factor);\n#else\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n
109in vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nout highp float v_cutout_factor;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp uvec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\n#ifdef FEATURE_CUTOUT_VERTEX\nv_cutout_factor=1.0;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 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;\n#ifdef FEATURE_CUTOUT_VERTEX\nhighp 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;\n#ifdef FLIP_Y\nfragDepthNDC=cutout_ndc.z;\n#endif\nhighp float cutoutFactor=get_cutout_factors_vert(uv).x;highp float cutoutDepthNDC=sample_cutout_depth(u_cutout_depth_image,uv);highp float groundThreshold=0.001;highp float groundLimit=clamp((fragDepthNDC+groundThreshold-cutoutDepthNDC)/groundThreshold+0.5,0.0,1.0);v_cutout_factor=mix(1.0-cutoutFactor,1.0,groundLimit);\n#endif\n#else\nlocal_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);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 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;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat 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);
109\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_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);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_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;\n#endif\n}'),modelDepth:y6("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 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;
109rs[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);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\n}"),fillExtrusionDepth:y6("void main() {}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin ivec4 a_pos_normal_ed;\n#if defined(HAS_CENTROID) || defined(TERRAIN)\nin uvec2 a_centroid_pos;\n#endif\n#ifdef RENDER_WALL_MODE\nin ivec4 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=vec2(a_centroid_pos);\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool 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);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec3 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;\n#endif\nfloat 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:y6
vendor: 3,847 bytes, line 109
109("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;\n#ifdef SDF_SUBPASS\nin 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);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp 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;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform 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;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec4 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;\n#ifdef SDF_SUBPASS\nv_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);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=float(a_hidden_by_landmark);\n#endif\nfloat 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));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),groundShadow:
109y6('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid 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);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);\n#endif\n#ifdef FEATURE_CUTOUT\nvec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform 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;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid 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);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);\n#endif\n}')};let y9=(t,i)=>({u_matrix:t,u_ground_shadow_factor:i}),y7=[];function xe(t){return y7[t]=y7[t]||new Float64Array(16)}let xt=[],xi=new Float32Array(16);class xr{constructor(t,i){this.aabb=t,this.lastCascade=i}}class xa{add(t,i){let r=this.receivers[t.key];void 0!==r?(r.aabb.min[0]=Math.min(r.aabb.min[0],i.min[0]),r.aabb.min[1]=Math.min(r.aabb.min[1],i.min[1]),r.aabb.min[2]=Math.min(r.aabb.min[2],i.min[2]),r.aabb.max[0]=Math.max(r.aabb.max[0],i.max[0]),r.aabb.max[1]=Math.max(r.aabb.max[1],i.max[1]),r.aabb.max[2]=Math.max(r.aabb.max[2],i.max[2])):this.receivers[t.key]=new xr(i,null)}clear(){this.receivers={}}get(t){return this.receivers[t.key]}computeRequiredCascades(t,i,r){let a=cg.fromPoints(t.points),n=0;for(let t in this.receivers){let o=this.receivers[t];if(!o||!a.intersectsAabb(o.aabb))continue;o.aabb.min=a.closestPoint(o.aabb.min),o.aabb.max=a.closestPoint(o.aabb.max);let s=o.aabb.getCorners();for(let t=0;t<r.length;t++){let a=!0;for(let n of s){let o=[n[0]*i,n[1]*i,n[2]];if(eQ(o,o,r[t].matrix),o[0]<-1||o[0]>1||o[1]<-1||o[1]>1){a=!1;break}}if(o.lastCascade=t,n=Math.max(n,t),a)break}}return n+1}}function xn(t,i,r){let a=eY([],ek([],r,i),ek([],t,i)),n=eL(a);return 0===n?[0,0,1,0]:(ej(a,a,1/n),[a[0],a[1],a[2],-eX(a,i)])}let xo=function(t,i,r,a){if("opaque"===t.renderPass)return;let n=r.paint.get("model-opacity").constantOr(1),o=r.paint.get("model-elevation-reference"),s="ground"===o,l="ground"===o;if(0===n)return;let h=r.paint.get("model-cast-shadows");if("shadow"===t.renderPass&&(!h||t.terrain&&n<.65&&r._transitionablePaint._values["model-opacity"].value.expression instanceof oT))return;let u=t.shadowRenderer,c=r.paint.get("model-receive-shadows");u&&(u.useNormalOffset=!0,c||(u.enabled=!1));let d=()=>{u&&(u.useNormalOffset=!0,c||(u.enabled=!0))},p=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==p.type)return;if("vector"===p.type||"geojson"===p.type)return function(t,i,r,a,n){let o=t.transform,s="globe"===o.projection.name,l=o.getFreeCameraOptions().position;if(!t.modelManager)return;let h=t.modelManager;r.modelManager=h;let u=t.shadowRenderer;if(!Object.hasOwn(r._unevaluatedLayout._values,"model-id"))return;let c=r._unevaluatedLayout._values["model-id"],d={...r.layout.get("model-id").parameters},p=t.style.order.indexOf(r.fqid),f=r.paint.get("model-opacity").constantOr(1);for(let _ of a){let a=i.getTile(_).getBucket(r);
109if(!a||a.projection.name!==o.projection.name)continue;let m=a.getModelUris();(m&&!a.modelsRequested&&(h.addModelsFromBucket(m,n),a.modelsRequested=!0),s)?d.zoom=_.overscaledZ:d.zoom=function(t,i){let r=1<<t.canonical.z,a=i.getFreeCameraOptions().position,n=i.elevation,o=t.canonical.x/r,s=(t.canonical.x+1)/r,l=t.canonical.y/r,h=(t.canonical.y+1)/r,u=i._centerAltitude;if(n){let i=n.getMinMaxForTile(t);i&&i.max>u&&(u=i.max)}let c=tL(a.x,o,s)-a.x,d=tL(a.y,l,h)-a.y,p=u/s2(i.center.lat)-a.z;return i._zoomFromMercatorZ(Math.sqrt(c*c+d*d+p*p))}(_,o);let g=c.possiblyEvaluate(d);if(function(t,i,r){let a=i.updateZoomBasedPaintProperties(),n=function(t,i,r){let a,n,o,s=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&s>0){let i=t.terrain,n=i.findDEMTileFor(r);n&&n.dem?a=_Z.create(i,r,n):s=0}if(0===s&&(i.terrainElevationMin=0,i.terrainElevationMax=0),s===i.validForExaggeration&&(0===s||a&&a._demTile&&a._demTile.tileID===i.validForDEMTile.id&&a._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(let t in i.instancesPerModel){let r=i.instancesPerModel[t];for(let t=0;t<r.instancedDataArray.length;++t){let l=(a?s*a.getElevationAt(0|r.instancedDataArray.float32[16*t],0|r.instancedDataArray.float32[16*t+1],!0,!0):0)+r.instancesEvaluatedElevation[t];r.instancedDataArray.float32[16*t+6]=l,n=n?Math.min(i.terrainElevationMin,l):l,o=o?Math.max(i.terrainElevationMax,l):l}}return i.terrainElevationMin=n||0,i.terrainElevationMax=o||0,i.validForExaggeration=s,i.validForDEMTile=a&&a._demTile?{id:a._demTile.tileID,timestamp:a._dem._timestamp}:{id:void 0,timestamp:0},!0}(t,i,r);(a||n)&&(i.uploaded=!1,i.upload(t.context))}(t,a,_),yP.shadowUniformsInitialized=!1,yP.useSingleShadowCascade=!!u&&0===u.getMaxCascadeForTile(_.toUnwrapped()),"shadow"===t.renderPass&&u){if(1===t.currentShadowCascade&&a.isInsideFirstShadowMapFrustum)continue;let i=o.calculatePosMatrix(_.toUnwrapped(),o.worldSize);if(yP.tileMatrix.set(i),yP.shadowTileMatrix.set(u.calculateShadowPassMatrixFromMatrix(i)),yP.aabb.min=[0,0,0],yP.aabb.max[0]=yP.aabb.max[1]=8192,yP.aabb.max[2]=0,function(t,i,r,a){if(!r.modelManager)return!0;let n=r.modelManager;if(!r.shadowRenderer)return!0;let o=r.shadowRenderer,s=i.aabb,l=!0,h=t.maxHeight;if(0===h){let i=0;for(let r in t.instancesPerModel){let t=n.getModel(r,a);t?i=Math.max(i,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1}h=t.maxScale*i*1.41+t.maxVerticalOffset,l&&(t.maxHeight=h)}s.max[2]=h,s.min[2]+=t.terrainElevationMin,s.max[2]+=t.terrainElevationMax,eQ(s.min,s.min,i.tileMatrix),eQ(s.max,s.max,i.tileMatrix);let u=s.intersects(o.getCurrentCascadeFrustum());return 0===r.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===u),0===u}(a,yP,t,r.scope))continue}let y=1<<_.canonical.z,x=[((l.x-_.wrap)*y-_.canonical.x)*8192,(l.y*y-_.canonical.y)*8192,l.z*y*8192];t.conflationActive&&Object.keys(a.instancesPerModel).length>0&&t.style.isLayerClipped(r,i.getSource())&&a.updateReplacement(_,t.replacementSource,p,r.scope)&&(a.uploaded=!1,a.upload(t.context));let v=0,b=[],w=[],T=[];for(let i in a.instancesPerModel){let o=a.instancesPerModel[i];o.features.length>0&&!s&&(i=g.evaluate(o.features[0].feature,{}));let u=h.getModel(i,n);if(u||h.hasURLBeenRequested(i)||a.modelUris.includes(i)||(a.modelUris.push(i),a.modelsRequested=!1),u&&u.uploaded)if(s){let i=ej([],[l.x,l.y,l.z],t.transform.worldSize);e$(i,i);for(let r=0;r<o.instancedDataArray.length;++r){let n=[0,0,0],s=[1,1,1],l=e7(),h=o.tileCoordinatesForInstance(r),c=o.transformForInstance(r);eC(s,c),function(t,i){var r=new ea(3);eC(r,i);var a=1/r[0],n=1/r[1],o=1/r[2],s=i[0]*a,l=i[1]*n,h=i[2]*o,u=i[4]*a,c=i[5]*n,d=i[6]*o,p=i[8]*a,f=i[9]*n,_=i[10]*o,m=s+c+_,g=0;m>0?(g=2*Math.sqrt(m+1),t[3]=.25*g,t[0]=(d-f)/g,t[1]=(p-h)/g,t[2]=(l-u)/g):s>c&&s>_?(g=2*Math.sqrt(1+s-c-_),t[3]=(d-f)/g,t[0]=.25*g,t[1]=(l+u)/g,t[2]=(p+h)/g):c>_?(g=2*Math.sqrt(1+c-s-_),t[3]=(p-h)/g,t[0]=(l+u)/g,t[1]=.25*g,t[2]=(d+f)/g):(g=2*Math.sqrt(1+_-s-c),t[3]=(l-u)/g,t[0]=(p+h)/g,t[1]=(d+f)/g,t[2]=.25*g)}(l,c),function(t,i){var r=Math.sin(2*Math.acos(i[3])/2);r>1e-6?(t[0]=i[0]/r,t[1]=i[1]/r,t[2]=i[2]/r):(t[0]=1,t[1]=0,t[2]=0)}(n,l);let d=o.translationForInstance(r),p=new s0(0,0);_8(a.canonical,p,h.x,h.y);let _=ec();p9(_,u,t.transform,p,n,s,d,!0,!1,!1);let m=o.colorForInstance(r),g=eT([],i),y=eE([],[1,1,1/s4(p.lat,t.transform.zoom)]);for(let i of(T.push({zScaleMatrix:y,negCameraPosMatrix:g}),u.nodes))yC(t,i,_,t.transform.expandedFarZProjMatrix,v,b,w,u.materialOverrides,f,m);++v}}else for(let i of u.nodes)!function t(i,r,a,n,o,s,l){let h=i.context,u="shadow"===i.renderPass,c=i.shadowRenderer,d=u&&c?c.getShadowPassDepthMode():new gz(h.gl.LEQUAL,gz.ReadWrite,i.depthRangeFor3D),p=i.isTileAffectedByFog(s),f="globe"===i.transform.projection.name;if(a.meshes)for(let t of a.meshes){let _,m,g,y=f?[]:["MODEL_POSITION_ON_GPU"],x=[],v=!f&&n.instancedDataArray.length>20;v&&y.push("INSTANCED_ARRAYS");let b=g2(i,r.paint.get("model-cutoff-fade-range"));if(b.shouldRenderCutoff&&y.push("RENDER_CUTOFF"),u&&c)_=i.getOrCreateProgram("modelDepth",{defines:y}),m=yh(l.shadowTileMatrix,l.shadowTileMatrix,a.globalMatrix),g=g6.disabled;
109else{yS(y,x,t,i,"none"===r.paint.get("model-color-use-theme").constantOr("default")?null:r.lut),_=i.getOrCreateProgram("model",{defines:y,overrideFog:p});let n=t.material,u=n.pbrMetallicRoughness,d=r.paint.get("model-opacity").constantOr(1),f=r.paint.get("model-emissive-strength").constantOr(0);m=yl(s.expandedProjMatrix,a.globalMatrix,yx,null,i,d,u.baseColorFactor,n.emissiveFactor,u.metallicFactor,u.roughnessFactor,n,f,r,o,void 0,void 0,void 0,1,_.fixedDefines.includes("LIGHTING_3D_MODE")),c&&(l.shadowUniformsInitialized?_.setShadowUniformValues(h,c.getShadowUniformValues()):(c.setupShadows(s.toUnwrapped(),_,"model-tile"),l.shadowUniformsInitialized=!0)),g=b.shouldRenderCutoff||d<1||"OPAQUE"!==n.alphaMode?g6.alphaBlended:g6.unblended}i.uploadCommonUniforms(h,_,s.toUnwrapped(),null,b);let w=t.material.doubleSided?gP.disabled:gP.backCCW;if(v)x.push(n.instancedDataBuffer),_.draw(i,h.gl.TRIANGLES,d,g3.disabled,g,w,m,r.id,t.vertexBuffer,t.indexBuffer,t.segments,r.paint,i.transform.zoom,void 0,x,n.instancedDataArray.length);else{let a=u?"u_instance":"u_normal_matrix";for(let o=0;o<n.instancedDataArray.length;++o)m[a]=new Float32Array(n.instancedDataArray.arrayBuffer,64*o,16),_.draw(i,h.gl.TRIANGLES,d,g3.disabled,g,w,m,r.id,t.vertexBuffer,t.indexBuffer,t.segments,r.paint,i.transform.zoom,void 0,x)}}if(a.children)for(let h of a.children)t(i,r,h,n,o,s,l)}(t,r,i,o,x,_,yP)}if(s)if("shadow"===t.renderPass){for(let i of w)yM(i.mesh,i.nodeModelMatrix,t,r);for(let i of b)yM(i.mesh,i.nodeModelMatrix,t,r)}else yD(t,r,b,w,T)}}(t,i,r,a,yA(t,r)),void d();if(!p.loaded())return;if("batched-model"===p.type)return function(t,i,r,a){r.resetLayerRenderingStats(t);let n=t.context,o=t.transform,s=t.style.fog,l=t.shadowRenderer;if("mercator"!==o.projection.name)return tX(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`);let h=t.transform.getFreeCameraOptions().position,u=ej([],[h.x,h.y,h.z],t.transform.worldSize),c=eT([],e$([],u)),d=s4(o.center.lat,o.zoom),p=eg([],c,eE([],[1,1,1/d])),f=r.paint.get("model-opacity").constantOr(1),_=new gz(n.gl.LEQUAL,gz.ReadWrite,t.depthRangeFor3D),m=new gz(n.gl.LEQUAL,gz.ReadOnly,t.depthRangeFor3D),g=new cg([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),y="shadow"===t.renderPass,x="light-beam"===t.renderPass,v="none"===r.paint.get("model-color-use-theme").constantOr("default"),b=y&&l?l.getCurrentCascadeFrustum():o.getFrustum(o.scaleZoom(o.worldSize)),w=r.paint.get("model-front-cutoff"),T=w[2]<1,E=g2(t,r.paint.get("model-cutoff-fade-range")),S=r.getLayerRenderingStats();(function(t,i,r,a){let n=t.terrain?t.terrain.exaggeration():0,o=t.transform.zoom;for(let s of a){let a=i.getTile(s).getBucket(r);a&&(a.setFilter(r.filter),t.conflationActive&&a.updateReplacement(s,t.replacementSource),a.evaluateTransform(t,r),t.terrain&&n>0&&a.elevationUpdate(t.terrain,n,s,r.source),a.needsReEvaluation(t,o,r)&&a.evaluate(r))}})(t,i,r,a),function(){let h,c,I,A=new Map;T?(h=a.length-1,c=-1,I=-1):(h=0,c=a.length,I=1);let C=eP(),M=new tg(0,0);for(let R=h;R!==c;R+=I){let h=a[R],c=i.getTile(h).getBucket(r);if(!c||!c.uploaded)continue;let I=!1;l&&(I=0===l.getMaxCascadeForTile(h.toUnwrapped()));let D=o.calculatePosMatrix(h.toUnwrapped(),o.worldSize),P=!!(4&c.modelTraits);eg(yf,p,D),eg(y_,o.expandedFarZProjMatrix,D),em(ym,yf),e_(ym,ym);let z=!y&&l&&l.enabled?l.computeCascadeTileMatrices(D):null;!y&&T&&(em(yd,D),eQ(C,u,yd),M.x=C[0],M.y=C[1]);let L=[];for(let i of(c.setFilter(r.filter),c.getNodesInfo())){if(i.hiddenByReplacement||!i.node.meshes)continue;let r=i.node,a=0;t.terrain&&r.elevation&&(a=r.elevation*t.terrain.exaggeration());let n=(()=>{let t=i.aabb,r=g.min,n=g.max;return r[0]=t.min[0],r[1]=t.min[1],r[2]=t.min[2]+a,n[0]=t.max[0],n[1]=t.max[1],n[2]=t.max[2]+a,eQ(r,r,D),eQ(n,n,D),g})(),s=i.evaluatedScale;if(s[0]<=1&&s[1]<=1&&s[2]<=1&&0===n.intersects(b))continue;if(!y){let r=n.min,a=n.max;yv[0]=.5*(r[0]+a[0]),yv[1]=.5*(r[1]+a[1]),yv[2]=.5*(r[2]+a[2]);let o=eH(u,yv)*d,l=t._debugParams.lodSwitchDistance,h=l>=0;if(h&&l>
109=9999)i.targetLod=0;else{let n;if(h)n=l;else{let t=(a[2]-r[2])*d*s[2],i=Math.max(a[0]-r[0],a[1]-r[1])*d*Math.max(s[0],s[1]);n=2e3+3e3*(t>=30?1:i>=80?.5:.25*(Math.max(t,i)>=20))}!function(t,i,r,a,n){let o=t.node;if(o.lodMeshes&&o.lodMeshes.length>0)if(t.targetLod<0)t.targetLod=+(i>a);else{let o=n>0?r/1e3/n:1;t.targetLod=tL(i>a?t.targetLod+o:t.targetLod-o,0,1)}else t.targetLod=0}(i,o,Math.min(t.frameTimeDelta,1e3/30),n,t._debugParams.lodSwitchFadeDuration)}}if(!y&&T){let t=1/6;i.cameraCollisionOpacity=u[0]>n.min[0]&&u[0]<n.max[0]&&u[1]>n.min[1]&&u[1]<n.max[1]&&u[2]*d<n.max[2]&&r.footprint&&dI(M,r.footprint)?Math.max(i.cameraCollisionOpacity-t,0):Math.min(1,i.cameraCollisionOpacity+t)}let l=1/s6(h.canonical),c=r.anchor?r.anchor[0]:0,p=r.anchor?r.anchor[1]:0,_=[c*(s[0]-1)+i.evaluatedTranslation[0]*l,p*(s[1]-1)+i.evaluatedTranslation[1]*l,a+i.evaluatedTranslation[2]],m=yE(new Float64Array(16),D,_,s),x=eg([],m,r.globalMatrix),v=eg([],o.expandedFarZProjMatrix,x),S=v[2]*c+v[6]*p+v[10]*a+v[14];r.hidden=!1;let I=f;y||(T&&(I*=i.cameraCollisionOpacity*function(t,i,r,a){var n,o,s,l,h,u,c;if(i.pitch<20)return 1;let d=i.getWorldToCameraMatrix();eg(d,d,t);let p=e5(r.min[0],r.min[1],r.min[2],1),f=e9(e4(),p,d),_=f,m=f;p[1]=r.max[1],_=(f=e9(e4(),p,d))[1]<_[1]?f:_,m=f[1]>m[1]?f:m,p[0]=r.max[0],_=(f=e9(e4(),p,d))[1]<_[1]?f:_,m=f[1]>m[1]?f:m,p[1]=r.min[1],_=(f=e9(e4(),p,d))[1]<_[1]?f:_,m=f[1]>m[1]?f:m;let g=tL(a[0],0,1),y=100*i.pixelsPerMeter*tL(a[1],0,1),x=tL(a[2],0,1),v=(n=e4(),h=(o=_)[1],u=o[2],c=o[3],n[0]=(l=o[0])+g*((s=m)[0]-l),n[1]=h+g*(s[1]-h),n[2]=u+g*(s[2]-u),n[3]=c+g*(s[3]-c),n),b=Math.tan(.5*i.fovX),w=-v[2]*b;if(0===y)return v[1]<-Math.abs(w)?x:1;let T=tL(rG(1,x,(-Math.abs(w)-v[1])/y),x,1);return rG(1,T,tL((i.pitch-20)/20,0,1))}(m,o,i.aabb,w)),I*=function(t,i){let r=t.uniformValues.u_cutoff_params[0],a=t.uniformValues.u_cutoff_params[1],n=t.uniformValues.u_cutoff_params[2],o=t.uniformValues.u_cutoff_params[3];return a===r||o===n?1:tL(((i-r)/(a-r)-n)/(o-n),0,1)}(E,S)),0!==I?L.push({nodeInfo:i,depth:S,opacity:I,wvpForNode:v,nodeModelMatrix:x,tileModelMatrix:m,tileTranslation:_}):r.hidden=!0}for(let i of(y||L.sort((t,i)=>T&&(1!==t.opacity||1!==i.opacity)?1===t.opacity?-1:1===i.opacity?1:t.depth>i.depth?-1:1:t.depth<i.depth?-1:1),L)){let a=i.nodeInfo,h=a.node,u=null;if(t._debugParams.show3DModelFootprints&&h.footprint){let t=h.id||h.name||"footprint";if(!A.has(t)){let r=yE(new Float64Array(16),y_,i.tileTranslation,i.nodeInfo.evaluatedScale);A.set(t,{node:h,mvp:r})}}let c=i.nodeInfo.evaluatedScale;yE(yc,yf,i.tileTranslation,c),yy[0]=1/c[0],yy[1]=-1/c[1],yy[2]=1/c[2],ex(yd,ym,yy),eg(yc,yc,h.globalMatrix);let d=P?0:a.evaluatedRMEA[0][2],p=a.targetLod,f=h.lodMeshes&&h.lodMeshes.length>0,g=f&&p>0&&p<1;if(y&&f&&1===Math.round(p))continue;let b=!y&&s?yT(yp,i.nodeModelMatrix,t.transform):null,w=y&&l?l.calculateShadowPassMatrixFromMatrix(i.nodeModelMatrix):null,T=g?2:1,E=f&&1===Math.round(p);for(let c=0;c<T;++c){let f=g?1===c:E,T=f?h.lodMeshes:h.meshes,A=g?f?-p:1-p:1;for(let c=0;c<T.length;++c){let p,E=T[c],C=!f&&c===h.lightMeshIndex,M=i.wvpForNode;if(C){if(!x&&!t.terrain&&t.shadowRenderer){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);continue}M=yE(yg,y_,i.tileTranslation,i.nodeInfo.evaluatedScale)}else if(x)continue;let R={defines:[]},D=[],L=!!E.normalBuffer;if(!y&&l&&(l.useNormalOffset=L),yS(R.defines,D,E,t,v?null:r.lut),P||R.defines.push("DIFFUSE_SHADED"),I&&R.defines.push("SHADOWS_SINGLE_CASCADE"),S&&(y?S.numRen
109deredVerticesInShadowPass+=E.vertexArray.length:S.numRenderedVerticesInTransparentPass+=E.vertexArray.length),y){yM(E,i.nodeModelMatrix,t,r,w);continue}if(s&&"globe"!==o.projection.name){let t=E.aabb.min,i=E.aabb.max,[r,a]=s.getOpacityForBounds(b,t[0],t[1],i[0],i[1]);R.overrideFog=r>=.05||a>=.05}let O=E.material;O.occlusionTexture&&O.occlusionTexture.offsetScale&&(p=O.occlusionTexture.offsetScale,R.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),g&&R.defines.push("DITHERED_DISCARD");let F=t.getOrCreateProgram("model",R);if(!y&&l&&l.enabled)if(u!==L){for(let t=0;t<z.length;t++)yE(yw[t]=yw[t]||new Float64Array(16),z[t],i.tileTranslation,i.nodeInfo.evaluatedScale);l.setupShadowsFromCascadeMatrices(yw,F,L),u=L}else F.setShadowUniformValues(n,l.getShadowUniformValues());t.uploadCommonUniforms(n,F,null,b);let B=O.pbrMetallicRoughness;B.metallicFactor=.9,B.roughnessFactor=.5;let k=yl(M,yc,yd,h.globalMatrix,t,i.opacity,B.baseColorFactor,O.emissiveFactor,B.metallicFactor,B.roughnessFactor,O,d,r,yb,p,void 0,void 0,A,F.fixedDefines.includes("LIGHTING_3D_MODE"));!C&&(a.hasTranslucentParts||i.opacity<1)&&F.draw(t,n.gl.TRIANGLES,_,g3.disabled,g6.disabled,gP.backCCW,k,r.id,E.vertexBuffer,E.indexBuffer,E.segments,r.paint,t.transform.zoom,void 0,D),F.draw(t,n.gl.TRIANGLES,C?m:_,g3.disabled,C||i.opacity<1||a.hasTranslucentParts?g6.alphaBlended:g6.unblended,gP.backCCW,k,r.id,E.vertexBuffer,E.indexBuffer,E.segments,r.paint,t.transform.zoom,void 0,D)}}}}if(t._debugParams.show3DModelFootprints&&A.size>0)for(let i of Array.from(A.keys()).sort()){let{node:r,mvp:a}=A.get(i);yR(t,0,r,a)}}()}(t,i,r,a),void d();if("model"!==p.type)return;let f=p.getModels(),_=[],m=t.transform.getFreeCameraOptions().position,g=ej([],[m.x,m.y,m.z],t.transform.worldSize);e$(g,g);let y=[],x=[],v=0;for(let a of f){let n=i.getFeatureState("",a.id),o={type:"Unknown",id:a.id,properties:a.featureProperties},h=r.paint.get("model-rotation").evaluate(o,n),u=r.paint.get("model-scale").evaluate(o,n),c=r.paint.get("model-translation").evaluate(o,n),d=r.paint.get("model-opacity").evaluate(o,n);(function(t,i,r,a,n,o){for(let s of n){let n={...a};n.part=s;let l={type:"Unknown",id:i,properties:n},h={orientation:t.paint.get("model-rotation").evaluate(l,r)};o.set(s,h)}})(r,a.id,n,a.featureProperties,a.nodeOverrideNames,a.nodeOverrides),function(t,i,r,a,n,o){for(let s of n){let n={...a};n.part=s;let l={type:"Unknown",id:i,properties:n},h={color:t.paint.get("model-color").evaluate(l,r),colorMix:t.paint.get("model-color-mix-intensity").evaluate(l,r),opacity:t.paint.get("model-opacity").evaluate(l,r),emissionStrength:t.paint.get("model-emissive-strength").evaluate(l,r)};o.set(s,h)}}(r,a.id,n,a.featureProperties,a.materialOverrideNames,a.materialOverrides),a.nodeOverrides.size>0&&a.computeBoundsAndApplyParent(),a.computeModelMatrix(t,h,u,c,l,s,!1);let p=eT([],g),f=eE([],[1,1,1/s4(a.position.lat,t.transform.zoom)]);for(let i of(_.push({zScaleMatrix:f,negCameraPosMatrix:p}),a.nodes))yC(t,i,a.matrix,t.transform.expandedFarZProjMatrix,v,y,x,a.materialOverrides,d,void 0,a.lightOverrides);v++}if(y.sort((t,i)=>i.depth-t.depth),"shadow"!==t.renderPass){if(t._debugParams.show3DModelFootprints){let i=t.transform.projMatrix,r=new Map,a=(t,a)=>{if(t.footprint){let n=t.id||t.name||"footprint";if(!r.has(n)){let o=eg([],i,a);r.set(n,{node:t,mvp:o})}}};for(let t of x)a(t.node,t.modelMatrix);for(let t of y)a(t.node,t.modelMatrix);for(let i of Array.from(r.keys()).sort()){let{node:a,mvp:n}=r.get(i);yR(t,0,a,n)}}yD(t,r,y,x,_),d()}else{for(let i of x)yM(i.mesh,i.nodeModelMatrix,t,r);for(let i of y)yM(i.mesh,i.nodeModelMatrix,t,r);d()}},xs=function(t,i,r){let a=i.getSource();if(a.loaded()){if("vector"===a.type||"geojson"===a.type)return void(r.modelManager&&r.modelManager.upload(r,yA(r,t)));if("batched-model"!==a.type&&"model"===a.type)for(let t of a.getModels())t.upload(r.context)}},xl={model:t=>({u_matrix:new hf(t),u_lighting_matrix:new hf(t),u_normal_matrix:new hf(t),u_node_matrix:new hf(t),u_lightpos:new hu(t),u_lightintensity:new hl(t),u_lightcolor:new hu(t),u_camera_pos:new hu(t),u_opacity:new hl(t),u_baseColorFactor:new hd(t),u_emissiveFactor:new hd(t),u_metallicFactor:new hl(t),u_roughnessFactor:new hl(t),u_baseTextureIsAlpha:new hs(t),u_alphaMask:new hs(t),u_alphaCutoff:new hl(t),u_baseColorTexture:new hs(t),u_metallicRoughnessTexture:new hs(t),u_normalTexture:new hs(t),u_occlusionTexture:new hs(t),u_emissionTexture:new hs(t),u_lutTexture:new hs(t),u_color_mix:new hd(t),u_aoIntensity:new hl(t),u_emissive_strength:new hl(t),u_occlusionTextureTransform:new hd(t),u_dithered_discard_threshold:new hl(t)}),modelDepth:t=>({u_matrix:new hf(t),u_instance:new hf(t),u_node_matrix:new hf(t)}),groundShadow:t=>({u_matrix:new hf(t),u_ground_shadow_factor:new hu(t)}),fillExtrusionDepth:t=>({u_matrix:new hf(t),u_edge_radius:new hl(t),u_width_scale:new hl(t),u_vertical_scale:new hl(t),u_height_type:new hs(t),u_base_type:new hs(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new hf(t),u_opacity:new hl(t),u_ao_pass:new hl(t),u_meter_to_tile:new hl(t),u_ao:new hh(t),u_flood_light_intensity:new hl(t),u_flood_light_color:new hu(t),u_attenuation:new hl(t),u_edge_radius:new hl(t),u_fb:new hs(t),u_fb_size:new hl(t),u_dynamic_offset:new hl(t)})},xh=class{constructor(t){this.painter=t,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new xa,this._depthMode=new gz(t.context.gl.LEQUAL,gz.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this._devtoolsFolder=null,this.useNormalOffset=!1,this._shadowParameters={cascadeCount:2,normalOffset:3,shadowMapResolution:2048}}destroy(){for(let t of this._cascades)t.texture.destroy(),t.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){let r=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!i||!i.properties)return;let a=i.properties.get("shadow-intensity"),n=i.properties.get("shadow-draw-before-layer");if(!i.shadowsEnabled()||a<=0)return;let o=-1,s=0;for(let i of r.style.order){let a=r.style._mergedLayers[i];a.hasShadowPass()&&!a.isHidden(t.zoom)&&(o=s),n&&(n===i||n===a.slot)&&(this._drawShadowAfterLayer=s>0?s-1:0),s+=1}if(this._enabled=o>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=o);let l=r.context,h=this._shadowParameters.shadowMapResolution,u=this._shadowParameters.shadowMapResolution;if(0===this._cascades.length||this._shadowParameters.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<this._shadowParameters.cascadeCount;++t){let t=l.gl,i=l.createFramebuffer(h,u,0,"texture"),r=new uW(l,{width:h,height:u,data:null},t.DEPTH_COMPONENT16);i.depthAttachment.set(r.texture),this._cascades.push({framebuffer:i,texture:r,matrix:[],far:0,boundingSphereRadius:0,frustum:new cm,scale:0})}}this.shadowDirection=ya(i);let c=0;if(t.elevation){let i=t.elevation,r=[1e4,-1e4];i.visibleDemTiles.filter(t=>t.dem).forEach(t=>{let i=t.dem.tree;r[0]=Math.min(r[0],i.minimums[0]),r[1]=Math.max(r[1],i.maximums[0])}),1e4!==r[0]&&(c=(r[1]-r[0])*i.exaggeration())}let d=1.5*t.cameraToCenterDistance,p=3*d,f=new Float64Array(16);for(let i=0;i<this._cascades.length;++i){let r=this._cascades[i],a=t.height/50,n=1;1===this._shadowParameters.cascadeCount?n=p:0===i?n=d:(a=d,n=p);let[o,s]=function(t,i,r,a,n,o){let s,l,h=t.zoom,u=t.scale,c=t.worldSize,d=1/c,p=t.aspect,f=Math.sqrt(1+p*p)*Math.tan(.5*t.fovX),_=f*f,m=a-r,g=a+r;_>m/g?(s=a,l=a*f):(s=.5*g*(1+_),l=.5*Math.sqrt(m*m+2*(a*a+r*r)*_+g*g*_*_));let y=t.projection.pixelsPerMeter(t.center.lat,c),x=[0,0,-s*d];eQ(x,x,t._camera.getCameraToWorldMercator());let v=l*d,b=t._edgeInsets;if((0!==b.left||0!==b.top||0!==b.right||0!==b.bottom)&&(b.left!==b.right||b.top!==b.bottom)){let i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?y:1),n=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,r,a);n[8]=-(2*t.centerOffset.x)/t.width,n[9]=2*t.centerOffset.y/t.height;let o=new Float64Array(16);eg(o,n,i);let s=new Float64Array(16);
109for(let i of(em(s,o),cm.fromInvProjectionMatrix(s,c,h,!0).points))v=Math.max(v,eL(ek([],x,function(i){return i[0]/=u,i[1]/=u,i[2]=i[2]/s2(t._center.lat),i}(i))))}v*=n/(n-1);let w=Math.acos(i[2]),T=Math.atan2(-i[0],-i[1]),E=new gN;E.position=x,E.setPitchBearing(w,T);let S=E.getWorldToCamera(c,y),I=v*c,A=Math.min(-(t._mercatorZfromZoom(17)*c*2),-2*I),C=E.getCameraToClipOrthographic(-I,I,-I,I,A,(I+o*y)/i[2]),M=new Float64Array(16);eg(M,C,S);let R=.5*n,D=[0,0,0];eQ(D,eO(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),M),ej(D,D,R);let P=[Math.floor(D[0]),Math.floor(D[1]),Math.floor(D[2])],z=[0,0,0];ek(z,D,P),ej(z,z,-1/R);let L=new Float64Array(16);return ef(L),ey(L,L,z),eg(M,L,M),[M,I]}(t,this.shadowDirection,a,n,this._shadowParameters.shadowMapResolution,c);r.scale=t.scale,r.matrix=o,r.boundingSphereRadius=s,em(f,r.matrix),r.frustum=cm.fromInvProjectionMatrix(f,1,0,!0),r.far=n}let _=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[_].far,this._cascades[_].far],this._uniformValues.u_shadow_intensity=a,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=this._shadowParameters.shadowMapResolution,this._uniformValues.u_shadowmap_0=11,this._uniformValues.u_shadowmap_1=12,this._groundShadowTiles=r.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});let m=r.transform.elevation;for(let t of this._groundShadowTiles){let i={min:0,max:0};if(m){let r=m.getMinMaxForTile(t);r&&(i=r)}this.addShadowReceiver(t.toUnwrapped(),i.min,i.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(t){this._enabled=t}drawShadowPass(t,i){if(!this.enabled)return;let r=this.painter,a=r.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(r.transform.getFrustum(0),r.transform.worldSize,this._cascades),a.viewport.set([0,0,this._shadowParameters.shadowMapResolution,this._shadowParameters.shadowMapResolution]);for(let n=0;n<this._numCascadesToRender;++n)for(let o of(r.currentShadowCascade=n,a.bindFramebuffer.set(this._cascades[n].framebuffer.framebuffer),a.clear({color:rq.white,depth:1}),t.order)){let a=t._mergedLayers[o];if(!a.hasShadowPass()||a.isHidden(r.transform.zoom))continue;let n=t.getLayerSourceCache(a),s=n?i[n.id]:void 0;("model"===a.type||s&&s.length)&&r.renderLayer(r,n,a,s)}r.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;let t=this.painter,i=t.style,r=t.context,a=r.gl,n=i.directionalLight,o=i.ambientLight;if(!n||!o)return;let s=[],l=g2(t,t.longestCutoffRange);l.shouldRenderCutoff&&s.push("RENDER_CUTOFF"),s.push("RENDER_SHADOWS"),this.useNormalOffset&&s.push("NORMAL_OFFSET");let h=yn(i,n,o),u=new gz(a.LEQUAL,gz.ReadOnly,t.depthRangeFor3D),c=new g3({func:a.EQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.KEEP);for(let i of this._groundShadowTiles){let n=i.toUnwrapped(),o=t.isTileAffectedByFog(i),d=t.getOrCreateProgram("groundShadow",{defines:s,overrideFog:o});this.setupShadows(n,d),t.uploadCommonUniforms(r,d,n,null,l);let p=y9(t.transform.calculateProjMatrix(n),h);d.draw(t,a.TRIANGLES,u,c,g6.multiply,gP.disabled,p,"ground_shadow",t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments,null,t.transform.zoom,null,null)}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(t){let i=this.painter.transform,r=i.calculatePosMatrix(t,i.worldSize);return eg(r,this._cascades[this.painter.currentShadowCascade].matrix,r),Float32Array.from(r)}calculateShadowPassMatrixFromMatrix(t){return eg(xi,this._cascades[this.painter.currentShadowCascade].matrix,t)}setupShadows(t,i,r){if(!this.enabled)return;let a=this.painter.transform,n=this.painter.context,o=n.gl,s=this._uniformValues,l=a.calculatePosMatrix(t,a.worldSize);for(let t=0;t<this._cascades.length;t++){let i=xe(t);eg(i,this._cascades[t].matrix,l),s[0===t?"u_light_matrix_0":"u_light_matrix_1"]=i,n.activeTexture.set(o.TEXTURE0+11+t),this._cascades[t].texture.bindExtraParam(o.LINEAR,o.LINEAR,o.CLAMP_TO_EDGE,o.CLAMP_TO_EDGE,o.GREATER)}if(this.useNormalOffset=!!r,this.useNormalOffset){let i=s6(t.canonical),n=2/a.tileSize*8192/this._shadowParameters.shadowMapResolution,o=n*this._cascades[0].boundingSphereRadius,l=n*this._cascades.at(-1).boundingSphereRadius,h=("vector-tile"===r?1:3)*function(t){let i=tL(-((t-22)/22),0,1);return .125*(1-i)+4*i}(a.zoom);s.u_shadow_normal_offset=[i,o*h,l*h],s.u_shadow_bias=[1e-4,.0012,.012]}else s.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(n,s)}computeCascadeTileMatrices(t){let i=this._shadowParameters.cascadeCount;for(let r=0;r<i;r++)eg(xt[r]=xt[r]||new Float64Array(16),this._cascades[r].matrix,t);return xt.length=i,xt}
109setupShadowsFromMatrix(t,i,r=!1){if(!this.enabled)return;let a=this._shadowParameters.cascadeCount;for(let i=0;i<a;i++)eg(xe(i),this._cascades[i].matrix,t);y7.length=a,this.setupShadowsFromCascadeMatrices(y7,i,r)}setupShadowsFromCascadeMatrices(t,i,r=!1){if(!this.enabled)return;let a=this.painter.context,n=a.gl,o=this._uniformValues;for(let i=0;i<this._shadowParameters.cascadeCount;i++)o[0===i?"u_light_matrix_0":"u_light_matrix_1"]=t[i],a.activeTexture.set(n.TEXTURE0+11+i),this._cascades[i].texture.bindExtraParam(n.LINEAR,n.LINEAR,n.CLAMP_TO_EDGE,n.CLAMP_TO_EDGE,n.GREATER);if(this.useNormalOffset=r,r){let t=this._shadowParameters.normalOffset;o.u_shadow_normal_offset=[1,t,t],o.u_shadow_bias=[6e-5,.0012,.012]}else o.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(a,o)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,i,r,a){if(a[2]>=0)return{};let n=(function(t,i,r){let a=r/(1<<t.canonical.z);return new cg([t.canonical.x*a+t.wrap*r,t.canonical.y*a+t.wrap*r,0],[(t.canonical.x+1)*a+t.wrap*r,(t.canonical.y+1)*a+t.wrap*r,i])})(t,i,r).getCorners(),o=-(i/a[2]);a[0]<0?(eB(n[0],n[0],[a[0]*o,0,0]),eB(n[3],n[3],[a[0]*o,0,0])):a[0]>0&&(eB(n[1],n[1],[a[0]*o,0,0]),eB(n[2],n[2],[a[0]*o,0,0])),a[1]<0?(eB(n[0],n[0],[0,a[1]*o,0]),eB(n[1],n[1],[0,a[1]*o,0])):a[1]>0&&(eB(n[2],n[2],[0,a[1]*o,0]),eB(n[3],n[3],[0,a[1]*o,0]));let s={};return s.vertices=n,s.planes=[xn(n[1],n[0],n[4]),xn(n[2],n[1],n[5]),xn(n[3],n[2],n[6]),xn(n[0],n[3],n[7])],s}addShadowReceiver(t,i,r){this._receivers.add(t,cg.fromTileIdAndHeight(t,i,r))}getMaxCascadeForTile(t){let i=this._receivers.get(t);return i&&i.lastCascade?i.lastCascade:0}};async function xu(){return Promise.resolve()}function xc(t,i,r,a,n,o,s,l){let h;r.resetLayerRenderingStats(t);let u=t.context,c=u.gl,d=t.transform,p=r.paint.get("fill-extrusion-pattern"),f=r.paint.get("fill-extrusion-pattern-cross-fade"),_=p.constantOr(null),m=p.constantOr(1),g=r.paint.get("fill-extrusion-opacity"),y=t.style.enable3dLights(),x=r.paint.get(y&&!m?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),v=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),x],b=r.layout.get("fill-extrusion-edge-radius"),w=b>0&&!r.paint.get("fill-extrusion-rounded-roof"),T=w?0:b,E="globe"===d.projection.name?f4():0,S="globe"===d.projection.name,I=S?cN(d.zoom):0,A=[az(d.center.lng),aL(d.center.lat)],C="none"===r.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),M=r.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(C?null:r.lut).toArray01().slice(0,3),R=r.paint.get("fill-extrusion-flood-light-intensity"),D=r.paint.get("fill-extrusion-vertical-scale"),P=0!==r.paint.get("fill-extrusion-line-width").constantOr(1),z=r.paint.get("fill-extrusion-height-alignment"),L=r.paint.get("fill-extrusion-base-alignment"),O=g2(t,r.paint.get("fill-extrusion-cutoff-fade-range")),F=r.paint.get("fill-extrusion-front-cutoff"),B=xp(d.pitch,F,!!t.terrain),
109k=B[2]<1;k&&(t.maxFrontCutoffRawStart=Math.max(t.maxFrontCutoffRawStart,F[0]));let N=[];S&&N.push("PROJECTION_GLOBE_VIEW"),v[0]>0&&N.push("FAUX_AO"),w&&N.push("ZERO_ROOF_RADIUS"),l&&N.push("HAS_CENTROID"),R>0&&N.push("FLOOD_LIGHT"),O.shouldRenderCutoff&&N.push("RENDER_CUTOFF"),k&&N.push("RENDER_FRONT_CUTOFF"),P&&N.push("RENDER_WALL_MODE");let V="shadow"===t.renderPass,U=t.shadowRenderer,j=V&&!!U,G=V?gP.disabled:gP.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let H=[0,0,0];if(U){let i=t.style.directionalLight,r=t.style.ambientLight;i&&r&&(H=yn(t.style,i,r)),V||(N.push("RENDER_SHADOWS"),U.useNormalOffset&&N.push("NORMAL_OFFSET")),h=N.concat(["SHADOWS_SINGLE_CASCADE"])}let q=j?"fillExtrusionDepth":m?"fillExtrusionPattern":"fillExtrusion",Z=r.getLayerRenderingStats();for(let p of a){let a,y=i.getTile(p),x=y.getBucket(r);if(!x||x.projection.name!==d.projection.name)continue;let b=!1;U&&(b=0===U.getMaxCascadeForTile(p.toUnwrapped()));let w=t.isTileAffectedByFog(p),C=x.programConfigurations.get(r.id),F=!1;if(_&&y.imageAtlas){let t=y.imageAtlas,i=au.from(_),r=i.getPrimary().scaleSelf(is.devicePixelRatio).toString(),a=i.getSecondary(),n=t.patternPositions.get(r),o=a?t.patternPositions.get(a.scaleSelf(is.devicePixelRatio).toString()):null;F=!!n&&!!o,n&&C.setConstantPatternPositions(n,o)}f>0&&(F||C.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&N.push("FILL_EXTRUSION_PATTERN_TRANSITION");let k=t.getOrCreateProgram(q,{config:C,defines:b?h:N,overrideFog:w});if(t.terrain&&t.terrain.setupElevationDraw(y,k,{useMeterToDem:!0}),!x.centroidVertexBuffer){let t=k.getAttributeLocation(c,"a_centroid_pos");-1!==t&&c.vertexAttribI4ui(t,0,0,0,0)}!V&&U&&U.setupShadows(y.tileID.toUnwrapped(),k,"vector-tile"),m&&(t.context.activeTexture.set(c.TEXTURE0),y.imageAtlasTexture&&y.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),C.updatePaintBuffers());let j=r.paint.get("fill-extrusion-vertical-gradient"),$=1/x.tileToMeter;if(V&&U){if(xg(y.tileID,x.maxHeight,t))continue;a=yi(U.calculateShadowPassMatrixFromTile(y.tileID.toUnwrapped()),T,$,D,z,L)}else{let i=t.translatePosMatrix(p.expandedProjMatrix,y,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),n=d.projection.createInversionMatrix(d,p.canonical),o=k.fixedDefines.includes("LIGHTING_3D_MODE");a=m?yr(i,t,j,g,v,T,$,p,y,E,z,L,I,A,n,M,D,f,o):yt(i,t,j,g,v,T,$,p,E,z,L,I,A,n,M,D,R,H,B,o)}t.uploadCommonUniforms(u,k,p.toUnwrapped(),null,O);let W=x.segments;if("mercator"===d.projection.name&&!V&&!(W=x.getVisibleSegments(y.tileID,t.terrain,t.transform.getFrustum(0))).get().length)continue;if(Z)if(V)for(let t of W.get())Z.numRenderedVerticesInShadowPass+=t.primitiveLength;else for(let t of W.get())Z.numRenderedVerticesInTransparentPass+=t.primitiveLength;let X=[];(t.terrain||l)&&X.push(x.centroidVertexBuffer),S&&X.push(x.layoutVertexExtBuffer),P&&X.push(x.wallVertexBuffer),k.draw(t,u.gl.TRIANGLES,n,o,s,G,a,r.id,x.layoutVertexBuffer,x.indexBuffer,W,r.paint,t.transform.zoom,C,X)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}class xd{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function xp(t,i,r){if(!(i[2]<1)||r)return[0,0,1];let a=180*t/Math.PI;if(a<15)return[-.5,i[1],i[2]];let n=Math.min(1,Math.max(0,(a-15)/5)),o=n*n*(3-2*n);return[-.5*(1-o)+i[0]*o,i[1],i[2]]}let xf=[1,0,0],x_=[0,1,0],xm=[0,0,1];function xg(t,i,r){let a=r.transform,n=r.shadowRenderer;if(!n)return!0;let o=r.frameCounter,s=r.currentShadowCascade,l=r._shadowCullCache;if(!l||l.frame!==o||l.cascade!==s){let t=a.tileSize*n._cascades[s].scale,i=a.scaleZoom(t),h=n.shadowDirection,u=[h[0],h[1],-h[2]],c=[xf,x_,xm,u,[u[0],0,u[2]],[0,u[1],u[2]]];r._shadowCullCache=l={frame:o,cascade:s,cameraFrustum:cm.fromInvProjectionMatrix(a.invProjMatrix,a.worldSize,i,"globe"!==a.projection.name),edges:c,shadowDir:u,ws:t,zoom:i}}let{cameraFrustum:h,edges:u,shadowDir:c,ws:d,zoom:p}=l,f=i;if(a.elevation){let i=a.elevation.getMinMaxForTile(t);i&&(f+=i.max)}f/=s4(a.center.lat,p);let _=n.computeSimplifiedTileShadowVolume(t.toUnwrapped(),f,d,c);if(!_)return!1;let{vertices:m,planes:g}=_;return 0===h.intersectsPrecise(m,g,u)||0===n.getCurrentCascadeFrustum().intersectsPrecise(m,g,u)}let xy=new Float32Array(16),xx=new Float32Array(16);function xv(t){let{painter:i,source:r,layer:a,coords:n}=t,o=t.defines,s=i.context,l="shadow"===i.renderPass,h="light-beam"===i.renderPass,u=i.shadowRenderer,c=s4(i.transform.center.lat,i.transform.zoom),d=g2(i,a.paint.get("building-cutoff-fade-range"));d.shouldRenderCutoff&&(o=o.concat("RENDER_CUTOFF"));let p=a.paint.get("building-front-cutoff"),f=p[2]<1&&!i.terrain,_=xp(i.transform.pitch,p,!!i.terrain);for(let m of(f&&(o=o.concat("RENDER_FRONT_CUTOFF"),i.maxFrontCutoffRawStart=Math.max(i.maxFrontCutoffRawStart,p[0])),t.floodLightIntensity>
1090&&(o=o.concat("FLOOD_LIGHT")),n)){let n,p,f,g=r.getTile(m),y=g.getBucket(a);if(!y)continue;u&&0===u.getMaxCascadeForTile(m.toUnwrapped())&&(o=o.concat("SHADOWS_SINGLE_CASCADE"));let x=y.programConfigurations.get(a.id);if(ex(xy,i.translatePosMatrix(m.expandedProjMatrix,g,[0,0],"map"),[1,1,t.verticalScale]),l&&u){if(xg(g.tileID,y.maxHeight*c,i))continue;let r=u.calculateShadowPassMatrixFromTile(g.tileID.toUnwrapped());ex(r,r,[1,1,t.verticalScale]),f=gD(r),n=p=i.getOrCreateProgram("buildingDepth",{config:x,defines:o,overrideFog:!1})}else if(h)n=p=i.getOrCreateProgram("buildingBloom",{config:x,defines:o,overrideFog:!1}),f=gR(xy);else{let r=i.transform.calculatePosMatrix(m.toUnwrapped(),i.transform.worldSize);ex(r,r,[1,1,t.verticalScale]),ex(xx,r,[1,-1,1/c]),em(xx,xx),e_(xx,xx);let a=i.transform.getFreeCameraOptions().position,l=1<<m.canonical.z;if(f=gM(xy,xx,t.opacity,t.facadeAOIntensity,[((a.x-m.wrap)*l-m.canonical.x)*8192,(a.y*l-m.canonical.y)*8192,a.z*l*8192],y.tileToMeter,t.facadeEmissiveChance,t.floodLightColor,t.floodLightIntensity,_),p=i.getOrCreateProgram("building",{config:x,defines:o,overrideFog:!1}),!0===t.depthOnly)n=p;else{let t=o.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);n=i.getOrCreateProgram("building",{config:x,defines:t,overrideFog:!1})}u&&(u.setupShadowsFromMatrix(r,p,!0),n!==p&&n.setShadowUniformValues(s,u.getShadowUniformValues()))}let v=(r,n)=>{if(h){let o=r.entranceBloom;n.draw(i,s.gl.TRIANGLES,t.depthMode,g3.disabled,t.blendMode,gP.disabled,f,a.id,o.layoutVertexBuffer,o.indexBuffer,o.segmentsBucket,a.paint,i.transform.zoom,x,[o.layoutAttenuationBuffer,o.layoutColorBuffer])}else{let o=r.segmentsBucket,h=[r.layoutNormalBuffer,r.layoutCentroidBuffer,r.layoutColorBuffer,r.layoutFloodLightDataBuffer];r.layoutFacadePaintBuffer&&(h=h.concat([r.layoutFacadeDataBuffer,r.layoutFacadeVerticalRangeBuffer,r.layoutFacadePaintBuffer])),n.draw(i,s.gl.TRIANGLES,t.depthMode,g3.disabled,t.blendMode,l?gP.disabled:gP.backCW,f,a.id,r.layoutVertexBuffer,r.indexBuffer,o,a.paint,i.transform.zoom,x,h)}};i.uploadCommonUniforms(s,p,m.toUnwrapped(),null,d),y.buildingWithoutFacade&&v(y.buildingWithoutFacade,p),y.buildingWithFacade&&(n!==p&&i.uploadCommonUniforms(s,n,m.toUnwrapped(),null,d),v(y.buildingWithFacade,n))}}function xb(t,i,r,a,n,o,s,l,h,u,c,d,p,f){let _=t.context.gl,m=t.depthModeForSublayer(1,gz.ReadOnly,_.LEQUAL,!0),g=rG(.1,3,c),y=t._showOverdrawInspector,x=new xd;y||g5(x,t,i,r,a,m,new g3({func:_.ALWAYS,mask:255},255,255,_.KEEP,_.KEEP,_.REPLACE),new g6([_.ONE,_.ONE,_.ONE,_.ONE],rq.transparent,[!1,!1,!1,!0],_.MIN),gP.disabled,n,"sdf",o,s,l,h,u,g,d,!1,void 0);{let c=y?g3.disabled:new g3({func:_.EQUAL,mask:255},255,255,_.KEEP,_.DECR,_.DECR),p=y?t.colorModeForRenderPass():new g6([_.ONE_MINUS_DST_ALPHA,_.DST_ALPHA,_.ONE,_.ONE],rq.transparent,[!0,!0,!0,!0]);g5(x,t,i,r,a,m,c,p,gP.disabled,n,"color",o,s,l,h,u,g,d,!1,void 0)}}class xw{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(t,i,r,a,n){if(r<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let o=null,s=Number.MAX_VALUE,l=Number.MAX_VALUE,h=!1,u=this._previousClosestBuildingId?t[this._previousClosestBuildingId]:null;for(let[r,c]of(this._previousClosestBuildingId&&u&&this._isBuildingVisible(u,a,n)&&(h=!0,l=this._calculateDistance(i,u)),Object.entries(t))){if(!this._isBuildingVisible(c,a,n))continue;let t=this._calculateDistance(i,c);t<s&&(s=t,o=r)}return h&&o&&this._previousClosestBuildingId&&o!==this._previousClosestBuildingId?s>l*this._hysteresisRatio&&(o=this._previousClosestBuildingId):h&&!o&&(o=this._previousClosestBuildingId),this._previousClosestBuildingId=o,o}_calculateDistance(t,i){if(!i.center)return Number.MAX_VALUE;let r=t.lat-i.center[1],a=t.lng-i.center[0];return r*r+a*a}_isBuildingVisible(t,i,r){if(!r)return!1;for(let i of t.floorIds){let a=t.floors[i];if(!a.geometry)continue;let n=a.geometry;if("Polygon"===n.type){if(hj(this._convertRingToPoints(n.coordinates[0]),r))return!0}else if("MultiPolygon"===n.type&&hG(r,this._convertMultiPolygonToPoints(n.coordinates)))return!0}return!1}_convertRingToPoints(t){return t.map(t=>new tg(t[0],t[1]))}_convertMultiPolygonToPoints(t){return t.map(t=>0===t.length?[]:t[0].map(t=>new tg(t[0],t[1])))}}let xT=(t,i,r,a,n,o,s,l,h,u,c,d)=>({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:r,u_merc_matrix:a,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:u,u_fade_t:c.mix,u_opacity:c.op
109acity,u_image0:0,u_image1:1,u_raster_elevation:d,u_zoom_transition:s,u_merc_center:l,u_cutoff_params:h}),xE=(t,i,r,a,n,o,s,l,h,u)=>({u_particle_texture:t,u_particle_texture_side_len:i,u_tile_offset:r,u_velocity:a,u_color_ramp:o,u_velocity_res:n,u_max_speed:s,u_uv_offset:l,u_data_scale:[255*h[0],255*h[1]],u_data_offset:u,u_particle_pos_scale:1.1,u_particle_pos_offset:[.05,.05]}),xS=(t,i,r,a,n,o,s,l,h,u)=>({u_particle_texture:t,u_particle_texture_side_len:i,u_velocity:r,u_velocity_res:a,u_max_speed:n,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:l,u_data_scale:[255*h[0],255*h[1]],u_data_offset:u,u_particle_pos_scale:1.1,u_particle_pos_offset:[.05,.05]});function xI(t,[i,r,a,n],[o,s]){if(o===s)return[0,0,0,0];let l=255*(t-1)/(t*(s-o));return[i*l,r*l,a*l,n*l]}function xA(t,i,[r,a]){return r===a?0:.5/t+(i-r)*(t-1)/(t*(a-r))}class xC{constructor(t){this._stringToNumber={},this._numberToString=[];for(let i=0;i<t.length;i++){let r=t[i];this._stringToNumber[r]=i,this._numberToString[i]=r}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}function xM(t,i,r,a,n){return tH(t,(t,o)=>{let s=i instanceof o9?i.get(o):null;return s&&s.evaluate?s.evaluate(r,a,void 0,n):s})}function xR(t,i){return i-t}function xD(t,i){let r={};if(!i)return r;for(let a of t){let t=a.layerIds.map(t=>i.getLayer(t)).filter(Boolean);if(0!==t.length)for(let i of(a.layers=t,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(i=>t.filter(t=>t.id===i)[0])),a.updateExpressions&&a.updateExpressions(t),t))r[i.fqid]=a}return r}oC(class{constructor(t,i){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new oI(8192,8192,512),this.featureIndexArray=new l0,this.promoteId=i,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(t,i,r,a,n,o=0,s=0){let l=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,a,n,o);let h=this.grid;for(let t=0;t<i.length;t++){let r=i[t],a=[1/0,1/0,-1/0,-1/0];for(let t=0;t<r.length;t++){let i=r[t];a[0]=Math.min(a[0],i.x),a[1]=Math.min(a[1],i.y),a[2]=Math.max(a[2],i.x),a[3]=Math.max(a[3],i.y)}
1090!==s&&(a[0]-=s,a[1]-=s,a[2]+=s,a[3]+=s),a[0]<8192&&a[1]<8192&&a[2]>=0&&a[3]>=0&&h.insert(l,a[0],a[1],a[2],a[3])}}loadVTLayers(){if(!this.vtLayers)for(let t in this.vtLayers=new hU(new uz(this.rawTileData)).layers,this.sourceLayerCoder=new xC(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[t]=[];return this.vtLayers}query(t,i){let r,{tilespaceGeometry:a,transform:n,tileTransform:o,pixelPosMatrix:s,availableImages:l,worldview:h}=i;this.loadVTLayers(),this.serializedLayersCache.clear();let u=i.queryRadius?i.queryRadius:0,c=a.bufferedTilespaceBounds,d=this.grid.queryKeys(c.min.x,c.min.y,c.max.x,c.max.y,(t,i,r,n)=>hX(a.bufferedTilespaceGeometry,t-u,i-u,r+u,n+u));d.sort(xR);let p=null;n.elevation&&d.length>0&&(p=_Z.create(n.elevation,this.tileID));let f={};for(let u=0;u<d.length;u++){let c=d[u];if(c===r)continue;r=c;let _=this.featureIndexArray.get(c),m=null;this.is3DTile?this.loadMatchingModelFeature(f,_,t,a,n,h):this.loadMatchingFeature(f,_,t,l,h,(t,r,l,h=0)=>(m||(m=le(t,this.tileID.canonical,o)),r.queryIntersectsFeature(a,t,l,m,this.z,n,s,p,h,i.scope)))}return f}loadMatchingFeature(t,i,r,a,n,o){let{featureIndex:s,bucketIndex:l,sourceLayerIndex:h,layoutVertexArrayOffset:u}=i,c=this.bucketLayerIDs[l],d=r.layers,p=Object.keys(d);if(p.length&&!t$(p,c))return;let f=r.sourceCache,_=this.sourceLayerCoder.decode(h),m=this.vtLayers[_].feature(s),g=this.getId(m,_);for(let i=0;i<c.length;i++){let r=c[i];if(!d[r])continue;let{styleLayer:l,targets:h}=d[r],p={};void 0!==g&&(p=f.getFeatureState(l.sourceLayer,g));let _=!o||o(m,l,p,u);if(!_)continue;let y=new _4(m,this.z,this.x,this.y,g);y.tile=this.tileID.canonical,y.state=p;let x=this.serializedLayersCache.get(r);x||((x=l.serialize()).id=r,this.serializedLayersCache.set(r,x)),y.source=x.source,y.sourceLayer=x["source-layer"],y.layer={...x},y.layer.paint=xM(x.paint,l.paint,m,p,a),y.layer.layout=xM(x.layout,l.layout,m,p,a);let v=new o0(this.tileID.overscaledZ,{worldview:n}),b=!1;for(let t of h){this.updateFeatureProperties(y,t);let{filter:i}=t;if(i){if(m.properties=y.properties,i.needGeometry){let t=lt(m,!0);if(!i.filter(v,t,this.tileID.canonical))continue}else if(!i.filter(v,m))continue}b=!0,t.targetId&&this.addFeatureVariant(y,t)}b&&this.appendToResult(t,r,s,y,_)}}loadMatchingModelFeature(t,i,r,a,n,o){let{featureIndex:s,bucketIndex:l}=i,h=this.bucketLayerIDs[l],u=r.layers,c=Object.keys(u);if(!c.length||t$(c,h))for(let i=0;i<h.length;i++){let l=h[i],{styleLayer:c,targets:d}=u[l];if("model"!==c.type)continue;let p=a.tile,f=p.getBucket(c);if(!(f&&f instanceof _J))continue;let _=function(t,i,r,a){let n=t.getNodesInfo()[i];if(!n||n.hiddenByReplacement||!n.node.meshes)return;let o=Number.MAX_VALUE,s=n.node,l=r.tile,h=a.calculatePosMatrix(l.tileID.toUnwrapped(),a.worldSize),u=n.evaluatedScale,c=0;a.elevation&&s.elevation&&(c=s.elevation*a.elevation.exaggeration()),ey(h,h,[(s.anchor?s.anchor[0]:0)*(u[0]-1),(s.anchor?s.anchor[1]:0)*(u[1]-1),c]),ex(h,h,u);let d=r.queryGeometry,p=d.isPointQuery()?d.screenBounds:d.screenGeometry,f=function(t){let i=eg([],h,t.globalMatrix);eg(i,a.expandedFarZProjMatrix,i);for(let r=0;r<t.meshes.length;++r){let n=t.meshes[r];if(r===t.lightMeshIndex)continue;let s=p6(p,a,i,n.aabb);null!=s&&(o=Math.min(s,o))}if(t.children)for(let i of t.children)f(i)};if(f(s),o===Number.MAX_VALUE)return;let _=new s0(0,0);return _8(l.tileID.canonical,_,n.node.anchor[0],n.node.anchor[1]),{intersectionZ:o,position:_,feature:n.feature}}(f,s,a,n);if(!_)continue;let{z:m,x:g,y:y}=p.tileID.canonical,{feature:x,intersectionZ:v,position:b}=_,w={};void 0!==x.id&&(w=r.sourceCache.getFeatureState(c.sourceLayer,x.id));let T=new _4({},m,g,y,x.id);T.tile=this.tileID.canonical,T.state=w,T.properties=x.properties,T.geometry={type:"Point",coordinates:[b.lng,b.lat]};let E=this.serializedLayersCache.get(l);E||((E=c.serialize()).id=l,this.serializedLayersCache.set(l,E)),T.source=E.source,T.sourceLayer=E["source-layer"],T.layer={...E};let S=new o0(this.tileID.overscaledZ,{worldview:o}),I=!1;for(let t of d){this.updateFeatureProperties(T,t);let{filter:i}=t;if(i){if(x.properties=T.properties,i.needGeometry){if(!i.filter(S,x,this.tileID.canonical))continue}else if(!i.filter(S,x))continue}I=!0,t.targetId&&this.addFeatureVariant(T,t)}I&&this.appendToResult(t,l,s,T,v)}}updateFeatureProperties(t,i,r){if(i.properties){let a={};for(let n in i.properties){let o=i.properties[n].evaluate({zoom:this.z},t._vectorTileFeature,t.state,t.tile,r);null!=o&&(a[n]=o)}t.properties=a}}addFeatureVariant(t,i,r){let a={target:i.target,namespace:i.namespace,uniqueFeatureID:i.uniqueFeatureID};i.properties&&(a.properties=t.properties),t.variants=t.variants||{},t.variants[i.targetId]=t.variants[i.targetId]||[],t.variants[i.targetId].push(a)}appendToResult(t,i,r,a,n){let o=t[i];void 0===o&&(o=t[i]=[]),o.push({featureIndex:r,feature:a,intersectionZ:n})}lookupSymbolFeatures(t,i,r,a,n,o){let s={};
109for(let l of(this.loadVTLayers(),t))this.loadMatchingFeature(s,{bucketIndex:i,sourceLayerIndex:r,featureIndex:l,layoutVertexArrayOffset:0},a,n,o);return s}loadFeature(t){let{featureIndex:i,sourceLayerIndex:r}=t;this.loadVTLayers();let a=this.sourceLayerCoder.decode(r),n=this.vtFeatures[a];if(n[i])return n[i];let o=this.vtLayers[a].feature(i);return n[i]=o,o}hasLayer(t){for(let i of this.bucketLayerIDs)for(let r of i)if(t===r)return!0;return!1}getId(t,i){let r=t.id;if(this.promoteId){let a=Array.isArray(this.promoteId)||"object"!=typeof this.promoteId?this.promoteId:this.promoteId[i];if(null!=a)if(Array.isArray(a)){if(!this.promoteIdExpression){let t=ob(a);if("success"!==t.result){let i=t.value.map(t=>`${t.key}: ${t.message}`).join(", ");return void tX(`Failed to create expression for promoteId: ${i}`)}this.promoteIdExpression=t.value}r=this.promoteIdExpression.evaluate({zoom:0},t)}else r=t.properties[a];"boolean"==typeof r&&(r=Number(r))}return r}},"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});let xP=new Uint16Array(8184);for(let t=0;t<2046;t++){let i=t+2,r=0,a=0,n=0,o=0,s=0,l=0;for(1&i?n=o=s=32:r=a=l=32;(i>>=1)>1;){let t=r+n>>1,h=a+o>>1;1&i?(n=r,o=a,r=s,a=l):(r=n,a=o,n=s,o=l),s=t,l=h}let h=4*t;xP[h+0]=r,xP[h+1]=a,xP[h+2]=n,xP[h+3]=o}let xz=new Uint16Array(2178),xL=new Uint8Array(1089),xO=new Uint16Array(1089);function xF(t){return 0===t?-.03125:.03125*(32===t)}var xB=lo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);let xk={type:2,extent:8192,loadGeometry:()=>[[new tg(0,0),new tg(8193,0),new tg(8193,8193),new tg(0,8193),new tg(0,0)]]},xN=0;class xV{constructor(t,i,r,a,n,o){this.tileID=t,this.uid=tN++,this.uses=0,this.tileSize=i,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,a&&a.style&&(this._lastUpdatedBrightness=a.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",a&&a.transform&&(this.projection=a.transform.projection),this.worldview=o,this._hasAppearances=null}registerFadeDuration(t){let i=t+this.timeAdded;i<is.now()||void 0!==this.fadeEndTime&&i<this.fadeEndTime||(this.fadeEndTime=i)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=c3(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,i,r){if(this.unloadVectorData(),this.state="loaded",t){for(let a in t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=xD(t.buckets,i.style),t.frcCoveragePolygons&&t.frcCoveragePolygons.length>0&&(this.frcCoveragePolygons=t.frcCoveragePolygons),this.hasDeferredRoadStructure=!!t.hasDeferredRoadStructure,void 0!==t.parsedElevationFeatures&&(this.parsedElevationFeatures=t.parsedElevationFeatures,this.parsedElevationGeneration=++xN),this.hasDeferredElevationFeatures=!!t.hasDeferredElevationFeatures,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!t.hasTunnelGeometry,this.buckets){let t=this.buckets[a];if(t instanceof dB){if(this.hasSymbolBuckets=!0,!r)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let t in this.buckets){let i=this.buckets[t];if(i instanceof dB&&i.hasRTLText){this.hasRTLText=!0,oJ();break}}for(let t in this.queryPadding=0,this.buckets){let r=this.buckets[t],a=i.style.getOwnLayer(t);if(!a)continue;let n=a.queryRadius(r)||0;this.queryPadding=Math.max(this.queryPadding,n)}t.imageAtlas&&(this.imageAtlas=i.style.imageManager.imageAtlasCache.getOrCache(t.imageAtlas)),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new lZ}unloadVectorData(){if(this.hasData()){for(let t in this.buckets)this.buckets[t].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(t,i,r){t&&(t.resourceTiming&&(this.resourceTiming=t.resourceTiming),this.buckets={...this.buckets,...xD(t.buckets,i.style)},t.featureIndex&&(this.latestFeatureIndex=t.featureIndex))}getBucket(t){return this.buckets[t.fqid]}upload(t,i){for(let r in this.buckets){let a=this.buckets[r];if(a.uploadPending()){let r={},n=[],o={zoom:0,pitch:0,brightness:0,worldview:""};if(i){if(i.style){n=i.style.listImages();let t=a.layers[0],o=t.sourceLayer||"_geojsonTileLayer",s=i.style.getLayerSourceCache(t);s&&(r=s._state.getState(o,void 0))}o={zoom:i.transform.zoom||0,pitch:i.transform.pitch||0,brightness:i.style.getBrightness()||0,worldview:i.worldview||""}}a.upload(t,this.tileID.canonical,r,n,o)}}let r=t.gl,a=this.imageAtlas;a&&i&&(this.imageAtlasTexture=i.style.imageManager.imageAtlasCache.getTextureForAtlas(a,t,r.RGBA8),a.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new uW(t,this.glyphAtlasImage,r.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new uW(t,this.lineAtlas.image,r.R8),this.lineAtlas.uploaded=!0)}prepare(t,i,r){if(this.imageAtlas&&this.imageAtlasTexture&&i){let a=i.style.getLut(r);this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,r,a)}if(!i||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;let a=i.style.getBrightness(),n=i.style.listImages(),o=n.length,s=i.style._changes.getUpd
109atedPaintProperties(),l=Object.keys(this.buckets).some(t=>this.buckets[t].layers.some(t=>s.has(t.fqid))),h=Object.keys(this.buckets).some(t=>this.buckets[t].layers.some(t=>t.hasTransition&&t.hasTransition())),u=this._firstPrepareComplete&&o!==this._lastAvailableImagesCount;null===this._hasAppearances&&(this._hasAppearances=this.hasAppearances(i));let c=this._lastUpdatedBrightness!==a;this._lastAvailableImagesCount=o,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||a||this._hasAppearances||l||h||u)&&(!(this._hasAppearances||l||h||u)&&this._lastUpdatedBrightness&&a&&.001>Math.abs(this._lastUpdatedBrightness-a)||(this.updateBuckets(i,c,void 0,u||l||h,s,n),this._lastUpdatedBrightness=a))}evaluateQueryRenderedFeaturePadding(){let t=0;for(let i in this.buckets){let r=this.buckets[i];r.evaluateQueryRenderedFeaturePadding&&(t=Math.max(t,r.evaluateQueryRenderedFeaturePadding()))}return t}queryRenderedFeatures(t,i,r,a,n,o,s){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};let l=this.evaluateQueryRenderedFeaturePadding(),h=function(t,i){let r=eE([],[.5*t.width,-(.5*t.height),1]);return ey(r,r,[1,-1,0]),eg(r,r,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(r)}(n,this.tileID);return this.latestFeatureIndex.query(t,{tilespaceGeometry:i,pixelPosMatrix:h,transform:a,availableImages:r,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:l,scope:s})}querySourceFeatures(t,i){let r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;let a=r.loadVTLayers(),n=i?i.sourceLayer:"",o=a._geojsonTileLayer||a[n];if(!o)return;let s=sh(i&&i.filter),{z:l,x:h,y:u}=this.tileID.canonical,c={z:l,x:h,y:u};for(let i=0;i<o.length;i++){let a=o.feature(i);if(s.needGeometry){let t=lt(a,!0);if(!s.filter(new o0(this.tileID.overscaledZ,{worldview:this.worldview}),t,this.tileID.canonical))continue}else if(!s.filter(new o0(this.tileID.overscaledZ,{worldview:this.worldview}),a))continue;let d=r.getId(a,n),p=new _4(a,l,h,u,d);p.tile=c,t.push(p)}}loaded(){return"loaded"===this.state||"errored"===this.state}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!this.imageAtlas.patternPositions.size}setExpiryData(t){let i=this.expirationTime;if(t.cacheControl){let i=t0(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){let t=Date.now(),r=!1;if(this.expirationTime>t)r=!1;else if(i)if(this.expirationTime<i)r=!0;else{let a=this.expirationTime-i;a?this.expirationTime=t+Math.max(a,3e4):r=!0}else r=!0;r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-Date.now(),0x7fffffff)}refreshFeatureState(t,i){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!t)return;let r=t.style.listImages();this.updateBuckets(t,!1,i,void 0,void 0,r)}hasAppearances(t){for(let i in this.buckets)if(t.style.hasLayer(i)&&this.buckets[i].layers.some(t=>t.appearances&&t.appearances.length>0))return!0;return!1}updateBuckets(t,i,r,a,n,o){if(!this.latestFeatureIndex||!t.style)return;let s=o||t.style.listImages(),l=t.style.getBrightness(),h=n||new Set;for(let n in this.buckets){if(!t.style.hasLayer(n))continue;let o=this.buckets[n],u=o.layers[0],c=u.sourceLayer||"_geojsonTileLayer",d=t.style.getLayerSourceCache(u),p=o.layers.some(t=>h.has(t.fqid)),f=(a||p)&&o instanceof dB?t.style.getOwnLayer(n):void 0,_=r&&r[c]||{};d&&!r&&(_=d._state.getState(c,void 0));let m=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},g=Object.keys(_).length>0&&!i;o.hasAppearances=o.layers.some(t=>t.appearances&&t.appearances.length>0);let y=g?o.stateDependentLayers:o.layers;if(g&&0!==o.stateDependentLayers.length||i||p||a){let r=this.latestFeatureIndex.loadVTLayers()[c];if(o.update(_,r,s,m,y,i,l,this.tileID.canonical),(a||p)&&(!i||i&&o instanceof dB&&(!o.text.uboBinder||o.text.uboBinder.isLightConstant||!o.icon.uboBinder||o.icon.uboBinder.isLightConstant))&&o instanceof dB&&f&&"symbol"===f.type&&(o.text&&o.text.uboBinder&&o.text.uboBinder.updateDynamicExpressions(f,r,this.tileID.canonical,s,_,l),o.icon&&o.icon.uboBinder&&o.icon.uboBinder.updateDynamicExpressions(f,r,this.tileID.canonical,s,_,l)),o instanceof dB){let i=t.context;o.text&&o.text.uboBinder&&o.text.uboBinder.upload(i),o.icon&&o.icon.uboBinder&&o.icon.uboBinder.upload(i)}}if(g&&0!==o.stateDependentLayers.length||i||o.hasAppearances){let i={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview},r=o.updateAppearances(this.tileID.canonical,_,s,i,t.imageManager,g&&0!==o.stateDependentLayers.length);if(r&&r.hasUboChanges){let i=t.context;o instanceof dB&&o.text&&o.text.uboBinder&&o.text.uboBinder.upload(i),o instanceof dB&&o.icon&&o.icon.uboBinder&&o.icon.uboBinder.upload(i)}}(o instanceof uo||o instanceof hD)&&t._terrain&&t._terrain.enabled&&d&&o.uploadPending()&&t._terrain._clearRenderCacheForTile(d.id,this.tileID);let x=t&&t.style&&t.style.getOwnLayer(n);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(o)||0))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<is.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=is.now()+t}setTexture(t,i){let r=i.context,a=r.gl;this.texture=this.texture||i.getTileTexture(t.width),this.texture&&this.texture instanceof uW?this.texture.update(t):(this.texture=new uW(r,t,a.RGBA8,{useMipmap:!0}),this.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE))}
109setDependencies(t,i){let r={};for(let t of i)r[t]=!0;this.dependencies[t]=r}hasDependency(t,i){for(let r of t){let t=this.dependencies[r];if(t){for(let r of i)if(t[r])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,i){if(!i||"mercator"===i.name||this._tileDebugBuffer)return;let r=le(xk,this.tileID.canonical,this.tileTransform)[0],a=new ll,n=new lV;for(let t=0;t<r.length;t++){let{x:i,y:o}=r[t];a.emplaceBack(i,o),n.emplaceBack(t)}n.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(n),this._tileDebugBuffer=t.createVertexBuffer(a,cs.members),this._tileDebugSegments=l9.simpleSegment(0,0,a.length,n.length)}_makeTileBoundsBuffers(t,i){let r,a;if(this._tileBoundsBuffer||!i||"mercator"===i.name)return;let n=le(xk,this.tileID.canonical,this.tileTransform)[0];if(this.isRaster){let t=function(t,i){let r=c3(t,i),a=Math.pow(2,t.z);for(let n=0;n<33;n++)for(let o=0;o<33;o++){let s=aO((t.x+(o+xF(o))/32)/a),l=aF((t.y+(n+xF(n))/32)/a),h=i.project(s,l),u=33*n+o;xz[2*u+0]=Math.round((h.x*r.scale-r.x)*8192),xz[2*u+1]=Math.round((h.y*r.scale-r.y)*8192)}xL.fill(0),xO.fill(0);for(let t=2045;t>=0;t--){let i=4*t,r=xP[i+0],a=xP[i+1],n=xP[i+2],o=xP[i+3],s=r+n>>1,l=a+o>>1,h=s+l-a,u=l+r-s,c=33*a+r,d=33*o+n,p=33*l+s,f=Math.hypot((xz[2*c+0]+xz[2*d+0])/2-xz[2*p+0],(xz[2*c+1]+xz[2*d+1]
109)/2-xz[2*p+1])>=16;xL[p]=xL[p]||+!!f,t<1022&&(xL[p]=xL[p]||xL[(a+u>>1)*33+(r+h>>1)]||xL[(o+u>>1)*33+(n+h>>1)])}let n=new lu,o=new lR,s=0;function l(t,i){let r=33*i+t;return 0===xO[r]&&(n.emplaceBack(xz[2*r+0],xz[2*r+1],8192*t/32,8192*i/32),xO[r]=++s),xO[r]-1}function h(t,i,r,a,n,s){let u=t+r>>1,c=i+a>>1;if(Math.abs(t-n)+Math.abs(i-s)>1&&xL[33*c+u])h(n,s,t,i,u,c),h(r,a,n,s,u,c);else{let h=l(t,i),u=l(r,a),c=l(n,s);o.emplaceBack(h,u,c)}}return h(0,0,32,32,32,0),h(32,32,0,0,0,32),{vertices:n,indices:o}}(this.tileID.canonical,i);r=t.vertices,a=t.indices}else{for(let{x:t,y:i}of(r=new lu,a=new lR,n))r.emplaceBack(t,i,0,0);let t=sC(r.int16.subarray(0,4*r.length),void 0,4);for(let i=0;i<t.length;i+=3)a.emplaceBack(t[i],t[i+1],t[i+2])}this._tileBoundsBuffer=t.createVertexBuffer(r,xB.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(a),this._tileBoundsSegments=l9.simpleSegment(0,0,r.length,a.length)}_makeGlobeTileDebugBuffers(t,i){let r,a=i.projection;if(!a||"globe"!==a.name||i.freezeTileCoverage)return;let n=this.tileID.canonical,o=cz(cS(n,i)),s=cN(i.zoom);s>0&&(r=em(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,i,o,r,s),this._makeGlobeTileDebugTextBuffer(t,n,i,o,r,s)}_globePoint(t,i,r,a,n,o,s){let l=cR(t,i,r);if(o){let n=1<<r.z,h=az(a.center.lng),u=aL(a.center.lat),c=(r.x+.5)/n-h,d=0;c>.5?d=-1:c<-.5&&(d=1);let p=(t/8192+r.x)/n+d,f=(i/8192+r.y)/n;p=(p-h)*a._pixelsPerMercatorPixel+h,f=(f-u)*a._pixelsPerMercatorPixel+u;let _=[p*a.worldSize,f*a.worldSize,0];eQ(_,_,o),l=cE(l,_,s)}return eQ(l,l,n)}_makeGlobeTileDebugBorderBuffer(t,i,r,a,n,o){let s=new ll,l=new lV,h=new lh,u=(t,u,c,d,p)=>{let f=(c-t)/(p-1),_=(d-u)/(p-1),m=s.length;for(let c=0;c<p;c++){let d=t+c*f,p=u+c*_;s.emplaceBack(d,p);let g=this._globePoint(d,p,i,r,a,n,o);h.emplaceBack(g[0],g[1],g[2]),l.emplaceBack(m+c)}};u(0,0,8192,0,16),u(8192,0,8192,8192,16),u(8192,8192,0,8192,16),u(0,8192,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(l),this._tileDebugBuffer=t.createVertexBuffer(s,cs.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(h,co.members),this._tileDebugSegments=l9.simpleSegment(0,0,s.length,l.length)}_makeGlobeTileDebugTextBuffer(t,i,r,a,n,o){let s=new ll,l=new lR,h=new lh;l.reserve(32),s.reserve(25),h.reserve(25);let u=(t,i)=>25*t+i;for(let t=0;t<25;t++){let l=2048*t;for(let t=0;t<25;t++){let u=2048*t;s.emplaceBack(u,l);let c=this._globePoint(u,l,i,r,a,n,o);h.emplaceBack(c[0],c[1],c[2])}}for(let t=0;t<4;t++)for(let i=0;i<4;i++){let r=u(t,i),a=u(t,i+1),n=u(t+1,i),o=u(t+1,i+1);l.emplaceBack(r,a,n),l.emplaceBack(n,a,o)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(l),this._tileDebugTextBuffer=t.createVertexBuffer(s,cs.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(h,co.members),this._tileDebugTextSegments=l9.simpleSegment(0,0,25,32)}destroy(t=!0){for(let i in this.buckets)this.buckets[i].destroy(t);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),t&&this.texture&&this.texture instanceof uW&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof uW&&(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"}}var xU=Uint8Array,xj=Uint16Array,xG=Int32Array,xH=new xU([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]),xq=new xU([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]),xZ=new xU([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),x$=function(t,i){for(var r=new xj(31),a=0;a<31;++a)r[a]=i+=1<<t[a-1];var n=new xG(r[30]);for(a=1;a<30;++a)for(var o=r[a];o<r[a+1];++o)n[o]=o-r[a]<<5|a;return{b:r,r:n}},xW=x$(xH,2),xX=xW.b,xY=xW.r;xX[28]=258,xY[258]=28;for(var xK=x$(xq,0).b,xQ=new xj(32768),xJ=0;xJ<32768;++xJ){var x0=(43690&xJ)>>1|(21845&xJ)<<1;xQ[xJ]=((65280&(x0=(61680&(x0=(52428&x0)>>2|(13107&x0)<<2))>>4|(3855&x0)<<4))>>8|(255&x0)<<8)>>1}var x1=function(t,i,r){for(var a=t.length,n=0,o=new xj(i);n<a;++n)t[n]&&++o[t[n]-1];var s,l=new xj(i);for(n=1;n<i;++n)l[n]=l[n-1]+o[n-1]<<1;s=new xj(1<<i);var h=15-i;for(n=0;n<a;++n)if(t[n])for(var u=n<<4|t[n],c=i-t[n],d=l[t[n]-1]++<<c,p=d|(1<<c)-1;d<=p;++d)s[xQ[d]>>h]=u;return s},x2=new xU(288);for(xJ=0;xJ<144;++xJ)x2[xJ]=8;for(xJ=144;xJ<256;++xJ)x2[xJ]=9;for(xJ=256;xJ<280;++xJ)x2[xJ]=7;for(xJ=280;xJ<288;++xJ)x2[xJ]=8;var x3=new xU(32);for(xJ=0;xJ<32;++xJ)x3[xJ]=5;var x4=x1(x2,9),x5=x1(x3,5),x6=function(t){for(var i=t[0],r=1;r<t.length;++r)t[r]>i&&(i=t[r]);return i},x8=function(t,i,r){var a=i/8|0;return(t[a]|t[a+1]<<8)>>(7&i)&r},x9=function(t,i){var r=i/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(7&i)}
109,x7=["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"],ve=function(t,i,r){var a=Error(i||x7[t]);if(a.code=t,Error.captureStackTrace&&Error.captureStackTrace(a,ve),!r)throw a;return a},vt=new xU(0),vi="undefined"!=typeof TextDecoder&&new TextDecoder;try{vi.decode(vt,{stream:!0})}catch(t){}let vr={gzip_data:"gzip"};class va extends Error{constructor(t){super(t),this.name="MRTError"}}let vn={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},vo={uint32:1,uint16:2,uint8:4},vs={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class vl{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){let i=this.layers[t];if(!i)throw new va(`Layer '${t}' not found`);return i}getHeaderLength(t){let i=new Uint8Array(t),r=new DataView(t);if(13!==i[0])throw new va("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(t){let i=new Uint8Array(t),r=this.getHeaderLength(t);if(i.length<r)throw new va(`Expected header with length >= ${r} but got buffer of length ${i.length}`);let a=function(t){let i,r={headerLength:0,x:0,y:0,z:0,layers:[]};for(;i=t.nextField(void 0);)1===i?r.headerLength=t.readFixed32():2===i?r.x=t.readVarint():3===i?r.y=t.readVarint():4===i?r.z=t.readVarint():5===i&&r.layers.push(function(t,i){let r,a={version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]};for(;r=t.nextField(i);)1===r?a.version=t.readVarint():2===r?a.name=t.readString():3===r?a.units=t.readString():4===r?a.tileSize=t.readVarint():5===r?a.buffer=t.readVarint():6===r?a.pixelFormat=t.readVarint():7===r&&a.dataIndex.push(function(t,i){let r={firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},a,n=0,o=0;for(;a=t.nextField(i);)1===a?r.firstByte=t.readFixed64():2===a?r.lastByte=t.readFixed64():3===a?r.filters.push(function(t,i){let r,a={};for(;r=t.nextField(i);)1===r?(a.delta_filter=function(t,i){let r,a={blockSize:0};for(;r=t.nextField(i);)1===r&&(a.blockSize=t.readVarint());return a}(t,t.readVarint()+t.pos),a.filter="delta_filter"):2===r?(t.readVarint(),a.filter="zigzag_filter"):3===r?(t.readVarint(),a.filter="bitshuffle_filter"):4===r&&(t.readVarint(),a.filter="byteshuffle_filter");return a}(t,t.readVarint()+t.pos)):4===a?r.codec=function(t,i){let r,a={};for(;r=t.nextField(i);)1===r?(t.readVarint(),a.codec="gzip_data"):2===r?(t.readVarint(),a.codec="jpeg_image"):3===r?(t.readVarint(),a.codec="webp_image"):4===r&&(t.readVarint(),a.codec="png_image");return a}(t,t.readVarint()+t.pos):5===a?o=t.readFloat():6===a?n=t.readFloat():7===a?r.bands.push(t.readString()):8===a?r.offset=t.readDouble():9===a&&(r.scale=t.readDouble());return 0===r.offset&&(r.offset=o),0===r.scale&&(r.scale=n),r}(t,t.readVarint()+t.pos));return a}(t,t.readVarint()+t.pos));return r}(new Q(i.subarray(0,r)));if(!isNaN(this.x)&&(this.x!==a.x||this.y!==a.y||this.z!==a.z))throw new va(`Invalid attempt to parse header ${a.z}/${a.x}/${a.y} for tile ${this.z}/${this.x}/${this.y}`);for(let t of(this.x=a.x,this.y=a.y,this.z=a.z,a.layers))this.layers[t.name]=new vh(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){let i=[],r=this.getLayer(t.layerName);for(let a of t.blockIndices){let n=r.dataIndex[a],o=n.firstByte-t.firstByte,s=n.lastByte-t.firstByte;if(r._blocksInProgress.has(a))continue;let l={layerName:r.name,firstByte:o,lastByte:s,pixelFormat:r.pixelFormat,blockIndex:a,blockShape:[n.bands.length].concat(r.bandShape),buffer:r.buffer,codec:n.codec.codec,filters:n.filters.map(t=>t.filter)};r._blocksInProgress.add(a),i.push(l)}return new vu(i,()=>{i.forEach(t=>r._blocksInProgress.delete(t.blockIndex))},(t,a)=>{if(i.forEach(t=>r._blocksInProgress.delete(t.blockIndex)),t)throw t;a.forEach(t=>{this.getLayer(t.layerName).processDecodedData(t)})})}}class vh{constructor({version:t,name:i,units:r,tileSize:a,pixelFormat:n,buffer:o,dataIndex:s},l){if(this.version=t,1!==this.version)throw new va(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=i,this.units=r,this.tileSize=a,this.buffer=o,this.pixelFormat=vn[n],this.dataIndex=s,this.bandShape=[a+2*o,a+2*o,vo[this.pixelFormat]],this._decodedBlocks=new mw(l?l.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return vo[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:t})=>t).flat()}processDecodedData(t){let i=t.blockIndex.toString();this._decodedBlocks.get(i)||this._decodedBlocks.put(i,t.data)}getBlockForBand(t){let i=0;switch(typeof t){case"string":for(let[r,a]of this.dataIndex.entries()){for(let[n,o]of a.bands.entries())if(o===t)return{bandIndex:i+n,blockIndex:r,blockBandIndex:n};i+=a.bands.length}break;case"number":for(let[r,a]of this.dataIndex.entries()){if(t>=i&&t<i+a.bands.length)return{bandIndex:t,blockIndex:r,blockBandIndex:t-i};i+=a.bands.length}break;default:throw new va(`Invalid band \`${JSON.stringify(t)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(t){let i=1/0,r=-1/0,a=[],n=new Set;for(let o of t){let{blockIndex:t}=this.getBlockForBand(o);if(t<0)throw new va(`Invalid band: ${JSON.stringify(o)}`);let s=this.dataIndex[t];a.includes(t)||a.push(t),n.add(t),i=Math.min(i,s.firstByte),r=Math.max(r,s.lastByte)}if(n.size>this.cacheSize)throw new va(`Number of blocks to decode (${n.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:i,lastByte:r,blockIndices:a}}hasBand(t){let{blockIndex:i}=this.getBlockForBand(t);return i>=0}hasDataForBand(t){let{blockIndex:i}=this.getBlockForBand(t);return i>=0&&!!this._decodedBlocks.get(i.toString())}getBandView(t){let{blockIndex:i,blockBandIndex:r}=this.getBlockForBand(t);if(i<0)throw new va(`Band not found: ${JSON.stringify(t)}`);let a=this._decodedBlocks.get(i.toString());if(!a)throw new va(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);let n=this.dataIndex[i],o=this.bandShape.reduce((t,i)=>t*i,1),s=r*o,l=a.subarray(s,s+o);return{data:l,bytes:new Uint8Array(l.buffer).subarray(l.byteOffset,l.byteOffset+l.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:n.offset,scale:n.scale}}}
109vl.setPbf=function(t){Q=t};class vu{constructor(t,i,r){this.tasks=t,this._onCancel=i,this._onComplete=r,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,i){this._finalized||(this._onComplete(t,i),this._finalized=!0)}}vl.performDecoding=function(t,i){let r=new Uint8Array(t);return Promise.all(i.tasks.map(t=>{let{layerName:i,firstByte:a,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:l,filters:h,codec:u}=t,c=r.subarray(a,n+1),d=new Uint32Array(s[0]*s[1]*s[2]);if("gzip_data"!==u)throw new va(`Unhandled codec: ${u}`);return(function(t,i){var r,a,n;if(!globalThis.DecompressionStream&&"gzip_data"===i)return Promise.resolve(((n=function(t){31==t[0]&&139==t[1]&&8==t[2]||ve(6,"invalid gzip data");var i=t[3],r=10;4&i&&(r+=2+(t[10]|t[11]<<8));for(var a=(i>>3&1)+(i>>4&1);a>0;a-=!t[r++]);return r+(2&i)}(t))+8>t.length&&ve(6,"invalid gzip data"),function(t,i,r,a){var n,o,s=t.length;if(!s||i.f&&!i.l)return r||new xU(0);var l=!r,h=l||2!=i.i,u=i.i;l&&(r=new xU(3*s));var c=function(t){var i=r.length;if(t>i){var a=new xU(Math.max(2*i,t));a.set(r),r=a}},d=i.f||0,p=i.p||0,f=i.b||0,_=i.l,m=i.d,g=i.m,y=i.n,x=8*s;do{if(!_){d=x8(t,p,1);var v=x8(t,p+1,3);if(p+=3,!v){var b=t[(P=((p+7)/8|0)+4)-4]|t[P-3]<<8,w=P+b;if(w>s){u&&ve(0);break}h&&c(f+b),r.set(t.subarray(P,w),f),i.b=f+=b,i.p=p=8*w,i.f=d;continue}if(1==v)_=x4,m=x5,g=9,y=5;else if(2==v){var T=x8(t,p,31)+257,E=x8(t,p+10,15)+4,S=T+x8(t,p+5,31)+1;p+=14;for(var I=new xU(S),A=new xU(19),C=0;C<E;++C)A[xZ[C]]=x8(t,p+3*C,7);p+=3*E;var M=x6(A),R=(1<<M)-1,D=x1(A,M);for(C=0;C<S;){var P,z=D[x8(t,p,R)];if(p+=15&z,(P=z>>4)<16)I[C++]=P;else{var L=0,O=0;for(16==P?(O=3+x8(t,p,3),p+=2,L=I[C-1]):17==P?(O=3+x8(t,p,7),p+=3):18==P&&(O=11+x8(t,p,127),p+=7);O--;)I[C++]=L}}var F=I.subarray(0,T),B=I.subarray(T);g=x6(F),y=x6(B),_=x1(F,g),m=x1(B,y)}else ve(1);if(p>x){u&&ve(0);break}}h&&c(f+131072);for(var k=(1<<g)-1,N=(1<<y)-1,V=p;;V=p){var U=(L=_[x9(t,p)&k])>>4;if((p+=15&L)>x){u&&ve(0);break}if(L||ve(2),U<256)r[f++]=U;else{if(256==U){V=p,_=null;break}var j=U-254;U>264&&(j=x8(t,p,(1<<(q=xH[C=U-257]))-1)+xX[C],p+=q);var G=m[x9(t,p)&N],H=G>>4;if(G||ve(3),p+=15&G,B=xK[H],H>3){var q=xq[H];B+=x9(t,p)&(1<<q)-1,p+=q}if(p>x){u&&ve(0);break}h&&c(f+131072);var Z=f+j;if(f<B){var $=0-B,W=Math.min(B,Z);for($+f<0&&ve(3);f<W;++f)r[f]=a[$+f]}for(;f<Z;++f)r[f]=r[f-B]}}i.l=_,i.p=V,i.b=f,i.f=d,_&&(d=1,i.m=g,i.d=m,i.n=y)}while(!d);return f!=r.length&&l?(n=r,(null==(o=f)||o>n.length)&&(o=n.length),new xU(n.subarray(0,o))):r.subarray(0,f)}(t.subarray(n,-8),{i:2},new xU((t[(a=t.length)-4]|t[a-3]<<8|t[a-2]<<16|t[a-1]<<24)>>>0),r)));let o=vr[i];if(!o)throw Error(`Unhandled codec: ${i}`);let s=new globalThis.DecompressionStream(o);return new Response(new Blob([t]).stream().pipeThrough(s)).arrayBuffer().then(t=>new Uint8Array(t))})(c,u).then(t=>((function(t,i){let r;for(;r=t.nextField();)if(2===r)!function(t,i,r){let a;for(;a=t.nextField(i);)if(1===a){let i=0,a=t.readVarint()+t.pos;for(;t.pos<a;)r[i++]=t.readVarint()}}(t,t.readVarint()+t.pos,i);else if(3===r)throw Error("Not implemented")})(new Q(t),d),new(0,vs[o])(d.buffer))).then(t=>{for(let i=h.length-1;i>=0;i--)switch(h[i]){case"delta_filter":!function(t,i){if(4!==i.length)throw Error(`Expected data of dimension 4 but got ${i.length}.`);let r=i[3];for(let a=2;a>=1;a--){let n=+(1===a),o=+(2===a);for(let a=0;a<i[0];a++){let s=i[1]*a;for(let a=n;a<i[1];a++){let n=i[2]*(a+s);for(let a=o;a<i[2];a++){let o=i[3]*(a+n);for(let a=0;a<i[3];a++){let i=o+a;t[i]+=t[i-r]}}}}r*=i[a]}}(t,s);break;case"zigzag_filter":var r=t;for(let t=0,i=r.length;t<i;t++)r[t]=r[t]>>>1^-(1&r[t]);break;case"bitshuffle_filter":!function(t,i){switch(i){case"uint32":return;case"uint16":for(let i=0;i<t.length;i+=2){let r=t[i],a=t[i+1];t[i]=(240&r)>>4|(61440&r)>>8|(240&a)<<4|61440&a,t[i+1]=15&r|(3840&r)>>4|(15&a)<<8|(3840&a)<<4}return;case"uint8":for(let i=0;i<t.length;i+=4){let r=t[i],a=t[i+1],n=t[i+2],o=t[i+3];t[i+0]=(192&r)>>6|(192&a)>>4|(192&n)>>2|192&o,t[i+1]=(48&r)>>4|(48&a)>>2|48&n|(48&o)<<2,t[i+2]=(12&r)>>2|12&a|(12&n)<<2|(12&o)<<4,t[i+3]=3&r|(3&a)<<2|(3&n)<<4|(3&o)<<6}return;default:throw Error(`Invalid pixel format, "${i}"`)}}(t,o);break;default:throw new va(`Unhandled filter "${h[i]}"`)}return{layerName:i,blockIndex:l,data:t}}).catch(t=>{throw t})}))},vl.setPbf(uz);class vc extends xV{constructor(t,i,r,a,n){super(t,i,r,a,n),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map}
109getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(t){return this._mrt&&this._mrt.getLayer(t)}setTexturePerLayer(t,i,r){let a=r.context,n=a.gl,o=this.texturePerLayer.get(t)||r.getTileTexture(i.width);o&&o instanceof uW?o.update(i,{premultiply:!1}):o=new uW(a,i,n.RGBA8,{premultiply:!1}),this.texturePerLayer.has(t)||this.texturePerLayer.set(t,o)}flushQueues(t){let i=this._workQueuePerLayer.get(t)||[],r=this._fetchQueuePerLayer.get(t)||[];for(;i.length;)i.pop()();for(;r.length;)r.pop()()}flushAllQueues(){for(let t of this._workQueuePerLayer.keys()){let i=this._workQueuePerLayer.get(t)||[];for(;i.length;)i.pop()()}for(let t of this._fetchQueuePerLayer.keys()){let i=this._fetchQueuePerLayer.get(t)||[];for(;i.length;)i.pop()()}}fetchHeader(t=16384,i){let r=this._mrt=new vl(30),a={...this.requestParams,headers:{Range:"bytes=0-"+(t-1)}};this.entireBuffer=null;let n=new AbortController;return this.request=n,i4(a,n.signal).then(({data:a,headers:n})=>{try{let o=r.getHeaderLength(a);if(o>t)return void(this.request=this.fetchHeader(o,i));r.parseHeader(a),this._isHeaderLoaded=!0;let s=0;for(let t of Object.values(r.layers))s=Math.max(s,t.dataIndex.at(-1).lastByte);a.byteLength>=s&&(this.entireBuffer=a),i(null,this.entireBuffer||a,n)}catch(t){i(t)}}).catch(t=>{n.signal.aborted||i(t)}),this.request}fetchBandForRender(t,i,r,a){this.fetchBand(t,i,r,n=>{if(n)return void a(n);this.updateTextureDescriptor(t,i,r);let o=this.textureDescriptorPerLayer.get(i);a(null,o?o.img:null)})}fetchBand(t,i,r,a){let n,o,s=this._mrt;if(!this._isHeaderLoaded||!s)return void a(Error("Tile header is not ready"));let l=this.actor;if(!l)return void a(Error("Can't fetch tile band without an actor"));let h=sy(String(r),sy(this.tileID.key,t)),u=this._taskQueue.get(h);u?u.add(a):((u=new Set).add(a),this._taskQueue.set(h,u));let c=(t,i)=>{n.complete(t,i),t?a(t):(u.forEach(t=>t(null,i)),this._taskQueue.delete(h))},d=(t,r)=>{if(t)return a(t);let o=l.sendCancelable("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:r,task:n},{},c);if(null!==i){let t=this._workQueuePerLayer.get(i)||[];t.push(()=>{o.abort(),n.cancel()}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,t)}};try{o=s.getLayer(t)}catch(t){if("reloading"===this.state)return;throw t}if(!o)return void a(Error(`Unknown sourceLayer "${t}"`));if(o.hasDataForBand(r))return u.forEach(t=>t(null,null)),void this._taskQueue.delete(h);let p=o.getDataRange([r]);if(!(n=s.createDecodingTask(p))||n.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)d(null,this.entireBuffer.slice(p.firstByte,p.lastByte+1));else{let t={...this.requestParams,headers:{Range:`bytes=${p.firstByte}-${p.lastByte}`}},r=new AbortController;if(i4(t,r.signal).then(({data:t})=>d(null,t)).catch(t=>{r.signal.aborted||d(t)}),null!==i){let t=this._fetchQueuePerLayer.get(i)||[];t.push(()=>{r.abort(),n.cancel()}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,t)}}}updateNeeded(t,i){return(!this.textureDescriptorPerLayer.get(t)||this.textureDescriptorPerLayer.get(t).band!==i||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,r){if(!this._mrt)return;let a=this._mrt.getLayer(t);if(!a||!a.hasBand(r)||!a.hasDataForBand(r))return;let{bytes:n,tileSize:o,buffer:s,offset:l,scale:h}=a.getBandView(r),u=o+2*s,c=new h7({width:u,height:u},n),d=this.texturePerLayer.get(i);d&&d instanceof uW&&d.update(c,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:r,img:c,buffer:s,offset:l,tileSize:o,format:a.pixelFormat,mix:[h,256*h,65536*h,0x1000000*h]})}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(let t of this.texturePerLayer.values())t&&t instanceof uW&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}async function vd(t,i,r){let a=t.url&&!t.tiles?await i.transformRequest(t.url,iX.Source,r):void 0;return{request:a,options:a?{...t,url:a.url}:t}}function vp(t,i,r){try{i=function(t){if(!t.variants)return t;
109if(!Array.isArray(t.variants))throw Error("variants must be an array");for(let i of t.variants){if(null==i||"object"!=typeof i||i.constructor!==Object)throw Error("variant must be an object");if(!Array.isArray(i.capabilities))throw Error("capabilities must be an array");if(1===i.capabilities.length&&"meshopt"===i.capabilities[0])return Object.assign(t,i)}return t}(i)}catch(t){return Error("Failed to process TileJSON variants",{cause:t})}let a=tk({...i,...t},["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return t.url&&i.tiles&&t.tiles&&(a.tiles=i.tiles),a.tiles=r.canonicalizeTileset(a,t.url),a}function vf(t,i,r,a,n){let o=function(r,a){if(r)return n(r);if(a){t.url&&a.tiles&&t.tiles&&delete t.tiles;let r=vp(t,a,i);if(r instanceof Error)return n(r);n(null,r)}},s=function(t,i,r){if(!t)return null;if(!i&&!r)return t;r=r||t.worldview_default;let a=Object.values(t.language||{});if(0===a.length)return null;let n=Object.values(t.worldview||{});if(0===n.length)return null;let o=a.every(t=>t===i),s=n.every(t=>t===r);return o&&s?t:i in(t.language_options||{})||r in(t.worldview_options||{})?null:t.language_options&&t.worldview_options?t:null}(t.data,r,a);if(s)return is.frame(()=>o(null,s));if(t.url){let n=new AbortController;return(async()=>{let s=await i.transformRequest(i.normalizeSourceURL(t.url,null,r,a),iX.Source,n.signal),{data:l}=await i3(s,n.signal);o(null,l)})().catch(t=>{n.signal.aborted||o(t)}),{cancel:()=>n.abort()}}return is.frame(()=>{let{data:i,...r}=t;o(null,r)})}function v_(t,i){let r=Math.pow(2,i.z),a=Math.floor(az(t.getWest())*r),n=Math.floor(aL(t.getNorth())*r),o=Math.ceil(az(t.getEast())*r),s=Math.ceil(aL(t.getSouth())*r);return i.x>=a&&i.x<o&&i.y>=n&&i.y<s}oC(vu,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),oC(vl,"MapboxRasterTile"),oC(vh,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class vm{constructor(t,i,r){this.bounds=t?s1.convert(this.validateBounds(t)):null,this.minzoom=i||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}addExtraBounds(t){if(t)for(let i of(this.extraBounds||(this.extraBounds=[]),t))this.extraBounds.push(s1.convert(this.validateBounds(i)))}contains(t){if(t.z>this.maxzoom||t.z<this.minzoom||this.bounds&&!v_(this.bounds,t))return!1;if(!this.extraBounds)return!0;for(let i of this.extraBounds)if(v_(i,t))return!0;return!1}static fromTileJSON(t){if(!t.bounds&&!t.extra_bounds)return null;let i=new vm(t.bounds,t.minzoom,t.maxzoom);return i.addExtraBounds(t.extra_bounds),i}}let vg=new Map,vy=new Map;function vx(t){let i;if("provider"in t&&!t.provider)return null;let r=t.provider;if(!r&&"url"in t&&t.url&&(r=function(t){try{let i=new URL(t).pathname.split("/").pop()||"",r=i.lastIndexOf(".");return r>=0?i.slice(r+1):""}catch{return""}}(t.url)),!r)return null;let a=iT.TILE_PROVIDER_URLS[r];if(!a)return null;try{i=new URL(a,iT.API_URL).href}catch(t){return Error(`TileProvider "${r}" has an invalid URL: "${a}"`)}return{name:r,url:i}}function vv(t,i,r){return i?vp(t,i,r):t.tiles&&t.tiles.length>0?{tiles:t.tiles}:Error('TileJSON is missing required "tiles" property')}class vb extends rB{constructor(t,i,r,a){super(),this.id=t,this.dispatcher=r,this.setEventedParent(a),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",...i},Object.assign(this,tk(i,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new rz("dataloading",{dataType:"source"}));let i=this.map.getWorldview(),r=(i,r)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new rL(i)):r&&(Object.assign(this,r),r.raster_layers&&(this.rasterLayers=r.raster_layers,this.rasterLayerIds=this.rasterLayers.map(t=>t.id)),this.tileBounds=vm.fromTileJSON(r),rg(r.tiles),this.fire(new rz("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new rz("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)};this.provider="string"==typeof this._options.provider?this._options.provider:void 0,this._tileProvider=void 0;let a=vx(this._options);return a instanceof Error?(this._loaded=!0,this.fire(new rL(a)),void(t&&t())):this.provider&&!a?(this._loaded=!0,this.fire(new rL(Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=a?this.loadTileJSONWithProvider(a,r):vf(this._options,this.map._requestManager,null,i,r))}loadTileJSONWithProvider(t,i){this.provider=t.name;let r=new AbortController;return(async()=>{let{request:a,options:n}=await vd(this._options,this.map._requestManager,r.signal);if(r.signal.aborted)return;let o=await async function(t,i){let r=vy.get(t);if(r)return r;let a=vg.get(t);if(void 0!==a)return a;let n=import(i).catch(i=>{throw Error(`TileProvider "${t}" failed to load: ${i instanceof Error?i.message:String(i)}`)}).then(i=>{let r=i.default;if("function"!=typeof r)throw Error(`TileProvider "${t}" module must default-export a class`);if("function"!=typeof r.prototype.loadTile)throw Error(`TileProvider "${t}" class must have a loadTile method`);return vy.set(t,r),r}).finally(()=>{vg.delete(t)});return vg.set(t,n),n}(t.name,t.url);if(r.signal.aborted)return;let s=new o(n),l=null;if(s.load&&a&&(l=await s.load({request:a}),r.signal.aborted))return;this._tileProvider=s;let h=vv(this._options,l,this.map._requestManager);h instanceof Error?i(h):i(null,h)})().catch(a=>{r.signal.aborted||i(Error(`Could not load tile provider ${t.name}`,{cause:a}))}),{cancel:()=>r.abort()}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();let t=sy(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(t){this.cancelTileJSONRequest()}serialize(){return{...this._options}}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}async loadTile(t,i){let r=is.devicePixelRatio>=2,a=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize),n=new AbortController;if(t.request=n,this._tileProvider)this.loadTileWithProvider(t,this._tileProvider,a,n,i);else try{let r=await this.map._requestManager.transformRequest(a,iX.Tile,n.signal);if(n.signal.aborted)return delete t.request,i(null);let{data:o,headers:s}=await i5(r,n.signal);if(delete t.request,t.aborted)return i(null);let l=t1(s);this.map._refreshExpiredTiles&&t.setExpiryData(l),t.setTexture(o,this.map.painter),t.state="loaded",iG(this.dispatcher),i(null)}catch(r){if(delete t.request,n.signal.aborted)return i(null);t.state="errored",i(r)}}async loadTileWithProvider(t,i,r,a,n){let{z:o,x:s,y:l}=t.tileID.canonical;try{let h=await this.map._requestManager.transformRequest(r,iX.Tile,a.signal);if(a.signal.aborted)return n(null);let u=await i.loadTile({z:o,x:s,y:l},{request:h,signal:a.signal});if(a.signal.aborted)return n(null);if(null==u){let i=Error("Tile not found");return i.status=404,t.state="errored",n(i)}if(null==u.data)return t.state="loaded",n(null);let c=u.data instanceof ImageBitmap?u.data:await createImageBitmap(new Blob([u.data]));if(a.signal.aborted)return n(null);t.setTexture(c,this.map.painter),t.state="loaded",this.map._refreshExpiredTiles&&t.setExpiryData({cac
109heControl:u.cacheControl,expires:u.expires}),n(null)}catch(i){if(a.signal.aborted)return n(null);t.state="errored",n(Error(`Could not load tile from ${r}`,{cause:i}))}finally{delete t.request}}abortTile(t,i){t.request&&(t.request.abort(),delete t.request),i&&i()}unloadTile(t,i){t.texture&&t.texture instanceof uW?(t.destroy(!1),t.texture&&t.texture instanceof uW&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class vw extends vb{constructor(t,i,r,a){super(t,i,r,a),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options={type:"raster-array",...i}}triggerRepaint(t){let i=this.map.painter._terrain,r=this.map.style.getSourceCache(this.id);i&&i.enabled&&r&&i._clearRenderCacheForTile(r.id,t.tileID),this.map.triggerRepaint()}async loadTile(t,i){let r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);t.source=this.id,t.scope=this.scope,t.actor||(t.actor=this.dispatcher.getActor());let a=new AbortController;t.request=a;let n=(r,a,n)=>{if(delete t.request,t.aborted)return i(null);if(r)return t.state="errored",i(r);if(this.map._refreshExpiredTiles&&a&&t.setExpiryData(t1(n)),this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!a)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=a}i(null)};try{let o=await this.map._requestManager.transformRequest(r,iX.Tile,a.signal);if(a.signal.aborted)return i(null);t.requestParams=o;
109let s={request:o,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};t.request=this.partial?t.fetchHeader(void 0,(t,i,r)=>{n(t,i,r)}):t.actor.sendCancelable("loadTile",s,{},(t,i)=>t?n(t):i?void n(null,i.mrt,i.headers):n(null,null))}catch(r){if(a.signal.aborted)return i(null);t.state="errored",i(r)}}abortTile(t){t.request&&(t.request.abort(),delete t.request),t.actor&&t.actor.notify("abortTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(t,i){let r=t.texturePerLayer;if(t.flushAllQueues(),r.size)for(let i of(t.destroy(!1),r.values()))this.map.painter.saveTileTexture(i);else t.destroy()}prepareTile(t,i,r,a){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,r,a,(i,a)=>{i?(t.state="errored",this.fire(new rL(i))):a&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(r,a,this.map.painter),t.state="loaded"),this.triggerRepaint(t)}))}getInitialBand(t){if(!this.rasterLayers)return 0;let i=this.rasterLayers.find(({id:i})=>i===t),r=i&&i.fields,a=r&&r.bands&&r.bands;return a?a[0]:0}getTextureDescriptor(t,i,r){if(!t)return;let a=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!a)return;let n=null;i instanceof _k?n=i.paint.get("raster-array-band"):i instanceof _N&&(n=i.paint.get("raster-particle-array-band"));let o=n||this.getInitialBand(a);if(null!=o)if(t.textureDescriptorPerLayer.get(i.id)){if(!t.updateNeeded(i.id,o)||r)return{...t.textureDescriptorPerLayer.get(i.id),texture:t.texturePerLayer.get(i.id)}}else this.prepareTile(t,a,i.id,o)}getImages(t,i){let r=new Map;for(let a of t)for(let t of i){let[i,n]=t.split("/"),o=a.getLayer(i);if(!o||!o.hasBand(n)||!o.hasDataForBand(n))continue;let{bytes:s,tileSize:l,buffer:h}=o.getBandView(n),u=l+2*h,c={data:new h7({width:u,height:u},s),pixelRatio:2,sdf:!1,usvg:!1,version:0};r.set(t,c)}return r}queryRasterArrayValueByBandId(t,i,r){let a=i._mrt;return new Promise(n=>{let o={},s=new Set;for(let[l,h]of Object.entries(a.layers)){if(r.layerName&&l!==r.layerName)continue;let u={};for(let{bands:c}of(o[l]=u,h.dataIndex))for(let d of c)r.bands&&!r.bands.includes(d)||(s.add(sy(l,d)),i.fetchBand(l,null,d,i=>{is.frame(()=>{u[d]=i?null:function([t,i],r,a,{scaled:n=!0}={}){let{tileSize:o,buffer:s}=a,{x:l,y:h,z:u}=r;if(!isFinite(l)||!isFinite(h)||!isFinite(u))throw Error("Invalid MRT header");let c=2**u;return function([t,i],r,{scaled:a=!0}={}){if(!r)throw Error("bandView is undefined");let{data:n,tileSize:o,buffer:s,offset:l,scale:h,dimension:u}=r;if(t<-s||t>o+s||i<-s||i>o+s)throw Error(`Point (${t}, ${i}) out of bounds for tileSize=${o}, buffer=${s}`);let c=(i+s)*(o+2*s)+(t+s);if(0xffffffff===new Uint32Array(n.buffer)[c])return null;let d=[];d=a?[]:new(0,r.data.constructor)(u);for(let t=0;t<u;t++)d[t]=Math.round(1e12*(n[u*c+t]*h+l))/1e12;return d}([Math.min(Math.max(-s,Math.floor((c*az(t)-l)*o)),o-1+s),Math.min(Math.max(-s,Math.floor((c*aL(i)-h)*o)),o-1+s)],a,{scaled:n})}([t.lng,t.lat],a,h.getBandView(d)),s.delete(sy(l,d)),0===s.size&&n(o)})}))}0===s.size&&n(o)})}_loadTileForQuery(t){if(this._loadTileLoaded[t.uid])return Promise.resolve(t._mrt);if(t.uid in this._loadTilePending)return this._loadTilePending[t.uid];let i=this._fetchTileForQuery(t);return this._loadTilePending[t.uid]=i,i}async _fetchTileForQuery(t){let i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);try{let r={request:await this.map._requestManager.transformRequest(i,iX.Tile),uid:t.uid,tileID:t.tileID,type:this.t
vendor: 5,368 bytes, line 109
109ype,source:this.id,scope:this.scope,partial:!1},a=await t.actor.send("loadTile",r);if(!a)return null;let n=a.mrt;return this.map._refreshExpiredTiles&&t.setExpiryData(t1(a.headers)),t._mrt=n,t._isHeaderLoaded=!0,t.state="loaded",this._loadTileLoaded[t.uid]=!0,n}finally{delete this._loadTilePending[t.uid]}}async queryRasterArrayValueByAllBands(t,i,r){return await this._loadTileForQuery(i)?this.queryRasterArrayValueByBandId(t,i,r):null}queryRasterArrayValue(t,i){let r=s0.convert(t),a=this.findLoadedParent(r);return a&&a._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(r,a,i):this.queryRasterArrayValueByAllBands(r,a,i):Promise.resolve(null)}findLoadedParent(t){let i=s8.fromLngLat(t,this.map.transform.tileSize),r=this.maxzoom+1,a=1<<r,n=Math.floor(i.x),o=Math.floor((i.x-n)*a),s=Math.floor(i.y*a),l=this.map.style.getSourceCache(this.id),h=new c0(r,n,r,o,s);return l.findLoadedParent(h,this.minzoom)}}var vT=lo([{name:"a_index",type:"Int16",components:1}]);class vE{constructor(t,i,r,a){let n={width:r[0],height:r[1],data:null},o=t.gl;this.targetColorTexture=new uW(t,n,o.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new uW(t,n,o.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,a),this.lastInvalidatedAt=0}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());let r=this.context.gl,a=i.width*i.height;this.particleTexture0=new uW(this.context,i,r.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new uW(this.context,i,r.RGBA8,{premultiply:!1,useMipmap:!1});let n=new lG;n.reserve(a);for(let t=0;t<a;t++)n.emplaceBack(t);this.particleIndexBuffer=this.context.createVertexBuffer(n,vT.members,!0),this.particleSegment=l9.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=i.width}update(t){return!(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=is.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function vS(t,i,r,a,n){if(n>0){let o=is.now(),s=(o-t.timeAdded)/n,l=i?(o-i.timeAdded)/n:-1,h=r.getSource(),u=a.coveringZoomLevel({tileSize:h.tileSize,roundZoom:h.roundZoom}),c=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=c&&t.refreshedUponExpiration?1:tL(c?s:1-l,0,1);return i?{opacity:1,mix:1-d,isFading:s<1}:{opacity:d,mix:0,isFading:s<1}}return{opacity:1,mix:0,isFading:!1}}var vI="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform 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;}";yX["_prelude_raster_particle.glsl"]||(yX["_prelude_raster_particle.glsl"]=vI);var vA={building:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nconst 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;\n#ifdef RENDER_FRONT_CUTOFF\nin float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nin vec4 v_ground_roof;\n#endif\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin 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;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
109\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform 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));}\n#ifdef BUILDING_FAUX_FACADE\nhighp 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;\n#if 0\nif (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;\n#else\nif (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 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;\n#ifdef BUILDING_FAUX_FACADE\nif (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);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\n#ifdef RENDER_CUTOFF\nshadowed_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;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\n#else\nshadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radiu
109s,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\n{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}\n#else\ncolor=applyCutout(color,v_pos.z);\n#endif\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nif (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\nglFragColor=color;\n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;\n#ifdef FLOOD_LIGHT\nin int a_flood_light_wall_radius_1i16;\n#endif\n#ifdef BUILDING_FAUX_FACADE\nin uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;\n#endif\nuniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;\n#ifdef RENDER_FRONT_CUTOFF\nuniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nout vec4 v_ground_roof;\n#endif\n#endif\nout vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout 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;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst 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));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 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);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_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);\n#endif\nvec4 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);\n#ifdef BUILDING_FAUX_FACADE\nvec4 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;}\n#endif\nv_pos=a_pos_3f;\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nfloat halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;
109vec2 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;\n#endif\n#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)\nvec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_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);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\n#ifdef RENDER_FRONT_CUTOFF\nv_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;\n#ifdef INDICATOR_CUTOUT\n#ifdef FEATURE_CUTOUT\nvec4 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);\n#endif\n#endif\n}'),buildingBloom:y6("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat 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);\n#endif\n#ifdef RENDER_CUTOFF\nopacity*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 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);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}"),buildingDepth:y6("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),rasterParticle:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;\n#endif\n#ifdef FOG\nhighp 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));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);
109\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:y6("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"\nin 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(\nmod(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:y6("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:y6('#include "_prelude_raster_particle.glsl"\nuniform 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(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);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:y6("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;}","\nin 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; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform 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);
109simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*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:y6("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;}","\nin 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; \nuniform float u_velocity; \nuniform 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; \npos+=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+\nlocalY*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:y6("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:y6("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:y6('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin vec3 v_normal;in float v_height;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
109vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{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;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);\n#ifdef FEATURE_CUTOUT\ncutout_factors=get_cutout_factors(gl_FragCoord);\n#endif\n#ifdef LIGHTING_3D_MODE\nvec3 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);\n#ifdef RENDER_SHADOWS\nfloat 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);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=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);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x,v_height);\n#endif\nout_color*=u_opacity_multiplier;glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin 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;\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_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);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 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();\n#endif\nv_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;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(vec2(a_pos));\n#endif\n}'),elevatedStructuresDepthReconstruct:y6("#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x,0.0);\n#endif\n#endif\nglFragColor=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;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}")};y6(vI,"");let vC=lo([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]),vM=lo([{type:"Float32",name:"a_pos_2f",components:2}]);class vR{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,i){var r;let a=t.getOrCreateProgram("vignette");
109if(!this.vignetteVx||!this.vignetteIdx){let i=new lk,r=new lR;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,vM.members),this.vignetteIdx=t.context.createIndexBuffer(r)}let n=l9.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,a);let o={u_vignetteShape:(r={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:r.vignetteColor};a.draw(t,t.context.gl.TRIANGLES,gz.disabled,g3.disabled,g6.alphaBlended,gP.disabled,o,"vignette",this.vignetteVx,this.vignetteIdx,n)}}}class vD{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,i){let r=t.getFreeCameraOptions().position,a=r.toAltitude(),n=r.toLngLat(),o=n.lng*tA,s=n.lat*tA,l=t.pixelsPerMeter/i,h=6371008.8*o,u=6371008.8*Math.log(Math.tan(Math.PI/4+s/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{let t=-this._offsetYPrev+u,i=-this._elevationPrev+a;this._accumulatedOffsetX+=(-this._offsetXPrev+h)*l,this._accumulatedOffsetY+=t*l,this._accumulatedElevation+=i*l,this._offsetXPrev=h,this._offsetYPrev=u,this._elevationPrev=a}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function vP(t,i){return[-(t[0]-Math.floor(t[0]/i)*i),-(t[1]-Math.floor(t[1]/i)*i),-(t[2]-Math.floor(t[2]/i)*i)]}function vz(t){let i=n5(0x134104da55e),r=[];for(let a=0;a<t;++a){let t=2*i()-1,a=2*i()-1,n=2*i()-1;r.push(eO(t,a,n))}return r}function vL(t,i,r,a,n){return rG(t,i,tL((n-r)/(a-r),0,1))}class vO{constructor(t){this._movement=new vD,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new vR,this._ppmScaleFactor=t}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(t,i){let r=t.transform;this._movement.update(r,this._ppmScaleFactor);let a=r.starsProjMatrix,n=te([]);tt(n,n,90*tA-r._pitch),tr(n,n,-r.angle);let o=eM(new Float32Array(16),n),s=eg([],e_([],new Float32Array([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])),o),l=Date.now()/1e3;return this._accumulatedTimeFromStart+=(l-this._prevTime)*i,this._prevTime=l,{projectionMatrix:a,modelviewMatrix:s}}}let vF=lo([{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}]),vB=(t,i)=>({u_matrix:t,u_depth_bias:i}),vk=(t,i)=>({u_matrix:t,u_ground_shadow_factor:i,u_opacity_multiplier:1}),vN=(t,i,r,a,n)=>({u_matrix:t,u_camera_pos:[i[0],i[1],i[2]],u_depth_bias:r,u_height_scale:a,u_reset_depth:n});function vV(t,i){let r=1<<t.canonical.z;return eO((i.x*r-t.canonical.x-t.wrap*r)*8192,(i.y*r-t.canonical.y)*8192,i.z*s2(aF(i.y)))}class vU{constructor(t=[]){this.tiles=t}getTile(t){for(let i of this.tiles)if(i.tileId.z===t.z&&i.tileId.x===t.x&&i.tileId.y===t.y)return i;return null}getTileOrParent(t){for(let i=t.z;i>0;--i){let r=Math.floor(t.x/(1<<t.z-i)),a=Math.floor(t.y/(1<<t.z-i));for(let t of this.tiles)if(t.tileId.z===i&&t.tileId.x===r&&t.tileId.y===a&&0!==t.frcMask)return t}return null}getFullCoverageMask(t){let i=null,r=0;for(let a=t.z;a>0;--a){let n=Math.floor(t.x/(1<<t.z-a)),o=Math.floor(t.y/(1<<t.z-a));for(let t of this.tiles)if(t.tileId.z===a&&t.tileId.x===n&&t.tileId.y===o){i=t,r=a;break}if(i)break}if(!i||0===i.frcMask)return null;let a=1<<t.z-r,n=8192/a,o=t.x%a*n,s=t.y%a*n,l=o+n,h=s+n,u=0;for(let a of i.polygons)0!==a.frcMask&&(a.hasGeometry()?0===a.rings.length||t.z<=r||function(t,i,r,a,n){let o=[0,0,0,0],s=[i,a,a,i],l=[r,r,n,n];for(let h of t){let t=h.length;if(!(t<2))for(let u=0,c=t-1;u<t;c=u++){let t=h[c].x,d=h[c].y,p=h[u].x,f=h[u].y;for(let i=0;i<4;++i)d>l[i]!=f>l[i]&&s[i]<t+(p-t)*(l[i]-d)/(f-d)&&o[i]++;let _=0,m=0;if(t<i?_|=1:t>a&&(_|=2),d<r?_|=4:d>n&&(_|=8),p<i?m|=1:p>a&&(m|=2),f<r?m|=4:f>n&&(m|=8),!(_&m)&&(0===_||0===m||function(t,i,r,a,n,o,s,l){let h=(t,i,r,a,n,o,s,l)=>{let h=(r-t)*(o-i)-(a-i)*(n-t),u=(r-t)*(l-i)-(a-i)*(s-t);if(h>0&&u>0||h<0&&u<0)return!1;let c=(s-n)*(i-o)-(l-o)*(t-n),d=(s-n)*(a-o)-(l-o)*(r-n);return!(c>0&&d>0||c<0&&d<0)};return!!(h(t,i,r,a,n,o,s,o)||h(t,i,r,a,s,o,s,l)||h(t,i,r,a,n,l,s,l)||h(t,i,r,a,n,o,n,l))}(t,d,p,f,i,r,a,n)))return!1}}for(let t=0;t<4;++t)if(!(1&o[t]))return!1;return!0}(a.rings,o,s,l,h)&&(u|=a.frcMask):u|=a.frcMask);return 0!==u?u:null}equals(t){if(this.tiles.length!==t.length)return!1;for(let i=0;i<this.tiles.length;++i){let r=this.tiles[i],a=t[i];if(r.tileId.z!==a.tileId.z||r.tileId.x!==a.tileId.x||r.tileId.y!==a.tileId.y||r.frcMask!==a.frcMask||r.polygons.length!==a.polygons.length)return!1}return!0}empty(){return 0===this.tiles.length}}class vj{constructor(){this._tileCoverages=[],this._snapshot=new vU}clear(){this._tileCoverages=[]}addTileCoverage(t,i){this._tileCoverages.push({tileId:t,polygons:i,frcMask:function(t){let i=0;for(let r of t)i|=r.frcMask;return i}(i)})}empty(){return 0===this._tileCoverages.length}updateSnapshotIfNeeded(){if(this._snapshot.equals(this._tileCoverages))return this._snapshot;let t=this._tileCoverages.map(t=>({tileId:t.tileId,polygons:t.polygons,frcMask:t.frcMask}));return this._snapshot=new vU(t),this._snapshot}}class vG{constructor(t,i){this.max=t,this.onRemove=i,this.reset()}reset(){for(let t in this.data)for(let i of this.data[t])i.timeout&&clearTimeout(i.timeout),this.onRemove(i.value);return this.data={},this.order=[],this}add(t,i,r){let a=t.wrapped().key;void 0===this.data[a]&&(this.data[a]=[]);let n={value:i,timeout:void 0};if(void 0!==r&&(n.timeout=setTimeout(()=>{this.remove(t,n)},r)),this.data[a].push(n),this.order.push(a),this.order.length>this.max){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){let i=this.data[t].shift();return i.timeout&&clearTimeout(i.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),i.value}getByKey(t){let i=this.data[t];return i?i[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,i){if(!this.has(t))return this;let r=t.wrapped().key,a=void 0===i?0:this.data[r].indexOf(i),n=this.data[r][a];return this.data[r].splice(a,1),n.timeout&&clearTimeout(n.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(n.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){let i=[];for(let r in this.data)for(let a of this.data[r])t(a.value)||i.push(a);for(let t of i)this.remove(t.value.tileID,t)}}class vH{constructor(){this.state=Object.create(null),this.stateChanges=Object.create(null),this.deletedStates=Object.create(null)}updateState(t,i,r){let a=String(i);if(this.stateChanges[t]=this.stateChanges[t]||Object.create(null),this.stateChanges[t][a]=this.stateChanges[t][a]||Object.create(null),Object.assign(this.stateChanges[t][a],r),null===this.deletedStates[t])for(let i in this.deletedStates[t]=Object.create(null),this.state[t])i!==a&&(this.deletedStates[t][i]=null);else if(this.deletedStates[t]&&null===this.deletedStates[t][a])for(let i in this.deletedStates[t][a]=Object.create(null),this.state[t][a])r[i]||(this.deletedStates[t][a][i]=null);else for(let i in r)this.deletedStates[t]&&this.deletedStates[t][a]&&null===this.deletedStates[t][a][i]&&delete this.deletedStates[t][a][i]}removeFeatureState(t,i,r){if(null===this.deletedStates[t])return;let a=String(i);if(this.deletedStates[t]=this.deletedStates[t]||Object.create(null),r&&void 0!==i)null!==this.deletedStates[t][a]&&(this.deletedStates[t][a]=this.deletedStates[t][a]||Object.create(null),this.deletedStates[t][a][r]=null);else if(void 0!==i)if(this.stateChanges[t]&&this.stateChanges[t][a])for(r in this.deletedStates[t][a]=Object.create(null),this.stateChanges[t][a])this.deletedStates[t][a][r]=null;else this.deletedStates[t][a]=null;else this.deletedStates[t]=null}getState(t,i){let r=this.state[t]||Object.create(null),a=this.stateChanges[t]||Object.create(null),n=this.deletedStates[t];if(null===n)return Object.create(null);if(void 0!==i){let t=String(i),o=Object.assign(Object.create(null),r[t],a[t]);if(n){let t=n[i];if(null===t)return Object.create(null);for(let i in t)delete o[i]}return o}let o=Object.assign(Object.create(null),r,a);if(n)for(let t in n)delete o[t];return o}initializeTileState(t,i){t.refreshFeatureState(i)}coalesceChanges(t,i){let r=Object.create(null);for(let t in this.stateChanges){this.state[t]=this.state[t]||Object.create(null);let i=Object.create(null);for(let r in this.stateChanges[t])this.state[t][r]||(this.state[t][r]=Object.create(null)),Object.assign(this.state[t][r],this.stateChanges[t][r]),i[r]=this.state[t][r];r[t]=i}for(let t in this.deletedStates){this.state[t]=this.state[t]||Object.create(null);let i=Object.create(null);if(null===this.deletedStates[t])for(let r in this.state[t])i[r]=Object.create(null),this.state[t][r]=Object.create(null);else for(let r in this.deletedStates[t]){if(null===this.deletedStates[t][r])this.state[t][r]=Object.create(null);else if(this.state[t][r])for(let i of Object.keys(this.deletedStates[t][r]))delete this.state[t][r][i];i[r]=this.state[t][r]}r[t]=r[t]||Object.create(null),Object.assign(r[t],i)}if(this.stateChanges=Object.create(null),this.deletedStates=Object.create(null),0!==Object.keys(r).length)for(let a in t)t[a].refreshFeatureState(i,r)}}class vq extends rB{constructor(t,i,r){super(),this.id=t,this._renderSourceType=r,this._maxzoomOverride=null,i.on("data",t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),i.on("error",()=>{this._sourceErrored=!0}),this._source=i,this._tiles={},this._cache=new vG(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={}
109,this._minTileCacheSize=i.minTileCacheSize,this._maxTileCacheSize=i.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new vH,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"_dataType"in this._source&&"raster"===this._source._dataType,this._supportsFading="raster"===this._source.type||"raster-array"===this._source.type||"image"===this._source.type||"video"===this._source.type||"custom"===this._source.type,this._isRasterElevatedOverTerrain=!1}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(let t in this._tiles)if(!this._tiles[t].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;let t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(t){this._maxzoomOverride=t}_loadTile(t,i){return t.renderSourceType=this._renderSourceType,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,i)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){for(let i in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){let r=this._tiles[i];r.upload(t,this.map?this.map.painter:void 0),r.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(vZ).map(t=>t.key)}getRenderableIds(t,i){let r=[];for(let a in this._tiles)this._isIdRenderable(+a,t,i)&&r.push(this._tiles[a]);return t?r.sort((t,i)=>{let r=t.tileID,a=i.tileID,n=new tg(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),o=new tg(a.canonical.x,a.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-a.overscaledZ||o.y-n.y||o.x-n.x}).map(t=>t.tileID.key):r.map(t=>t.tileID).sort(vZ).map(t=>t.key)}hasRenderableParent(t){let i=this.findLoadedParent(t,0);return!!i&&this._isIdRenderable(i.tileID.key)}_isIdRenderable(t,i,r){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(i||!this._tiles[t].holdingForFade())&&(r||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(let t in this._cache.reset(),this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}_reloadTile(t,i){let r=this._tiles[t];r&&("loading"!==r.state&&(r.state=i),this._loadTile(r,this._tileLoaded.bind(this,r,t,i)))}_tileLoaded(t,i,r,a,n){if(a){if(t.state="errored",iK(a)){if(this._source.fire(new rz("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){let t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform)}else this._source.fire(new rL(a,{tile:t}));return}t.timeAdded=is.now(),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let o=new Headers;n&&n.headers&&(o=n.headers),this._source.fire(new rz("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:o}))}_hasTunnelGeometry(){for(let t in this._tiles){let i=this._tiles[t];if(i&&i.hasTunnelGeometry)return!0}return!1}_backfillDEM(t){let i=this.getRenderableIds();for(let a=0;a<i.length;a++){let n=i[a];if(t.neighboringTiles&&t.neighboringTiles[n]){let i=this.getTileByID(n);r(t,i),r(i,t)}}function r(t,i){if(!t.dem||t.dem.borderReady)return;t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0;let r=i.tileID.canonical.x-t.tileID.canonical.x,a=i.tileID.canonical.y-t.tileID.canonical.y,n=Math.pow(2,t.tileID.canonical.z),o=i.tileID.key;0===r&&0===a||Math.abs(a)>1||(Math.abs(r)>1&&(1===Math.abs(r+n)?r+=n:1===Math.abs(r-n)&&(r-=n)),i.dem&&t.dem&&(t.dem.backfillBorder(i.dem,r,a),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,i,r,a){for(let n in this._tiles){let o=this._tiles[n];if(a[n]||!o.hasData()||o.tileID.overscaledZ<=i||o.tileID.overscaledZ>r)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>i+1;){let t=o.tileID.scaledTo(o.tileID.overscaledZ-1);(o=this._tiles[t.key])&&o.hasData()&&(s=t)}let l=s;for(;l.overscaledZ>i;)if(t[(l=l.scaledTo(l.overscaledZ-1)).key]){a[s.key]=s;break}}}findLoadedParent(t,i){if(t.key in this._loadedParentTiles){let r=this._loadedParentTiles[t.key];return r&&r.tileID.overscaledZ>=i?r:null}for(let r=t.overscaledZ-1;r>=i;r--){let i=t.scaledTo(r),a=this._getLoadedTile(i);if(a)return a}}_getLoadedTile(t){let i=this._tiles[t.key];return i&&i.hasData()?i:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,i){i=i||this._source.tileSize;let r=Math.floor((Math.ceil(t.width/i)+1)*(Math.ceil(t.height/i)+1)*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,n="number"==typeof this._maxTileC
109acheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(n)}handleWrapJump(t){let i=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,i){let t={};for(let r in this._tiles){let a=this._tiles[r];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+i),t[a.tileID.key]=a}for(let i in this._tiles=t,this._timers)clearTimeout(this._timers[i]),delete this._timers[i];for(let t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,i,r,a,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!r)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};let o="batched-model"===this._source.type,s,l=this._source.maxzoom;null!==this._maxzoomOverride&&(l=Math.min(l,this._maxzoomOverride));let h=this.map&&this.map.painter?this.map.painter._terrain:null;if(h&&h.sourceCache===this&&h.attenuationRange()){let t=Math.floor(h.attenuationRange()[0])-Math.log2(h.getDemUpscale());l>t&&(l=t)}let u=null===this._maxzoomOverride&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)s=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new c0(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){let a=t.clone();a.tileCoverLift=this.tileCoverLift,s=a.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:u,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:o}),this._source.minzoom<=1&&"globe"===t.projection.name&&(s.push(new c0(1,0,1,0,0)),s.push(new c0(1,0,1,1,0)),s.push(new c0(1,0,1,0,1)),s.push(new c0(1,0,1,1,1)))}else if(s=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:u,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:o}),this._source.hasTile){let t=this._source.hasTile.bind(this._source);s=s.filter(i=>t(i))}}else s=[];if(s.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!this._supportsFading){let h=Math.min(t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!r}),l);if(o)for(let i of t.extendTileCover(s,h))s.push(i);else if(n){let i=this.transform.getFrustum(h);for(let r of t.extendTileCoverToNearPlane(s,i,h))s.push(r);if(h>=18&&this._hasTunnelGeometry())for(let r of t.extendTileCoverForTunnels(s,i,h,20))s.push(r)}else if(this.castsShadows&&a)for(let i of t.extendTileCover(s,h,a,16))this._shadowCasterTiles[i.key]=!0,s.push(i)}let c=this._updateRetainedTiles(s);if(this._supportsFading&&0!==s.length){let t={},i={},r=is.now();for(let a of Object.keys(c)){let n=c[a],o=this._tiles[a];if(!o||void 0!==o.fadeEndTime&&o.fadeEndTime<=r)continue;let s=this.findLoadedParent(n,Math.max(n.overscaledZ-vq.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[a]=n}let a=s.at(-1).overscaledZ;for(let t in this._tiles){let r=this._tiles[t];if(c[t]||!r.hasData())continue;let n=r.tileID;for(;n.overscaledZ>a;){n=n.scaledTo(n.overscaledZ-1);let a=this._tiles[n.key];if(a&&a.hasData()&&i[n.key]){c[t]=r.tileID;break}}}for(let i in t)c[i]||(this._coveredTiles[i]=!0,c[i]=t[i])}for(let t in c)this._tiles[t].clearFadeHold();for(let t of function(t,i){let r=[];for(let a in t)a in i||r.push(a);return r}(this._tiles,c)){let i=this._tiles[t];i.hasSymbolBuckets&&!i.holdingForFade()?i.setHoldDuration(this.map._fadeDuration):i.hasSymbolBuckets&&!i.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),1===this._renderSourceType&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(let t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){let i={};if(0===t.length)return i;let r={},a=t.reduce((t,i)=>Math.min(t,i.overscaledZ),1/0),n=t[0].overscaledZ,o=Math.max(n-vq.maxOverzooming,this._source.minzoom),s=Math.max(n+vq.maxUnderzooming,this._source.minzoom),l={};for(let r of t){let t=this._addTile(r);i[r.key]=r,t.hasData()||a<this._source.maxzoom&&(l[r.key]=r)}for(let n of(this._retainLoadedChildren(l,a,s,i),t)){let t=this._tiles[n.key];if(t.hasData())continue;if(n.canonical.z>=this._source.maxzoom){let t=n.children(this._source.maxzoom)[0],r=this.getTile(t);if(r&&r.hasData()){i[t.key]=t;continue}}else{let t=n.children(this._source.maxzoom);
109if(i[t[0].key]&&i[t[1].key]&&i[t[2].key]&&i[t[3].key])continue}let a=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){let o=n.scaledTo(s);if(r[o.key]||(r[o.key]=!0,(t=this.getTile(o))||!a||(t=this._addTile(o)),t&&(i[o.key]=o,a=t.wasRequested(),t.hasData())))break}}return i}_updateLoadedParentTileCache(){for(let t in this._loadedParentTiles={},this._tiles){let i=[],r,a=this._tiles[t].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){r=this._loadedParentTiles[a.key];break}i.push(a.key);let t=a.scaledTo(a.overscaledZ-1);if(r=this._getLoadedTile(t))break;a=t}for(let t of i)this._loadedParentTiles[t]=r}}_addTile(t){let i=this._tiles[t.key];if(i)return!0!==i.isExtraShadowCaster||this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;(i=this._cache.getAndRemove(t))&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));let r=!!i;if(!r){let r=this.map?this.map.painter:null,a=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new vc(t,a,this.transform.tileZoom,r,this._isRaster):new xV(t,a,this.transform.tileZoom,r,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state))}return i.uses++,this._tiles[t.key]=i,r||this._source.fire(new rz("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,i){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);let r=i.getExpiryTimeout();r&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},r))}_removeTile(t){let i=this._tiles[t];i&&(i.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),i.uses>0||(i.hasData()&&"reloading"!==i.state||"empty"===i.state?this._cache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}clearTiles(){for(let t in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,i,r){let a=[],n=this.transform;if(!n)return a;let o="globe"===n.projection.name,s=az(n.center.lng),l=n.getFreeCameraOptions().position||new s8(0,0,0);for(let h in this._tiles){let u,c=this._tiles[h];if(r&&c.clearQueryDebugViz(),!c.holdingForFade()){if(o){let t=c.tileID.canonical;if(0===t.z){let i=[Math.abs(tL(s,...v$(t,-1))-s),Math.abs(tL(s,...v$(t,1))-s)];u=[0,2*i.indexOf(Math.min(...i))-1]}else{let i=[Math.abs(tL(s,...v$(t,-1))-s),Math.abs(tL(s,...v$(t,0))-s),Math.abs(tL(s,...v$(t,1))-s)];u=[i.indexOf(Math.min(...i))-1]}}else u=[0];for(let r of u){let o=t.containsTile(c,n,i,r,l);o&&a.push(o)}}}return a}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,i){if(!this.transform)return[];let r=this.getRenderableIds(t,i).map(t=>this._tiles[t].tileID),a="globe"===this.transform.projection.name;for(let t of r)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=a?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return r}sortCoordinatesByDistance(t){if(!this.transform)return t.slice();let i=t.slice(),r=this.transform._camera.position,a=this.transform._camera.forward(),n={};for(let t of i){let i=1/(1<<t.canonical.z);n[t.key]=((t.canonical.x+.5)*i+t.wrap-r[0])*a[0]+((t.canonical.y+.5)*i-r[1])*a[1]-r[2]*a[2]}return i.sort((t,i)=>n[t.key]-n[i.key]),i}hasTransition(){if(this._source.hasTransition())return!0;if(this._supportsFading){let t=is.now();for(let i in this._tiles){let r=this._tiles[i];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=t)return!0}}return!1}setFeatureState(t,i,r){this._state.updateState(t=t||"_geojsonTileLayer",i,r)}removeFeatureState(t,i,r){this._state.removeFeatureState(t=t||"_geojsonTileLayer",i,r)}getFeatureState(t,i){return this._state.getState(t=t||"_geojsonTileLayer",i)}
109setDependencies(t,i,r){let a=this._tiles[t];a&&a.setDependencies(i,r)}reloadTilesForDependencies(t,i){for(let r in this._tiles)this._tiles[r].hasDependency(t,i)&&this._reloadTile(+r,"reloading");this._cache.filter(r=>!r.hasDependency(t,i))}_preloadTiles(t,i){if(!this._sourceLoaded){let r=()=>{this._sourceLoaded&&(this._source.off("data",r),this._preloadTiles(t,i))};return void this._source.on("data",r)}let r=new Map,a=Array.isArray(t)?t:[t],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(let t of a){for(let i of t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}))r.set(i.key,i);this.usedForTerrain&&t.updateElevation(!1)}tB(Array.from(r.values()),(t,i)=>{let r=new xV(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(r,t=>{"raster-dem"===this._source.type&&r.dem&&this._backfillDEM(r),i(t,r)})},i)}}function vZ(t,i){let r=Math.abs(2*t.wrap)-(t.wrap<0),a=Math.abs(2*i.wrap)-(i.wrap<0);return t.overscaledZ-i.overscaledZ||a-r||i.canonical.y-t.canonical.y||i.canonical.x-t.canonical.x}function v$(t,i){let r=1<<t.z;return[t.x/r+i,(t.x+1)/r+i]}function vW(t,i){return t.sourceFQID!==i.sourceFQID?t.sourceFQID<i.sourceFQID?-1:1:t.tileId.z!==i.tileId.z?t.tileId.z-i.tileId.z:t.tileId.x!==i.tileId.x?t.tileId.x-i.tileId.x:t.tileId.y-i.tileId.y}vq.maxOverzooming=10,vq.maxUnderzooming=3;class vX{constructor(t=[]){this.tiles=t}getTilesIntersecting(t){let i=[];for(let r of this.tiles)(function(t,i){if(t.z<=i.z){let r=i.z-t.z;return i.x>>r===t.x&&i.y>>r===t.y}let r=t.z-i.z;return t.x>>r===i.x&&t.y>>r===i.y})(r.tileId,t)&&i.push(r);return i}equals(t){if(this.tiles.length!==t.length)return!1;for(let i=0;i<this.tiles.length;++i){let r=this.tiles[i],a=t[i];if(r.sourceFQID!==a.sourceFQID||r.tileId.z!==a.tileId.z||r.tileId.x!==a.tileId.x||r.tileId.y!==a.tileId.y||r.generation!==a.generation)return!1}return!0}empty(){return 0===this.tiles.length}}class vY{constructor(){this._tiles=[],this._snapshot=new vX,this._snapshotChanged=!1}clear(){this._tiles.length=0}consumeSnapshotChanged(){let t=this._snapshotChanged;return this._snapshotChanged=!1,t}addTileElevation(t,i,r,a){this._tiles.push({sourceFQID:t,tileId:i,features:r,generation:a})}updateSnapshotIfNeeded(){return this._tiles.sort(vW),this._snapshot.equals(this._tiles)||(this._snapshot=new vX(this._tiles.slice()),this._snapshotChanged=!0),this._snapshot}}function vK(t,i){let r=[];for(let a of t.getTilesIntersecting(i))r.push(`${a.tileId.z}/${a.tileId.x}/${a.tileId.y}:${a.generation}`);return r.sort(),r.join("|")}function vQ(t,i){return t._mergedOtherSourceCaches[i]||t._mergedSymbolSourceCaches[i]||t._mergedHdRoadElevationSourceCaches[i]}function vJ(t){let i=t.sourceLayer;return!!i&&i.startsWith("hd_road_")}function v0(t){return!!t.layout&&("line"===t.type&&"hd-road-markup"===t.layout.get("line-elevation-reference")||"circle"===t.type&&"hd-road-markup"===t.layout.get("circle-elevation-reference")||"symbol"===t.type&&"hd-road-markup"===t.layout.get("symbol-elevation-reference")||"fill"===t.type&&"hd-road-markup"===t.layout.get("fill-elevation-reference"))}function v1(t){let i=new Set;for(let r in t._mergedLayers){let a=t._mergedLayers[r];v0(a)&&i.add(sy(a.source,a.scope))}return i}function v2(t){let i=v1(t),r=new Set;for(let a in t._mergedLayers){let n=t._mergedLayers[a];if(!n.source||!vJ(n))continue;let o=sy(n.source,n.scope);i.has(o)||r.add(o)}return r}function v3(t){let i=v1(t);if(0===i.size)return!1;let r=v4(t);for(let t of i)for(let i of r)if(t!==i)return!0;return!1}function v4(t){let i=new Set;for(let r in t._mergedLayers){let a=t._mergedLayers[r];a.source&&vJ(a)&&i.add(sy(a.source,a.scope))}return i}function v5(t,i,r){let a=v1(t);if(0!==a.size){if(!r)for(let i of v4(t))a.delete(i);if(0!==a.size)for(let r of[t._mergedOtherSourceCaches,t._mergedSymbolSourceCaches])for(let t in r){if(!a.has(t))continue;let n=r[t];for(let t in n._tiles){let r=n._tiles[t];r&&(i&&!i(r)||(r.hasDeferredElevationFeatures=!1,n._reloadTile(+t,"reloading")))}}}}class v6{constructor(){this.elevationSourceCaches={},this.manager=new vY,this._needsCrossSourceElevation=!1,this._ingestFQIDs=new Set,this._terrainActiveLast=void 0}}function v8(t){t.map&&t.map.painter&&(t.map.painter.elevationCoverageSnapshot=null,t.map.painter.elevationProvidersReady=void 0)}function v9(t){t._crossSourceElevationActive=!1,function(t){let i=t._hdElevation,r=!!(t.map&&t.map.painter&&t.map.painter.elevationCoverageSnapshot);return i?!i._needsCrossSourceElevation&&0===i._ingestFQIDs.size&&0===i.manager._tiles.length&&!r:!r}(t)||(v8(t),t._hdElevation&&(t._hdElevation._needsCrossSourceElevation=!1,t._hdElevation._ingestFQIDs.clear(),t._hdElevation.manager.clear(),t._hdElevation._terrainActiveLast=void 0))}function v7(t,i,r){let a=sy(r.id,t.scope);if(i.elevationSourceCaches[a])return;let n=`hd-road-elevation:${r.id}`,o=sy(n,t.scope),s=t._sourceCaches[n]=new vq(o,r,4);i.elevationSourceCaches[a]=s,s.onAdd(t.map);let l=t._otherSourceCaches[r.id];l&&l._sourceLoaded&&(s._sourceLoaded=!0)}function be(t,i){if(gh(t,t.map&&t.map.transform))return i.manager.clear(),void(t.map.painter&&(t.map.painter.elevationCoverageSnapshot=null));if(!i._needsCrossSourceElevation)return void v8(t);for(let r of i._ingestFQIDs){let i=vQ(t,r);
109i&&(i.used=!0)}i.manager.clear();let r=!0;for(let a of i._ingestFQIDs){let n=vQ(t,a);if(!n)continue;let o=n._tiles;for(let t in o){let n=o[t];if(!n||!n.loaded())continue;let s=n.parsedElevationFeatures;void 0!==s?i.manager.addTileElevation(a,n.tileID.canonical,s,n.parsedElevationGeneration):r=!1}}let a=i.manager._snapshot,n=i.manager.updateSnapshotIfNeeded();t.map.painter&&(t.map.painter.elevationCoverageSnapshot=n.empty()?null:n);let o=r&&function(t,i){for(let r of i){let i=vQ(t,r);if(!i||!i._sourceLoaded)return!1;for(let t in i._tiles){let r=i._tiles[t];if(r&&("loading"===r.state||"reloading"===r.state))return!1}}return!0}(t,v2(t));t.map.painter&&(t.map.painter.elevationProvidersReady=o);let s=i.manager.consumeSnapshotChanged();(s||o)&&v5(t,t=>{var i;return!!t.hasDeferredElevationFeatures||s&&vK(a,i=t.tileID.canonical)!==vK(n,i)})}let bt=t=>({u_matrix:t});function bi(t,i){if(!t.frcCoverageSnapshot||!t.frcCoverageRenderer)return null;let r=t.frcCoverageSnapshot.getTileOrParent(i.canonical);if(!r||0===r.frcMask)return null;let a=t.frcCoverageRenderer.getBuffers(r.tileId);if(!a)return null;let n=new cQ(r.tileId.z,r.tileId.x,r.tileId.y),o=new cJ(i.wrap,n);return{buffers:a,projMatrix:t.transform.calculateProjMatrix(o),coverageTile:r}}function br(t,i,r,a,n){if(0===i.length)return;let o=0;for(let t of i)o|=t.frcMask;let s=i.map(t=>t.coord);for(let l=0;l<9;++l)if(o&1<<l){if(function(t,i,r){if(!t.frcCoverageSnapshot)return;let a=t.context,n=a.gl,o=t.getOrCreateProgram("clippingMask");for(let s of(a.setColorMode(g6.disabled),a.setDepthMode(gz.disabled),i)){let i=bi(t,s);if(!i)continue;let a=i.buffers.frcLevelSegments[r];a&&o.draw(t,n.TRIANGLES,gz.disabled,new g3({func:n.EQUAL,mask:255},t._tileClippingMaskIDs[s.key]||0,255,n.KEEP,n.KEEP,n.INVERT),g6.disabled,gP.disabled,bt(i.projMatrix),`$frc_coverage_${r}`,i.buffers.vertexBuffer,i.buffers.indexBuffer,a)}}(t,s,l),a)for(let r of i)r.frcMask&1<<l&&a(r,l,function(t,i){let r=t.context.gl;return new g3({func:r.EQUAL,mask:255},t._tileClippingMaskIDs[i.key]||0,0,r.KEEP,r.KEEP,r.KEEP)}(t,r.coord));if(r>0&&n)for(let r of i)r.frcMask&1<<l&&n(r,l,function(t,i){let r=t.context.gl;return new g3({func:r.EQUAL,mask:255},255&~(t._tileClippingMaskIDs[i.key]||0),0,r.KEEP,r.KEEP,r.KEEP)}(t,r.coord));!function(t,i,r){if(!t.frcCoverageSnapshot)return;let a=t.context,n=a.gl,o=t.getOrCreateProgram("clippingMask");for(let s of(a.setColorMode(g6.disabled),a.setDepthMode(gz.disabled),i)){let i=bi(t,s);if(!i)continue;let a=i.buffers.frcLevelSegments[r];a&&o.draw(t,n.TRIANGLES,gz.disabled,new g3({func:n.EQUAL,mask:255},255&~(t._tileClippingMaskIDs[s.key]||0),255,n.KEEP,n.KEEP,n.INVERT),g6.disabled,gP.disabled,bt(i.projMatrix),`$frc_coverage_restore_${r}`,i.buffers.vertexBuffer,i.buffers.indexBuffer,a)}}(t,s,l)}}function ba(t){for(let i of t)if(i.rings.length>0&&i.rings[0].length>0)return!0;return!1}function bn(t){let i=t.frcCoverageFadeRange;return!i||i[1]<=i[0]?0:1-Math.max(0,Math.min(1,(t.transform.zoom-i[0])/(i[1]-i[0])))}let bo=function(t,i,r,a){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);let n=r.paint.get("building-ambient-occlusion-ground-intensity"),o=r.paint.get("building-ambient-occlusion-ground-radius"),s=r.paint.get("building-ambient-occlusion-ground-attenuation"),l=r.paint.get("building-opacity");if(l<=0)return;let h=n>0&&o>0,u=!0,c=r.paint.get("building-vertical-scale");if(c<=0)return;t.shadowRenderer||(u=!1);let d=t.conflationActive&&t.style.isLayerClipped(r,i.getSource()),p=t.style.order.indexOf(r.fqid);if(function(t,i,r,a,n,o){for(let s of o){let o=i.getTile(s).getBucket(r);o&&(n&&o.updateReplacement(s,t.replacementSource,a),o.uploadUpdatedIndexBuffer(t.context))}}(t,i,r,p,d,a),function(t,i,r,a){for(let n of a){let a=i.getTile(n).getBucket(r);a&&a.needsEvaluation()&&a.uploadUpdatedColorBuffer(t.context)}}(t,i,r,a),r.resetLayerRenderingStats(t),t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0),"shadow"===t.renderPass&&t.shadowRenderer){let n=t.shadowRenderer.getShadowPassDepthMode();xv({painter:t,source:i,layer:r,coords:a,defines:[],blendMode:g6.disabled,depthMode:n,opacity:l,verticalScale:c,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if("translucent"===t.renderPass){let p=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];u&&(p=p.concat("RENDER_SHADOWS")),t.shadowRenderer&&t.shadowRenderer.useNormalOffset&&(p=p.concat("NORMAL_OFFSET"));let f=r.paint.get("building-facade-emissive-chance"),_=r.paint.get("building-ambient-occlusion-intensity"),m=r.paint.get("building-flood-light-intensity"),g="none"===r.paint.get("building-flood-light-color-use-theme").
109constantOr("default"),y=r.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:r.lut).toArray01().slice(0,3),x=r.paint.get("building-flood-light-ground-attenuation"),v=m>0,b=new gz(t.context.gl.LEQUAL,gz.ReadWrite,t.depthRangeFor3D);l<1&&xv({painter:t,source:i,layer:r,coords:a,defines:p,blendMode:g6.disabled,depthMode:b,opacity:l,verticalScale:c,facadeEmissiveChance:f,facadeAOIntensity:_,floodLightIntensity:m,floodLightColor:y,depthOnly:!0});let w=t.colorModeForRenderPass();xv({painter:t,source:i,layer:r,coords:a,defines:p,blendMode:w,depthMode:b,opacity:l,verticalScale:c,facadeEmissiveChance:f,facadeAOIntensity:_,floodLightIntensity:m,floodLightColor:y});let T=r.paint.get("building-front-cutoff");xp(t.transform.pitch,T,!!t.terrain),h&&xb(t,i,r,a,!0,l,n,o,m,y,s,d),v&&xb(t,i,r,a,!1,l,n,o,m,y,x,d)}else if("light-beam"===t.renderPass){let n=new gz(t.context.gl.LEQUAL,gz.ReadOnly,t.depthRangeFor3D);xv({painter:t,source:i,layer:r,coords:a,defines:["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],blendMode:g6.alphaBlended,depthMode:n,opacity:l,verticalScale:c,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1),t.resetStencilClippingMasks()},bs=class{constructor(){this.visibleTiles=[]}updateBorders(t,i){let r=[],a=[];for(let n of t._getRenderableCoordinates(!1,!0)){let o=t.getTile(n);if(!o.hasData())continue;let s=o.getBucket(i);s&&(s.isEmpty()||(r.push(n.key),a.push({bucket:s,tileID:n.canonical})))}let n=r.length!==this.visibleTiles.length;if(!n){r.sort();for(let t=0;t<r.length;t++)if(r[t]!==this.visibleTiles[t]){n=!0;break}}if(!n)return;let o=new Set;for(let t of(this.visibleTiles=r,a.sort((t,i)=>t.tileID.z-i.tileID.z||t.tileID.x-i.tileID.x||t.tileID.y-i.tileID.y),a)){let i=[],r=[],a=t.bucket;for(let t of a.featuresOnBorder)o.has(t.featureId)?r.push(t.footprintIndex):(o.add(t.featureId),i.push(t.footprintIndex));a.updateFootprintHiddenFlags(i,2,!1),a.updateFootprintHiddenFlags(r,2,!0)}}},bl=function(t,i,r,a,n,o){"offscreen"===t.renderPass&&function(t,i,r,a){if(!a.length)return;let n=t.context,o=n.gl,s=i.getSource();if(!(s instanceof vw))return;let l=Math.ceil(Math.sqrt(r.paint.get("raster-particle-count"))),h=r.particlePositionRGBAImage;if(!h||h.width!==l){let t=function(t){let i=t*t,r=new Uint8Array(4*i);for(let t=0;t<i;t++){let i=.9090909090909091*(ia(2*t+0)+.05),a=.9090909090909091*(ia(2*t+1)+.05),n=255*i%1,o=255*a%1,s=a-o/255;r[4*t+0]=255*(i-n/255),r[4*t+1]=255*n,r[4*t+2]=255*s,r[4*t+3]=255*o}return r}(l);h=r.particlePositionRGBAImage=new h7({width:l,height:l},t)}let u=r.particleFramebuffer;u?u.width!==l&&(u.destroy(),u=r.particleFramebuffer=n.createFramebuffer(l,l,1,null)):u=r.particleFramebuffer=n.createFramebuffer(l,l,1,null);let c=[];for(let t of a){let a=i.getTile(t);if(!(a instanceof vc))continue;let o=function(t,i,r){if(!t)return null;let a=i.getTextureDescriptor(t,r,!0);if(!a)return null;let{texture:n,mix:o,offset:s,tileSize:l,buffer:h,format:u}=a;if(!n||!u)return null;let c=!1;return"uint32"===u&&(c=!0,o[3]=0,o=xI(256,o,[0,r.paint.get("raster-particle-max-speed")]),s=xA(256,s,[0,r.paint.get("raster-particle-max-speed")])),{texture:n,textureOffset:[h/(l+2*h),l/(l+2*h)],tileSize:l,scalarData:c,scale:o,offset:s,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[u]]}}(a,s,r);if(!o)continue;let u=[a.tileSize,a.tileSize],d=r.tileFramebuffer;d||(d=r.tileFramebuffer=n.createFramebuffer(u[0],u[1],1,null));let p=a.rasterParticleState;p||(p=a.rasterParticleState=new vE(n,t,u,h));let f=p.update(r.lastInvalidatedAt);p.particleTextureDimension!==l&&p.updateParticleTexture(t,h);let _=p.targetColorTexture;p.targetColorTexture=p.backgroundColorTexture,p.backgroundColorTexture=_;let m=p.particleTexture0;p.particleTexture0=p.particleTexture1,p.particleTexture1=m,c.push([t,o,p,f])}if(0===c.length)return;let d=is.now(),p=r.previousDrawTimestamp?.001*(d-r.previousDrawTimestamp):.0167;if(r.previousDrawTimestamp=d,r.hasColorMap()){n.activeTexture.set(o.TEXTURE0+2);let t=r.colorRampTexture;t||(t=r.colorRampTexture=new uW(n,r.colorRamp,o.RGBA8)),t.bind(o.LINEAR,o.CLAMP_TO_EDGE)}n.bindFramebuffer.set(r.tileFramebuffer.framebuffer),function(t,i,r){var a;let n=t.context,o=n.gl,s=i.tileFramebuffer;n.activeTexture.set(o.TEXTURE0);let l={u_texture:0,u_opacity:1.05*(a=i.paint.get("raster-particle-fade-opacity-factor"))/(a+.05)},h=t.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});for(let a of r){let[,,r,u]=a;s.colorAttachment0.set(r.targetColorTexture.texture),n.viewport.set([0,0,s.width,s.height]),n.clear({color:rq.transparent}),u&&(r.backgroundColorTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),h.draw(t,o.TRIANGLES,gz.disabled,g3.disabled,g6.alphaBlended,gP.disabled,l,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments))}}(t,r,c),function(t,i,r,a){let n=t.context,o=n.gl,s=r.tileFramebuffer,l="globe"===t.transform.projection.name,h=r.paint.get("raster-particle-max-speed");for(let u of a){let[a,c,d]=u;n.activeTexture.set(o.TEXTURE0+0),c.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s.colorAttachment0.set(d.targetColorTexture.texture);let p=t.getOrCreateProgram("rasterParticleDraw",{defines:c.defines,overrideFog:!1});n.activeTexture.set(o.TEXTURE0+1);let f=c.scalarData?[]:[0,1,2,3].map(t=>c2[t](a));f.push(a);let _=a.canonical.x,m=a.canonical.y;for(let n of f){let s=i.getTile(l?n.wrapped():n);if(!s)continue;let u=s.rasterParticleState;if(!u)continue;let d=n.canonical.x+(1<<n.canonical.z)*(n.wrap-a.wrap),f=n.canonical.y;u.particleTexture0.bind(o.NEAREST,o.CLAMP_TO_EDGE);let g=xE(1,u.particleTexture0.size[0],[d-_,f-m],0,c.texture.size,2,h,c.textureOffset,c.scale,c.offset);p.draw(t,o.POINTS,gz.disabled,g3.disabled,g6.alphaBlended,gP.disabled,g,r.id,u.particleIndexBuffer,void 0,u.particleSegment)}}}(t,i,r,c),n.bindFramebuffer.set(r.particleFramebuffer.framebuffer),function(t,i,r,a){let n=t.context,o=n.gl,s=i.paint.get("raster-particle-max-speed"),l=a*i.paint.get("raster-particle-speed-factor")*.15,h=Math.pow(.01+ +i.paint.get("raster-particle-reset-rate-factor"),6),u=i.particleFramebuffer;for(let a of(n.viewport.set([0,0,u.width,u.height]),r)){let[,r,c]=a;n.activeTexture.set(o.TEXTURE0+0),r.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE0+1);let d=c.particleTexture0;d.bind(o.NEAREST,o.CLAMP_TO_EDGE);let p=xS(1,d.size[0],0,r.texture.size,s,l,h,r.textureOffset,r.scale,r.offset);u.colorAttachment0.set(c.particleTexture1.texture),n.clear({color:rq.transparent}),t.getOrCreateProgram("rasterParticleUpdate",{defines:r.defines}).draw(t,o.TRIANGLES,gz.disabled,g3.disabled,g6.unblended,gP.disabled,p,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}}(t,r,c,p)}(t,i,r,a),"translucent"===t.renderPass&&(function(t,i,r,a){let n=t.context,o=n.gl,s=i.getSource().tileSize,l=5*(1-tO(6,7,t.transform.zoom))*s+r.paint.get("raster-particle-elevation"),h=!t.o
109ptions.moving,u="globe"===t.transform.projection.name;if(!a.length)return;let[c,d]=t.stencilConfigForOverlap(a),p=[];u&&p.push("PROJECTION_GLOBE_VIEW");let f=t.stencilModeFor3D();for(let a of d){let s,d,_,m,g,y,x,v=a.toUnwrapped(),b=i.getTile(a);if(!b.rasterParticleState)continue;let w=b.rasterParticleState;b.registerFadeDuration(100);let T=i.findLoadedParent(a,0),E=vS(b,T,i,t.transform,100);t.terrain&&t.terrain.prepareDrawTile(),n.activeTexture.set(o.TEXTURE0),w.targetColorTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE1),T&&T.rasterParticleState?(T.rasterParticleState.targetColorTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s=Math.pow(2,T.tileID.overscaledZ-b.tileID.overscaledZ),d=[b.tileID.canonical.x*s%1,b.tileID.canonical.y*s%1]):w.targetColorTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);let S=u?t.transform.expandedFarZProjMatrix:t.transform.calculateProjMatrix(v,h),I=t.transform,A=function(t){let i=t._nearZ,r=t.projection.farthestPixelDistance(t),a=r-i,n=.2*t.height,o=i+n;return[i,r,(o-n-i)/a,(o-i)/a]}(I),C=cC(a.canonical),M=cG(C.getCenter().lat);u?(_=Float32Array.from(cz(cT(a.canonical))),m=Float32Array.from(I.globeMatrix),g=Float32Array.from(ck(I)),y=[az(I.center.lng),aL(I.center.lat)],x=Float32Array.from(cj(a.canonical,C,M,I.worldSize/I._pixelsPerMercatorPixel))):(_=new Float32Array(16),m=new Float32Array(9),g=new Float32Array(16),y=[0,0],x=new Float32Array(9));let R=xT(S,_,m,g,x,d||[0,0],cN(t.transform.zoom),y,A,s||1,E,l),D=t.isTileAffectedByFog(a),P=t.getOrCreateProgram("rasterParticle",{defines:p,overrideFog:D});if(t.uploadCommonUniforms(n,P,v),u){let i=new gz(o.LEQUAL,gz.ReadOnly,t.depthRangeFor3D),a=t.globeSharedBuffers;if(a){let[n,s,l]=a.getGridBuffers(M,!1);P.draw(t,o.TRIANGLES,i,f,g6.alphaBlended,t.renderElevatedRasterBackface?gP.frontCCW:gP.backCCW,R,r.id,n,s,l)}}else{let i=t.depthModeForSublayer(0,gz.ReadOnly),n=c[a.overscaledZ],{tileBoundsBuffer:s,tileBoundsIndexBuffer:l,tileBoundsSegments:h}=t.getTileBoundsBuffers(b);P.draw(t,o.TRIANGLES,i,n,g6.alphaBlended,gP.disabled,R,r.id,s,l,h)}}t.resetStencilClippingMasks()}(t,i,r,a),t.style.map.triggerRepaint())},bh=function(t,i,r){let a=i.getSource();if(!(a instanceof vw&&a.loaded()))return;let n=t.sourceLayer||a.rasterLayerIds&&a.rasterLayerIds[0];if(!n)return;let o=t.paint.get("raster-particle-array-band")||a.getInitialBand(n);if(null!=o)for(let r of i.getIds().map(t=>i.getTileByID(t)))r.updateNeeded(t.id,o)&&a.prepareTile(r,n,t.id,o)},bu=class extends vO{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(t){let i=t.context;if(!this.particlesVx){let t=vz(this.particlesCount),r=new lB,a=new lR,n=0,o=n5(0x134104da55e);for(let i=0;i<t.length;++i){let s=t[i],l=[2*o()-1,o(),o(),o()];r.emplaceBack(s[0],s[1],s[2],-1,-1,...l),r.emplaceBack(s[0],s[1],s[2],1,-1,...l),r.emplaceBack(s[0],s[1],s[2],1,1,...l),r.emplaceBack(s[0],s[1],s[2],-1,1,...l),a.emplaceBack(n+0,n+1,n+2),a.emplaceBack(n+0,n+2,n+3),n+=4}this.particlesVx=i.createVertexBuffer(r,vC.members),this.particlesIdx=i.createIndexBuffer(a)}}getDrawParams(t){if(!t.style.rain)return null;let i=t.style.rain.state,r=structuredClone(this._params);r.intensity=i.density,r.timeFactor=i.intensity,r.color=structuredClone(i.color),r.screenThinning.intensity=i.centerThinning,r.dropletSizeX=i.dropletSize[0],r.dropletSizeYScale=i.dropletSize[1]/i.dropletSize[0],r.distortionStrength=100*i.distortionStrength;let a=structuredClone(this._vignetteParams);return a.strength=1,a.color=structuredClone(i.vignetteColor),{params:r,vignetteParams:a,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(i.direction)}}draw(t){let i=this.getDrawParams(t);if(!i)return;
109let{params:r,revealParams:a,direction:n,vignetteParams:o}=i,s=t.transform.zoom;if(a.revealStart>s)return;let l=vL(0,1,a.revealStart,a.revealStart+a.revealRange,s);if(!this.particlesVx||!this.particlesIdx)return;o.strength*=l;let h=this.updateOnRender(t,r.timeFactor),u=t.context,c=u.gl,d=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new uW(u,{width:t.width,height:t.height,data:null},c.RGBA8)),r.distortionStrength>0&&(u.activeTexture.set(c.TEXTURE0),this.screenTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),c.copyTexSubImage2D(c.TEXTURE_2D,0,0,0,0,0,t.width,t.height));let p=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(u,p),u.activeTexture.set(c.TEXTURE0),this.screenTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE);let f=[r.color.r,r.color.g,r.color.b,r.color.a],_=(i,a)=>{var o;let s=vP(this._movement.getPosition(),i),l=r.dropletSizeX,u=r.dropletSizeX*r.dropletSizeYScale,_=t.width/2,m=t.height/2,g=vL(0,r.screenThinning.start,0,1,r.screenThinning.intensity),y=vL(.001,r.screenThinning.range,0,1,r.screenThinning.intensity),x=vL(0,r.screenThinning.particleOffset,0,1,r.screenThinning.intensity),v=(o={modelview:h.modelviewMatrix,projection:h.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:r.velocityConeAperture,velocity:r.velocity,boxSize:i,rainDropletSize:[l,u],distortionStrength:r.distortionStrength,rainDirection:n,color:f,screenSize:[d.width,d.height],thinningCenterPos:[_,m],thinningShape:[g,y,Math.pow(10,r.screenThinning.fadePower)],thinningAffectedRatio:r.screenThinning.affectedRatio,thinningParticleOffset:x,shapeDirectionalPower:r.shapeDirPower,shapeNormalPower:r.shapeNormalPower,mode:+!a},{u_modelview:Float32Array.from(o.modelview),u_projection:Float32Array.from(o.projection),u_time:o.time,u_cam_pos:o.camPos,u_texScreen:0,u_velocityConeAperture:o.velocityConeAperture,u_velocity:o.velocity,u_boxSize:o.boxSize,u_rainDropletSize:o.rainDropletSize,u_distortionStrength:o.distortionStrength,u_rainDirection:o.rainDirection,u_color:o.color,u_screenSize:o.screenSize,u_thinningCenterPos:o.thinningCenterPos,u_thinningShape:o.thinningShape,u_thinningAffectedRatio:o.thinningAffectedRatio,u_thinningParticleOffset:o.thinningParticleOffset,u_shapeDirectionalPower:o.shapeDirectionalPower,u_shapeNormalPower:o.shapeNormalPower,u_mode:o.mode}),b=Math.round(r.intensity*this.particlesCount),w=l9.simpleSegment(0,0,4*b,2*b);p.draw(t,c.TRIANGLES,gz.disabled,g3.disabled,g6.alphaBlended,gP.disabled,v,"rain_particles",this.particlesVx,this.particlesIdx,w)};r.distortionStrength>0&&_(r.boxSize,!0),_(r.boxSize,!1),this._vignette.draw(t,o)}},bc=class extends vO{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(t){let i=t.context;if(!this.particlesVx){let t=vz(this.particlesCount),r=new lF,a=new lR,n=0,o=n5(0x134104da55e);for(let i=0;i<t.length;++i){let s=t[i],l=o(),h=o(),u=o(),c=[i/t.length,l,h,u],d=[o(),o()];r.emplaceBack(s[0],s[1],s[2],-1,-1,...c,...d),r.emplaceBack(s[0],s[1],s[2],1,-1,...c,...d),r.emplaceBack(s[0],s[1],s[2],1,1,...c,...d),r.emplaceBack(s[0],s[1],s[2],-1,1,...c,...d),a.emplaceBack(n+0,n+1,n+2),a.emplaceBack(n+0,n+2,n+3),n+=4}this.particlesVx=i.createVertexBuffer(r,vF.members),this.particlesIdx=i.createIndexBuffer(a)}}getDrawParams(t){if(!t.style.snow)return null;let i=t.style.snow.state,r=structuredClone(this._params);r.intensity=i.density,r.timeFactor=i.intensity,r.color=structuredClone(i.color),r.screenThinning.intensity=i.centerThinning,r.billboardSize=2.79*i.flakeSize;
109let a=structuredClone(this._vignetteParams);return a.strength=1,a.color=structuredClone(i.vignetteColor),{params:r,vignetteParams:a,revealParams:{revealStart:0,revealRange:.01},direction:structuredClone(i.direction)}}draw(t){let i=this.getDrawParams(t);if(!i)return;let{params:r,revealParams:a,direction:n,vignetteParams:o}=i,s=t.transform.zoom;if(a.revealStart>s)return;let l=vL(0,1,a.revealStart,a.revealStart+a.revealRange,s);o.strength*=l;let h=this.updateOnRender(t,r.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;let u=t.context,c=u.gl,d=t.transform,p=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(u,p),((i,r,a)=>{var o;let s=vP(this._movement.getPosition(),i),l=d.width/2,u=d.height/2,f=vL(0,a.screenThinning.start,0,1,a.screenThinning.intensity),_=vL(.001,a.screenThinning.range,0,1,a.screenThinning.intensity),m=vL(0,a.screenThinning.particleOffset,0,1,a.screenThinning.intensity),g=(o={modelview:h.modelviewMatrix,projection:h.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:a.velocityConeAperture,velocity:a.velocity,horizontalOscillationRadius:a.horizontalOscillationRadius,horizontalOscillationRate:a.horizontalOscillationRate,boxSize:i,billboardSize:+a.billboardSize,simpleShapeParameters:[a.shapeFadeStart,a.shapeFadePower],screenSize:[d.width,d.height],thinningCenterPos:[l,u],thinningShape:[f,_,Math.pow(10,a.screenThinning.fadePower)],thinningAffectedRatio:a.screenThinning.affectedRatio,thinningParticleOffset:m,color:[a.color.r,a.color.g,a.color.b,a.color.a],direction:n},{u_modelview:Float32Array.from(o.modelview),u_projection:Float32Array.from(o.projection),u_time:o.time,u_cam_pos:o.camPos,u_velocityConeAperture:o.velocityConeAperture,u_velocity:o.velocity,u_horizontalOscillationRadius:o.horizontalOscillationRadius,u_horizontalOscillationRate:o.horizontalOscillationRate,u_boxSize:o.boxSize,u_billboardSize:o.billboardSize,u_simpleShapeParameters:o.simpleShapeParameters,u_screenSize:o.screenSize,u_thinningCenterPos:o.thinningCenterPos,u_thinningShape:o.thinningShape,u_thinningAffectedRatio:o.thinningAffectedRatio,u_thinningParticleOffset:o.thinningParticleOffset,u_particleColor:o.color,u_direction:o.direction}),y=Math.round(a.intensity*this.particlesCount),x=l9.simpleSegment(0,0,4*y,2*y);this.particlesVx&&this.particlesIdx&&p.draw(t,c.TRIANGLES,gz.disabled,g3.disabled,g6.alphaBlended,gP.disabled,g,"snow_particles",this.particlesVx,this.particlesIdx,x)})(r.boxSize,0,r),this._vignette.draw(t,o)}},bd={building:t=>({u_matrix:new hf(t),u_normal_matrix:new hf(t),u_opacity:new hl(t),u_faux_facade_ao_intensity:new hl(t),u_camera_pos:new hu(t),u_tile_to_meter:new hl(t),u_facade_emissive_chance:new hl(t),u_flood_light_color:new hu(t),u_flood_light_intensity:new hl(t),u_front_cutoff_params:new hu(t)}),buildingBloom:t=>({u_matrix:new hf(t)}),buildingDepth:t=>({u_matrix:new hf(t)}),elevatedStructuresDepth:t=>({u_matrix:new hf(t),u_depth_bias:new hl(t)}),elevatedStructures:t=>({u_matrix:new hf(t),u_ground_shadow_factor:new hu(t),u_opacity_multiplier:new hl(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new hf(t),u_camera_pos:new hu(t),u_depth_bias:new hl(t),u_height_scale:new hl(t),u_reset_depth:new hl(t)}),rasterParticle:t=>({u_matrix:new hf(t),u_normalize_matrix:new hf(t),u_globe_matrix:new hf(t),u_merc_matrix:new hf(t),u_grid_matrix:new h_(t),u_tl_parent:new hh(t),u_scale_parent:new hl(t),u_fade_t:new hl(t),u_opacity:new hl(t),u_image0:new hs(t),u_image1:new hs(t),u_raster_elevation:new hl(t),u_zoom_transition:new hl(t),u_merc_center:new hh(t),u_cutoff_params:new hd(t)}),rasterParticleTexture:t=>({u_texture:new hs(t),u_opacity:new hl(t)}),rasterParticleDraw:t=>({u_particle_texture:new hs(t),u_particle_texture_side_len:new hl(t),u_tile_offset:new hh(t),u_velocity:new hs(t),u_color_ramp:new hs(t),u_velocity_res:new hh(t),u_max_speed:new hl(t),u_uv_offset:new hh(t),u_data_scale:new hh(t),u_data_offset:new hl(t),u_particle_pos_scale:new hl(t),u_particle_pos_offset:new hh(t)}),rasterParticleUpdate:t=>({u_particle_texture:new hs(t),u_particle_texture_side_len:new hl(t),u_velocity:new hs(t),u_velocity_res:new hh(t),u_max_speed:new hl(t),u_speed_factor:new hl(t),u_reset_rate:new hl(t),u_rand_seed:new hl(t),u_uv_offset:new hh(t),u_data_scale:new hh(t),u_data_offset:new hl(t),u_particle_pos_scale:new hl(t),u_particle_pos_offset:new hh(t)}),snowParticle:t=>({u_modelview:new hf(t),u_projection:new hf(t),u_time:new hl(t),u_cam_pos:new hu(t),u_velocityConeAperture:new hl(t),u_velocity:new hl(t),u_horizontalOscillationRadius:new hl(t),u_horizontalOscillationRate:new hl(t),u_boxSize:new hl(t),u_billboardSize:new hl(t),u_simpleShapeParameters:new hh(t),u_screenSize:new hh(t),u_thinningCenterPos:new hh(t),u_thinningShape:new hu(t),u_thinningAffectedRatio:new hl(t),u_thinningParticleOffset:new hl(t),u_particleColor:new hd(t),u_direction:new hu(t)}),rainParticle:t=>({u_modelview:new hf(t),u_projection:new hf(t),u_time:new hl(t),u_cam_pos:new hu(t),u_texScreen:new hs(t),u_velocityConeAperture:new hl(t),u_velocity:new hl(t),u_boxSize:new hl(t),u_rainDropletSize:new hh(t),u_distortionStrength:new hl(t),u_rainDirection:new hu(t),u_color:new hd(t),u_screenSize:new hh(t),u_thinningCenterPos:new hh(t),u_thinningShape:new hu(t),u_thinningAffectedRatio:new hl(t),u_thinningParticleOffset:new hl(t),u_shapeDirectionalPower:new hl(t),u_shapeNormalPower:new hl(t),u_mode:new hl(t)}),vignette:t=>({u_vignetteShape:new hu(t),u_vignetteColor:new hd(t)})},bp=function(t){let{painter:i,sourceCache:r,layer:a,coords:n,colorMode:o}=t,s=i.context.gl,l=t.painter.shadowRenderer,h=!!l&&l.enabled,u=new gz(i.context.gl.LEQUAL,gz.ReadOnly,i.depthRangeFor3D),c=[0,0,0];if(h){let t=i.style.directionalLight,r=i.style.ambientLight;t&&r&&(c=yn(i.style,t,r))}let d=t=>{for(let d of n){let n,p,f=r.getTile(d),_=f.getBucket(a);if(!_)continue;let m=_.hdExt?_.hdExt.elevatedStructures:void 0;if(!m||(t?(n=m.renderableBridgeSegments,p=m.bridgeProgramConfigurations.get(a.id)):(n=m.renderableTunnelSegments,p=m.tunnelProgramConfigurations.get(a.id)),!n||0===n.segments[0].primitiveLength))continue;p.updatePaintBuffers(),i.prepareDrawTile();let g=i.isTileAffectedByFog(d),y=[];h&&y.push("RENDER_SHADOWS","NORMAL_OFFSET");let x=i.getOrCreateProgram("elevatedStructures",{config:p,overrideFog:g,defines:y}),v=i.translatePosMatrix(d.projMatrix,f,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));h&&l.setupShadows(f.tileID.toUnwrapped(),x,"vector-tile");let b=vk(v,c);i.uploadCommonUniforms(i.context,x,d.toUnwrapped()),x.draw(i,s.TRIANGLES,u,g3.disabled,o,gP.backCCW,b,a.id,m.vertexBuffer,m.indexBuffer,n,a.paint,i.transform.zoom,p,[m.vertexBufferNormal])}};d(!0),d(!1)},bf=function(t){let{painter:i,sourceCache:r,layer:a,coords:n}=t,o=i.context.gl,s=t.painter.shadowRenderer;for(let t of n){let n=r.getTile(t),l=n.getBucket(a);if(!l)continue;let h=l.hdExt?l.hdExt.elevatedStructures:void 0;if(!h||!h.shadowCasterSegments||0===h.shadowCasterSegments.segments[0].primitiveLength)continue;i.prepareDrawTile();let u=l.bufferData.programConfigurations.get(a.id),c=i.isTileAffectedByFog(t),d=i.getOrCreateProgram("elevatedStructuresDepth",{config:u,overrideFog:c}),p=s.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());i.uploadCommonUniforms(i.context,d,t.toUnwrapped());let f=vB(p,0);d.draw(i,o.TRIANGLES,s.getShadowPassDepthMode(),g3.disabled,g6.disabled,gP.disabled,f,a.id,h.vertexBuffer,h.indexBuffer,h.shadowCasterSegments,a.paint,i.transform.zoom,u)}},b_=function(t,i,r,a,n){var o;let s;if(!i||!r.layout||"none"===r.layout.get("fill-elevation-reference")||0===r.paint.get("fill-opacity").constantOr(1))return;let l=t.context.gl,h=new gz(t.context.gl.LEQUAL,gz.ReadWrite,t.depthRangeFor3D),u=new gz(t.context.gl.GREATER,gz.ReadWrite,t.depthRangeFor3D),c=(o=t.transform,s=.01,o.isOrthographic&&(s=rG(1e-4,s,ir(o.pitch>=15?1:o.pitch/15))),2*s),d=t.transform.getFreeCameraOptions().position,p="elevatedStructuresDepthReconstruct",f=t.getOrCreateProgram(p,{defines:["DEPTH_RECONSTRUCTION"]}),_=t.getOrCreateProgram(p);for(let o of a){let a,s,p,m,g=i.getTile(o),y=g.getBucket(r);
109if(!y||!y.hdExt)continue;let x=y.hdExt.elevatedStructures,v=y.hdExt.elevationBufferData;if(!x||!x.depthSegments||!v)continue;let b=v.heightRange,w=vV(o.toUnwrapped(),d),T=t.translatePosMatrix(o.projMatrix,g,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if("initialize"===n){if(!b||b.min>=1||0===x.depthSegments.segments[0].primitiveLength)continue;a=vN(T,w,c,1,0),s=h,p=x.depthSegments,m=f}else if("reset"===n){if(!b||b.min>=0||0===x.maskSegments.segments[0].primitiveLength)continue;a=vN(T,w,0,0,1),s=u,p=x.maskSegments,m=f}else if("geometry"===n){if(0===x.depthSegments.segments[0].primitiveLength)continue;a=vN(T,w,c,1,0),s=h,p=x.depthSegments,m=_}m.draw(t,l.TRIANGLES,s,g3.disabled,g6.disabled,gP.disabled,a,r.id,x.vertexBuffer,x.indexBuffer,p,r.paint,t.transform.zoom)}},bm=function(t,i,r,a){if(!i||!r.layout||"none"===r.layout.get("fill-elevation-reference")||0===r.paint.get("fill-opacity").constantOr(1))return;let n=t.context.gl,o=new gz(n.LEQUAL,gz.ReadOnly,t.depthRangeFor3D),s=new g3({func:n.ALWAYS,mask:255},255,255,n.KEEP,n.KEEP,n.REPLACE),l=t.transform.getFreeCameraOptions().position,h=t.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(let u of a){let a=i.getTile(u),c=a.getBucket(r);if(!c)continue;let d=c.hdExt?c.hdExt.elevatedStructures:void 0;if(!d||!d.depthSegments||0===d.depthSegments.segments[0].primitiveLength)continue;let p=vV(u.toUnwrapped(),l),f=vN(t.translatePosMatrix(u.projMatrix,a,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),p,0,1,0);h.draw(t,n.TRIANGLES,o,s,g6.disabled,gP.disabled,f,r.id,d.vertexBuffer,d.indexBuffer,d.depthSegments,r.paint,t.transform.zoom)}},bg=class extends rB{constructor(t,i=!1){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new xw,this._initialLoadDone=!1,tG(["_updateUI"],this);let r=()=>{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))};i?(this._initialLoadDone=!0,r()):this._style.on("style.load",r)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(t){t===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=t,this._recalculateActiveFloors())}setActiveFloorsVisibility(t){this._updateActiveFloors(t),this._updateIndoorSelector()}setIndoorData(t){let i=!1;for(let[r,a]of Object.entries(t.buildings))if(this._buildings[r])for(let t of a.floorIds)this._buildings[r].floorIds.add(t),this._buildings[r].floors[t]?this._mergeFloors(this._buildings[r].floors[t],a.floors[t]):(this._buildings[r].floors[t]=a.floors[t],i=!0);else this._buildings[r]=a,i=!0;i&&this._recalculateActiveFloors()}getIndoorTileOptions(t,i){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(t,i),indo
109orState:this._indoorState}:null}getControlState(){let t=this._buildings,i=this._closestBuildingId,r=i&&t?t[i]:void 0;if(!r)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let a=null;for(let t of r.floorIds)if(this._activeFloors&&this._activeFloors.has(t)){a=t;break}let n=Array.from(r.floorIds).map(t=>({id:t,name:r.floors[t].name,zIndex:r.floors[t].zIndex})).sort((t,i)=>i.zIndex-t.zIndex).filter((t,i,r)=>0===i||t.zIndex!==r[i-1].zIndex);return{selectedFloorId:a,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:n}}_updateUI(){this._initialLoadDone=!0;let t=this._style.map.transform,i=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,t.center,t.zoom,t.getBounds(),this._makeViewportPolygon());if(i!==this._closestBuildingId){let t=this._closestBuildingId;this._closestBuildingId=i,this._onBuildingTransition(t,i),this._updateIndoorSelector()}}_onBuildingTransition(t,i){this._indoorState&&(!i&&t?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):i&&!t&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0)))}_updateIndoorSelector(){this.fire(new rz("selector-update",this.getControlState()))}_updateActiveFloors(t){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:t,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;let t=_n.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(t,i){if(t===i)return!0;if(!t||!i||t.size!==i.size)return!1;for(let r of t)if(!i.has(r))return!1;return!0})(t,this._activeFloors)||(this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(t,i){i.geometry&&(t.geometry?("Polygon"===t.geometry.type&&(t.geometry={type:"MultiPolygon",coordinates:[t.geometry.coordinates]}),"Polygon"===i.geometry.type?t.geometry.coordinates.push(i.geometry.coordinates):"MultiPolygon"===i.geometry.type&&t.geometry.coordinates.push(...i.geometry.coordinates)):t.geometry=i.geometry)}_makeViewportPolygon(){let t=this._style.map.transform,i=t.width,r=t.height;return[t.pointLocation(new tg(0,0)),t.pointLocation(new tg(i,0)),t.pointLocation(new tg(i,r)),t.pointLocation(new tg(0,r))].map(t=>new tg(t.lng,t.lat))}},by=class{constructor(){this.coverageSourceCaches={},this.manager=new vj}},bx=function(t,i){for(let r in i.manager.clear(),t._mergedHdRoadCoverageSourceCaches){let a=t._mergedHdRoadCoverageSourceCaches[r]._tiles;for(let t in a){let r=a[t];if(!r||!r.loaded())continue;let n=r.frcCoveragePolygons;i.manager.addTileCoverage(r.tileID.canonical,n&&n.length>0?n:[])}}let r=i.manager.updateSnapshotIfNeeded();if(t.map.painter&&(t.map.painter.frcCoverageSnapshot=r.empty()?null:r),!r.empty())for(let i of[t._mergedOtherSourceCaches,t._mergedSymbolSourceCaches])for(let t in i){let r=i[t];for(let t in r._tiles){let i=r._tiles[t];i&&i.hasDeferredRoadStructure&&(i.hasDeferredRoadStructure=!1,r._reloadTile(+t,"reloading"))}}},bv=function(t,i,r){if("fill"!==r.type||r.sourceLayer!==_a||i.coverageSourceCaches[r.source])return;let a=t.getOwnSource(r.source);if(!a||"vector"!==a.type)return;let n=`hd-road-coverage:${r.source}`,o=sy(n,t.scope),s=t._sourceCaches[n]=new vq(o,a,3);i.coverageSourceCaches[r.source]=s,s.setMaxzoomOverride(14),s.onAdd(t.map);let l=t._otherSourceCaches[r.source];l&&l._sourceLoaded&&(s._sourceLoaded=!0)},bb=function(t,i){let r=null,a=null,n={globals:{zoom:0}};t.forEachFragmentStyle(i=>{if(r)return;let o=i.stylesheet?i.stylesheet.schema:null;if(!o||!o.sdCoverageFadeRange)return;let s=sy("sdCoverageFadeRange",i.scope),l=i.options?i.options.get(s):void 0,h=l?l.value||l.default:null;if(h){let t=h.evaluate(n);Array.isArray(t)&&2===t.length&&(t[0]>0||t[1]>0)&&(r=[t[0],t[1]])}let u=sy("sdCoverageSourceLayers",i.scope),c=i.options?i.options.get(u):void 0,d=c?c.value||c.default:null;if(d){let t=d.evaluate(n);Array.isArray(t)&&t.length>0&&(a=t)}else for(let r of t.stylesheet&&t.stylesheet.imports||[])if(r.id===i.scope){let t=r.config?r.config.sdCoverageSourceLayers:void 0;Array.isArray(t)&&t.length>0&&(a=t);break}}),i.frcCoverageFadeRange=r,i.frcCoverageSourceLayers=null!=r?a||["road","structure"]:[]},bw=function(t){if(!function(t){for(let i in t._mergedLayers)if(v0(t._mergedLayers[i])
109)return!0;return!1}(t))return void v9(t);let i=gh(t,t.map&&t.map.transform);t._hdElevation||(t._hdElevation=new v6);let r=t._hdElevation._terrainActiveLast;if(t._hdElevation._terrainActiveLast=i,void 0!==r&&r!==i&&v5(t,void 0,!0),i)return void(t.map.painter&&(t.map.painter.elevationCoverageSnapshot=null));if(!v3(t))return void v9(t);void 0===r&&v5(t,void 0,!0);let a=t._hdElevation;a._needsCrossSourceElevation=!0,t._crossSourceElevationActive=!0,a._ingestFQIDs=v4(t);let n=v2(t);t.forEachFragmentStyle(t=>{for(let i of n){if(!function(t,i){let r=sv(t);return r===i||!r&&!i}(i,t.scope))continue;let r=sx(i);if(t._otherSourceCaches[r]||t._symbolSourceCaches[r])continue;let a=t.getOwnSource(r);a&&"vector"===a.type&&(t._hdElevation||(t._hdElevation=new v6),v7(t,t._hdElevation,a))}}),t.mergeSources(),be(t,a)},bT=function(t){if(!t._hdElevation||!t._hdElevation._needsCrossSourceElevation)return;let i=t._hdElevation._ingestFQIDs;if(i)for(let r of i){let i=vQ(t,r);i&&(i.used=!0)}},bE=function(t){t._crossSourceElevationActive=v3(t);let i=t._mergedHdRoadElevationSourceCaches;i&&0!==Object.keys(i).length&&(t._hdElevation||(t._hdElevation=new v6),t._hdElevation._needsCrossSourceElevation=t._crossSourceElevationActive)},bS=function(t,i,r){if(4===i.renderSourceType||gh(t.style,t.transform)||!r)return null;let a=t.painter?t.painter.elevationCoverageSnapshot:null,n=!(!t.painter||!t.painter.elevationProvidersReady);return a?function(t,i,r){let a=t.getTilesIntersecting(i);if(0===a.length)return{registry:[],hasCoveringTile:!1,allProvidersReady:r};let n=[];for(let t of a)for(let i of t.features)n.push({tileId:t.tileId,feature:i});return n.sort((t,i)=>t.feature.id-i.feature.id),{registry:n,hasCoveringTile:!0,allProvidersReady:r}}(a,i.tileID.canonical,n):{registry:[],hasCoveringTile:!1,allProvidersReady:n}},bI=class{constructor(){this.tileBuffers=new Map,this._context=null}update(t,i){this._context=t;let r=new Set;for(let a of i){if(0===a.frcMask)continue;let i=!1;for(let t of a.polygons)if(t.hasGeometry()){i=!0;break}if(!i)continue;let n=`${a.tileId.z}/${a.tileId.x}/${a.tileId.y}`;if(r.add(n),!this.tileBuffers.has(n)){let i=this._createBuffers(t,a);i&&this.tileBuffers.set(n,i)}}for(let t of this.tileBuffers.keys())if(!r.has(t)){let i=this.tileBuffers.get(t);for(let t of(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.frcLevelSegments))t&&t.destroy();this.tileBuffers.delete(t)}}getBuffers(t){return this.tileBuffers.get(`${t.z}/${t.x}/${t.y}`)||null}destroy(){for(let t of this.tileBuffers.values())for(let i of(t.vertexBuffer.destroy(),t.indexBuffer.destroy(),t.frcLevelSegments))i&&i.destroy();this.tileBuffers.clear()}_createBuffers(t,i){let r=new ll,a=new lR,n=[];for(let t of i.polygons){if(!t.hasGeometry()||0===t.rings.length)continue;let i=r.length,o=a.length,s=r.length,l=[],h=[],u=0;for(let i=0;i<t.rings.length;i++){let a=t.rings[i];if(!(a.length<3))for(let t of(i>0&&h.push(u),a))r.emplaceBack(t.x,t.y),l.push(t.x,t.y),u++}let c=sC(l,h.length>0?h:void 0);for(let t=0;t<c.length;t+=3)a.emplaceBack(s+c[t],s+c[t+1],s+c[t+2]);n.push({vertexOffset:i,indexOffset:o,vertexCount:r.length-i,indexCount:a.length-o,frcMask:t.frcMask})}if(0===r.length)return null;let o=Array(9).fill(null);for(let t=0;t<9;++t){let r=1<<t;if(0==(i.frcMask&r))continue;let a=1/0,s=0,l=0,h=!1;for(let t of n)0!=(t.frcMask&r)&&(a=Math.min(a,t.indexOffset),s=Math.max(s,t.indexOffset+t.indexCount),l=Math.max(l,t.vertexOffset+t.vertexCount),h=!0);h&&(o[t]=l9.simpleSegment(0,a,l,s-a))}return{vertexBuffer:t.createVertexBuffer(r,cs.members),indexBuffer:t.createIndexBuffer(a),frcLevelSegments:o}}},bA=function(t){let{painter:i,bucket:r,coord:a,elevatedGeometry:n}=t,o="road"===r.sourceLayerName,s="structure"===r.sourceLayerName;if(!o&&!s||!i.frcCoverageSnapshot||n)return"fallthrough";let l=i.frcCoverageSnapshot.getTileOrParent(a.canonical);if(!l||0===l.frcMask)return"fallthrough";let h=r.hdExt&&r.hdExt.frcData,u=!!h&&!h.empty(),c=ba(l.polygons);if(s&&!c)return"skip";if(s&&c)return t.polygonCoverageTiles.push({coord:t.coord,bufferData:t.bufferData,program:t.program,programConfiguration:t.programConfiguration,uniformValues:t.uniformValues,depthMode:t.depthMode,dynamicBuffers:t.dynamicBuffers,indexBuffer:t.indexBuffer,segments:t.segments,frcMask:l.frcMask}),"deferred";if(o&&u&&h){let r=l.frcMask,a=i.transform.zoom;for(let[n,o]of h.frcPerLevel)r&1<<n||0!==o.segments.length&&t.program.draw(i,t.drawMode,t.depthMode,t.stencilMode,t.colorMode,gP.disabled,t.uniformValues,t.layer.id,t.bufferData.layoutVertexBuffer,t.indexBuffer,o,t.layer.paint,a,t.programConfiguration,t.dynamicBuffers);return h.frcNonRoadSegments.segments.length>0&&t.program.draw(i,t.drawMode,t.depthMode,t.stencilMode,t.colorMode,gP.disabled,t.uniformValues,t.layer.id,t.bufferData.layoutVertexBuffer,t.indexBuffer,h.frcNonRoadSegments,t.layer.paint,a,t.programConfiguration,t.dynamicBuffers),"drawn"}return"fallthrough"},bC=function(t,i,r,a,n){if(0===r.length)return;let o=bn(t),s=t.transform.zoom,l=(r,o,l)=>{1!==l&&(r.uniformValues.u_opacity_multiplier=l),r.program.draw(t,a,r.depthMode,o,n,gP.disabled,r.uniformValues,i.id,r.bufferData.layoutVertexBuffer,r.indexBuffer,r.segments,i.paint,s,r.programConfiguration,r.dynamicBuffers),1!==l&&(r.uniformValues.u_opacity_multiplier=1)};br(t,r,o,(t,i,r)=>l(t,r,1),(t,i,r)=>l(t,r,o))},bM=function(t,i,r,a,n,o,s,l,h,u){let c=i.hdExt&&i.hdExt.frcData;if(!c||0===c.frcPerLevel.size||!t.frcCoverageSnapshot||a)return null;let d=t.frcCoverageSnapshot.getTileOrParent(r.canonical);if(!d||0===d.frcMask)return null;let p=ba(d.polygons),f=t.frcCoverageFadeRange,_=null!=f&&t.transform.zoom>=f[0];if(p&&_){let t=!1;for(let i of c.frcPerLevel.keys())if(d.frcMask&1<<i){t=!0;break}t&&u.push({coord:r,bucket:i,uniformValues:n,programConfiguration:o,program:s,depthMode:l,colorMode:h,frcMask:d.frcMask})}return{coverageTile:d,frcMask:d.frcMask,active:_,hasPolygonGeometry:p}},bR=function(t,i,r,a){let n=t.hdExt&&t.hdExt.frcData;if(!n)return;let o=i.frcMask;for(let[t,i]of n.frcPerLevel)o&1<<t||a(r,i);let s=n.frcNonRoadSegments;s.segments.length>0&&a(r,s)}
109,bD=function(t,i,r,a,n,o,s){if(a.hasPolygonGeometry)return;let l=i.hdExt&&i.hdExt.frcData;if(!l||!t.frcCoverageFadeRange)return;let[h,u]=t.frcCoverageFadeRange;if(h>=u)return;let c=1-Math.max(0,Math.min(1,(t.transform.zoom-h)/(u-h)));if(c<=0)return;let d=n?o:t.stencilModeForClipping(r),p=a.frcMask;for(let[t,i]of l.frcPerLevel)p&1<<t&&s(d,i,c)},bP=function(t,i,r){if(0===r.length)return;let a=t.context.gl,n=bn(t),o=t.transform.zoom,s=(r,n,s,l)=>{let h=r.bucket.hdExt&&r.bucket.hdExt.frcData,u=h&&h.frcPerLevel.get(n);u&&0!==u.segments.length&&(1!==l&&(r.uniformValues.u_opacity_multiplier=l),r.program.draw(t,a.TRIANGLES,r.depthMode,s,r.colorMode,gP.disabled,r.uniformValues,i.id,r.bucket.layoutVertexBuffer,r.bucket.indexBuffer,u,i.paint,o,r.programConfiguration,[r.bucket.layoutVertexBuffer2,r.bucket.patternVertexBuffer,r.bucket.zOffsetVertexBuffer,r.bucket.elevationIdColVertexBuffer,r.bucket.elevationGroundScaleVertexBuffer]),1!==l&&(r.uniformValues.u_opacity_multiplier=1))};br(t,r,n,(t,i,r)=>s(t,i,r,1),(t,i,r)=>s(t,i,r,n))};async function bz(){return Promise.resolve()}class bL{constructor(t,i,r){this.screenBounds=t,this.cameraPoint=r.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,i){let r,a;if(t instanceof tg||"number"==typeof t[0]){let n=tg.convert(t);r=[n],a=i.isPointAboveHorizon(n)}else{let n=tg.convert(t[0]),o=tg.convert(t[1]),s=n.add(o)._div(2);r=[n,o],a=tP(n,o).every(t=>i.isPointAboveHorizon(t))&&i.isPointAboveHorizon(s)}return new bL(r,a,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return tP(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){let i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new tg(1,1)):this.screenBounds[1],a=tP(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<r.x?a.splice(3,0,this.cameraPoint):this.cameraPoint.x>=r.x?a[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(a[3]=this.cameraPoint)),function(t,i){let r=[];for(let a=0;a<t.length;a++){let n=tF(a-1,-1,t.length-1),o=tF(a+1,-1,t.length-1),s=t[a],l=t[o],h=t[n].sub(s).unit(),u=l.sub(s).unit(),c=u.angleWithSep(h.x,h.y),d=h.add(u).unit().mult(-1*i/Math.sin(c/2));r.push(s.add(d))}return r}(a,t)}bufferedCameraGeometryGlobe(t){let i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new tg(1,1)):this.screenBounds[1],a=tP(i,r,t),n=this.cameraPoint.clone(),o=Number(n.x>i.x)+Number(n.x>r.x);switch(3*(Number(n.y>i.y)+Number(n.y>r.y))+o){case 0:a[0]=n,a[4]=n.clone();break;case 1:a.splice(1,0,n);break;case 2:a[1]=n;break;case 3:a.splice(4,0,n);break;case 5:a.splice(2,0,n);break;case 6:a[3]=n;break;case 7:a.splice(3,0,n);break;case 8:a[2]=n}return a}containsTile(t,i,r,a=0,n){var o;let s=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,l=r?this._bufferedCameraMercator(s,i):this._bufferedScreenMercator(s,i),h=t.tileID.wrap+(l.unwrapped?a:0),u=l.polygon.map(i=>c5(t.tileTransform,i,h));if(!hX(u,0,0,8192,8192))return;h=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?a:0);let c=this.screenGeometryMercator.polygon.map(i=>c6(t.tileTransform,i,h)),d=c.map(t=>new tg(t[0],t[1])),p=c6(t.tileTransform,n,h),f=c.map(t=>{let i=ek(t,t,p);return eW(i,i),new ch(p,i)}),_=_S(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:d,tilespaceRays:f,bufferedTilespaceGeometry:u,bufferedTilespaceBounds:((o=function(t){let i=1/0,r=1/0,a=-1/0,n=-1/0;for(let o of t)i=Math.min(i,o.x),r=Math.min(r,o.y),a=Math.max(a,o.x),n=Math.max(n,o.y);return{min:new tg(i,r),max:new tg(a,n)}}(u)).min.x=tL(o.min.x,0,8192),o.min.y=tL(o.min.y,0,8192),o.max.x=tL(o.max.x,0,8192),o.max.y=tL(o.max.y,0,8192),o),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:_}}_bufferedScreenMercator(t,i){let r=100*t|0;if(this._screenRaycastCache[r])return this._screenRaycastCache[r];{let a;return a="globe"===i.projection.name?this._projectAndResample(this.bufferedScreenGeometry(t),i):{polygon:this.bufferedScreenGeometry(t).map(t=>i.pointCoordinate3D(t)),unwrapped:!0},this._screenRaycastCache[r]=a,a}}_bufferedCameraMercator(t,i){let r=100*t|0;if(this._cameraRaycastCache[r])return this._cameraRaycastCache[r];{let a;return a="globe"===i.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),i):{polygon:this.bufferedCameraGeometry(t).map(t=>i.pointCoordinate3D(t)),unwrapped:!0},this._cameraRaycastCache[r]=a,a}}_projectAndResample(t,i){let r=function(t,i){let r=eg([],i.pixelMatrix,i.globeMatrix),a=[0,-sW,0,1],n=[0,sW,0,1],o=[0,0,0,1];e9(a,a,r),e9(n,n,r),e9(o,o,r);let s=new tg(a[0]/a[3],a[1]/a[3]),l=new tg(n[0]/n[3],n[1]/n[3]),h=hW(t,s)&&a[3]<o[3],u=hW(t,l)&&n[3]<o[3];if(!h&&!u)return null;
109let c=function(t,i,r){for(let a=1;a<t.length;a++){let n=bF(i.pointCoordinate3D(t[a-1]).x),o=bF(i.pointCoordinate3D(t[a]).x);if(r<0){if(n<o)return{idx:a,t:-n/(o-1-n)}}else if(o<n)return{idx:a,t:(1-n)/(o+1-n)}}return null}(t,i,h?-1:1);if(!c)return null;let{idx:d,t:p}=c,f=d>1?bO(t.slice(0,d),i):[],_=d<t.length?bO(t.slice(d),i):[];f=f.map(t=>new tg(bF(t.x),t.y)),_=_.map(t=>new tg(bF(t.x),t.y));let m=[...f];0===m.length&&m.push(_.at(-1));let g=rG(m.at(-1).y,(0===_.length?f[0]:_[0]).y,p);return m.push(...h?[new tg(0,g),new tg(0,0),new tg(1,0),new tg(1,g)]:[new tg(1,g),new tg(1,1),new tg(0,1),new tg(0,g)]),0===_.length?m.push(f[0]):m.push(..._),{polygon:m.map(t=>new s8(t.x,t.y)),unwrapped:!1}}(t,i);if(r)return r;let a=function(t,i){let r=!1,a=-1/0,n=0;for(let i=0;i<t.length-1;i++)t[i].x>a&&(a=t[i].x,n=i);for(let i=0;i<t.length-1;i++){let a=(n+i)%(t.length-1),o=t[a],s=t[a+1];Math.abs(o.x-s.x)>.5&&(o.x<s.x?(o.x+=1,0===a&&(t.at(-1).x+=1)):(s.x+=1,a+1===t.length-1&&(t[0].x+=1)),r=!0)}let o=az(i.center.lng);return r&&o<Math.abs(o-1)&&t.forEach(t=>{t.x-=1}),{polygon:t,unwrapped:r}}(bO(t,i).map(t=>new tg(bF(t.x),t.y)),i);return{polygon:a.polygon.map(t=>new s8(t.x,t.y)),unwrapped:a.unwrapped}}}function bO(t,i){return s9(t,t=>{let r=i.pointCoordinate3D(t);t.x=r.x,t.y=r.y},1/256)}function bF(t){return t<0?1+t%1:t%1}class bB{constructor(t){this.entries={},this.scheduler=t}request(t,i,r,a){let n=this.entries[t]=this.entries[t]||{callbacks:[]};if(n.result){let[t,r]=n.result;return this.scheduler?this.scheduler.add(()=>{a(t,r)},i):a(t,r),()=>{}}return n.callbacks.push(a),n.cancel||(n.cancel=r((r,a)=>{for(let t of(n.result=[r,a],n.callbacks))this.scheduler?this.scheduler.add(()=>{t(r,a)},i):t(r,a);setTimeout(()=>delete this.entries[t],3e3)})),()=>{n.result||(n.callbacks=n.callbacks.filter(t=>t!==a),n.callbacks.length||(n.cancel(),delete this.entries[t]))}}}function bk(t,i,r){let a=JSON.stringify(t.request);return t.data&&(this.deduped.entries[a]={result:[null,t.data]}),this.deduped.request(a,{type:"parseTile",renderSourceType:t.renderSourceType,zoom:t.tileZoom},i=>{let a=new AbortController;return i4(t.request,a.signal).then(({data:t,headers:a})=>{i(null,{rawData:t,vectorTile:r?void 0:new hU(new uz(t)),headers:a})}).catch(t=>{a.signal.aborted||(iK(t)?i(null,null):i(t))}),()=>{a.abort(),i(null,null)}},i)}class bN extends rB{constructor(t,i,r,a){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.provider=i.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,tk(i,["url","scheme","tileSize","promoteId"])),this._options={type:"vector",...i},this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(a),this._tileWorkers={},this._deduped=new bB}load(t){this._loaded=!1,this.fire(new rz("dataloading",{dataType:"source"}));let i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map.getWorldview(),a=(a,n)=>{this._tileJSONRequest=null,this._loaded=!0,a?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new rL(a))):n&&(this._setTileJSON(n),bE&&this.map.style&&bE(this.map.style),rg(n.tiles,this.map._requestManager._customAccessToken),this.fire(new rz("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new rz("data",{dataType:"source",sourceDataType:"content"}))),t&&t(a)};this.provider=this._options.provider;let n=vx(this._options);return n instanceof Error?(this._loaded=!0,this.fire(new rL(n)),void(t&&t())):this.provider&&!n?(this._loaded=!0,this.fire(new rL(Error(`TileProvider "${this.provider}" is not registered`))),void(t&&t())):void(this._tileJSONRequest=n?this.loadTileJSONWithProvider(n,a):vf(this._options,this.map._requestManager,i,r,a))}loadTileJSONWithProvider(t,i){this.provider=t.name;let r=new AbortController;return(async()=>{let{request:a,options:n}=await vd(this._options,this.map._requestManager,r.signal);if(r.signal.aborted)return;let o=await this.dispatcher.send("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.t
109ype,options:n,request:a},{signal:r.signal});if(r.signal.aborted)return;let s=o?o.find(t=>null!=t):null,l=vv(this._options,s,this.map._requestManager);l instanceof Error?i(l):i(null,l)})().catch(t=>{r.signal.aborted||i(t)}),{cancel:()=>r.abort()}}_setTileJSON(t){if(Object.assign(this,t),this.hasWorldviews=!!t.worldview_options,t.worldview_default&&(this.worldviewDefault=t.worldview_default),t.vector_layers)for(let i of(this.vectorLayers=t.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set,t.vector_layers))this.vectorLayerIds.push(i.id),t.worldview&&t.worldview[i.source]&&this.localizableLayerIds.add(i.id);this.tileBounds=vm.fromTileJSON(t)}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();let t=sy(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(t){this.cancelTileJSONRequest()}serialize(){return{...this._options}}async loadTile(t,i){let r=t.tileID.canonical.url(this.tiles,this.scheme),a=this.map._requestManager.normalizeTileURL(r),n=!t.actor||"expired"===t.state;if(!n&&"loading"===t.state)return void(t.reloadCallback=i);n&&(t.actor=this._tileWorkers[a]=this._tileWorkers[a]||this.dispatcher.getActor());let o=new AbortController;t.request=o;try{let s=await this.map._requestManager.transformRequest(a,iX.Tile,o.signal);if(o.signal.aborted)return i(null);this.dispatchTile(t,a,r,s,o,n,i)}catch(t){if(o.signal.aborted)return i(null);i(t)}}dispatchTile(t,i,r,a,n,o,s){let l=this.map.style?this.map.style.getLut(this.scope):null,h=l?{image:l.image.clone()}:null,u=!(!this.map.style||!this.map.style._crossSourceElevationActive),c=!(!this.map.style||!u),d={request:a,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:h,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.t
109ype,source:this.id,scope:this.scope,pixelRatio:is.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,showElevationIdDebug:!!this.map.painter&&this.map.painter._debugParams.showElevationIdDebug,promoteId:this.promoteId,renderSourceType:t.renderSourceType,frcCoverage:(()=>{let i=this.map.painter,r=i?i.frcCoverageFadeRange:null;if(null==r)return null;let a=i?i.frcCoverageSnapshot:null,n=this.map.transform.zoom<r[0],o=a?a.getTileOrParent(t.tileID.canonical):null,s=t.tileID.overscaledZ>=Math.ceil(r[1]),l=a&&s?a.getFullCoverageMask(t.tileID.canonical):null;return{frcMask:s&&null!=l?l:null,resolved:n||null!=a,polygons:o&&0!==o.frcMask?o.polygons:null,tileZoom:o&&0!==o.frcMask?o.tileId.z:null,sourceLayers:i?i.frcCoverageSourceLayers:["road","structure"]}})(),terrainEnabled:gh(this.map.style,this.map.transform),crossSourceElevationEnabled:c,elevation:bS?bS(this.map,t,u):null,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&iq(r)&&(d.localizableLayerIds=this.localizableLayerIds),d.request.collectResourceTiming=this._collectResourceTiming,o)if(this.dispatcher.ready||this.provider)t.request=t.actor.sendCancelable("loadTile",d,{},p.bind(this));else{let i=bk.call({deduped:this._deduped},d,(i,r)=>{t.aborted||(i||!r?p.call(this,i):(d.data={rawData:r.rawData.slice(0),headers:r.headers},t.actor&&(t.request=t.actor.sendCancelable("loadTile",d,{},p.bind(this)))))},!0);n.signal.addEventListener("abort",i,{once:!0})}else t.request=t.actor.sendCancelable("reloadTile",d,{},p.bind(this));function p(i,r){return delete t.request,t.aborted?s(null):i?s(i):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(t1(r.headers)),void(function(){if(t.aborted)return s(null);t.loadVectorData(r,this.map.painter),iG(this.dispatcher),s(null,r),t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)}).call(this))}}abortTile(t){t.request&&(t.request.abort(),delete t.request),t.actor&&t.actor.notify("abortTile",{uid:t.uid,type:this.t
109ype,source:this.id,scope:this.scope})}unloadTile(t,i){t.actor&&t.actor.notify("removeTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope}),t.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class bV{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,i){let r=this.toIdx(t,i);return{min:this.minimums[r],max:this.maximums[r]}}isLeaf(t,i){return this.leaves[this.toIdx(t,i)]}toIdx(t,i){return i*this.size+t}}function bU(t,i,r,a){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(1e-15>Math.abs(a[s])){if(r[s]<t[s]||r[s]>i[s])return null}else{let l=1/a[s],h=(t[s]-r[s])*l,u=(i[s]-r[s])*l;if(h>u){let t=h;h=u,u=t}if(h>n&&(n=h),u<o&&(o=u),n>o)return null}return n}function bj(t,i,r,a,n,o,s,l,h,u,c){let d=a-t,p=n-i,f=o-r,_=s-t,m=l-i,g=h-r,y=c[1]*g-c[2]*m,x=c[2]*_-c[0]*g,v=c[0]*m-c[1]*_,b=d*y+p*x+f*v;if(1e-15>Math.abs(b))return null;let w=1/b,T=u[0]-t,E=u[1]-i,S=u[2]-r,I=(T*y+E*x+S*v)*w;if(I<0||I>1)return null;let A=E*f-S*p,C=S*d-T*f,M=T*p-E*d,R=(c[0]*A+c[1]*C+c[2]*M)*w;return R<0||I+R>1?null:(_*A+m*C+g*M)*w}function bG(t,i,r,a,n,o,s,l,h){let u=1<<r,c=o-a,d=s-n;l[0]=(t+0)/u*c+a,l[1]=(i+0)/u*d+n,h[0]=(t+1)/u*c+a,h[1]=(i+1)/u*d+n}class bH{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;let i=function(t){let i=t.dim,r=[],a=Math.ceil(Math.pow(2,Math.ceil(Math.log2(i/8)))),n=(t,i,r,a,n)=>{let o=+!!a;n[0]=t*r,n[1]=i*r,n[2]=(t+1)*r-o,n[3]=(i+1)*r-o},o=new bV(a),s=1/a,{floatView:l,stride:h}=t,u=[];for(let r=0;r<a*a;r++){let c=Math.floor(r/a),d=r%a;n(d,c,s,!1,u);let p=bZ(u[0],u[1],t),f=bZ(u[2],u[1],t),_=Math.min(p,f,bZ(u[2],u[3],t),bZ(u[0],u[3],t)),m=Math.max(0,8*d-1),g=Math.min(i-1,8*(d+1)),y=Math.max(0,8*c-1),x=Math.min(i-1,8*(c+1)),v=-1/0;for(let t=y;t<=x;t++){let i=(t+1)*h;for(let t=m;t<=g;t++){let r=l[i+t+1];r>v&&(v=r)}}o.minimums.push(_),o.maximums.push(v),o.leaves.push(1)}for(r.push(o),a/=2;a>=1;a/=2){let t=r.at(-1);o=new bV(a);for(let i=0;i<a*a;i++){n(i%a,Math.floor(i/a),2,!0,u);let r=t.getElevation(u[0],u[1]),s=t.getElevation(u[2],u[1]),l=t.getElevation(u[2],u[3]),h=t.getElevation(u[0],u[3]),c=t.isLeaf(u[0],u[1]),d=t.isLeaf(u[2],u[1]),p=t.isLeaf(u[2],u[3]),f=t.isLeaf(u[0],u[3]),_=Math.min(r.min,s.min,l.min,h.min),m=Math.max(r.max,s.max,l.max,h.max),g=c&&d&&p&&f;o.maximums.push(m),o.minimums.push(_),o.leaves.push(m-_<=5&&g?1:0)}r.push(o)}return r}(this.dem),r=i.length-1,a=i[r];this._addNode(a.minimums[0],a.maximums[0],a.leaves[0]),this._construct(i,0,0,r,0)}raycastRoot(t,i,r,a,n,o,s=1){return bU([t,i,-100],[r,a,this.maximums[0]*s],n,o)}raycast(t,i,r,a,n,o,s=1){if(!this.nodeCount)return null;let l=this.raycastRoot(t,i,r,a,n,o,s);if(null==l)return null;let h=[],u=[],c=[],d=[],p=[{idx:0,t:l,nodex:0,nodey:0,depth:0}];for(;p.length>0;){let{idx:l,t:f,nodex:_,nodey:m,depth:g}=p.pop();if(this.leaves[l]){bG(_,m,g,t,i,r,a,c,d);let l=1<<g,h=_/l,u=(_+1)/l,p=m/l,y=(m+1)/l,{dim:x,floatView:v,stride:b}=this.dem,w=Math.floor(h*x),T=Math.ceil(u*x),E=Math.floor(p*x),S=T-w,I=Math.ceil(y*x)-E;if(S<=0||I<=0)continue;let A=c[0],C=c[1],M=(d[0]-A)/S,R=(d[1]-C)/I,D=Math.max(0,f),P=n[0]+o[0]*D,z=n[1]+o[1]*D,L=Math.abs(o[0])>1e-10,O=Math.abs(o[1])>1e-10,F=o[0]>=0?1:-1,B=o[1]>=0?1:-1,k=Math.max(0,Math.min(S-1,Math.floor((P-A)/M))),N=Math.max(0,Math.min(I-1,Math.floor((z-C)/R))),V=L?Math.abs(M/o[0]):Number.MAX_VALUE,U=O?Math.abs(R/o[1]):Number.MAX_VALUE,j=L?D+(A+(o[0]>=0?k+1:k)*M-P)/o[0]:Number.MAX_VALUE,G=O?D+(C+(o[1]>=0?N+1:N)*R-z)/o[1]:Number.MAX_VALUE,H=(t,i)=>v[(i+1)*b+t+1]*s,q=H(w+k,E+N),Z=H(w+k+1,E+N),$=H(w+k,E+N+1),W=H(w+k+1,E+N+1),X=null;for(let t=0;t<S+I;t++){let t=Math.min(j,G);if(o[2]>=0||n[2]+o[2]*t<=Math.max(q,Z,$,W)){let t=A+k*M,i=t+M,r=C+N*R,a=r+R,s=bj(i,r,Z,t,r,q,t,a,$,n,o),l=bj(t,a,$,i,a,W,i,r,Z,n,o);null!=s&&s>=0&&(null===X||s<X)&&(X=s),null!=l&&l>=0&&(null===X||l<X)&&(X=l)}let i=j<G;if(i?(k+=F,j+=V):(N+=B,G+=U),k<0||k>=S||N<0||N>=I||null!==X&&t>X)break;i?F>0?(q=Z,$=W,Z=H(w+k+1,E+N),W=H(w+k+1,E+N+1)):(Z=q,W=$,q=H(w+k,E+N),$=H(w+k,E+N+1)):B>0?(q=$,Z=W,$=H(w+k,E+N+1),W=H(w+k+1,E+N+1)):($=q,W=Z,q=H(w+k,E+N),Z=H(w+k+1,E+N))}if(null!==X)return X||0;let Y=eG([],n,o,f),K=(Y[0]-c[0])/(d[0]-c[0]),Q=(Y[1]-c[1])/(d[1]-c[1]),J=bZ(h,p,this.dem)*s,ee=bZ(u,p,this.dem)*s,et=bZ(u,y,this.dem)*s;
109if(bq(J,ee,bZ(h,y,this.dem)*s,et,K,Q)>=Y[2])return f;continue}let y=0;for(let p=0;p<this._siblingOffset.length;p++){bG((_<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],g+1,t,i,r,a,c,d),c[2]=-100,d[2]=this.maximums[this.childOffsets[l]+p]*s;let f=bU(c,d,n,o);if(null!=f){h[p]=f;let t=!1;for(let i=0;i<y&&!t;i++)f>=h[u[i]]&&(u.splice(i,0,p),t=!0);t||(u[y]=p),y++}}for(let t=0;t<y;t++){let i=u[t];p.push({idx:this.childOffsets[l]+i,t:h[i],nodex:(_<<1)+this._siblingOffset[i][0],nodey:(m<<1)+this._siblingOffset[i][1],depth:g+1})}}return null}_addNode(t,i,r){return this.minimums.push(t),this.maximums.push(i),this.leaves.push(r),this.childOffsets.push(0),this.nodeCount++}_construct(t,i,r,a,n){if(1===t[a].isLeaf(i,r))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);let o=a-1,s=t[o],l=0,h=0;for(let t=0;t<this._siblingOffset.length;t++){let a=2*i+this._siblingOffset[t][0],n=2*r+this._siblingOffset[t][1],o=s.getElevation(a,n),u=s.isLeaf(a,n),c=this._addNode(o.min,o.max,u);u&&(l|=1<<t),h||(h=c)}for(let a=0;a<this._siblingOffset.length;a++)l&1<<a||this._construct(t,2*i+this._siblingOffset[a][0],2*r+this._siblingOffset[a][1],o,h+a)}}function bq(t,i,r,a,n,o){return rG(rG(t,r,o),rG(i,a,o),n)}function bZ(t,i,r){let a=r.dim,n=tL(t*a-.5,0,a-1),o=tL(i*a-.5,0,a-1),s=Math.floor(n),l=Math.floor(o),h=Math.min(s+1,a-1),u=Math.min(l+1,a-1);return bq(r.get(s,l),r.get(h,l),r.get(s,u),r.get(h,u),n-s,o-l)}let b$={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function bW(t,i,r){return(256*t*256+256*i+r)/10-1e4}function bX(t,i,r){return 256*t+i+r/256-32768}class bY{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,i,r,a=!1){if(this.uid=t,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&"mapbox"!==r&&"terrarium"!==r)return void tX(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=i.height;let n=this.dim=i.height-2,o=new Uint32Array(i.data.buffer);if(this.pixels=new Uint8Array(i.data.buffer),this.floatView=new Float32Array(i.data.buffer),this.borderReady=a,this._modifiedForSources={},!a){for(let t=0;t<n;t++)o[this._idx(-1,t)]=o[this._idx(0,t)],o[this._idx(n,t)]=o[this._idx(n-1,t)],o[this._idx(t,-1)]=o[this._idx(t,0)],o[this._idx(t,n)]=o[this._idx(t,n-1)];o[this._idx(-1,-1)]=o[this._idx(0,0)],o[this._idx(n,-1)]=o[this._idx(n-1,0)],o[this._idx(-1,n)]=o[this._idx(0,n-1)],o[this._idx(n,n)]=o[this._idx(n-1,n-1)]}let s="terrarium"===r?bX:bW;for(let t=0;t<o.length;++t){let i=4*t;this.floatView[t]=s(this.pixels[i],this.pixels[i+1],this.pixels[i+2])}this._timestamp=is.now()}_buildQuadTree(){this._tree=new bH(this)}get(t,i,r=!1){r&&(t=tL(t,-1,this.dim),i=tL(i,-1,this.dim));let a=this._idx(t,i);return this.floatView[a]}set(t,i,r){let a=this._idx(t,i),n=this.floatView[a];return this.floatView[a]=r,r-n}static getUnpackVector(t){return b$[t]}_idx(t,i){if(t<-1||t>=this.dim+1||i<-1||i>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(t+1)}static pack(t,i){let r=[0,0,0,0],a=bY.getUnpackVector(i),n=Math.floor((t+a[3])/a[2]);return r[2]=n%256,n=Math.floor(n/256),r[1]=n%256,n=Math.floor(n/256),r[0]=n,r}getPixels(){return new ue({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,i,r){if(this.dim!==t.dim)throw Error("dem dimension mismatch");let a=i*this.dim,n=i*this.dim+this.dim,o=r*this.dim,s=r*this.dim+this.dim;switch(i){case -1:a=n-1;break;case 1:n=a+1}switch(r){case -1:o=s-1;break;case 1:s=o+1}let l=-i*this.dim,h=-r*this.dim;for(let i=o;i<s;i++)for(let r=a;r<n;r++){let a=4*this._idx(r,i),n=4*this._idx(r+l,i+h);this.pixels[a+0]=t.pixels[n+0],this.pixels[a+1]=t.pixels[n+1],this.pixels[a+2]=t.pixels[n+2],this.pixels[a+3]=t.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function bK(t,i,r,a,n,o,s,l){let h=[t,i,1,r,a,1,n,o,1],u=[s,l,1],[c,d,p]=eJ(u,u,el([],h));return eh(h,h,[c,0,0,0,d,0,0,0,p])}function bQ(t,i,r,a,n,o,s,l){let h=function(t,i,r,a,n,o,s,l){let h=bK(0,0,1,0,1,1,0,1),u=bK(t,i,r,a,n,o,s,l);return eh(u,u,el([],h))}(t,i,r,a,n,o,s,l);return[h[2]/h[8]/8192,h[5]/h[8]/8192]}function bJ(t){return[t[0],Math.min(Math.max(t[1],-85.051129),85.051129)]}oC(bY,"DEMData"),oC(bH,"DemMinMaxQuadTree",{omit:["dem"]});class b0 extends rB{constructor(t,i,r,a){super(),this.id=t,this.dispatcher=r,this.coordinates=i.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(a),this.options=i,this._dirty=!1}async load(t,i){if(this._loaded=i||!1,this.fire(new rz("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();let r=new AbortController;this._imageRequest=r;
109try{let i=await this.map._requestManager.transformRequest(this.url,iX.Image,r.signal),{data:a}=await i5(i,r.signal);this._imageRequest=null,this._loaded=!0,this.image=a,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}catch(t){if(r.signal.aborted)return;this._imageRequest=null,this._loaded=!0,this.fire(new rL(t))}}loaded(){return this._loaded}updateImage(t){return t.url&&(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.abort(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded)),this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw Error("The provided handle is not a WebGLTexture instance");return this.texture=new uY(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new rz("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.abort(),this._imageRequest=null),!this.texture||this.texture instanceof uY||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let i=t[0][1],r=t[0][1];for(let a of t)a[1]>r&&(r=a[1]),a[1]<i&&(i=a[1]);let a=(r+i)/2;if(a>85.051129?this.onNorthPole=!0:a<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){let i=t.map(s8.fromLngLat);this.tileID=function(t){let i=1/0,r=1/0,a=-1/0,n=-1/0;for(let o of t)i=Math.min(i,o.x),r=Math.min(r,o.y),a=Math.max(a,o.x),n=Math.max(n,o.y);let o=Math.max(0,Math.floor(-Math.log2(Math.max(a-i,n-r)))),s=Math.pow(2,o),l=Math.floor((i+a)/2*s);return l>1&&(l-=1),new cQ(o,l,Math.floor((r+n)/2*s))}(i),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new rz("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof uY||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){var i;for(let t in this.tiles){let i=this.tiles[t];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;let r=c3(new cQ(0,0,0),this.map.transform.projection),a=[r.projection.project(this.coordinates[0][0],this.coordinates[0][1]),r.projection.project(this.coordinates[1][0],this.coordinates[1][1]),r.projection.project(this.coordinates[2][0],this.coordinates[2][1]),r.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){let i=t[1].x-t[0].x,r=t[1].y-t[0].y,a=t[2].x-t[1].x,n=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,l=t[0].x-t[3].x,h=t[0].y-t[3].y,u=i*n-a*r,c=a*s-o*n,d=o*h-l*s,p=l*r-i*h;return u>0&&c>0&&d>0&&p>0||u<0&&c<0&&d<0&&p<0}(a))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);let n=c3(this.tileID,this.map.transform.projection),[o,s,l,h]=this.coordinates.map(t=>{let i=n.projection.project(t[0],t[1]);return c5(n,i)._round()});this.perspectiveTransform=bQ(o.x,o.y,s.x,s.y,l.x,l.y,h.x,h.y);let u=this._boundsArray=new lu;u.emplaceBack(o.x,o.y,0,0),u.emplaceBack(s.x,s.y,8192,0),u.emplaceBack(h.x,h.y,0,8192),u.emplaceBack(l.x,l.y,8192,8192),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(u,xB.members),this.boundsSegments=l9.simpleSegment(0,0,4,2);let c=[],[d,p,f,_]=function(t){let i=t[0][0],r=i,a=t[0][1],n=a;for(let o=1;o<t.length;o++)t[o][0]<i?i=t[o][0]:t[o][0]>r&&(r=t[o][0]),t[o][1]<a?a=t[o][1]:t[o][1]>n&&(n=t[o][1]);return[i,a,r-i,n-a]}([bJ((i=this.coordinates)[0]),bJ(i[1]),bJ(i[2]),bJ(i[3])]);{let i=new lu,[n,o,s,l]=function(t){let i=t[0].x,r=i,a=t[0].y,n=a;for(let o=1;o<t.length;o++)t[o].x<i?i=t[o].x:t[o].x>r&&(r=t[o].x),t[o].y<a?a=t[o].y:t[o].y>n&&(n=t[o].y);return[i,a,r-i,n-a]}(a),h=t=>[(t.x-n)/s,(t.y-o)/l],[u,m,g,y]=a.map(h),x=function(t,i,r,a,n,o,s,l){let h=bK(0,0,1,0,1,1,0,1);return eh(h,h,el([],bK(t,i,r,a,n,o,s,l)))}(u[0],u[1],m[0],m[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=bQ(u[0],u[1],m[0],m[1],g[0],g[1],y[0],y[1]);let v=(t,r)=>{c.push(t.lng);let a=Math.round((t.lng-d)/f*8192),n=Math.round((t.lat-p)/_*8192),o=h(r),s=eJ([],[o[0],o[1],1],x),l=Math.round(s[0]/s[2]*8192),u=Math.round(s[1]/s[2]*8192);i.emplaceBack(a,n,l,u)},b=a[3].x-a[0].x,w=a[3].y-a[0].y,T=a[2].x-a[1].x,E=a[2].y-a[1].y;for(let t=0;t<65;t++){let i=t/64,n=[a[0].x+i*b,a[0].y+i*w],o=[a[1].x+i*T,a[1].y+i*E],s=o[0]-n[0],l=o[1]-n[1];for(let t=0;t<65;t++){let i=t/64,a={x:n[0]+s*i,y:n[1]+l*i};v(r.projection.unproject(a.x,a.y),a)}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(i,xB.members)}{this.maxLongitudeTriangleSize=0;let i=[],r=new lR,a=(t,a,n)=>{r.emplaceBack(t,a,n);let o=c[t],s=c[a],l=c[n],h=Math.min(Math.min(o,s),l),u=Math.max(Math.max(o,s),l)-h;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),i.push(h+u/2)};for(let t=0;t<64;t++)for(let i=0;i<64;i++){let r=65*t+i,n=r+1,o=r+65,s=o+1;a(r,o,n),a(n,o,s)}[i,r]=function(t,i){let r=Array.from({length:t.length},(t,i)=>i);r.sort((i,r)=>t[i]-t[r]);let a=[],n=new lR;for(let o=0;o<r.length;o++){let s=r[o];a.push(t[s]);let l=3*s,h=l+1;n.emplaceBack(i.uint16[l],i.uint16[h],i.uint16[h+1])}return[a,n]}(i,r),this.elevatedGlobeTrianglesCenterLongitudes=i,this.elevatedGlobeIndexBuffer=t.createIndexBuffer(r)}this.elevatedGlobeSegments=l9.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,f/8192,0,_/8192,0,0,p,d,0])}prepare(){let t=0!==Object.keys(this.tiles).length;if(this.tileID&&!t)return;let i=this.map.painter.context,r=i.gl;!this._dirty||this.texture instanceof uY||(this.texture?this.texture.update(this.image):(this.texture=new uW(i,this.image,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this._dirty=!1),t&&this._prepareData(i)}loadTile(t,i){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored",i(null)}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(t){var i;let r=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!r)return null;let a=this.elevatedGlobeTrianglesCenterLongitudes,n=(i=t+180)+360*Math.round((a[0]-i)/360),o=new l9,s=(t,i)=>{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:r.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},l=.51*this.maxLongitudeTriangleSize;if(Math.abs(a[0]-n)<=l){let t=t7(a,0,a.length,n+l);return t===a.length||s(t,t9(a,t+1,a.length,n+360-l)-t),o}n<a[0]&&(n+=360);let h=t9(a,0,a.length,n-l);if(h===a.length)return s(0,a.length),o;s(0,h-0);let u=t7(a,h+1,a.length,n+l);return u!==a.length&&s(u,a.length-u),o}}let b1={vector:bN,raster:vb,"raster-dem":class extends vb{constructor(t,i,r,a){super(t,i,r,a),this.type="raster-dem",this.maxzoom=22,this._options={type:"raster-dem",...i},this.encoding=i.encoding||"mapbox"}loadTileJSONWithProvider(t,i){this.provider=t.name;let r=new AbortController;return(async()=>{let{request:a,options:n}=await vd(this._options,this.map._requestManager,r.signal);if(r.signal.aborted)return;let o=await this.dispatcher.send("loadTileProvider",{name:t.name,url:t.url,source:this.id,scope:this.scope,type:this.t
109ype,options:n,request:a},{signal:r.signal});if(r.signal.aborted)return;let s=o?o.find(t=>null!=t):null,l=vv(this._options,s,this.map._requestManager);l instanceof Error?i(l):i(null,l)})().catch(t=>{r.signal.aborted||i(t)}),{cancel:()=>r.abort()}}async loadTile(t,i){if(t.actor&&"expired"!==t.state)return;let r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);t.actor=this.dispatcher.getActor();let a=new AbortController;t.request=a;try{let n=await this.map._requestManager.transformRequest(r,iX.Tile,a.signal);if(a.signal.aborted)return i(null);t.request=t.actor.sendCancelable("loadTile",{uid:t.uid,tileID:t.tileID,source:this.id,type:this.type,scope:this.scope,request:n,encoding:this.encoding},{},(function(r,a){return delete t.request,t.aborted?i(null):r?(t.state="errored",i(r)):(a&&(this.map._refreshExpiredTiles&&t.setExpiryData(t1(a.headers)),a.borderReady||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID)),t.dem=a.dem,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0),t.state="loaded",void i(null))}).bind(this))}catch(r){if(a.signal.aborted)return i(null);t.state="errored",i(r)}}abortTile(t,i){t.request&&(t.request.abort(),delete t.request),t.actor&&t.actor.notify("abortTile",{uid:t.uid,type:this.t
109ype,source:this.id,scope:this.scope}),i&&i()}_getNeighboringTiles(t){let i=t.canonical,r=Math.pow(2,i.z),a=(i.x-1+r)%r,n=0===i.x?t.wrap-1:t.wrap,o=(i.x+1+r)%r,s=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new c0(t.overscaledZ,n,i.z,a,i.y).key]={backfilled:!1},l[new c0(t.overscaledZ,s,i.z,o,i.y).key]={backfilled:!1},i.y>0&&(l[new c0(t.overscaledZ,n,i.z,a,i.y-1).key]={backfilled:!1},l[new c0(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new c0(t.overscaledZ,s,i.z,o,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new c0(t.overscaledZ,n,i.z,a,i.y+1).key]={backfilled:!1},l[new c0(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new c0(t.overscaledZ,s,i.z,o,i.y+1).key]={backfilled:!1}),l}},"raster-array":vw,geojson:class extends rB{constructor(t,i,r,a){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=r.getActor(),this.setEventedParent(a),this._data=i.data,this._options={...i},this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),void 0!==i.minzoom&&(this.minzoom=i.minzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;let n=8192/this.tileSize;this.workerOptions={source:this.id,scope:this.scope,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*n,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*n,extent:8192,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:8192,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*n,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter,dynamic:i.dynamic,...i.workerOptions}}onAdd(t){this.map=t,this.setData(this._data)}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){if(!this._options.dynamic)return this.fire(new rL(Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if("string"!=typeof t&&("Feature"===t.type&&(t={type:"FeatureCollection",features:[t]}),"FeatureCollection"!==t.type))return this.fire(new rL(Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&"string"!=typeof t&&"string"!=typeof this._data&&"FeatureCollection"===this._data.type){let i=new Map;for(let t of this._data.features)i.set(t.id,t);for(let r of t.features)i.set(r.id,r);this._data.features=[...i.values()]}else this._data=t;return this._updateWorkerData(!0),this}getClusterExpansionZoom(t,i){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id,scope:this.scope}).then(t=>i(null,t)).catch(t=>i(t)),this}getClusterChildren(t,i){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id,scope:this.scope}).then(t=>i(null,t)).catch(t=>i(t)),this}getClusterLeaves(t,i,r,a){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:t,limit:i,offset:r}).then(t=>a(null,t)).catch(t=>a(t)),this}async _updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new rz("dataloading",{dataType:"source"})),this._loaded=!1;let i={append:t,...this.workerOptions};i.scope=this.scope;let r=this._data,a=new AbortController;this._pendingLoad=a;try{if("string"==typeof r){if(i.request=await this.map._requestManager.transformRequest(is.resolveURL(r),iX.Source,a.signal),a.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);i.request.collectResourceTiming=this._collectResourceTiming}else i.data=JSON.stringify(r);let n=await this.actor.send(`${this.type}.loadData`,i,{signal:a.signal});this._loaded=!0,this._pendingLoad=null;let o={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(o.resourceTiming=n.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new rz("data",o)),this._partialReload=!1,this._metadataFired=!0}catch(t){if(a.signal.aborted)return this._pendingLoad=null,void(this._coalesce=!1);this._loaded=!0,this._pendingLoad=null,this.fire(new rL(t))}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)}loaded(){return this._loaded}reload(){let t=sy(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData()}loadTile(t,i){let r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;let a=this.map.style?this.map.style.getLut(this.scope):null,n=a?{image:a.image.clone()}
vendor: 1,097 bytes, line 109
109:null,o=this._partialReload,s={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:n,scope:this.scope,pixelRatio:is.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:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:o,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};t.request=this.actor.sendCancelable(r,s,{},(a,n)=>o&&!n?(t.state="loaded",i(null)):(delete t.request,t.destroy(!1),t.aborted?i(null):a?i(a):(t.loadVectorData(n,this.map.painter,"reloadTile"===r),void i(null))))}abortTile(t){t.request&&(t.request.abort(),delete t.request),t.aborted=!0}unloadTile(t,i){this.actor.notify("removeTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope}),t.destroy()}onRemove(t){this._pendingLoad&&this._pendingLoad.abort()}
109serialize(){return{...this._options,type:this.type,data:this._data}}hasTransition(){return!1}},video:class extends b0{constructor(t,i,r,a){super(t,i,r,a),this.roundZoom=!0,this.type="video",this.options=i}async load(){this._loaded=!1;let t=this.options,i=new AbortController;this._imageRequest=i;try{let r=await Promise.all(t.urls.map(async t=>(await this.map._requestManager.transformRequest(t,iX.Source,i.signal)).url));if(i.signal.aborted)return;this.urls=r;let a=await async function(t){let i=document.createElement("video");for(let r of(i.muted=!0,t)){let t=document.createElement("source");(function(t){let i=document.createElement("a");return i.href=t,i.protocol===location.protocol&&i.host===location.host})(r)||(i.crossOrigin="Anonymous"),t.src=r,i.appendChild(t)}return await new Promise((r,a)=>{i.onloadstart=()=>r(),i.onerror=()=>a(Error(`Could not load video: ${t.join(", ")}`))}),i}(r);if(i.signal.aborted)return;this._imageRequest=null,this.video=a,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(t){if(i.signal.aborted)return;this.fire(new rL(t))}finally{this._loaded=!0}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){let i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new rL(new mS(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;let t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new uW(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.options.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:b0,model:_6,"batched-model":class extends rB{constructor(t,i,r,a){super(),this.type="batched-model",this.id=t,this.tileSize=512,this._options=i,this.tiles=this._options.tiles,this.maxzoom=i.maxzoom||19,this.minzoom=i.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=r,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(a)}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();let t=sy(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(t){this._loaded=!1,this.fire(new rz("dataloading",{dataType:"source"}));let i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map.getWorldview();this._tileJSONRequest=vf(this._options,this.map._requestManager,i,r,(a,n)=>{this._tileJSONRequest=null,this._loaded=!0,a?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new rL(a))):n&&(Object.assign(this,n),n.bounds&&(this.tileBounds=new vm(n.bounds,this.minzoom,this.maxzoom)),rg(n.tiles,this.map._requestManager._customAccessToken),this.fire(new rz("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new rz("data",{dataType:"source",sourceDataType:"content"}))),t&&t(a)})}hasTransition(){return!1}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loaded(){return this._loaded}async loadTile(t,i){let r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),a=!t.actor||"expired"===t.state;if(a)t.actor=this.dispatcher.getActor();else{if("loading"===t.state)return void(t.reloadCallback=i);if(t.buckets){for(let i of Object.values(t.buckets))i.dirty=!0;return void(t.state="loaded")}}let n=new AbortController;t.request=n;let o=(r,a)=>(delete t.request,t.aborted?i(null):r&&!iK(r)?i(r):(this.map._refreshExpiredTiles&&a&&t.setExpiryData(t1(a.headers)),t.loadModelData(a,this.map.painter),t.state="loaded",i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null))));try{let s=await this.map._requestManager.transformRequest(r,iX.Tile,n.signal);if(n.signal.aborted)return i(null);let l={request:s,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.t
109ype,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:t.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:is.devicePixelRatio,promoteId:this.promoteId};t.request=t.actor.sendCancelable(a?"loadTile":"reloadTile",l,{},o)}catch(t){if(n.signal.aborted)return i(null);i(t)}}abortTile(t){t.request&&(t.request.abort(),delete t.request),t.actor&&t.actor.notify("abortTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope})}serialize(){return{...this._options}}},canvas:class extends b0{constructor(t,i,r,a){super(t,i,r,a),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(t=>!Array.isArray(t)||2!==t.length||t.some(t=>"number"!=typeof t))||this.fire(new rL(new mS(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new rL(new mS(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new rL(new mS(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new rL(new mS(`sources.${t}`,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 rL(new mS(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.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 rL(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(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(t){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;let i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof uY||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new uW(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}},custom:class extends rB{constructor(t,i,r,a){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=i,this.setEventedParent(a),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new rL(Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new rL(Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new vm(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,tk(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return tk(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new rz("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new rz("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new rz("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(t){this._implementation.onRemove&&this._implementation.onRemove(t)}hasTile(t){if(this._implementation.hasTile){let{x:i,y:r,z:a}=t.canonical;return this._implementation.hasTile({x:i,y:r,z:a})}return!this.tileBounds||this.tileBounds.contains(t.canonical)}async loadTile(t,i){let{x:r,y:a,z:n}=t.tileID.canonical,o=new AbortController;t.request=o;try{let s=await this._implementation.loadTile({x:r,y:a,z:n},{signal:o.signal});if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(void 0===s)return t.state="errored",i(null);if(null===s)return this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",i(null);if(!(s instanceof ImageData||s instanceof HTMLCanvasElement||s instanceof ImageBitmap||s instanceof HTMLImageElement))return t.state="errored",i(Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`));this.loadTileData(t,s),t.state="loaded",i(null)}catch(r){if(o.signal.aborted)return;t.state="errored",i(r)}}loadTileData(t,i){t.setTexture(i,this.map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof uW?(t.destroy(!1),t.texture&&t.texture instanceof uW&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){let{x:i,y:r,z:a}=t.tileID.canonical;this._implementation.unloadTile({x:i,y:r,z:a})}i&&i()}abortTile(t,i){t.request&&(t.request.abort(),delete t.request),i&&i()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(t=>({x:t.canonical.x,y:t.canonical.y,z:t.canonical.z}))}_clearTiles(){let t=sy(this.id,this.scope);this.map.style.clearSource(t)}
109_update(){this.fire(new rz("data",{dataType:"source",sourceDataType:"content"}))}}},b2=function(t,i,r,a){let n=new b1[i.type](t,i,r,a);if(n.id!==t)throw Error(`Expected Source id to be ${t} instead of ${n.id}`);return tG(["load","abort","unload","serialize","prepare"],n),n};function b3(t,i,r=""){return`${r}:${i.id||""}:${i.layer.id}:${function(t){if("layerId"in t)return`layer:${t.layerId}`;{let{featuresetId:i,importId:r}=t;return`featureset:${i}${r?`:import:${r}`:""}`}}(t.target)}`}function b4(t,i,r,a=""){if(t.uniqueFeatureID){let n=b3(t,i,a);if(r.has(n))return!0;r.add(n)}return!1}function b5(t,i){let r=t.tileID,a=i.tileID;return r.overscaledZ-a.overscaledZ||r.canonical.y-a.canonical.y||r.wrap-a.wrap||r.canonical.x-a.canonical.x}class b6{constructor(t){this.style=t,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){for(let t in this.layers=[],this.style._mergedLayers){let i=this.style._mergedLayers[t];if("fill-extrusion"===i.type||"building"===i.type)this.layers.push({layer:i,visible:!1,visibilityChanged:!1});else if("model"===i.type){let t=this.style.getLayerSource(i);t&&"batched-model"===t.type&&this.layers.push({layer:i,visible:!1,visibilityChanged:!1})}}}onNewFrame(t){for(let i of(this.layersGotHidden=!1,this.layers)){let r=i.layer,a=!1;"fill-extrusion"===r.type?a=!r.isHidden(t)&&r.paint.get("fill-extrusion-opacity")>0:"building"===r.type?a=!r.isHidden(t)&&r.paint.get("building-opacity")>0:"model"===r.type&&(a=!r.isHidden(t)&&r.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!a&&i.visible,i.visible=a}}updateZOffset(t,i){for(let t of(this.currentBuildingBuckets=[],this.layers)){let r=t.layer,a=this.style.getLayerSourceCache(r),n=1;"fill-extrusion"===r.type?n=t.visible?r.paint.get("fill-extrusion-vertical-scale"):0:"building"===r.type&&(n=t.visible?r.paint.get("building-vertical-scale"):0);let o=a?a.getTile(i):null;if(!o&&a)for(let t in a._tiles){let r=a._tiles[t];if(i.canonical.isChildOf(r.tileID.canonical)){o=r;break}}this.currentBuildingBuckets.push({bucket:o?o.getBucket(r):null,tileID:o?o.tileID:i,verticalScale:n})}t.hasAnyZOffset=!1;let r=!1;for(let a=0;a<t.symbolInstances.length;a++){let n=t.symbolInstances.get(a),o=n.zOffset,s=this._getHeightAtTileOffset(i,n.tileAnchorX,n.tileAnchorY);n.zOffset=s!==-1/0?s:o,r||o===n.zOffset||(r=!0),t.hasAnyZOffset||0===n.zOffset||(t.hasAnyZOffset=!0)}r&&(t.zOffsetBuffersNeedUpload=!0,t.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(t,i,r,a){let n=i,o=r;if(t.canonical.z!==a.canonical.z){let s=a.canonical,l=1/(1<<t.canonical.z-s.z);n=(i+8192*t.canonical.x)*l-8192*s.x|0,o=(r+8192*t.canonical.y)*l-8192*s.y|0}return{tileX:n,tileY:o}}_getHeightAtTileOffset(t,i,r){let a,n;for(let o=0;o<this.layers.length;++o){let s=this.layers[o].layer;if("fill-extrusion"!==s.type&&"building"!==s.type)continue;let{bucket:l,tileID:h,verticalScale:u}=this.currentBuildingBuckets[o];if(!l)continue;let{tileX:c,tileY:d}=this._mapCoordToOverlappingTile(t,i,r,h),p=l.getHeightAtTileCoord(c,d);p&&void 0!==p.height&&(p.hidden?a=p.height:n=Math.max(p.height*u,n||0))}if(void 0!==n)return n;for(let n=0;n<this.layers.length;++n){let o=this.layers[n];if("model"!==o.layer.type||!o.visible)continue;let{bucket:s,tileID:l}=this.currentBuildingBuckets[n];if(!s)continue;let{tileX:h,tileY:u}=this._mapCoordToOverlappingTile(t,i,r,l),c=s.getHeightAtTileCoord(h,u);if(c&&!c.hidden)return void 0===c.height&&void 0!==a?Math.min(c.maxHeight,a)*c.verticalScale:c.height?c.height*c.verticalScale:-1/0}return this.layersGotHidden?0:-1/0}}function b8(){return J||(J=new gE),J}var b9=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function b7(t){t=t.slice();let i=Object.create(null);for(let r of t)i[r.id]=r;for(let r=0;r<t.length;r++){let a=t[r];if(a&&"ref"in a){let n=i[a.ref];n&&(t[r]=function(t,i){let r={};for(let i in t)"ref"!==i&&(r[i]=t[i]);return b9.forEach(t=>{t in i&&(r[t]=i[t])}),r}(a,n))}}return t}let we={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setSnow:"setSnow",setRain:"setRain",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport",addIconset:"addIconset",removeIconset:"removeIconset"};function wt(t,i,r){r.push({command:we.addSource,args:[t,i[t]]})}function wi(t,i,r){i.push({command:we.removeSource,args:[t]}),r[t]=!0}function wr(t,i,r,a,n,o){let s;for(s in i=i||{},t=t||{})Object.hasOwn(t,s)&&(ty(t[s],i[s])||r.push({command:o,args:[a,s,i[s],n]}));for(s in i)Object.hasOwn(i,s)&&!Object.hasOwn(t,s)&&(ty(t[s],i[s])||r.push({command:o,args:[a,s,i[s],n]}))}function wa(t){return t.id}function wn(t,i){return t[i.id]=i,t}function wo(t,i,r){let a=i.createTileMatrix(t,t.worldSize,r.toUnwrapped());return eg(new Float32Array(16),t.projMatrix,a)}function ws(t,i,r){return i.name===r.projection.name?t.projMatrix:wo(r,i,t)}class wl{constructor(t,i,r,a){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?i:-i))):a&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}}class wh{constructor(t,i,r,a,n,o=!1){this.text=new wl(t?t.text:null,i,r,n),this.icon=new wl(t?t.icon:null,i,a,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class wu{constructor(t,i,r,a=!1){this.text=t,this.icon=i,this.skipFade=r,this.clipped=a}}class wc{constructor(){this.invProjMatrix=ec(),this.viewportMatrix=ec(),this.circles=[]}}class wd{constructor(t,i,r,a,n){this.bucketInstanceId=t,this.featureIndex=i,this.sourceLayerIndex=r,this.bucketIndex=a,this.tileID=n}}class wp{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let i=++this.maxGroupID;this.collisionGroups[t]={ID:i,predicate:t=>t.collisionGroupID===i}}return this.collisionGroups[t]}}function wf(t,i,r,a,n){let{horizontalAlign:o,verticalAlign:s}=uO(t),l=ci(t,a);return new tg(-(o-.5)*i+l[0]*n,-(s-.5)*r+l[1]*n)}function w_(t,i,r,a,n){let o=new tg(t,i);return r&&o._rotate(a?n:-n),o}function wm(t,i,r,a){let{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:l,crossTileID:h}=r,u=function(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}
109(i),c=a===uL.vertical?l:"left"===u?n:"center"===u?o:"right"===u?s:-1;n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=c>=0&&n!==c?0:h),o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=c>=0&&o!==c?0:h),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=c>=0&&s!==c?0:h),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=c>=0&&l!==c?0:h)}function wg(t,i,r){let a=i===uL.horizontal||i===uL.horizontalOnly?i:0,n=i===uL.vertical?i:0,{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:h}=r,u=t.text.placedSymbolArray;o>=0&&(u.get(o).placedOrientation=a),s>=0&&(u.get(s).placedOrientation=a),l>=0&&(u.get(l).placedOrientation=a),h>=0&&(u.get(h).placedOrientation=n)}class wy{constructor(t,i,r,a,n,o,s,l){this.transform=t.clone(),this.projection=t.projection.name,this.algorithm=a,this.collisionIndex=this.algorithm.createCollisionDetector(this.transform,o,l),this.buildingIndex=s,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new wp(r),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(t,i,r,a,n=1){var o,s,l;let h=r.getBucket(i),u=r.latestFeatureIndex;if(!h||!u||i.fqid!==h.layerIds[0])return;let c=h.layers[0].layout,d=h.layers[0].paint,p=r.collisionBoxArray,f=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),_=r.tileSize/8192,m=r.tileID.toUnwrapped();this.transform.setProjection(h.projection);let g=(o=r.tileID,s=h.getProjection(),l=this.transform,s.name===this.projection?l.calculateProjMatrix(o.toUnwrapped()):wo(l,s,o)),y="map"===c.get("text-pitch-alignment"),x="map"===c.get("text-rotation-alignment");i.compileFilter(i.options);let v=i.dynamicFilter(),b=i.dynamicFilterNeedsFeature(),w=i.dynamicFilterNeedsGeometry(),T=this.transform.calculatePixelsToTileUnitsMatrix(r),E=gj(g,r.tileID.canonical,y,x,this.transform,h.getProjection(),T),S=null,I=h.getProjection().createInversionMatrix(this.transform,r.tileID.canonical);if(y){let t=gG(g,r.tileID.canonical,y,x,this.transform,h.getProjection(),T);S=eg([],this.transform.labelPlaneMatrix,t)}let A=null;v&&r.latestFeatureIndex&&(A={unwrappedTileID:m,dynamicFilter:v,dynamicFilterNeedsFeature:b,needGeometry:w}),this.retainedQueryData[h.bucketInstanceId]=new wd(h.bucketInstanceId,u,h.sourceLayerIndex,h.index,r.tileID);let[C,M]=h.layers[0].layout.get("text-size-scale-range"),R=tL(n,C,M),[D,P]=c.get("icon-size-scale-range"),z=tL(n,D,P),L={bucket:h,layout:c,paint:d,posMatrix:g,invMatrix:I,mercatorCenter:[az(this.transform.center.lng),aL(this.transform.center.lat)],textLabelPlaneMatrix:E,labelToScreenMatrix:S,clippingData:A,scale:f,textPixelRatio:_,holdingForFade:r.holdingForFade(),collisionBoxArray:p,partiallyEvaluatedTextSize:uk(h.textSizeData,this.transform.zoom,R),partiallyEvaluatedIconSize:uk(h.iconSizeData,this.transform.zoom,z),collisionGroup:this.collisionGroups.get(h.sourceID),latestFeatureIndex:r.latestFeatureIndex};if(a)for(let i of h.sortKeyRanges){let{sortKey:r,symbolInstanceStart:a,symbolInstanceEnd:n}=i;t.push({sortKey:r,symbolInstanceStart:a,symbolInstanceEnd:n,parameters:L})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:h.symbolInstances.length,parameters:L})}placeLayerBucketPart(t,i,r,a,n=1){this.algorithm.placeLayerBucketPart(this,t,i,r,a,n)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let i=this.prevPlacement,r=!1;this.prevZoomAdjustment=i?i.zoomAdjustment(this.transform.zoom):0;let a=i?i.symbolFadeChange(t):1,n=i?i.opacities:{},o=i?i.variableOffsets:{},s=i?i.placedOrientations:{};for(let t in this.placements){let i=this.placements[t],o=n[t];o?(this.opacities[t]=new wh(o,a,i.text,i.icon,null,i.clipped),r=r||i.text!==o.text.placed||i.icon!==o.icon.placed):(this.opacities[t]=new wh(null,a,i.text,i.icon,i.skipFade,i.clipped),r=r||i.text||i.icon)}for(let t in n){let i=n[t];if(!this.opacities[t]){let n=new wh(i,a,!1,!1);n.isHidden()||(this.opacities[t]=n,r=r||i.text.placed||i.icon.placed)}}for(let t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(let t in s)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=s[t]);r?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=i?i.lastPlacementChangeTime:t)}updateLayerOpacities(t,i,r,a){a&&(this.lastReplacementSourceUpdateTime=a.updateTime);let n=new Set;for(let o of i){let i=o.getBucket(t);i&&o.latestFeatureIndex&&t.fqid===i.layerIds[0]&&(this.updateBucketOpacities(i,n,o,o.collisionBoxArray,r,a,o.tileID,t.scope),"offset"===i.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(i,o.tileID),"road"===i.elevationType&&i.hdExt&&i.hdExt.updateRoadElevation(i,o.tileID.canonical),i.updateZOffset())}}updateBucketOpacities(t,i,r,a,n,o,s,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();let h=t.layers[0].layout,u=t.layers[0].paint,c=!!t.layers[0].dynamicFilter(),d=new wh(null,0,!1,!1,
109!0),p=h.get("text-allow-overlap"),f=h.get("icon-allow-overlap"),_=h.get("text-variable-anchor"),m="map"===h.get("text-rotation-alignment"),g="map"===h.get("text-pitch-alignment"),y=u.get("symbol-z-offset"),x="sea"===h.get("symbol-elevation-reference"),v=!y.isConstant(),b=new wh(null,0,p&&(f||!t.hasIconData()||h.get("icon-optional")),f&&(p||!t.hasTextData()||h.get("text-optional")),!0);!t.collisionArrays&&a&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(a);let w=(t,i,r)=>{for(let a=0;a<i/4;a++)t.opacityVertexArray.emplaceBack(r)},T=0;o&&t.updateReplacement(s,o),this.collisionIndex.clearClippedSymbolsForBucket(t.bucketInstanceId);for(let a=0;a<t.symbolInstances.length;a++){let h=t.symbolInstances.get(a),{numHorizontalGlyphVertices:u,numVerticalGlyphVertices:p,crossTileID:f,numIconVertices:E,tileAnchorX:S,tileAnchorY:I}=h,A=null,C=this.retainedQueryData[t.bucketInstanceId];v&&h&&C&&(A=r.latestFeatureIndex.loadFeature({featureIndex:h.featureIndex,bucketIndex:C.bucketIndex,sourceLayerIndex:C.sourceLayerIndex,layoutVertexArrayOffset:0}));let M=y.evaluate(A,{}),R=i.has(f),D=this.opacities[f];R?D=d:D||(D=b,this.opacities[f]=D),i.add(f);let P=u>0||p>0,z=E>0,L=this.placedOrientations[f],O=L===uL.vertical,F=L===uL.horizontal||L===uL.horizontalOnly;!P&&!z||D.isHidden()||T++;let B=!1;if((P||z)&&o){for(let i of t.activeReplacements)if(!dg(i,n,2,l)&&!(i.min.x>S||S>i.max.x||i.min.y>I||I>i.max.y)&&(B=dI(dS(S,I,s.canonical,i.footprintTileId.canonical),i.footprint)))break}if(B&&this.collisionIndex.markSymbolAsClipped(t.bucketInstanceId,h.featureIndex),P){let i=B?wb:wv(D.text);w(t.text,u,O?wb:i),w(t.text,p,F?wb:i);let r=D.text.isHidden(),{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=h,l=t.text.placedSymbolArray,c=r||O?1:0;a>=0&&(l.get(a).hidden=c),n>=0&&(l.get(n).hidden=c),o>=0&&(l.get(o).hidden=c),s>=0&&(l.get(s).hidden=r||F?1:0);let d=this.variableOffsets[f];d&&wm(t,d.anchor,h,L);let _=this.placedOrientations[f];_&&(wm(t,"left",h,_),wg(t,_,h))}if(z){let i=B?wb:wv(D.icon),{placedIconSymbolIndex:r,verticalPlacedIconSymbolIndex:a}=h,n=t.icon.placedSymbolArray,o=+!!D.icon.isHidden();r>=0&&(w(t.icon,E,O?wb:i),n.get(r).hidden=o),a>=0&&(w(t.icon,h.numVerticalIconVertices,F?wb:i),n.get(a).hidden=o)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let i=t.collisionArrays[a];if(i){let r=new tg(0,0),a=!0;if(i.textBox||i.verticalTextBox){if(_){let t=this.variableOffsets[f];t?(r=wf(t.anchor,t.width,t.height,t.textOffset,t.textScale),m&&r._rotate(g?this.transform.angle:-this.transform.angle)):a=!1}c&&(a=!D.clipped),i.textBox&&wx(t.textCollisionBox.collisionVertexArray,D.text.placed,!a||O,M,x,r.x,r.y),i.verticalTextBox&&wx(t.textCollisionBox.collisionVertexArray,D.text.placed,!a||F,M,x,r.x,r.y)}let n=a&&!!(!F&&i.verticalIconBox);i.iconBox&&wx(t.iconCollisionBox.collisionVertexArray,D.icon.placed,n,M,x,h.hasIconTextFit?r.x:0,h.hasIconTextFit?r.
109y:0),i.verticalIconBox&&wx(t.iconCollisionBox.collisionVertexArray,D.icon.placed,!n,M,x,h.hasIconTextFit?r.x:0,h.hasIconTextFit?r.y:0)}}}if(t.fullyClipped=0===T,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){let i=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=i.invProjMatrix,t.placementViewportMatrix=i.viewportMatrix,t.collisionCircleArray=i.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,i){let r=this.zoomAtLastRecencyCheck===i?1-this.zoomAdjustment(i):1;return this.zoomAtLastRecencyCheck=i,this.commitTime+this.fadeDuration*r>t}isStale(){return this.stale}setStale(){this.stale=!0}}function wx(t,i,r,a,n,o,s){t.emplaceBack(+!!i,+!!r,o||0,s||0,a,+!!n),t.emplaceBack(+!!i,+!!r,o||0,s||0,a,+!!n),t.emplaceBack(+!!i,+!!r,o||0,s||0,a,+!!n),t.emplaceBack(+!!i,+!!r,o||0,s||0,a,+!!n)}function wv(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 0xffffffff;let i=+!!t.placed,r=Math.floor(127*t.opacity);return 0x2000000*r+0x1000000*i+131072*r+65536*i+512*r+256*i+2*r+i}let wb=0;class ww{constructor(t,i){this.reset(t,i)}reset(t,i){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances.at(-1),this.padding=Math.min(i||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=tL(t,0,1);let i=1,r=this._distances[i],a=t*this.paddedLength+this.padding;for(;r<a&&i<this._distances.length;)r=this._distances[++i];let n=i-1,o=this._distances[n],s=r-o,l=s>0?(a-o)/s:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}class wT{constructor(t,i){this.gridRightBoundary=0,this.gridBottomBoundary=0,this.clippedSymbols=new Map,this.reset(t,i)}reset(t,i){let r=t.width+200,a=t.height+200;r!==this.gridRightBoundary||a!==this.gridBottomBoundary?(this.grid=new oI(r,a,25),this.ignoredGrid=new oI(r,a,25)):(this.grid.clear(),this.ignoredGrid.clear()),this.transform=t,this.fogState=i,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+100,this.screenBottomBoundary=t.height+100,this.gridRightBoundary=r,this.gridBottomBoundary=a,this.clippedSymbols.clear()}clearClippedSymbolsForBucket(t){this.clippedSymbols.delete(t)}markSymbolAsClipped(t,i){let r=this.clippedSymbols.get(t);r||(r=new Set,this.clippedSymbols.set(t,r)),r.add(i)}placeCollisionBox(t,i,r,a,n,o,s,l,h,u,c){let d=r.projectedAnchorX,p=r.projectedAnchorY,f=r.projectedAnchorZ,_=r.tileAnchorX,m=r.tileAnchorY,g=r.elevation,y=r.tileID,x=t.getProjection();if(g&&y){let[t,i,a]=x.upVector(y.canonical,r.tileAnchorX,r.tileAnchorY),n=x.upVectorScale(y.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;d+=t*g*n,p+=i*g*n,f+=a*g*n}let v="globe"===t.projection.name,b="globe"===t.projection.name?cN(this.transform.zoom):0;if(y&&v&&b<1&&!o){let t=1<<y.canonical.z,i=th(_,m);td(i,i,1220703125e-13),tu(i,i,th(y.canonical.x,y.canonical.y)),td(i,i,1/t),tc(i,i,th(a[0],a[1])),i[0]=tF(i[0],-.5,.5),td(i,i,8192);let r=e5(i[0],i[1],8192/(2*Math.PI),1);e9(r,r,n),d=rG(d,r[0],b),p=rG(p,r[1],b),f=rG(f,r[2],b)}let w=this.projectAndGetPerspectiveRatio(u,d,p,f,r.tileID,"globe"===x.name||!!g||this.transform.pitch>0,x),T=h*w.perspectiveRatio,E=(r.x1*i+s.x-r.padding)*T+w.point.x,S=(r.y1*i+s.y-r.padding)*T+w.point.y,I=(r.x2*i+s.x+r.padding)*T+w.point.x,A=(r.y2*i+s.y+r.padding)*T+w.point.y,C=w.perspectiveRatio<=.55||w.occluded;return!this.isInsideGrid(E,S,I,A)||!l&&this.grid.hitTest(E,S,I,A,c)||C?{box:[],offscreen:!1,occluded:w.occluded}:{box:[E,S,I,A],offscreen:this.isOffscreen(E,S,I,A),occluded:!1}}placeCollisionCircles(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m){let g=[],y=this.transform.elevation,x=t.getProjection(),v="road"===t.elevationType,b=!!y||v,w=_q.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,x),T=new tg(r.tileAnchorX,r.tileAnchorY),E=new tg(r.tileAnchorX,r.tileAnchorY),{x:S,y:I,z:A}=x.projectTilePoint(E.x,E.y,m.canonical),C=null;if(b){let i=v&&t.hdExt?t.hdExt.getElevationFeatureForPlacedSymbol(t,t.text,a):null;C={getElevation:w,elevation:y,elevationFeature:i};let[r,n,o]=w(T,y,i);S+=r,I+=n,A+=o}let M="globe"===x.name,R=this.projectAndGetPerspectiveRatio(l,S,I,A,m,M||!!y||this.transform.pitch>0,x),{perspectiveRatio:D}=R,P=(d?s/D:s*D)/24,z=gH(S,I,A,h),L=r.lineOffsetX*P,O=r.lineOffsetY*P,F=Math.cos(t.layers[0].layout.get("text-max-angle")*tA),B=R.signedDistanceFromCamera>0?g$(P,o,L,O,v&&1===r.flipState,z,E,r,n,h,{},b&&!d?C:null,d&&b,x,m,d,F):null,k=!1,N=!1,V=!0;if(B&&!R.occluded){let t=.5*f*D+_,r=new tg(-100,-100),a=new tg(this.screenRightBoundary,this.screenBottomBoundary),n=new ww,{first:o,last:s}=B,l=o.path.length,h=[];for(let t=l-1;t>=1;t--)h.push(o.path[t]);for(let t=1;t<s.path.length;t++)h.push(s.path[t]);let d=2.5*t;u&&(h=h.map(([t,i,r],a)=>(b&&!M&&(r=w(a<l-1?o.tilePath[l-1-a]:s.tilePath[a-l+2],y,C.elevationFeature)[2]),gH(t,i,r,u)))).some(t=>t[3]<=0)&&(h=[]);let m=[];
109if(h.length>0){let t=1/0,i=-1/0,n=1/0,o=-1/0;for(let r of h)t=Math.min(t,r[0]),n=Math.min(n,r[1]),i=Math.max(i,r[0]),o=Math.max(o,r[1]);i>=r.x&&t<=a.x&&o>=r.y&&n<=a.y&&(m=[h.map(t=>new tg(t[0],t[1]))],(t<r.x||i>a.x||n<r.y||o>a.y)&&(m=h3(m,r.x,r.y,a.x,a.y)))}for(let r of m){n.reset(r,.25*t);let a=0;a=n.length<=.5*t?1:Math.ceil(n.paddedLength/d)+1;for(let r=0;r<a;r++){let o=r/Math.max(a-1,1),s=n.lerp(o),l=s.x+100,h=s.y+100;g.push(l,h,t,0);let u=l-t,d=h-t,f=l+t,_=h+t;if(V=V&&this.isOffscreen(u,d,f,_),N=N||this.isInsideGrid(u,d,f,_),!i&&this.grid.hitTestCircle(l,h,t,p)&&(k=!0,!c))return{circles:[],offscreen:!1,collisionDetected:k,occluded:!1}}}}return{circles:(c||!k)&&N?g:[],offscreen:V,collisionDetected:k,occluded:R.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};let i=[],r=1/0,a=1/0,n=-1/0,o=-1/0;for(let s of t){let t=new tg(s.x+100,s.y+100);r=Math.min(r,t.x),a=Math.min(a,t.y),n=Math.max(n,t.x),o=Math.max(o,t.y),i.push(t)}let s=this.grid.query(r,a,n,o).concat(this.ignoredGrid.query(r,a,n,o)),l={},h={};for(let t of s){let r=t.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;let a=this.clippedSymbols.get(r.bucketInstanceId);a&&a.has(r.featureIndex)||hj(i,[new tg(t.x1,t.y1),new tg(t.x2,t.y1),new tg(t.x2,t.y2),new tg(t.x1,t.y2)])&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===h[r.bucketInstanceId]&&(h[r.bucketInstanceId]=[]),h[r.bucketInstanceId].push(r.featureIndex))}return h}insertCollisionBox(t,i,r,a,n){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:a,collisionGroupID:n},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,i,r,a,n){let o=i?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:a,collisionGroupID:n};for(let i=0;i<t.length;i+=4)o.insertCircle(s,t[i],t[i+1],t[i+2])}projectAndGetPerspectiveRatio(t,i,r,a,n,o,s){let l=[i,r,a,1],h=!1;a||this.transform.pitch>0?(e9(l,l,t),this.fogState&&n&&"globe"!==s.name&&(h=function(t,i,r,a,n,o){let s=[i,r,a];return eQ(s,s,o.calculateFogTileMatrix(n)),gu(t,eL(s),o.pitch)}(this.fogState,i,r,a,n.toUnwrapped(),this.transform)>.9)):g0(l,l,t);let u=l[3];return{point:new tg((l[0]/u+1)/2*this.transform.width+100,(-l[1]/u+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/u*.5,1.5),signedDistanceFromCamera:u,occluded:o&&l[2]>u||h}}isOffscreen(t,i,r,a){return r<100||t>=this.screenRightBoundary||a<100||i>this.screenBottomBoundary}isInsideGrid(t,i,r,a){return r>=0&&t<this.gridRightBoundary&&a>=0&&i<this.gridBottomBoundary}getViewportMatrix(){let t=ef([]);return ey(t,t,[-100,-100,0]),t}}let wE={default:new class{createCollisionDetector(t,i,r){return r instanceof wT?(r.reset(t,i),r):new wT(t,i)}shouldPause(t){return t>2}placeLayerBucketPart(t,i,r,a,n,o=1){let{bucket:s,layout:l,paint:h,posMatrix:u,textLabelPlaneMatrix:c,labelToScreenMatrix:d,clippingData:p,textPixelRatio:f,mercatorCenter:_,invMatrix:m,holdingForFade:g,collisionBoxArray:y,partiallyEvaluatedTextSize:x,partiallyEvaluatedIconSize:v,collisionGroup:b,latestFeatureIndex:w}=i.parameters,T=l.get("text-optional"),E=l.get("icon-optional"),S=l.get("text-allow-overlap"),I=l.get("icon-allow-overlap"),A="map"===l.get("text-rotation-alignment"),C="map"===l.get("icon-rotation-alignment"),M="map"===l.get("text-pitch-alignment"),R=h.get("symbol-z-offset"),D="sea"===l.get("symbol-elevation-reference"),P=l.get("symbol-placement"),[z,L]=l.get("text-size-scale-range"),[O,F]=l.get("icon-size-scale-range"),B=tL(o,z,L),k=tL(o,O,F),N=l.get("text-variable-anchor"),V=A&&"point"!==P,U=N&&s.hasTextData(),j=s.hasIconTextFit()&&U&&s.hasIconData();t.transform.setProjection(s.projection);let G=U||V,H=C&&"point"!==P||j,q=S&&(I||!s.hasIconData()||E),Z=I&&(S||!s.hasTextData()||T),$=!R.isConstant();!s.collisionArrays&&y&&s.deserializeCollisionBoxes(y),a&&n&&s.updateCollisionDebugBuffers(t.transform.zoom,y,B,k);let W=(i,n,o)=>{let{crossTileID:h,numVerticalGlyphVertices:y}=i,C=null;if(p&&p.dynamicFilterNeedsFeature||$){let r=t.retainedQueryData[s.bucketInstanceId],a=w.loadFeature({featureIndex:i.featureIndex,bucketIndex:r.bucketIndex,sourceLayerIndex:r.
109sourceLayerIndex,layoutVertexArrayOffset:0}),n=a.properties?a.properties.worldview:null;if(s.localizable&&s.worldview&&"string"==typeof n)if("all"===n)a.properties.$localized=!0;else{if(!n.split(",").includes(s.worldview))return;a.properties.$localized=!0,a.properties.worldview=s.worldview}C=p&&p.needGeometry?lt(a,!0):a}if(p&&!(0,p.dynamicFilter)({zoom:t.transform.zoom,pitch:t.transform.pitch,worldview:s.worldview},C,t.retainedQueryData[s.bucketInstanceId].tileID.canonical,new tg(i.tileAnchorX,i.tileAnchorY),t.transform.calculateDistanceTileData(p.unwrappedTileID)))return t.placements[h]=new wu(!1,!1,!1,!0),void r.add(h);let P=R.evaluate(C,{});if((i.zOffset||0)+(P||0)>0&&t.frontCutoffStart>0){let a=2*t.frontCutoffStart-1,n=[i.tileAnchorX,i.tileAnchorY,0,1],o=e9(e4(),n,u);if(o[1]/o[3]<a)return t.placements[h]=new wu(!1,!1,!1,!0),void r.add(h)}if(r.has(h))return;if(g)return void(t.placements[h]=new wu(!1,!1,!1));let z=!1,L=!1,O=!0,F=!1,B=!1,k=null,V={box:null,offscreen:null,occluded:null},U={box:null},j=null,W=null,X=null,Y=0,K=0,Q=0;o.textFeatureIndex?Y=o.textFeatureIndex:i.useRuntimeCollisionCircles&&(Y=i.featureIndex),o.verticalTextFeatureIndex&&(K=o.verticalTextFeatureIndex);let J=s.hdExt?s.hdExt.elevationFeatures[i.elevationFeatureIndex]:void 0,ee=r=>{r.tileID=t.retainedQueryData[s.bucketInstanceId].tileID;let a=t.transform.elevation;r.elevation=D?P:P+_q.getAtTileOffset(r.tileID,new tg(r.tileAnchorX,r.tileAnchorY),a,J),r.elevation+=i.zOffset},et=o.textBox;if(et){ee(et);let r=r=>{let a=uL.horizontal;if(s.allowVerticalPlacement&&!r&&t.prevPlacement){let r=t.prevPlacement.placedOrientations[h];r&&(t.placedOrientations[h]=r,wg(s,a=r,i))}return a},a=(t,i)=>{if(s.allowVerticalPlacement&&y>0&&o.verticalTextBox){for(let r of s.writingModes)if(r===uL.vertical?U=V=i():V=t(),V&&V.box&&V.box.length)break}else V=t()};if(N){let l=N;if(t.prevPlacement&&t.prevPlacement.variableOffsets[h]){let i=t.prevPlacement.variableOffsets[h];l.indexOf(i.anchor)>0&&(l=l.filter(t=>t!==i.anchor)).unshift(i.anchor)}let c=(r,a,o)=>{let h=s.getSymbolInstanceTextSize(x,i,t.transform.zoom,n),c=(r.x2-r.x1)*h+2*r.padding,d=(r.y2-r.y1)*h+2*r.padding,p=i.hasIconTextFit&&!I?a:null;p&&ee(p);let g={box:[],offscreen:!1,occluded:!1},y=S?2*l.length:l.length;for(let a=0;a<y;++a){let y=this.attemptAnchorPlacement(t,l[a%l.length],r,_,m,G,c,d,h,A,M,f,u,b,a>=l.length,i,n,s,o,p,x,v);if(y&&(g=y.placedGlyphBoxes)&&g.box&&g.box.length){z=!0,k=y.shift;break}}return g};a(()=>c(et,o.iconBox,uL.horizontal),()=>{let t=o.verticalTextBox;return t&&ee(t),s.allowVerticalPlacement&&!(V&&V.box&&V.box.length)&&y>0&&t?c(t,o.verticalIconBox,uL.vertical):{box:null,offscreen:null,occluded:null}}),V&&(z=V.box,O=V.offscreen,F=V.occluded);let d=r(!(!V||!V.box));if(!z&&t.prevPlacement){let r=t.prevPlacement.variableOffsets[h];r&&(t.variableOffsets[h]=r,wm(s,r.anchor,i,d))}}else{let l=(r,a)=>{let o=s.getSymbolInstanceTextSize(x,i,t.transform.zoom,n),l=t.collisionIndex.placeCollisionBox(s,o,r,_,m,G,new tg(0,0),S,f,u,b.predicate);return l&&l.box&&l.box.length&&(wg(s,a,i),t.placedOrientations[h]=a),l};a(()=>l(et,uL.horizontal),()=>{let t=o.verticalTextBox;return s.allowVerticalPlacement&&y>0&&t?(ee(t),l(t,uL.vertical)):{box:null,offscreen:null,occluded:null}}),r(!!(V&&V.box&&V.box.length))}}if(z=(j=V)&&j.box&&j.box.length>0,O=j&&j.offscreen,F=j&&j.occluded,i.useRuntimeCollisionCircles){let r=i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex,n=s.text.placedSymbolArray.get(r),o=uB(s.textSizeData,x,n),h=l.get("text-padding");W=t.collisionIndex.placeCollisionCircles(s,S,n,r,s.lineVertexArray,s.glyphOffsetArray,o,u,c,d,a,M,b.predicate,i.collisionCircleDiameter*o/24,h,t.retainedQueryData[s.bucketInstanceId].tileID),z=S||W.circles.length>0&&!W.collisionDetected,O=O&&W.offscreen,F=W.occluded}if(o.iconFeatureIndex&&(Q=o.iconFeatureIndex),o.iconBox){let r=r=>{ee(r);let a=i.hasIconTextFit&&k?w_(k.x,k.y,A,M,t.transform.angle):new tg(0,0),n=s.getSymbolInstanceIconSize(v,t.transform.zoom,i.placedIconSymbolIndex);return t.collisionIndex.placeCollisionBox(s,n,r,_,m,H,a,I,f,u,b.predicate)};L=U&&U.box&&U.box.length&&o.verticalIconBox?(X=r(o.verticalIconBox)).box.length>0:(X=r(o.iconBox)).box.length>0,O=O&&X.offscreen,B=X.occluded}let ei=T||0===i.numHorizontalGlyphVertices&&0===y,er=E||0===i.numIconVertices;if(ei||er?er?ei||(L=L&&z):z=L&&z:L=z=L&&z,z&&j&&j.box&&t.collisionIndex.insertCollisionBox(j.box,l.get("text-ignore-placement"),s.bucketInstanceId,U&&U.box&&K?K:Y,b.ID),L&&X&&t.collisionIndex.insertCollisionBox(X.box,l.get("icon-ignore-placement"),s.bucketInstanceId,Q,b.ID),W&&(z&&t.collisionIndex.insertCollisionCircles(W.circles,l.get("text-ignore-placement"),s.bucketInstanceId,Y,b.ID),a)){let i=s.bucketInstanceId,r=t.collisionCircleArrays[i];void 0===r&&(r=t.collisionCircleArrays[i]=new wc);for(let t=0;t<W.circles.length;t+=4)r.circles.push(W.circles[t+0]),r.circles.push(W.circles[t+1]),r.circles.push(W.circles[t+2]),r.circles.push(+!!W.collisionDetected)}let ea="globe"!==s.projection.name;q=q&&(ea||!F),Z=Z&&(ea||!B),t.placements[h]=new wu(z||q,L||Z,O||s.justReloaded),r.add(h)},X=t.retainedQueryData[s.bucketInstanceId].tileID;if("offset"===s.elevationType&&t.buildingIndex&&t.buildingIndex.updateZOffset(s,X),"road"===s.elevationType&&s.hdExt&&s.hdExt.updateRoadElevation(s,X.canonical),s.updateZOffset(),s.sortFeaturesByY){let i=s.getSortedSymbolIndexe
109s(t.transform.angle);for(let t=i.length-1;t>=0;--t){let r=i[t];W(s.symbolInstances.get(r),r,s.collisionArrays[r])}s.hasAnyZOffset&&tX(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset){let t=s.getSortedIndexesByZOffset();for(let i=0;i<t.length;++i){let r=t[i];W(s.symbolInstances.get(r),r,s.collisionArrays[r])}}else for(let t=i.symbolInstanceStart;t<i.symbolInstanceEnd;t++)W(s.symbolInstances.get(t),t,s.collisionArrays[t]);if(a&&s.bucketInstanceId in t.collisionCircleArrays){let i=t.collisionCircleArrays[s.bucketInstanceId];em(i.invProjMatrix,u),i.viewportMatrix=t.collisionIndex.getViewportMatrix()}s.justReloaded=!1}attemptAnchorPlacement(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w){let{textOffset0:T,textOffset1:E,crossTileID:S}=m,I=[T,E],A=wf(i,s,l,I,h),C=t.collisionIndex.placeCollisionBox(y,h,r,a,n,o,w_(A.x,A.y,u,c,t.transform.angle),_,d,p,f.predicate);if(v){let i=y.getSymbolInstanceIconSize(w,t.transform.zoom,m.placedIconSymbolIndex);if(0===t.collisionIndex.placeCollisionBox(y,i,v,a,n,o,w_(A.x,A.y,u,c,t.transform.angle),_,d,p,f.predicate).box.length)return}if(C.box.length>0){let r;return t.prevPlacement&&t.prevPlacement.variableOffsets[S]&&t.prevPlacement.placements[S]&&t.prevPlacement.placements[S].text&&(r=t.prevPlacement.variableOffsets[S].anchor),t.variableOffsets[S]={textOffset:I,width:s,height:l,anchor:i,textScale:h,prevAnchor:r},wm(y,i,m,x),y.allowVerticalPlacement&&(wg(y,x,m),t.placedOrientations[S]=x),{shift:A,placedGlyphBoxes:C}}}}};class wS{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(t,i,r,a,n,o){let s=this._bucketParts;for(;this._currentTileIndex<t.length;)if(i.getBucketParts(s,a,t[this._currentTileIndex],this._sortAcrossTiles,o),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort((t,i)=>t.sortKey-i.sortKey));this._currentPartIndex<s.length;){let t=s[this._currentPartIndex];if(i.placeLayerBucketPart(t,this._seenCrossTileIDs,r,0===t.symbolInstanceStart,o),this._currentPartIndex++,n())return!0}return!1}}class wI{constructor(){this._retiredCI=null}startNewPlacement(t,i,r,a,n,o,s,l,h){return this.placement=new wy(t,a,n,wE[h||"default"],o,s,l,this._retiredCI),this._retiredCI=null,this._currentPlacementIndex=i.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=r,this._fadeDuration=a,this._done=!1,this._inProgressLayer=null,this}requestFullPlacement(){this._forceFullPlacement=!0}isFullPlacementRequested(){return this._forceFullPlacement}setStale(){this.placement&&(this.placement.stale=!0)}isStale(){return!!this.placement&&this.placement.stale}isDone(){return this._done}continuePlacement(t,i,r,a,n){let o=is.now(),s=()=>!this.isFullPlacementRequested()&&0!==this._fadeDuration&&this.placement.algorithm.shouldPause(is.now()-o);for(;this._currentPlacementIndex>=0;){let o=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===o.type&&"none"!==o.visibility&&(!o.minzoom||o.minzoom<=l)&&(!o.maxzoom||o.maxzoom>l)){let t=o.layout.get("symbol-z-elevate"),i=void 0!==o.layout.get("symbol-sort-key").constantOr(1),l=o.layout.get("symbol-z-order"),h="viewport-y"===l||"auto"===l&&!("viewport-y"!==l&&i),u=o.layout.get("text-allow-overlap")||o.layout.get("icon-allow-overlap")||o.layout.get("text-ignore-placement")||o.layout.get("icon-ignore-placement"),c=h&&u,d=this._inProgressLayer=this._inProgressLayer||new wS(o),p=sy(o.source,o.scope);if(d.continuePlacement(t||c?a[p]:r[p],this.placement,this._showCollisionBoxes,o,s,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(t){return this._retiredCI=this.placement.prevPlacement?this.placement.prevPlacement.collisionIndex:null,this.placement.commit(t),this.placement}}let wA=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array
109],wC=new Uint32Array(96);class wM{static from(t){if(!t||void 0===t.byteLength||t.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(t,0,2);if(219!==i)throw Error("Data does not appear to be in a KDBush format.");let a=r>>4;if(1!==a)throw Error(`Got v${a} data when expected v1.`);let n=wA[15&r];if(!n)throw Error("Unrecognized array type.");let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new wM(s,o,n,void 0,t)}constructor(t,i=64,r=Float64Array,a=ArrayBuffer,n){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let o=wA.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,l=t*this.IndexArrayType.BYTES_PER_ELEMENT,h=(8-l%8)%8;if(o<0)throw Error(`Unexpected typed array class: ${r}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(n,8+l+h,2*t),this._pos=2*t,this._finished=!0;else{let n=this.data=new a(8+s+l+h);this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(n,8+l+h,2*t),this._pos=0,this._finished=!1,new Uint8Array(n,0,2).set([219,16+o]),new Uint16Array(n,2,1)[0]=i,new Uint32Array(n,4,1)[0]=t}}add(t,i){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=i,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return function t(i,r,a,n,o,s){if(o-n<=a)return;let l=n+o>>1;(function t(i,r,a,n,o,s){for(;o>n;){if(o-n>600){let l=o-n+1,h=a-n+1,u=Math.log(l),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(l-c)/l)*(h-l/2<0?-1:1);t(i,r,a,Math.max(n,Math.floor(a-h*c/l+d)),Math.min(o,Math.floor(a+(l-h)*c/l+d)),s)}let l=r[2*a+s],h=n,u=o;for(wR(i,r,n,a),r[2*o+s]>l&&wR(i,r,n,o);h<u;){for(wR(i,r,h,u),h++,u--;r[2*h+s]<l;)h++;for(;r[2*u+s]>l;)u--}r[2*n+s]===l?wR(i,r,n,u):wR(i,r,++u,o),u<=a&&(n=u+1),a<=u&&(o=u-1)}})(i,r,l,n,o,s),t(i,r,a,n,l-1,1-s),t(i,r,a,l+1,o,1-s)}(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:o,nodeSize:s}=this;wC[0]=0,wC[1]=n.length-1,wC[2]=0;let l=3,h=[];for(;l>0;){let u=wC[--l],c=wC[--l],d=wC[--l];if(c-d<=s){for(let s=d;s<=c;s++){let l=o[2*s],u=o[2*s+1];l>=t&&l<=r&&u>=i&&u<=a&&h.push(n[s])}continue}let p=d+c>>1,f=o[2*p],_=o[2*p+1];f>=t&&f<=r&&_>=i&&_<=a&&h.push(n[p]),(0===u?t<=f:i<=_)&&(wC[l++]=d,wC[l++]=p-1,wC[l++]=1-u),(0===u?r>=f:a>=_)&&(wC[l++]=p+1,wC[l++]=c,wC[l++]=1-u)}return h}within(t,i,r){let a=[];return this.withinInto(t,i,r,a),a}withinInto(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:o,nodeSize:s}=this;wC[0]=0,wC[1]=n.length-1,wC[2]=0;let l=3,h=0,u=r*r;for(;l>0;){let c=wC[--l],d=wC[--l],p=wC[--l];if(d-p<=s){for(let r=p;r<=d;r++)wP(o[2*r],o[2*r+1],t,i)<=u&&(a[h++]=n[r]);continue}let f=p+d>>1,_=o[2*f],m=o[2*f+1];wP(_,m,t,i)<=u&&(a[h++]=n[f]),(0===c?t-r<=_:i-r<=m)&&(wC[l++]=p,wC[l++]=f-1,wC[l++]=1-c),(0===c?t+r>=_:i+r>=m)&&(wC[l++]=f+1,wC[l++]=d,wC[l++]=1-c)}return h}}function wR(t,i,r,a){wD(t,r,a),wD(i,2*r,2*a),wD(i,2*r+1,2*a+1)}function wD(t,i,r){let a=t[i];t[i]=t[r],t[r]=a}function wP(t,i,r,a){let n=t-r,o=i-a;return n*n+o*o}class wz{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this.index=new wM(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];let a=8192*t.canonical.x,n=8192*t.canonical.y;for(let t=0;t<i.length;t++){let{key:r,crossTileID:o,tileAnchorX:s,tileAnchorY:l}=i.get(t),h=Math.floor((a+s)*.03125),u=Math.floor((n+l)*.03125);this.index.add(h,u),this.keys.push(r),this.crossTileIDs.push(o)}this.index.finish()}findMatches(t,i,r){let a=this.tileID.canonical.z<i.canonical.z?1:Math.pow(2,this.tileID.canonical.z-i.canonical.z),n=.03125/Math.pow(2,i.canonical.z-this.tileID.canonical.z),o=8192*i.canonical.x,s=8192*i.canonical.y;for(let i=0;i<t.length;i++){let l=t.get(i);if(l.crossTileID)continue;let{key:h,tileAnchorX:u,tileAnchorY:c}=l,d=Math.floor((o+u)*n),p=Math.floor((s+c)*n);for(let t of this.index.range(d-a,p-a,d+a,p+a).sort((t,i)=>t-i)){let i=this.crossTileIDs[t];if(this.keys[t]===h&&!r.has(i)){r.add(i),l.crossTileID=i;break}}}}}class wL{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class wO{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let i=Math.round((t-this.lng)/360);if(0!==i)for(let t in this.indexes){let r=this.indexes[t],a={};for(let t in r){let n=r[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+i),a[n.tileID.key]=n}this.indexes[t]=a}this.lng=t}
109addBucket(t,i,r){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===i.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<i.symbolInstances.length;t++)i.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||(this.usedCrossTileIDs[t.overscaledZ]=new Set);let a=this.usedCrossTileIDs[t.overscaledZ];for(let r in this.indexes){let n=this.indexes[r];if(Number(r)>t.overscaledZ)for(let r in n){let o=n[r];o.tileID.isChildOf(t)&&o.findMatches(i.symbolInstances,t,a)}else{let o=n[t.scaledTo(Number(r)).key];o&&o.findMatches(i.symbolInstances,t,a)}}for(let t=0;t<i.symbolInstances.length;t++){let n=i.symbolInstances.get(t);n.crossTileID||(n.crossTileID=r.generate(),a.add(n.crossTileID))}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new wz(t,i.symbolInstances,i.bucketInstanceId),!0}removeBucketCrossTileIDs(t,i){for(let r of i.crossTileIDs)this.usedCrossTileIDs[t].delete(r)}removeStaleBuckets(t){let i=!1;for(let r in this.indexes){let a=this.indexes[r];for(let n in a)t[a[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,a[n]),delete a[n],i=!0)}return i}}class wF{constructor(){this.layerIndexes={},this.crossTileIDs=new wL,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,i,r,a){let n=this.layerIndexes[t.fqid];void 0===n&&(n=this.layerIndexes[t.fqid]=new wO);let o=!1,s={};for(let l of("globe"!==a.name&&n.handleWrapJump(r),i)){let i=l.getBucket(t);i&&t.fqid===i.layerIds[0]&&(i.bucketInstanceId||(i.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(l.tileID,i,this.crossTileIDs)&&(o=!0),s[i.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(t){let i={};for(let r in t.forEach(t=>{i[t]=!0}),this.layerIndexes)i[r]||delete this.layerIndexes[r]}}class wB extends rB{constructor(t){super(),this.requestManager=t,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(t,i){try{let r=await this.requestManager.transformRequest(i,iX.Model);if(!this.modelByURL[i])return null;let a=ff(await pV(r.url)),n=new p7(t,i,void 0,void 0,a);return n.computeBoundsAndApplyParent(),n}catch(r){if(404===r.status)return null;this.fire(new rL(Error(`Could not load model ${t} from ${i}`,{cause:r})))}}load(t,i,r={forceReload:!1}){this.models[i]||(this.models[i]=Object.create(null));let a=Object.keys(t),n=[],o=[];for(let s of a){let a=t[s];this.hasURLBeenRequested(a)&&!r.forceReload||(this.modelByURL[a]={modelId:s,scope:i},n.push(this.loadModel(s,a)),o.push(s)),this.models[i][s]||(this.models[i][s]={model:null,numReferences:1})}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+o.length,Promise.allSettled(n).then(t=>{for(let r=0;r<t.length;r++){let{status:a}=t[r];if("rejected"===a)continue;let{value:n}=t[r];this.models[i][o[r]]||(this.models[i][o[r]]={model:null,numReferences:1}),this.models[i][o[r]].model=n}this.numModelsLoading[i]-=o.length,this.fire(new rz("data",{dataType:"style"}))}).catch(t=>{this.fire(new rL(Error(`Could not load models: ${t.message}`)))})}isLoaded(){for(let t in this.numModelsLoading)if(this.numModelsLoading[t]>0)return!1;return!0}hasModel(t,i,r={exactIdMatch:!1}){return!!(r.exactIdMatch?this.getModel(t,i):this.getModelByURL(this.modelUris[i][t]))}getModel(t,i){return this.models[i]||(this.models[i]=Object.create(null)),this.models[i][t]?this.models[i][t].model:void 0}getModelByURL(t){if(!t)return null;let i=this.modelByURL[t];return i?this.models[i.scope][i.modelId].model:null}hasModelBeenAdded(t,i){return this.models[i]&&void 0!==this.models[i][t]}getModelURIs(t){return this.modelUris[t]||Object.create(null)}addModel(t,i,r){this.models[r]||(this.models[r]=Object.create(null)),this.modelUris[r]||(this.modelUris[r]=Object.create(null));let a=this.requestManager.normalizeModelURL(i);if((this.hasModel(t,r,{exactIdMatch:!0})||this.hasModelBeenAdded(t,r))&&this.modelUris[r][t]===a)this.models[r][t].numReferences++;else if(this.hasURLBeenRequested(a)){let{scope:t,modelId:i}=this.modelByURL[a];this.models[t][i].numReferences++}else this.modelUris[r][t]=a,this.load({[t]:this.modelUris[r][t]},r)}addModelURLs(t,i){this.models[i]||(this.models[i]=Object.create(null)),this.modelUris[i]||(this.modelUris[i]=Object.create(null));let r=this.modelUris[i];for(let i of Object.keys(t))r[i]=this.requestManager.normalizeModelURL(t[i])}
109reloadModels(t){this.load(this.modelUris[t],t,{forceReload:!0})}addModelsFromBucket(t,i){this.models[i]||(this.models[i]=Object.create(null)),this.modelUris[i]||(this.modelUris[i]=Object.create(null));let r=Object.create(null);for(let a of t)this.hasModel(a,i,{exactIdMatch:!0})||this.hasURLBeenRequested(a)?this.models[i][a].numReferences++:this.modelUris[i][a]&&!this.hasURLBeenRequested(a)?r[a]=this.modelUris[i][a]:!this.hasURLBeenRequested(a)&&mG(a,!1)&&(this.modelUris[i][a]=this.requestManager.normalizeModelURL(a),r[a]=this.modelUris[i][a]);this.load(r,i)}hasURLBeenRequested(t){return void 0!==this.modelByURL[t]}removeModel(t,i,r=!1,a=!1){if(this.models[i]&&this.models[i][t]&&(this.models[i][t].numReferences--,0===this.models[i][t].numReferences||a)){let a=this.modelUris[i][t];r||delete this.modelUris[i][t],delete this.modelByURL[a];let n=this.models[i][t].model;n&&(delete this.models[i][t],n.destroy())}}destroy(){for(let t of Object.keys(this.models))for(let i of Object.keys(this.models[t])){let r=this.models[t][i].model;delete this.models[t][i],r&&r.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(t){return this.models[t]||(this.models[t]=Object.create(null)),Object.keys(this.models[t])}upload(t,i){for(let r in this.models[i]||(this.models[i]=Object.create(null)),this.models[i])this.models[i][r].model&&this.models[i][r].model.upload(t.context)}}let wk=["RENDER_SHADOWS","NORMAL_OFFSET"],wN=new Set(["symbol","circle"]),wV=class t{constructor(){this._queue=[],this._needsBuild=!0,this._idleHandle=null}needsBuild(){return this._needsBuild}buildQueue(t,i,r){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=null,this._queue=[],this._needsBuild=!1;let a=!!r.fog,n=r.hasTerrain(),o=!(!r.projection||"globe"!==r.projection.name),s=n||o,l=!(!r.directionalLight||!r.directionalLight.shadowsEnabled()),h=r.map&&r.map.painter,u=!h||!h.context.extParallelShaderCompile,c=!!h&&"mrt-fallback"===h.emissiveMode,d=(t,i=[],r={})=>{this._queue.push({programId:t,params:{...r.params,defines:i,overrideFog:!!r.fog,overrideTerrain:!!r.terrain,overrideGlobe:!!r.globe,overrideRtt:!!r.rtt,precompiled:!0}})};for(let p of t){if("none"===p.visibility)continue;let t=p.getProgramIds();if(t)for(let f of t){if(wN.has(f))continue;let t=p.getDefaultProgramParams(f,i.zoom,r._styleColorTheme.lut);if(!t)continue;let _=h?h.getShaderSource(f):null,m=s&&(!_||_.usedDefines.has("RENDER_TO_TEXTURE")),g=c&&m?(t.defines||[]).concat("USE_MRT1"):t.defines;if(u){d(f,t.defines,{params:t}),m&&d(f,g,{params:t,rtt:!0});continue}let y=a&&(!_||_.usedDefines.has("FOG")),x=n&&!p.isDraped()&&(!_||_.usedDefines.has("TERRAIN")),v=o&&(!_||_.usedDefines.has("GLOBE"));for(let i of l&&p.hasElevation()&&(!_||_.usedDefines.has("RENDER_SHADOWS"))?[!1,!0]:[!1]){let r=i?(t.defines||[]).concat(wk):t.defines||[];for(let i of x?[!1,!0]:[!1])for(let a of v?[!1,!0]:[!1])for(let n of y?[!1,!0]:[!1])d(f,r,{params:t,fog:n,terrain:i,globe:a})}m&&d(f,g,{params:t,rtt:!0})}}if(d("clippingMask"),n)for(let t of[!1,!0])d("terrainRaster",t?["TERRAIN_VERTEX_MORPHING"]:[],{terrain:!0,fog:a});if(!u){if(t.some(t=>"hillshade"===t.type)&&d("hillshadePrepare"),l)for(let t of[!1,!0])for(let i of[!1,!0]){let r=[];t&&r.push("RENDER_CUTOFF"),r.push("RENDER_SHADOWS"),i&&r.push("NORMAL_OFFSET"),d("groundShadow",r),a&&d("groundShadow",r,{fog:!0})}if(o){for(let t of[[],["TERRAIN_VERTEX_MORPHING"],["GLOBE_POLES"]])for(let i of[!1,!0]){let r=[...t,"PROJECTION_GLOBE_VIEW"];i&&r.push("CUSTOM_ANTIALIASING"),d("globeRaster",r,{terrain:n,globe:!0,fog:a})}for(let t of[!1,!0]){let i=t?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];d("globeAtmosphere",i,{fog:!0,terrain:n,globe:t}),d("globeAtmosphere",[...i,"ALPHA_PASS"],{fog:!0,terrain:n,globe:t})}d("stars",[],{fog:a,terrain:n,globe:!0})}}}_executeBatch(i,r,a){if(a.map&&a.map.isMoving())return void(this._idleHandle=is.requestIdleCallback(t=>this._executeBatch(t,r,a)));r.context.sweepPendingPrograms();let n=r.context.extParallelShaderCompile?t.DEADLINE_MARGIN_KHR_MS:t.DEADLINE_MARGIN_SYNC_MS,o=0;for(;this._queue.length>0;){let t=this._queue.shift();if(!t||(r.style=a,r._fogVisible=!!t.params.overrideFog,r.getOrCreateProgram(t.programId,t.params),o++,i.timeRemaining()<=n))break}let s=0===this._queue.length||i.timeRemaining()>n;o>0&&s&&r.context.gl.flush(),this._idleHandle=this._queue.length>0||r.context._pendingPrograms.size>0?is.requestIdleCallback(t=>this._executeBatch(t,r,a)):null}processQueue(t,i){0!==this._queue.length&&(null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._idleHandle=is.requestIdleCallback(r=>this._executeBatch(r,t,i)))}reset(){null!=this._idleHandle&&"undefined"!=typeof cancelIdleCallback&&cancelIdleCallback(this._idleHandle),this._queue=[],this._idleHandle=null,this._needsBuild=!0}};wV.DEADLINE_MARGIN_KHR_MS=5,wV.DEADLINE_MARGIN_SYNC_MS=25;let wU=sn.colorTheme,wj=new sa({data:new o7(wU.data)});function wG(t){if(t)return t.map(([t,i])=>[t*is.devicePixelRatio,i*is.devicePixelRatio])}class wH{constructor(t,i,r){this.id=t,this.scope=i,this.sourceCache=r,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(t){this.missingRequests.has(t.name)||this.pendingRequests.has(t.name)||this.pendingRequests.add(t.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){let t=new Map;if(!this.sourceCache.loaded())return t;let i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;let r=this.sourceCache.getSource();if(!(r instanceof vw))return t;let a=i.map(t=>this.sourceCache.getTile(t));for(let[i,n]of r.getImages(a,Array.from(this.pendingRequests)))t.set(rk.from({name:i,iconsetId:this.id}),n),this.pendingRequests.delete(i);for(let t of this.pendingRequests)this.missingRequests.add(t);return this.pendingRequests.clear(),t}}let wq=(t,i)=>ga(t,i&&i.filter(t=>"source.canvas"!==t.identifier)),wZ=(t,i)=>ob(i,t.type&&!t.array&&Array.isArray(i)?{type:t.type,"property-type":"data-constant"}:void 0),w$=tk(we,["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"]),wW=tk(we,["setCenter","setZoom","setBearing","setP
109itch"]),wX=new Set(["background","sky","slot","custom"]),wY={version:8,layers:[],sources:{}},wK={duration:300,delay:0};class wQ extends rB{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition={...wK},this._buildingIndex=new b6(this),this.crossTileSymbolIndex=new wF,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=i.styleChanges||new rN,this._hasDataDrivenEmissive=!1,this.indoorManager=null,this.dispatcher=i.dispatcher?i.dispatcher:new gS(b8(),this);let r={referrer:iQ(),config:{API_URL:iT.API_URL,DRACO_URL:iT.DRACO_URL,MESHOPT_URL:iT.MESHOPT_URL,MESHOPT_SIMD_URL:iT.MESHOPT_SIMD_URL,BUILDING_GEN_URL:iT.BUILDING_GEN_URL}};this.map.painter&&this.map.painter.context&&(r.contextOptions={maxBindingPoints:this.map.painter.context.maxUniformBufferBindings,maxUniformBlockSizeDwords:Math.floor(this.map.painter.context.maxUniformBlockSize/4)}),this.isRootStyle()&&this.dispatcher.broadcast("setGlobalParams",r),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new mE(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new u8(t._requestManager,i.localFontFamily?2:+!!i.localIdeographFontFamily,i.localFontFamily||i.localIdeographFontFamily,i.fontstackCompositing),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new wB(t._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 wV:null,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._layerExpressionDependencies=i.layerExpressionDependencies?i.layerExpressionDependencies:new Map,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig;let a=this;this._rtlTextPluginCallback=wQ.registerForPluginStateChange(t=>{a.dispatcher.send("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL}).then(t=>{if(o$(null),t.every(t=>t))for(let t in a._sourceCaches){let i=a._sourceCaches[t],r=i.getSource().type;"vector"!==r&&"geojson"!==r||i.reload()}}).catch(t=>{o$(t)})}),this.on("data",t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;let i=this.getOwnSource(t.sourceId);if(i&&i.vectorLayerIds)for(let t in this._layers){let r=this._layers[t];r.source===i.id&&this._validateLayer(r)}})}load(t){return t&&("string"==typeof t?this.loadURL(t):this.loadJSON(t)),this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(iq(t))return t;let i=iO(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(t){}return i}return`json://${rP(JSON.stringify(t))}`}_diffStyle(t,i,r){this.globalId=this._getGlobalId(t);let a=(t,i)=>{try{i(null,this.setState(t,r))}catch(t){i(t,!1)}};if("string"==typeof t){let r=this.map._requestManager.normalizeStyleURL(t),n=new AbortController;this._request={cancel:()=>n.abort()},(async()=>{let t=await this.map._requestManager.transformRequest(r,iX.Style,n.signal),{data:o}=await i3(t,n.signal);this._request=null,a(o,i)})().catch(t=>{this._request=null,n.signal.aborted||this.fire(new rL(t))})}else"object"==typeof t&&a(t,i)}loadURL(t,i={}){this.fire(new rz("dataloading",{dataType:"style"}));
109let r="boolean"==typeof i.validate?i.validate:!iq(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);let a=this.importsCache.get(t);if(a)return this._load(a,r);let n=new AbortController;this._request={cancel:()=>n.abort()},(async()=>{let i=await this.map._requestManager.transformRequest(t,iX.Style,n.signal),{data:a}=await i3(i,n.signal);this._request=null,this.importsCache.set(t,a),this._load(a,r)})().catch(t=>{this._request=null,n.signal.aborted||this.fire(new rL(t))})}loadJSON(t,i={}){this.fire(new rz("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=is.frame(()=>{this._request=null,this._load(t,!1!==i.validate)})}loadEmpty(){this.fire(new rz("dataloading",{dataType:"style"})),this._load(wY,!1)}_loadImports(t,i,r){if(this.importDepth>=4)return tX("Style doesn't support nesting deeper than 5"),Promise.resolve();let a=[];for(let n of t){let t=this._createFragmentStyle(n),o=new Promise(i=>{t.once("style.import.load",i),t.once("error",i)}).then(()=>{this.mergeAll(),this.fire(new rz("data",{dataType:"style"}))});if(a.push(o),this.resolvedImports.has(n.url)){t.loadEmpty();continue}let s=n.data||this.importsCache.get(n.url);s?(n.data?(t.fire(new rz("dataloading",{dataType:"style"})),t.globalId=t._getGlobalId(s),queueMicrotask(()=>t._load(s,i))):t.loadJSON(s,{validate:i}),this._isInternalStyle(s)&&(t.globalId=null)):n.url?t.loadURL(n.url,{validate:i}):t.loadEmpty();let l={style:t,id:n.id,config:n.config};if(r){let t=this.fragments.findIndex(({id:t})=>t===r);this.fragments=this.fragments.slice(0,t).concat(l).concat(this.fragments.slice(t))}else this.fragments.push(l)}return Promise.allSettled(a)}getImportGlobalIds(t=this,i=new Set){for(let r of t.fragments)r.style.globalId&&i.add(r.style.globalId),this.getImportGlobalIds(r.style,i);return[...i.values()]}_createFragmentStyle(t){let i,r=this.scope?sy(t.id,this.scope):t.id,a=this._initialConfig&&this._initialConfig[r];(t.config||a)&&(i={...t.config,...a});let n=new wQ(this.map,{scope:r,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:i,configOptions:this.options,colorThemeOverride:t["color-theme"],layerExpressionDependencies:this._layerExpressionDependencies});return n.setEventedParent(this.map,{style:n}),n}_reloadImports(t=!1){this.mergeAll(),this._updateMapProjection(),t||this.updateConfigDependencies(),this._updateLayers(this._dependentLayerIds(t=>t.isIndoorDependent)),this.map._triggerCameraUpdate(this.camera),(!t||this.isRootStyle()||this.map.style._initialBroadcastDone)&&(t&&this.isRootStyle()?(this.forEachFragmentStyle(t=>{this.dispatcher.broadcast("setLayers",{layers:t._serializeLayers(t._order),scope:t.scope,options:t.options})}),this._initialBroadcastDone=!0):this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}))}_isInternalStyle(t){return this.isRootStyle()&&(t.fragment||!!t.schema&&!1!==t.fragment)}_load(t,i){if(this._isInternalStyle(t)){let r={...wY,imports:[{id:"basemap",data:t,url:""}],...t.center?{center:t.center}:{},...t.bearing?{bearing:t.bearing}:{},...t.pitch?{pitch:t.pitch}:{},...t.zoom?{zoom:t.zoom}:{},...t.light?{light:t.light}:{}};return this._importedAsBasemap=!0,void this._load(r,i)}if(this.updateConfig(this._config,t.schema),i&&wq(this,m0(t)))return;for(let i in this._loaded=!0,t.sources)this.addSource(i,t.sources[i],{validate:!1,isInitialLoad:!0});this.stylesheet=tZ(t);let r=()=>{if(t.iconsets)for(let i in t.iconsets)this.addIconset(i,t.iconsets[i]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);let r=b7(this.stylesheet.layers);if(this._order=r.map(t=>t.id),this.stylesheet.light&&tX("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){let t=this.stylesheet.lights[0];this.light=new go(t.properties,t.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new go(this.stylesheet.light)),this._layers=Object.create(null);let a=!1;for(let t of r){let i=_7(t,this.scope,this._styleColorTheme.lut,this.options);this._layerExpressionDependencies.set(i.fqid,new me(i)),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._updateHdCoverageSourceCache(i)&&(a=!0);let r=this.getOwnLayerSourceCache(i),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();r&&i.canCastShadows()&&n&&(r.castsShadows=!0)}if(a&&bz().then(()=>
109{if(!this.map)return;for(let t in this._layers)this._updateHdCoverageSourceCache(this._layers[t]);this.map.style.mergeAll();let t=this.map.transform;for(let i in this.map.style._mergedHdRoadCoverageSourceCaches){let r=this.map.style._mergedHdRoadCoverageSourceCaches[i];r.used=!0,t&&r.update(t)}this.map._update()}),this.glyphManager.url){let t=new Set;for(let i in this._layers){let r=this._layers[i];if("symbol"===r.type&&r.layout){let i=r.layout.get("text-font");i&&i.value&&"constant"===i.value.kind&&t.add(i.value.value.join(","))}}for(let i of t)this.glyphManager.prefetchRange(i,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);let n=this.stylesheet.terrain;n&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(n,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 rz("data",{dataType:"style"}));let o=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(!0),this.fire(new rz(o?"style.load":"style.import.load"))}).catch(t=>{this.fire(new rL(Error("Failed to load imports",t))),this.fire(new rz(o?"style.load":"style.import.load"))}):(this._reloadImports(!0),this.fire(new rz(o?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];let a=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(a){let t=this._evaluateColorThemeData(a);this._loadColorTheme(t).then(()=>{r()}).catch(t=>{tX(`Couldn't load color theme from the stylesheet: ${t}`),r()})}else this._styleColorTheme.lut=null,r()}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances||this.fragments.some(t=>t.style.hasAppearances())}mergeAll(){let t,i,r,a,n,o,s,l,h,u,c={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(d=>{if(d.stylesheet){if(d.disableElevatedTerrain&&(this.disableElevatedTerrain=!0),null!=d.light&&(t=d.light),d.stylesheet.lights)for(let t of d.stylesheet.lights)"ambient"===t.type&&null!=d.ambientLight&&(i=d.ambientLight),"directional"===t.type&&null!=d.directionalLight&&(r=d.directionalLight);a=this._prioritizeTerrain(a,d.terrain,d.stylesheet.terrain),d.stylesheet.fog&&null!=d.fog&&(n=d.fog),d.stylesheet.snow&&null!=d.snow&&(o=d.snow),d.stylesheet.rain&&null!=d.rain&&(s=d.rain),null!=d.stylesheet.camera&&(u=d.stylesheet.camera),null!=d.stylesheet.projection&&(l=d.stylesheet.projection),null!=d.stylesheet.transition&&(h=d.stylesheet.transition),c[d.scope]=d._styleColorTheme}}),this.light=t,this.ambientLight=i,this.directionalLight=r,this.fog=n,this.snow=o,this.rain=s,this._styleColorThemeForScope=c,null===a?delete this.terrain:this.terrain=a,this.camera=u||{"camera-projection":"perspective"},this.projection=l||{name:"mercator"},this.transition={...wK,...h},this.mergeSources(),this.mergeLayers(),this.mergeIndoor(),this._programPrecompiler&&this._programPrecompiler.reset()}forEachFragmentStyle(t){let i=r=>{for(let t of r.fragments)i(t.style);t(r)};i(this)}_prioritizeTerrain(t,i,r){let a=t&&0===t.drapeRenderMode;return null===r?i&&0===i.drapeRenderMode?i:a?t:null:null!=i&&(!t||a||i&&1===i.drapeRenderMode)?i:t}mergeTerrain(){let t;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(i=>{t=this._prioritizeTerrain(t,i.terrain,i.stylesheet.terrain)}),null===t?delete this.terrain:this.terrain=t,this._programPrecompiler&&this._programPrecompiler.reset()}mergeProjection(){let t;this.forEachFragmentStyle(i=>{null!=i.stylesheet.projection&&(t=i.stylesheet.projection)}),this.projection=t||{name:"mercator"},this._programPrecompiler&&this._programPrecompiler.reset()}mergeSources(){let t={},i=Object.create(null),r=Object.create(null),a=Object.create(null),n=Object.create(null),o=Object.create(null);this.forEachFragmentStyle(s=>{for(let i in s._sourceCaches)t[sy(i,s.scope)]=s._sourceCaches[i];for(let t in s._otherSourceCaches)i[sy(t,s.scope)]=s._otherSourceCaches[t];for(let t in s._symbolSourceCaches)r[sy(t,s.scope)]=s._symbolSourceCaches[t];for(let t in s._fillExtrusionSourceCaches)a[sy(t,s.scope)]=s._fillExtrusionSourceCaches[t];
109if(s._hdCoverage){let t=s._hdCoverage.coverageSourceCaches;for(let i in t)n[sy(i,s.scope)]=t[i]}if(s._hdElevation){let t=s._hdElevation.elevationSourceCaches;for(let i in t)o[i]=t[i]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=r,this._mergedFillExtrusionSourceCaches=a,this._mergedHdRoadCoverageSourceCaches=n,this._mergedHdRoadElevationSourceCaches=o,Object.keys(n).length>0&&!this._hdCoverage&&by&&(this._hdCoverage=new by),bE&&bE(this)}mergeIndoor(){this._mergedIndoor={},this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(let i of Object.values(t.stylesheet.indoor)){let r=sy(i.sourceId,t.scope);this._mergedIndoor[r]=new Set(i.sourceLayers||[])}}),this._updateIndoorEnabled()}_updateIndoorEnabled(){let t=this._indoorEnabled;if(this._indoorEnabled=!1,Object.keys(this._mergedIndoor).length>0)for(let t of this._mergedOrder){let i=this._mergedLayers[t];if("none"!==i.visibility&&this._mergedIndoor[sy(i.source,i.scope)]){this._indoorEnabled=!0;break}}!this._indoorEnabled||t||this.indoorManager||bz().then(()=>{this._initIndoorManager()})}_initIndoorManager(){if(!this.indoorManager&&bg&&this.isRootStyle()&&0!==Object.keys(this._mergedIndoor).length&&(this.indoorManager=new bg(this,this._loaded),this._loaded))for(let t of Object.keys(this._mergedIndoor)){let i=this._mergedSourceCaches[t]||this._mergedOtherSourceCaches[t];i&&i.reload()}}mergeLayers(){let t={},i=[],r=Object.create(null);this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(r=>{for(let a of r._order){let n=r._layers[a];if("slot"===n.type){let i=sx(a);if(t[i])continue;t[i]=[]}n.slot&&t[n.slot]?t[n.slot].push(n):i.push(n)}}),this._mergedOrder=[];let a=-1,n=(i=[])=>{for(let o of i)if("slot"===o.type){let i=sx(o.id);t[i]&&n(t[i]),this._mergedSlots.push(i)}else{let t=sy(o.id,o.scope);this._mergedOrder.push(t),r[t]=o,o.is3D(!!this.terrain)&&(this._has3DLayers=!0,a=this._mergedOrder.length-1),"circle"===o.type&&(this._hasCircleLayers=!0),"symbol"===o.type&&(this._hasSymbolLayers=!0),"clip"===o.type&&(this._clipLayerPresent=!0)}};if(n(i),this._has3DLayers){let t={};for(let i=0;i<this._mergedOrder.length;++i){let n=this._mergedOrder[i];t[n]=i===a?1:i<a?2*!!r[n].hasOcclusionOpacityProperties:4}this._mergedOrder.sort((i,r)=>t[i]-t[r])}this._mergedLayers=r,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera={...this.stylesheet.camera,...t},this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?(function(t,i,r){let a={...i};for(let t of Object.keys(wU))void 0===a[t]&&(a[t]=wU[t].default);let n=new o3(wj,t,new Map(r));return n.setTransitionOrValue(a,r),n.untransitioned().possiblyEvaluate(new o0(0,{worldview:void 0}))})(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;let i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((r,a)=>{let n="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void r();let o=t;o.startsWith(n)||(o=n+o);let s=rk.from("mapbox-reserved-lut"),l=new Image;l.src=o,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,a(Error("Failed to load image data"))},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void r();this._styleColorTheme.lutLoading=!1;let{width:n,height:o,data:h}=is.getImageData(l);if(o>32)return void a(Error("The height of the image must be less than or equal to 32 pixels."));if(n!==o*o)return void a(Error("The width of the image must be equal to the height squared."));this.getImage(s)&&this.removeImage(s),this.addImage(s,{data:new h7({width:n,height:o},h),pixelRatio:1,sdf:!1,usvg:!1,version:0});let u=this.imageManager.getImage(s,this.scope);u?(this._styleColorTheme.lut={image:u.data,data:t},r()):a(Error("Missing LUT image."))}})}getLut(t){let i=this._styleColorThemeForScope[t];return i?i.lut:null}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.hasTerrain()||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){let i=new AbortController;this._spriteRequest=i,function(t,i,r,a){let n,o,s,l=is.devicePixelRatio>1?"@2x":"";function h(t){s||t&&r.aborted||(t&&(s=t),function(){if(s)a(s);else if(n&&o){let t=is.getImageData(o),i={};for(let r in n){let{width:a,height:o,x:s,y:l,sdf:h,pixelRatio:u,stretchX:c,stretchY:d,content:p}=n[r],f=new h7({width:a,height:o});h7.copy(t,f,{x:s,y:l},{x:0,y:0},{width:a,height:o},null),i[r]={data:f,pixelRatio:void 0!==u?u:1,sdf:void 0!==h&&h,stretchX:c,stretchY:d,content:p,usvg:!1,version:0}}a(null,i)}}())}(async function(){let a=await i.transformRequest(i.normalizeSpriteURL(t,l,".json"),iX.SpriteJSON,r),{data:o}=await i3(a,r);s||(n=o)})().then(()=>h(void 0),t=>h(t)),(async function(){let a=await i.transformRequest(i.normalizeSpriteURL(t,l,".png"),iX.SpriteImage,r),{data:n}=await i5(a,r);s||(o=n)})().then(()=>h(void 0),t=>h(t))}(t,this.map._requestManager,i.signal,(t,i)=>{if(this._spriteRequest=null,t)this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new rL(t));else if(i){let t=new Map;for(let r in i)t.set(rk.from(r),i[r]);this.addImages(t,!0)}this.imageManager.setLoaded(!0,this.scope),this.fire(new rz("data",{dataType:"style"}))})}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);let r=this.getOwnSourceCache(i.source);if(!r)return void this.fire(new rL(Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));let a=r.getSource();if("raster-array"!==a.type)return void this.fire(new rL(Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));a.partial=!1;let n=new wH(t,this.scope,r);this.imageManager.addImageProvider(n,this.scope)}removeIconset(t){this.imageManager.removeImageProvider(t,this.scope)}_loadIconset(t){if(!iq(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);let i="auto"===this.map._spriteFormat,r=new AbortController;this._spriteRequest=r,async function(t,i,r,a){try{let n=await i.transformRequest(i.normalizeIconsetURL(t),iX.Iconset,r),{data:o}=await i4(n,r),s={};for(let t of function(t){let i,r={icons:[]};for(;i=t.nextField(void 0);)1===i&&r.icons.push(function(t,i){let r,a={name:void 0};for(;r=t.nextField(i);)1===r?a.name=t.readString():2===r?a.metadata=function(t,i){let r,a={stretch_x:null,stretch_y:null,
109stretch_x_areas:null,stretch_y_areas:null,variables:[]};for(;r=t.nextField(i);)1===r?a.stretch_x=t.readPackedVarint():2===r?a.stretch_y=t.readPackedVarint():3===r?a.content_area=mr(t,t.readVarint()+t.pos):4===r?a.variables.push(function(t,i){let r,a={name:void 0};for(;r=t.nextField(i);)1===r?a.name=t.readString():2===r&&(a.rgb_color=mo(t.readVarint()),a.value="rgb_color");return a}(t,t.readVarint()+t.pos)):5===r&&(a.text_placeholder=mr(t,t.readVarint()+t.pos));return a}(t,t.readVarint()+t.pos):3===r&&(a.usvg_tree=function(t,i){let r,a={width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[],height:20};for(;r=t.nextField(i);)1===r?a.width=a.height=t.readVarint():2===r?a.height=t.readVarint():3===r?a.children.push(ma(t,t.readVarint()+t.pos)):4===r?a.linear_gradients.push(function(t,i){let r,a={spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0};for(;r=t.nextField(i);)1===r?a.transform=mn(t,t.readVarint()+t.pos):2===r?a.spread_method=t.readVarint():3===r?a.stops.push(ms(t,t.readVarint()+t.pos)):4===r?a.x1=t.readFloat():5===r?a.y1=t.readFloat():6===r?a.x2=t.readFloat():7===r&&(a.y2=t.readFloat());return a}(t,t.readVarint()+t.pos)):5===r?a.radial_gradients.push(function(t,i){let r,a={spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0};for(;r=t.nextField(i);)1===r?a.transform=mn(t,t.readVarint()+t.pos):2===r?a.spread_method=t.readVarint():3===r?a.stops.push(ms(t,t.readVarint()+t.pos)):4===r?a.cx=t.readFloat():5===r?a.cy=t.readFloat():6===r?a.r=t.readFloat():7===r?a.fx=t.readFloat():8===r?a.fy=t.readFloat():9===r&&(a.fr=t.readFloat());return a}(t,t.readVarint()+t.pos)):7===r?a.clip_paths.push(function(t,i){let r,a={children:[]};for(;r=t.nextField(i);)1===r?a.transform=mn(t,t.readVarint()+t.pos):2===r?a.clip_path_idx=t.readVarint():3===r&&a.children.push(ma(t,t.readVarint()+t.pos));return a}(t,t.readVarint()+t.pos)):8===r&&a.masks.push(function(t,i){let r,a={left:0,width:20,mask_type:1,children:[]};for(;r=t.nextField(i);)1===r?a.left=a.top=t.readFloat():2===r?a.width=a.height=t.readFloat():3===r?a.top=t.readFloat():4===r?a.height=t.readFloat():5===r?a.mask_type=t.readVarint():6===r?a.mask_idx=t.readVarint():7===r&&a.children.push(ma(t,t.readVarint()+t.pos));return null==a.height&&(a.height=a.width),null==a.top&&(a.top=a.left),a}(t,t.readVarint()+t.pos));return a}(t,t.readVarint()+t.pos),a.data="usvg_tree");if(a.usvg_tree.height||(a.usvg_tree.height=a.usvg_tree.width),!a.metadata)return a;let{metadata:n}=a;if(n.content_area){let{content_area:t}=n;null==t.left&&(t.left=0),null==t.top&&(t.top=t.left),null==t.width&&(t.width=a.usvg_tree.width),null==t.height&&(t.height=t.width)}if(n.text_placeholder){let{text_placeholder:t}=n;null==t.top&&(t.top=t.left),null==t.height&&(t.height=t.width)}return n.stretch_x&&n.stretch_x.length&&mi(n,"x"),n.stretch_y&&n.stretch_y.length&&mi(n,"y"),a}(t,t.readVarint()+t.pos));return r}(new uz(o)).icons){let i={version:1,pixelRatio:is.devicePixelRatio,content:function(t){if(!t.metadata||!t.metadata.content_area)return;let i=is.devicePixelRatio,{left:r,top:a,width:n,height:o}=t.metadata.content_area,s=r*i,l=a*i;return[s,l,s+n*i,l+o*i]}(t),stretchX:t.metadata?wG(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?wG(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};s[t.name]=i}a(null,s)}catch(t){r.aborted||a(t)}}(t,this.map._requestManager,r.signal,(r,a)=>{if(this._spriteRequest=null,r)i?this._loadSprite(t):(this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this.fire(new rL(r)));else if(a){let t=new Map;for(let i in a)t.set(rk.from(i),a[i]);this.addImages(t,!0)}this.imageManager.setLoaded(!0,this.scope),this.fire(new rz("data",{dataType:"style"}))})}_validateLayer(t){let i=this.getOwnSource(t.source);if(!i)return;let r=t.sourceLayer;
109r&&("geojson"===i.type||i.vectorLayerIds&&!i.vectorLayerIds.includes(r))&&this.fire(new rL(Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(let t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(let{style:t}of this.fragments)if(!t.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((t,i)=>{let r=this.fragments[i];return r&&r.style&&(t.data=r.style.serialize()),t})}_serializeSources(){let t={};for(let i in this._sourceCaches){let r=this._sourceCaches[i].getSource();t[r.id]||(t[r.id]=r.serialize())}return t}_serializeLayers(t){let i=[];for(let r of t){let t=this._layers[r];t&&"custom"!==t.type&&i.push(t.serialize())}return i}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(let t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(let t in this._mergedLayers){let i=this._mergedLayers[t];if(i._transitionablePaint&&i._transitionablePaint._values){let t=i._transitionablePaint._values["line-emissive-strength"];if(t&&t.value&&t.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(t){return t?this.order:this._mergedOrder}isLayerDraped(t){return!!this.terrain&&t.isDraped(this.getLayerSourceCache(t))}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}_checkLayer(t){let i=this.getOwnLayer(t);if(i)return i;this.fire(new rL(Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){let i=this.getOwnSource(t);if(i)return i;this.fire(new rL(Error(`The source '${t}' does not exist in the map's style.`)))}handleIdle(){let t=this.map.painter;t&&(t.context.sweepPendingPrograms(),this._programPrecompiler&&this._programPrecompiler.processQueue(t,this))}handleContextLost(){this._programPrecompiler&&this._programPrecompiler.reset()}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);let i=this.calculateLightsBrightness();t.brightness=i||0;let r=!1;i!==this._brightness&&(this._brightness=i,r=!0),t.worldview!==this._worldview&&(this._worldview=t.worldview,r=!0),r&&this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness,worldview:this._worldview});let a=this._changes.isDirty(),n=!1;if(this._changes.isDirty()){let i=this._changes.getLayerUpdatesByScope();for(let t in i){let{updatedIds:r,removedIds:a}=i[t];(r||a)&&(this._updateWorkerLayers(t,r,a),n=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset()}let o={};for(let t in this._mergedSourceCaches){let i=this._mergedSourceCaches[t];o[t]=i.used,i.used=!1,i.tileCoverLift=0}let s={};for(let i of this._mergedOrder){let r=this._mergedLayers[i];if(("none"!==r.visibility||r.hasTransition())&&r.recalculate(t,this._availableImages),!r.isHidden(t.zoom)){r.mayUse("HD")&&(r.prepare(),bz()),r.mayUse("Standard")&&(r.prepare(),xu());let t=this.getLayerSourceCache(r);t&&(t.used=!0,t.tileCoverLift=Math.max(t.tileCoverLift,r.tileCoverLift()))}
109if(r.source){let t=sy(r.source,r.scope),i=this._mergedHdRoadCoverageSourceCaches[t];i&&!i.used&&(i.used=!0)}if("fill-extrusion"===r.type){let t=sy(r.source,r.scope);if(t in this._mergedFillExtrusionSourceCaches){let i=r.layout&&r.layout.get("source-max-zoom");if(null!=i){let r=s[t];s[t]=null==r?i:Math.min(r,i)}}}}if(this._programPrecompiler&&this._programPrecompiler.needsBuild()){let i=this._mergedOrder.map(t=>this._mergedLayers[t]);this._programPrecompiler.buildQueue(i,t,this)}for(let t in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[t].setMaxzoomOverride(null!=s[t]?s[t]:null);for(let t of(this.terrain&&n&&this.mergeLayers(),this.imageManager.getPendingImageProviders()))t.sourceCache.used=!0;for(let t in o){let i=this._mergedSourceCaches[t];o[t]!==i.used&&i.getSource().fire(new rz("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),a&&this.fire(new rz("data",{dataType:"style"}))}updateImageProviders(){for(let t of this.imageManager.getPendingImageProviders()){let i=t.resolvePendingRequests(),r=this.getFragmentStyle(t.scope);r&&r.addImages(i)}}_updateTilesForChangedImages(){let t={};for(let i in this._mergedSourceCaches){let r=this._mergedSourceCaches[i].getSource().scope;t[r]=t[r]||this._changes.getUpdatedImages(r),0!==t[r].length&&this._mergedSourceCaches[i].reloadTilesForDependencies(["icons","patterns"],t[r])}for(let i in t)this._changes.resetUpdatedImages(i)}_updateWorkerLayers(t,i,r){let a=this.getFragmentStyle(t);a&&this.dispatcher.broadcast("updateLayers",{layers:i?a._serializeLayers(i):[],scope:t,removedIds:r||[],options:a.options})}setState(t,i){if(this._checkLoaded(),wq(this,m0(t)))return!1;(t=tZ(t)).layers=b7(t.layers);let r=(function(t,i){if(!t)return[{command:we.setStyle,args:[i]}];let r=[];try{if(!ty(t.version,i.version)||(ty(t.center,i.center)||r.push({command:we.setCenter,args:[i.center]}),ty(t.zoom,i.zoom)||r.push({command:we.setZoom,args:[i.zoom]}),ty(t.bearing,i.bearing)||r.push({command:we.setBearing,args:[i.bearing]}),ty(t.pitch,i.pitch)||r.push({command:we.setPitch,args:[i.pitch]}),ty(t.sprite,i.sprite)||r.push({command:we.setSprite,args:[i.sprite]}),ty(t.glyphs,i.glyphs)||r.push({command:we.setGlyphs,args:[i.glyphs]}),ty(t.imports,i.imports)||function(t=[],i=[],r){let a,n,o,s;i=i||[];let l=(t=t||[]).map(wa),h=i.map(wa),u=t.reduce(wn,{}),c=i.reduce(wn,{}),d=l.slice();for(a=0,n=0;a<l.length;a++)o=l[a],Object.hasOwn(c,o)?n++:(r.push({command:we.removeImport,args:[o]}),d.splice(d.indexOf(o,n),1));for(a=0,n=0;a<h.length;a++)o=h[h.length-1-a],d[d.length-1-a]!==o&&(Object.hasOwn(u,o)?(r.push({command:we.removeImport,args:[o]}),d.splice(d.lastIndexOf(o,d.length-n),1)):n++,s=d[d.length-a],r.push({command:we.addImport,args:[c[o],s]}),d.splice(d.length-a,0,o));for(let t of i){let i=u[t.id];i&&(delete i.data,ty(i,t)||r.push({command:we.updateImport,args:[t.id,t]}))}}(t.imports,i.imports,r),ty(t.transition,i.transition)||r.push({command:we.setTransition,args:[i.transition]}),ty(t.light,i.light)||r.push({command:we.setLight,args:[i.light]}),ty(t.fog,i.fog)||r.push({command:we.setFog,args:[i.fog]}),ty(t.snow,i.snow)||r.push({command:we.setSnow,args:[i.snow]}),ty(t.rain,i.rain)||r.push({command:we.setRain,args:[i.rain]}),ty(t.projection,i.projection)||r.push({command:we.setProjection,args:[i.projection]}),ty(t.lights,i.lights)||r.push({command:we.setLights,args:[i.lights]}),ty(t.camera,i.camera)||r.push({command:we.setCamera,args:[i.camera]}),ty(t.iconsets,i.iconsets)||function(t,i,r){let a;for(a in i=i||{},t=t||{})Object.hasOwn(t,a)&&(Object.hasOwn(i,a)||r.push({command:we.removeIconset,args:[a]}));for(a in i){if(!Object.hasOwn(i,a))continue;let n=i[a];Object.hasOwn(t,a)?ty(t[a],n)||(r.push({command:we.removeIconset,args:[a]}),r.push({command:we.addIconset,args:[a,n]})):r.push({command:we.addIconset,args:[a,n]})}}(t.iconsets,i.iconsets,r),!ty(t["color-theme"],i["color-theme"])))return[{command:we.setStyle,args:[i]}];let a={},n=[];!function(t,i,r,a){let n;for(n in i=i||{},t=t||{})Object.hasOwn(t,n)&&(Object.hasOwn(i,n)||wi(n,r,a));for(n in i){var o;if(!Object.hasOwn(i,n))continue;let s=i[n];Object.hasOwn(t,n)?ty(t[n],s)||("geojson"===t[n].type&&"geojson"===s.type&&function(t,i,r){let a;for(a in t[r])if(Object.hasOwn(t[r],a)&&"data"!==a&&!ty(t[r][a],i[r][a]))return!1;for(a in i[r])if(Object.hasOwn(i[r],a)&&"data"!==a&&!ty(t[r][a],i[r][a]))return!1;return!0}(t,i,n)?r.push({command:we.setGeoJSONSourceData,args:[n,s.data]}):(o=i,wi(n,r,a),wt(n,o,r))):wt(n,i,r)}}(t.sources,i.sources,n,a);let o=[];
109t.layers&&t.layers.forEach(t=>{t.source&&a[t.source]?r.push({command:we.removeLayer,args:[t.id]}):o.push(t)});let s=t.terrain;s&&a[s.source]&&(r.push({command:we.setTerrain,args:[void 0]}),s=void 0),r=r.concat(n),ty(s,i.terrain)||r.push({command:we.setTerrain,args:[i.terrain]}),function(t,i,r){let a,n,o,s,l,h,u;i=i||[];let c=(t=t||[]).map(wa),d=i.map(wa),p=t.reduce(wn,{}),f=i.reduce(wn,{}),_=c.slice(),m=Object.create(null);for(a=0,n=0;a<c.length;a++)o=c[a],Object.hasOwn(f,o)?n++:(r.push({command:we.removeLayer,args:[o]}),_.splice(_.indexOf(o,n),1));for(a=0,n=0;a<d.length;a++)o=d[d.length-1-a],_[_.length-1-a]!==o&&(Object.hasOwn(p,o)?(r.push({command:we.removeLayer,args:[o]}),_.splice(_.lastIndexOf(o,_.length-n),1)):n++,h=_[_.length-a],r.push({command:we.addLayer,args:[f[o],h]}),_.splice(_.length-a,0,o),m[o]=!0);for(a=0;a<d.length;a++)if(s=p[o=d[a]],l=f[o],!m[o]&&!ty(s,l))if(ty(s.source,l.source)&&ty(s["source-layer"],l["source-layer"])&&ty(s.type,l.type)){for(u in wr(s.layout,l.layout,r,o,null,we.setLayoutProperty),wr(s.paint,l.paint,r,o,null,we.setPaintProperty),ty(s.slot,l.slot)||r.push({command:we.setSlot,args:[o,l.slot]}),ty(s.filter,l.filter)||r.push({command:we.setFilter,args:[o,l.filter]}),ty(s.minzoom,l.minzoom)&&ty(s.maxzoom,l.maxzoom)||r.push({command:we.setLayerZoomRange,args:[o,l.minzoom,l.maxzoom]}),s)Object.hasOwn(s,u)&&"layout"!==u&&"paint"!==u&&"filter"!==u&&"metadata"!==u&&"minzoom"!==u&&"maxzoom"!==u&&"slot"!==u&&(0===u.indexOf("paint.")?wr(s[u],l[u],r,o,u.slice(6),we.setPaintProperty):ty(s[u],l[u])||r.push({command:we.setLayerProperty,args:[o,u,l[u]]}));for(u in l)Object.hasOwn(l,u)&&!Object.hasOwn(s,u)&&"layout"!==u&&"paint"!==u&&"filter"!==u&&"metadata"!==u&&"minzoom"!==u&&"maxzoom"!==u&&"slot"!==u&&(0===u.indexOf("paint.")?wr(s[u],l[u],r,o,u.slice(6),we.setPaintProperty):ty(s[u],l[u])||r.push({command:we.setLayerProperty,args:[o,u,l[u]]}))}else r.push({command:we.removeLayer,args:[o]}),h=_[_.lastIndexOf(o)+1],r.push({command:we.addLayer,args:[l,h]})}(o,i.layers,r)}catch(t){console.warn("Unable to compute style diff:",t),r=[{command:we.setStyle,args:[i]}]}return r})(this.serialize(),t).filter(t=>!(t.command in wW));if(0===r.length)return!1;let a=r.filter(t=>!(t.command in w$));if(a.length>0)throw Error(`Unimplemented: ${a.map(t=>t.command).join(", ")}.`);let n=[];return r.forEach(t=>{n.push(this[t.command](...t.args))}),i&&Promise.all(n).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(t=!1){this._availableImages=this.imageManager.listImages(this.scope);let i={scope:this.scope,images:this._availableImages};t&&(i.isSpriteLoaded=!0),this.dispatcher.broadcast("setImages",i)}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t,i){if(0===t.size)return i&&this.dispatcher.broadcast("spriteLoaded",{scope:this.scope}),this;for(let[i,r]of t.entries()){if(this.getImage(i))return this.fire(new rL(Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,r),this._changes.updateImage(i,this.scope)}return this._updateWorkerImages(i),this.fire(new rz("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new rL(Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new rz("data",{dataType:"style"})),this)}updateImage(t,i,r=!1){this.imageManager.updateImage(t,this.scope,i),r&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new rz("data",{dataType:"style"})))}getImage(t){return this.imageManager.getImage(t,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new rz("data",{dataType:"style"})),this):this.fire(new rL(Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new rz("data",{dataType:"style"})),this}addModel(t,i,r={}
109){return this._checkLoaded(),this._validate(gi,`models.${t}`,i,null,r)||(this.modelManager.addModel(t,i,this.getActualScope()),this.fire(new rz("data",{dataType:"style"}))),this}hasModel(t){return this.modelManager.hasModel(t,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new rz("data",{dataType:"style"})),this):this.fire(new rL(Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw Error(`There is already a source with ID "${t}".`);if(!i.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(i.type)&&this._validate(m1,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);let a=b2(t,i,this.dispatcher,this);a.scope=this.scope,a.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(a.id),source:a.serialize(),sourceId:a.id}));let n=t=>{let i=(1===t?"symbol:":2===t?"fill-extrusion:":"other:")+a.id,r=sy(i,this.scope),n=this._sourceCaches[i]=new vq(r,a,t);1===t?this._symbolSourceCaches[a.id]=n:2===t?this._fillExtrusionSourceCaches[a.id]=n:this._otherSourceCaches[a.id]=n,n.onAdd(this.map)};n(0),"vector"!==i.type&&"geojson"!==i.type||(n(1),"vector"===i.type&&n(2)),a.onAdd&&a.onAdd(this.map),r.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();let i=this.getOwnSource(t);if(!i)throw Error("There is no source with this ID");for(let i in this._layers)if(this._layers[i].source===t)return this.fire(new rL(Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new rL(Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){let i=Object.entries(this.stylesheet.iconsets).find(([i,r])=>"source"===r.type&&r.source===t);if(i)return this.fire(new rL(Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}for(let i of this.getOwnSourceCaches(t)){let t=sx(i.id);delete this._sourceCaches[t],this._changes.discardSourceCacheUpdate(i.id),i.fire(new rz("data",{sourceDataType:"metadata",dataType:"source",sourceId:i.getSource().id})),i.setEventedParent(null),i.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],delete this._fillExtrusionSourceCaches[t],this._hdCoverage&&delete this._hdCoverage.coverageSourceCaches[t],this._hdElevation&&delete this._hdElevation.elevationSourceCaches[sy(t,this.scope)],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(t,i){this._checkLoaded(),this.getOwnSource(t).setData(i),this._changes.setDirty()}getOwnSource(t){let i=this.getOwnSourceCache(t);return i&&i.getSource()}getOwnSources(){let t=[];for(let i in this._otherSourceCaches){let r=this.getOwnSourceCache(i);r&&t.push(r.getSource())}return t}areTilesLoaded(){let t=this._mergedSourceCaches;for(let i in t){let r=t[i]._tiles;for(let t in r){let i=r[t];if("loaded"!==i.state&&"errored"!==i.state)return!1}}return!0}setLights(t){if(this._checkLoaded(),this._programPrecompiler&&this._programPrecompiler.reset(),!t)return delete this.ambientLight,void delete this.directionalLight;let i=this._getTransitionParameters();for(let r of t){if(this._validate(m3,"lights",r))return;switch(r.type){case"ambient":if(this.ambientLight){let t=this.ambientLight;t.set(r),t.updateTransitions(i)}else this.ambientLight=new gI(r,gA(),this.scope,this.options);break;case"directional":if(this.directionalLight){let t=this.directionalLight;t.set(r),t.updateTransitions(i)}else this.directionalLight=new gI(r,gC(),this.scope,this.options)}}let r=Object.assign(i,{worldview:this.map.getWorldview()}),a=new o0(this.z||0,r);this.ambientLight&&this.ambientLight.recalculate(a),this.directionalLight&&this.directionalLight.recalculate(a),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("upsertRenderParams",{brightness:this._brightness})}calculateLightsBrightness(){let t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;let r=t=>.2126*(t[0]<=.03928?t[0]/12.92:Math.pow((t[0]+.055)/1.055,2.4))+.7152*(t[1]<=.03928?t[1]/12.92:Math.pow((t[1]+.055)/1.055,2.4))+.0722*(t[2]<=.03928?t[2]/12.92:Math.pow((t[2]+.055)/1.055,2.4)),a=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),n=t.properties.get("intensity"),o=t.properties.get("direction"),s=1-tQ(o.x,o.y,o.z)[2]/90,l=r(a)*n*s,h=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),u=i.properties.get("intensity");return Number(((l+r(h)*u)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;let t=[];return this.directionalLight&&t.push(this.directionalLight.get()),this.ambientLight&&t.push(this.ambientLight.get()),t}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(null==t||""===t&&this.isRootStyle())return this;if(sg(t)){let i=function(t){let i=t.lastIndexOf("\x1f");return i>=0?t.slice(i+1):""}(t),r=this.fragments.find(({id:t})=>t===i);if(!r)return;let a=sx(t);return r.style.getFragmentStyle(a)}{let i=this.fragments.find(({id:i})=>i===t);return i?i.style:void 0}}setFeaturesetSelectors(t){if(!t)return;let i=(t,i="")=>`${t}::${i}`;for(let r in this._featuresetSelectors={},t){let a={},n=this._featuresetSelectors[r]=[];for(let o of t[r].selectors){let t;if(o.featureNamespace){let t=this.getOwnLayer(o.layer);if(!t){tX(`Layer is undefined for selector: ${o.layer}`);continue}let n=i(t.source,t.sourceLayer);
109if(n in a&&a[n]!==o.featureNamespace){tX(`"featureNamespace ${o.featureNamespace} of featureset ${r}'s selector is not associated to the same source, skip this selector`);continue}a[n]=o.featureNamespace}if(o.properties)for(let i in o.properties){let r=ob(o.properties[i]);"success"===r.result&&((t=t||{})[i]=r.value)}n.push({layerId:o.layer,namespace:o.featureNamespace,properties:t,uniqueFeatureID:o._uniqueFeatureID})}}}getFeaturesetDescriptors(t){let i=this.getFragmentStyle(t);if(!i||!i.stylesheet.featuresets)return[];let r=[];for(let t in i.stylesheet.featuresets)r.push({featuresetId:t,importId:i.scope?i.scope:void 0});return r}getFeaturesetLayers(t,i){let r=this.getFragmentStyle(i),a=r.stylesheet.featuresets;if(!a||!a[t])return this.fire(new rL(Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];let n=[];for(let i of a[t].selectors){let t=r.getOwnLayer(i.layer);t&&n.push(t)}return n}getConfigProperty(t,i){let r=this.getFragmentStyle(t);if(!r)return null;let a=sy(i,r.scope),n=r.options.get(a),o=n?n.value||n.default:null;return o?o.serialize():null}isIndoorEnabled(){return this._indoorEnabled}getIndoorSourceLayers(t,i){let r=sy(t,i);return this._mergedIndoor[r]}setIndoorData(t,i){this.indoorManager&&this.indoorManager.setIndoorData(i)}updateIndoorDependentLayers(){this._updateLayers(this._dependentLayerIds(t=>t.isIndoorDependent)),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,i,r){let a,n=this.getFragmentStyle(t);if(!n)return;let o=n.stylesheet.schema;if(!o||!o[i])return;let s=wZ(o[i],r);if("success"!==s.result)return void wq(this,s.value);let l=s.value.expression,h=sy(i,n.scope),u=n.options.get(h);if(!u)return;let{minValue:c,maxValue:d,stepValue:p,type:f,values:_}=o[i],m=wZ(o[i],o[i].default);"success"===m.result&&(a=m.value.expression),a?(this.options.set(h,{...u,value:l,default:a,minValue:c,maxValue:d,stepValue:p,type:f,values:_}),this.updateConfigDependencies(i)):this.fire(new rL(Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)))}getConfig(t){let i=this.getFragmentStyle(t);if(!i)return null;let r=i.stylesheet.schema;if(!r)return null;let a={};for(let t in r){let r=sy(t,i.scope),n=i.options.get(r),o=n?n.value||n.default:null;a[t]=o?o.serialize():null}return a}setConfig(t,i){let r=this.getFragmentStyle(t);r&&(r.updateConfig(i,r.stylesheet.schema),this.updateConfigDependencies())}getSchema(t){let i=this.getFragmentStyle(t);return i?i.stylesheet.schema:null}setSchema(t,i){let r=this.getFragmentStyle(t);r&&(r.stylesheet.schema=i,r.updateConfig(r._config,i),this.updateConfigDependencies())}updateConfig(t,i){if(this._config=t,t||i)if(i)for(let r in i){let a,n,o=wZ(i[r],i[r].default);if("success"===o.result&&(a=o.value.expression),t&&void 0!==t[r]){let a=wZ(i[r],t[r]);"success"===a.result&&(n=a.value.expression)}let{minValue:s,maxValue:l,stepValue:h,type:u,values:c}=i[r];if(a){let t=sy(r,this.scope);this.options.set(t,{default:a,value:n,minValue:s,maxValue:l,stepValue:h,type:u,values:c})}else this.fire(new rL(Error(`No schema defined for config option "${r}".`)))}else this.fire(new rL(Error("Attempting to set config for a style without schema.")))}_updateLayers(t){for(let i of t){let t=this.getLayer(i);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t),this._changes.setDirty())}}_dependentLayerIds(t){let i=[];for(let[r,a]of this._layerExpressionDependencies)t(a)&&i.push(r);return i}updateConfigDependencies(t){this._updateLayers(this._dependentLayerIds(i=>t?i.hasConfigDependency(t):i.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(t=>{let i=t._styleColorTheme.colorThemeOverride?t._styleColorTheme.colorThemeOverride:t._styleColorTheme.colorTheme;if(i){let r=t._evaluateColorThemeData(i);(!t._styleColorTheme.lut&&""!==r||t._styleColorTheme.lut&&r!==t._styleColorTheme.lut.data)&&t.setColorTheme(i)}}),this._updateIndoorEnabled(),this._changes.setDirty()}addLayer(t,i,r={}){let a;this._checkLoaded();let n=t.id;if(this._layers[n])return void this.fire(new rL(Error(`Layer with i
109d "${n}" already exists on this map`)));if("custom"===t.type){if(wq(this,function(t){let i=[],r=t.id;return void 0===r&&i.push({message:`layers.${r}: missing required property "id"`}),void 0===t.render&&i.push({message:`layers.${r}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&i.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),i}(t)))return;a=_7(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=Object.assign(t=tZ(t),{source:n})),this._validate(m9,`layers.${n}`,t,{arrayIndex:-1},r))return;a=_7(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(a),a.setEventedParent(this,{layer:{id:n}})}this._layerExpressionDependencies.set(a.fqid,new me(a));let o=this._order.length;if(i){let t=this._order.indexOf(i);if(-1===t)return void this.fire(new rL(Error(`Layer with id "${i}" does not exist on this map.`)));a.slot&&a.slot!==this._layers[i].slot?tX(`Layer with i
109d "${i}" has a different slot. Layers can only be rearranged within the same slot.`):o=t}this._order.splice(o,0,n),this._handleLayerOrderChange(),this._layers[n]=a;let s=this.getOwnLayerSourceCache(a),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();s&&a.canCastShadows()&&l&&(s.castsShadows=!0);let h=this._changes.getRemovedLayer(a);if(h&&a.source&&s&&"custom"!==a.type){this._changes.discardLayerRemoval(a);let t=sy(a.source,a.scope);h.type!==a.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),s.pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map),a.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();let r=this._checkLayer(t);if(!r||t===i)return;let a=this._order.indexOf(t);this._order.splice(a,1);let n=this._order.length;if(i){let t=this._order.indexOf(i);if(-1===t)return void this.fire(new rL(Error(`Layer with id "${i}" does not exist on this map.`)));r.slot&&r.slot!==this._layers[i].slot?tX(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):n=t}this._order.splice(n,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(t){this._checkLoaded();let i=this._checkLayer(t);if(!i)return;i.setEventedParent(null);let r=this._order.indexOf(t);this._order.splice(r,1),delete this._layers[t],this._changes.setDirty(),this._handleLayerOrderChange(),this._layerExpressionDependencies.delete(i.fqid),this._changes.removeLayer(i);let a=this.getOwnLayerSourceCache(i);if(a&&a.castsShadows){let t=!1;for(let r in this._layers)if(this._layers[r].source===i.source&&this._layers[r].canCastShadows()){t=!0;break}a.castsShadows=t}i.onRemove&&i.onRemove(this.map),this.mergeLayers()}getOwnLayer(t){return this._layers[t]}hasLayer(t){return t in this._mergedLayers}hasLayerType(t){for(let i in this._layers)if(this._layers[i].type===t)return!0;return!1}setLayerZoomRange(t,i,r){this._checkLoaded();let a=this._checkLayer(t);a&&(a.minzoom===i&&a.maxzoom===r||(null!=i&&(a.minzoom=i),null!=r&&(a.maxzoom=r),this._updateLayer(a)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(t,i){this._checkLoaded();let r=this._checkLayer(t);r&&r.slot!==i&&(r.slot=i,this._updateLayer(r))}setFilter(t,i,r={}){this._checkLoaded();let a=this._checkLayer(t);if(!a||ty(a.filter,i))return;let n=this._layerExpressionDependencies.get(a.fqid);if(null==i)return a.filter=void 0,n&&n.invalidateFilter(),void this._updateLayer(a);this._validate(m7,`layers.${a.id}.filter`,i,{layerType:a.type},r)||(a.filter=tZ(i),n&&n.invalidateFilter(),this._updateLayer(a))}getFilter(t){let i=this._checkLayer(t);if(i)return tZ(i.filter)}setLayoutProperty(t,i,r,a={}){this._checkLoaded();let n=this._checkLayer(t);if(n&&!ty(n.getLayoutProperty(i),r)){if(null!=r&&(!a||!1!==a.validate)&&wq(n,gt.call(m0,{key:`layers.${t}.layout.${i}`,layerType:n.type,objectKey:i,value:r,styleSpec:sn,style:{glyphs:!0,sprite:!0}})))return;n.setLayoutProperty(i,r),this._updateLayer(n)}}getLayerProperty(t,i){let r=this._checkLayer(t);if(r){switch(i){case"minzoom":return r.minzoom;case"maxzoom":return r.maxzoom;case"filter":return this.getFilter(t);case"slot":return r.slot;case"appearances":return r.getAppearances().map(t=>t.serialize())}return r.isPaintProperty(i)?this.getPaintProperty(t,i):this.getLayoutProperty(t,i)}}setLayerProperty(t,i,r,a={}){this._checkLoaded();let n=this._checkLayer(t);if(n){switch(i){case"appearances":return n.setAppearances(r),void this._updateLayer(n);case"minzoom":return this.setLayerZoomRange(t,r);case"maxzoom":return this.setLayerZoomRange(t,null,r);case"filter":return this.setFilter(t,r,a);case"slot":return this.setSlot(t,r)}n.isPaintProperty(i)?this.setPaintProperty(t,i,r,a):this.setLayoutProperty(t,i,r,a)}}getLayoutProperty(t,i){let r=this._checkLayer(t);if(r)return r.getLayoutProperty(i)}setPaintProperty(t,i,r,a={}){this._checkLoaded();let n=this._checkLayer(t);n&&(ty(n.getPaintProperty(i),r)||(null==r||a&&!1===a.validate||!wq(n,ge.call(m0,{key:`layers.${t}.paint.${i}`,layerType:n.type,objectKey:i,value:r,styleSpec:sn})))&&(n.setPaintProperty(i,r)&&this._updateLayer(n),this._changes.updatePaintProperties(n)))}getPaintProperty(t,i){let r=this._checkLayer(t);if(r)return r.getPaintProperty(i)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){let{featuresetId:r,importId:a}=t.target,n=this.getFragmentStyle(a);for(let{source:a,sourceLayer:o}of n.getFeaturesetLayers(r))n.setFeatureState({id:t.id,source:a,sourceLayer:o},i)}else if("layerId"in t.target){let{layerId:r}=t.target,a=this.getLayer(r);this.setFeatureState({id:t.id,source:a.source,sourceLayer:a.sourceLayer},i)}return}let r=t.source,a=t.sourceLayer,n=this._checkSource(r);if(!n)return;let o=n.type;if("geojson"===o&&a)return void this.fire(new rL(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!a)return void this.fire(new rL(Error("The sourceLayer parameter must be provided for vector source types.")));for(let n of(void 0===t.id&&this.fire(new rL(Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(r)))n.setFeatureState(a,t.id,i)}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){let{featuresetId:r,importId:a}=t.target,n=this.getFragmentStyle(a);for(let{source:a,sourceLayer:o}of n.getFeaturesetLayers(r))n.removeFeatureState({id:t.id,source:a,sourceLayer:o},i)}else if("layerId"in t.target){let{layerId:r}=t.target,a=this.getLayer(r);this.removeFeatureState({id:t.id,source:a.source,sourceLayer:a.sourceLayer},i)}return}let r=t.source,a=this._checkSource(r);if(!a)return;let n=a.type,o="vector"===n?t.sourceLayer:void 0;if("vector"===n&&!o)return void this.fire(new rL(Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new rL(Error("A feature id is required to remove its specific state property.")));
109for(let a of this.getOwnSourceCaches(r))a.removeFeatureState(o,t.id,i)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){let{featuresetId:r,importId:a}=t.target,n=this.getFragmentStyle(a);for(let{source:a,sourceLayer:o}of n.getFeaturesetLayers(r)){let r=n.getFeatureState({id:t.id,source:a,sourceLayer:o});if(r&&!i)i=r;else if(!ty(i,r))return void this.fire(new rL(Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){let{layerId:r}=t.target,a=this.getLayer(r);i=this.getFeatureState({id:t.id,source:a.source,sourceLayer:a.sourceLayer})}return i}let i=t.source,r=t.sourceLayer,a=this._checkSource(i);if(a){if("vector"!==a.type||r)return void 0===t.id&&this.fire(new rL(Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(r,t.id);this.fire(new rL(Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition={...this.stylesheet.transition,...t},this.transition=this.stylesheet.transition,this}getTransition(){return{...this.stylesheet.transition}}setWorldview(t){t!==this._worldview&&(this._worldview=t,this.dispatcher.broadcast("upsertRenderParams",{worldview:this._worldview}),this.reloadSources())}serialize(){this._checkLoaded();let t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return tq({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:i,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)},t=>void 0!==t)}_updateFilteredLayers(t){for(let i of Object.values(this._mergedLayers))t(i)&&this._updateLayer(i)}_updateLayer(t){this._changes.updateLayer(t);let i=this.getLayerSourceCache(t),r=sy(t.source,t.scope),a=this._changes.getUpdatedSourceCaches();t.source&&!a[r]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(r,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){let i=t=>this._mergedLayers[t].is3D(!!this.terrain),r=this.order,a={},n=[];for(let o=r.length-1;o>=0;o--){let s=r[o];if(i(s))for(let i of(a[s]=o,t)){let t=i[s];if(t)for(let i of t)n.push(i)}}n.sort((t,i)=>i.intersectionZ-t.intersectionZ);let o=[];for(let s=r.length-1;s>=0;s--){let l=r[s];if(i(l))for(let t=n.length-1;t>=0;t--){let i=n[t].feature;if(i.layer&&a[i.layer.id]<s)break;o.push(i),n.pop()}else for(let i of t){let t=i[l];if(t)for(let i of t)o.push(i.feature)}}return o}queryRasterValue(t,i,r){let a=this.getOwnSource(t);return a?"raster-array"!==a.type?(this.fire(new rL(Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):a.queryRasterArrayValue(i,r):(this.fire(new rL(Error(`Source with id "${t}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(t,i,r){let a;i&&!Array.isArray(i)&&i.filter&&(this._validate(m7,"queryRenderedFeatures.filter",i.filter,null,i),a=sh(i.filter));let n={},o=t=>{if(wX.has(t.type))return;let i=this.getOwnLayerSourceCache(t),r=n[i.id]=n[i.id]||{sourceCache:i,layers:{},has3DLayers:!1};t.is3D(!!this.terrain)&&(r.has3DLayers=!0),r.layers[t.fqid]=r.layers[t.fqid]||{styleLayer:t,targets:[]},r.layers[t.fqid].targets.push({filter:a})};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new rL(Error("parameters.layers must be an Array."))),[];for(let t of i.layers){let i=this._layers[t];
109if(!i)return this.fire(new rL(Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];o(i)}}else for(let t in this._layers)o(this._layers[t]);let s=this._queryRenderedFeatures(t,n,r),l=this._flattenAndSortRenderedFeatures(s),h=[];for(let t of l)sv(t.layer.id)===this.scope&&h.push(t);return h}queryRenderedFeatureset(t,i,r){let a;i&&!Array.isArray(i)&&i.filter&&(this._validate(m7,"queryRenderedFeatures.filter",i.filter,null,i),a=sh(i.filter));let n="mock",o=[];if(i&&i.target)o.push({...i,targetId:n,filter:a});else{for(let t of this.getFeaturesetDescriptors())o.push({targetId:n,filter:a,target:t});for(let{style:t}of this.fragments)for(let i of t.getFeaturesetDescriptors())o.push({targetId:n,filter:a,target:i})}let s=this.queryRenderedTargets(t,o,r),l=[],h=new Set;for(let t of s)for(let i of t.variants[n])b4(i,t,h)||l.push(new _5(t,i));return l}queryRenderedTargets(t,i,r){let a={},n=(t,i,r,n)=>{let o=a[i.id]=a[i.id]||{sourceCache:i,layers:{},has3DLayers:!1};if(o.layers[t.fqid]=o.layers[t.fqid]||{styleLayer:t,targets:[]},t.is3D(!!this.terrain)&&(o.has3DLayers=!0),!n)return r.uniqueFeatureID=!1,void o.layers[t.fqid].targets.push(r);o.layers[t.fqid].targets.push({...r,namespace:n.namespace,properties:n.properties,uniqueFeatureID:n.uniqueFeatureID})};for(let t of i)if("featuresetId"in t.target){let{featuresetId:i,importId:r}=t.target,a=this.getFragmentStyle(r);if(!a||!a._featuresetSelectors)continue;let o=a._featuresetSelectors[i];if(!o){this.fire(new rL(Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(let i of o){let r=a.getOwnLayer(i.layerId);r&&!wX.has(r.type)&&n(r,a.getOwnLayerSourceCache(r),t,i)}}else if("layerId"in t.target){let{layerId:i}=t.target,r=this.getLayer(i);if(!r||wX.has(r.type))continue;n(r,this.getLayerSourceCache(r),t)}let o=this._queryRenderedFeatures(t,a,r);return this._flattenAndSortRenderedFeatures(o)}_queryRenderedFeatures(t,i,r){let a=[],n=!!this.map._showQueryGeometry,o=bL.createFromScreenPoints(t,r);for(let t in i){let s=function(t,i,r,a,n=!1,o){let s=i.sourceCache.transform,l=i.sourceCache.tilesIn(t,i.has3DLayers,n);l.sort(b5);let h=[];for(let t of l){let l=t.tile.queryRenderedFeatures(i,t,r,a,s,n,o);Object.keys(l).length&&h.push({wrappedTileID:t.tile.tileID.wrapped().key,queryResults:l})}for(let r in i.layers){let n=i.layers[r];if(n.styleLayer){let r=n.styleLayer.queryRenderedFeatures(t,i.sourceCache,a);Object.keys(r).length&&h.push({wrappedTileID:0,queryResults:r})}}return 0===h.length?{}:function(t){let i={},r={};for(let a of t){let t=a.queryResults,n=a.wrappedTileID,o=r[n]=r[n]||{};for(let r in t){let a=t[r],n=o[r]=o[r]||{},s=i[r]=i[r]||[];for(let t of a)n[t.featureIndex]||(n[t.featureIndex]=!0,s.push(t))}}return i}(h)}(o,i[t],this._availableImages,r,n,this.getActualScope());Object.keys(s).length&&a.push(s)}if(this.placement)for(let t in i){if(1!==i[t].sourceCache._renderSourceType)continue;let r=function(t,i,r,a,n,o){let s={},l=a.queryRenderedSymbols(t),h=[];for(let t of Object.keys(l).map(Number))h.push(n[t]);for(let t of(h.sort(b5),h)){let a=t.featureIndex.lookupSymbolFeatures(l[t.bucketInstanceId],t.bucketIndex,t.sourceLayerIndex,i,r,o);for(let i in a){let r=s[i]=s[i]||[],n=a[i];for(let i of(n.sort((i,r)=>{let a=t.featureSortOrder;if(a){let t=a.indexOf(i.featureIndex);return a.indexOf(r.featureIndex)-t}return r.featureIndex-i.featureIndex}),n))r.push(i)}}return s}(o.screenGeometry,i[t],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(r).length&&a.push(r)}return a}querySourceFeatures(t,i){let r=i&&i.filter;r&&this._validate(m7,"querySourceFeatures.filter",r,null,i);let a=[];for(let r of this.getOwnSourceCaches(t))a=a.concat(function(t,i){let r=t.getRenderableIds().map(i=>t.getTileByID(i)),a=[],n={};for(let t=0;t<r.length;t++){let o=r[t],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(a,i))}return a}(r,i));return a}addSourceType(t,i,r){return wQ.getSourceType(t)?r(Error(`A source type called "${t}" already exists.`)):(wQ.setSourceType(t,i),r(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,r={}){this._checkLoaded();let a=this.light.getLight(),n=!1;for(let i in t)if(!ty(t[i],a[i])){n=!0;break}if(!n)return;let o=this._getTransitionParameters();this.light.setLight(t,i,r),this.light.updateTransitions(o)}hasTerrain(){return!!this.terrain&&1===this.terrain.drapeRenderMode}getTerrain(){return this.hasTerrain()?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=is.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&tX("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedU
109pdate=!0);this.checkCanvasFingerprintNoise();let r=t,a=!("source"in t)||null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("source"in r&&"object"==typeof r.source){let t="terrain-dem-src";this.addSource(t,r.source),r=Object.assign(r=tZ(r),{source:t})}let t={...r},i={};if(this.terrain&&a){t.source=this.terrain.get().source;let r=this.terrain?this.getFragmentStyle(this.terrain.scope):null;r&&(i.style=r.serialize())}if(this._validate(m4,"terrain",t,i))return}if(this.terrain&&(this.terrain.scope===this.scope||a)&&(!this.terrain||i===this.terrain.drapeRenderMode)){let i=this.terrain,a=i.get();for(let t of Object.keys(sn.terrain))!Object.hasOwn(r,t)&&sn.terrain[t].default&&(r[t]=sn.terrain[t].default);for(let r in t)if(!ty(t[r],a[r])){i.set(t,this.options),this.stylesheet.terrain=t;let r=this._getTransitionParameters({duration:0});i.updateTransitions(r),this.fire(new rz("data",{dataType:"style"}));break}}else{if(!r)return;this._createTerrain(r,i),this.fire(new rz("data",{dataType:"style"}))}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){let i=this.fog=new gf(t,this.map.transform,this.scope,this.options);this.stylesheet.fog=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_createSnow(t){let i=this.snow=new gg(t,this.map.transform,this.scope,this.options);this.stylesheet.snow=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_createRain(t){let i=this.rain=new gy(t,this.map.transform,this.scope,this.options);this.stylesheet.rain=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(let t of this.map._markers)t._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),t)if(this.fog){let i=this.fog;if(!ty(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}}else this._createFog(t);else delete this.fog,delete this.stylesheet.fog;this._markersNeedUpdate=!0,this._programPrecompiler&&this._programPrecompiler.reset()}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){let i=this.snow;if(!ty(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}}else this._createSnow(t);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){let i=this.rain;if(!ty(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();let r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}}else this._createRain(t);this._markersNeedUpdate=!0}_reloadColorTheme(){let t=()=>{for(let t in this._layers)this._layers[t].lut=this._styleColorTheme.lut;for(let t in this._sourceCaches)this._sourceCaches[t].clearTiles()},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();let r=this._evaluateColorThemeData(i);this._loadColorTheme(r).then(()=>{this.fire(new rz("colorthemeset")),t()}).catch(t=>{tX(`Couldn't set color theme: ${t}`)})}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&tX("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme()}setImportColorTheme(t,i){let r=this.getFragmentStyle(t);r&&(r._styleColorTheme.colorThemeOverride=i,r._reloadColorTheme())}_getTransitionParameters(t){return{now:is.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;let t=[],i=[];for(let r of this._mergedOrder)this.isLayerDraped(this._mergedLayers[r])?t.push(r):i.push(r);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...i)}_createTerrain(t,i){let r=this.terrain=new gl(t,i,this.scope,this.options,this.map.getWorldview());1===i&&(this.stylesheet.terrain=t),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();let a=this._getTransitionParameters({duration:0});r.updateTransitions(a)}_force3DLayerUpdate(){for(let t in this._layers){let i=this._layers[t];
109"fill-extrusion"===i.type&&this._updateLayer(i)}}_forceSymbolLayerUpdate(){for(let t in this._layers){let i=this._layers[t];"symbol"===i.type&&this._updateLayer(i)}}_validate(t,i,r,a,n={}){if(n&&!1===n.validate)return!1;let o={...this.serialize()};return wq(this,t.call(m0,{key:i,style:o,value:r,styleSpec:sn,...a}))}_remove(){for(let t in this._programPrecompiler&&(this._programPrecompiler.reset(),this._programPrecompiler=null),this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),oX.off("pluginStateChange",this._rtlTextPluginCallback),this._mergedLayers)this._mergedLayers[t].setEventedParent(null);for(let t in this._mergedSourceCaches){let i=this._mergedSourceCaches[t];i.clearTiles(),i.setEventedParent(null);let r=i.getSource();r&&r.onRemove&&r.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())}
109clearSource(t){for(let i of this.getSourceCaches(t))i.clearTiles()}clearSources(){for(let t in this._mergedSourceCaches)this._mergedSourceCaches[t].clearTiles()}clearLayers(){for(let t in this._mergedLayers){let i=this._mergedLayers[t];i._clear&&i._clear()}}reloadSource(t){for(let i of this.getSourceCaches(t))i.resume(),i.reload()}reloadSources(){for(let t of this.getSources())t.reload&&t.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(t=>{t.modelManager.reloadModels(t.scope)})}updateSources(t){let i;this.directionalLight&&(i=ya(this.directionalLight));let r=new Set,a=new Set,n=new Set;for(let t in this._mergedLayers){let i=this._mergedLayers[t];"building"===i.type?r.add(i.source):"raster"===i.type&&i.paint&&"ground"===i.paint.get("raster-elevation-reference")&&n.add(i.source),i.hasElevation()&&!a.has(i.source)&&a.add(i.source)}for(let o in this.updateFrcCoverageFadeRange(),this._mergedSourceCaches){let s=this._mergedSourceCaches[o],l=a.has(s._source.id);s._isRasterElevatedOverTerrain=n.has(s._source.id),r.has(s._source.id)&&(s._source.reparseOverscaled=!1),s.update(t,void 0,void 0,i,l)}this.updateFrcCoverage(),this.updateElevationCoverage(),bT&&bT(this)}_reloadSources(){for(let t in this._sourceCaches){let i=this._sourceCaches[t];i.resume(),i.reload()}}updateFrcCoverageFadeRange(){this.map.painter&&bb&&bb(this,this.map.painter)}updateFrcCoverage(){this._hdCoverage&&bx&&bx(this,this._hdCoverage)}updateElevationCoverage(){this.isRootStyle()&&bw&&bw(this)}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new rz("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new wI),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(t,i,r,a,n,o){this.pauseablePlacement||(this.pauseablePlacement=new wI);let s=!1,l=!1,h={},u={};for(let i of this._mergedOrder){let r=this._mergedLayers[i];if("symbol"!==r.type)continue;let a=sy(r.source,r.scope),n=h[a];if(!n){let t=this.getLayerSourceCache(r);if(!t)continue;let i=t.getRenderableIds(!0).map(i=>t.getTileByID(i));u[a]=i.slice(),n=h[a]=i.sort((t,i)=>i.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(i.tileID)?-1:1))}let o=this.crossTileSymbolIndex.addLayer(r,n,t.center.lng,t.projection);s=s||o}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);let c=!!(this.placement&&!t.equals(this.placement.transform)),d=!!(this.placement&&(0!==this.placement.lastReplacementSourceUpdateTime&&!n||this.placement.lastReplacementSourceUpdateTime!==n.updateTime)),p=c||d||s,f=(p||this.pauseablePlacement.isStale())&&0===r,_=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(is.now(),t.zoom)&&0!==r;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||f||_)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,i,r,a,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex,o),this.map.painter)){let i=this.map.painter.maxFrontCutoffRawStart;if(i>0){let r=180*t.pitch/Math.PI;if(r>=15){let t=Math.min(1,Math.max(0,(r-15)/5)),a=t*t*(3-2*t);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-a)+i*a}}}if(this.pauseablePlacement.isDone()?p&&0!==r&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,h,u,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(is.now()),l=!0),s&&this.pauseablePlacement.setStale()),l||s){this._buildingIndex.onNewFrame(t.zoom);for(let t=0;t<this._mergedOrder.length;t++){let i=this._mergedLayers[this._mergedOrder[t]];if("symbol"!==i.type||"none"===i.visibility)continue;let r=this.isLayerClipped(i);this.placement.updateLayerOpacities(i,h[sy(i.source,i.scope)],t,r?n:null)}}return!this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(is.now())}_releaseSymbolFadeTiles(){for(let t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}addImport(t,i){this._checkLoaded();let r=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==r.findIndex(({id:i})=>
109i===t.id))return void this.fire(new rL(Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return r.push(t),this._loadImports([t],!0);let a=r.findIndex(({id:t})=>t===i);return -1===a&&this.fire(new rL(Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=r.slice(0,a).concat(t).concat(r.slice(a)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();let r=this.stylesheet.imports||[],a=this.getImportIndex(t);return -1===a||("string"==typeof i?this.setImportUrl(t,i):(i.url&&i.url!==r[a].url&&this.setImportUrl(t,i.url),ty(i.config,r[a].config)||this.setImportConfig(t,i.config,i.data.schema),ty(i.data,r[a].data)||this.setImportData(t,i.data))),this}moveImport(t,i){this._checkLoaded();let r=this.stylesheet.imports||[],a=this.getImportIndex(t);if(-1===a)return this;let n=this.getImportIndex(i);if(-1===n)return this;let o=r[a],s=this.fragments[a];return r=r.filter(({id:i})=>i!==t),this.fragments=this.fragments.filter(({id:i})=>i!==t),this.stylesheet.imports=r.slice(0,n).concat(o).concat(r.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(t,i){this._checkLoaded();let r=this.stylesheet.imports||[],a=this.getImportIndex(t);if(-1===a)return this;r[a].url=i;let n=this.fragments[a];return n.style=this._createFragmentStyle(r[a]),n.style.on("style.import.load",()=>this.mergeAll()),n.style.loadURL(i),this}setImportData(t,i){this._checkLoaded();let r=this.getImportIndex(t),a=this.stylesheet.imports||[];return -1===r?this:i?(this.fragments[r].style.setState(i),this._reloadImports(),this):(delete a[r].data,this.setImportUrl(t,a[r].url))}setImportConfig(t,i,r){this._checkLoaded();let a=this.getImportIndex(t),n=this.stylesheet.imports||[];if(-1===a)return this;i?n[a].config=i:delete n[a].config;let o=this.fragments[a];r&&o.style.stylesheet&&(o.style.stylesheet.schema=r);let s=o.style.stylesheet&&o.style.stylesheet.schema;return o.config=i,o.style.updateConfig(i,s),this.updateConfigDependencies(),this}removeImport(t){this._checkLoaded();let i=this.stylesheet.imports||[],r=this.getImportIndex(t);-1!==r&&(i.splice(r,1),this.fragments[r].style._remove(),this.fragments.splice(r,1),this._reloadImports())}getImportIndex(t){let i=(this.stylesheet.imports||[]).findIndex(i=>i.id===t);return -1===i&&this.fire(new rL(Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(t){return this._mergedLayers[t]}getSources(){let t=[];for(let i in this._mergedOtherSourceCaches){let r=this._mergedOtherSourceCaches[i];r&&t.push(r.getSource())}return t}getSource(t,i){let r=this.getSourceCache(t,i);return r&&r.getSource()}getLayerSource(t){let i=this.getLayerSourceCache(t);return i&&i.getSource()}getSourceCache(t,i){let r=sy(t,i);return this._mergedOtherSourceCaches[r]}getLayerSourceCache(t){let i=sy(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[i]:"fill-extrusion"===t.type?this._mergedFillExtrusionSourceCaches[i]||this._mergedOtherSourceCaches[i]:"fill"===t.type&&t.sourceLayer===_a&&this._mergedHdRoadCoverageSourceCaches[i]?this._mergedHdRoadCoverageSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(t){if(null==t)return Object.values(this._mergedSourceCaches);let i=[];return this._mergedOtherSourceCaches[t]&&i.push(this._mergedOtherSourceCaches[t]),this._mergedSymbolSourceCaches[t]&&i.push(this._mergedSymbolSourceCaches[t]),this._mergedFillExtrusionSourceCaches[t]&&i.push(this._mergedFillExtrusionSourceCaches[t]),this._mergedHdRoadCoverageSourceCaches[t]&&i.push(this._mergedHdRoadCoverageSourceCaches[t]),this._mergedHdRoadElevationSourceCaches[t]&&i.push(this._mergedHdRoadElevationSourceCaches[t]),i}updateSourceCaches(){let t=this._changes.getUpdatedSourceCaches();for(let i in t){let r=t[i];"reload"===r?this.reloadSource(i):"clear"===r&&this.clearSource(i)}}updateLayers(t){for(let i of this._changes.getUpdatedPaintProperties()){let r=this.getLayer(i);r&&r.updateTransitions(t)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(t){this.stylesheet.glyphs=t,this.glyphManager.setURL(t)}getOwnSourceCache(t){return this._otherSourceCaches[t]}getOwnLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:"fill-extrusion"===t.type&&this._fillExtrusionSourceCaches[t.source]||this._otherSourceCaches[t.source]}getOwnSourceCaches(t){let i=[];return this._otherSourceCaches[t]&&i.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&i.push(this._symbolSourceCaches[t]),this._fillExtrusionSourceCaches[t]&&i.push(this._fillExtrusionSourceCaches[t]),this._hdCoverage&&this._hdCoverage.coverageSourceCaches[t]&&i.push(this._hdCoverage.coverageSourceCaches[t]),this._hdElevation&&this._hdElevation.elevationSourceCaches[sy(t,this.scope)]&&i.push(this._hdElevation.elevationSourceCaches[sy(t,this.scope)]),i}_updateHdCoverageSourceCache(t){return by&&bv?(this._hdCoverage||(this._hdCoverage=new by),bv(this,this._hdCoverage,t),!1):"fill"===t.type&&t.sourceLayer===_a}_isSourceCacheLoaded(t){let i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new rL(Error(`There is no source with ID '${t}'`))),!1):i.every(t=>t.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(t,i){if(!this._clipLayerPresent&&"fill-extrusion"!==t.type&&"building"!==t.type)return!1;let r="fill-extrusion"===t.type&&("building"===t.sourceLayer||"procedural_buildings"===t.sourceLayer),a="building"===t.type;if(t.is3D(!!this.terrain)){if(r||a||i&&"batched-model"===i.type||"model"===t.type)return!0}else if("symbol"===t.type)return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEac
109h(t=>{t.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}async getImages(t,i){let r=new Promise((t,r)=>{this.imageManager.getImages(i.icons.concat(i.patterns),i.scope,(i,a)=>{i?r(i):t(a)})});this._updateTilesForChangedImages();let a=i.icons.map(t=>rk.toString(t)),n=i.patterns.map(t=>rk.toString(t)),o=t=>{t&&(t.setDependencies(i.tileID.key,"icons",a),t.setDependencies(i.tileID.key,"patterns",n))},s=sy(i.source,i.scope);return o(this._mergedOtherSourceCaches[s]),o(this._mergedSymbolSourceCaches[s]),(i.icons.some(t=>t.iconsetId)||i.patterns.some(t=>t.iconsetId))&&this.fire(new rz("data",{dataType:"style"})),r}async rasterizeImages(t,i){return new Promise((t,r)=>{this.imageManager.rasterizeImages(i,(i,a)=>{i?r(i):t(a)})})}async checkAtlasCache(t,i){let r=this.imageManager.imageAtlasCache.findCachedAtlas(i.descriptor);return r&&r.contentDescriptor?{iconPositions:r.iconPositions,patternPositions:r.patternPositions,sourceHash:r.contentDescriptor.hash}:null}async getGlyphs(t,i){return new Promise((t,r)=>{this.glyphManager.getGlyphs(i.stacks,(i,a)=>{i?r(i):t(a)})})}}wQ.getSourceType=function(t){return b1[t]},wQ.setSourceType=function(t,i){b1[t]=i},wQ.registerForPluginStateChange=function(t){return t({pluginStatus:oq,pluginURL:oZ}),oX.on("pluginStateChange",t),t};class wJ{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(t,i,r,a,n,o,s,l){this.context=t;let h=this.boundPaintVertexBuffers.length!==a.length;for(let t=0;!h&&t<a.length;t++)this.boundPaintVertexBuffers[t]!==a[t]&&(h=!0);let u=this.boundDynamicVertexBuffers.length!==s.length;for(let t=0;!u&&t<s.length;t++)this.boundDynamicVertexBuffers[t]!==s[t]&&(u=!0);if(!this.vao||this.boundProgram!==i||this.boundLayoutVertexBuffer!==r||h||u||this.boundIndexBuffer!==n||this.boundVertexOffset!==o)this.freshBind(i,r,a,n,o,s,l);else{for(let r of(t.bindVertexArrayOES.set(this.vao),s))r&&(r.bind(),l&&r.instanceCount&&r.setVertexAttribDivisor(t.gl,i,l));n&&n.dynamicDraw&&n.bind()}}freshBind(t,i,r,a,n,o,s){let l=this.context,h=l.gl;for(let s of(this.vao&&this.destroy(),this.vao=l.gl.createVertexArray(),l.bindVertexArrayOES.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=i,this.boundPaintVertexBuffers=r,this.boundIndexBuffer=a,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o,i.enableAttributes(h,t),i.bind(),i.setVertexAttribPointers(h,t,n),r))s.enableAttributes(h,t),s.bind(),s.setVertexAttribPointers(h,t,n);for(let i of o)i&&(i.enableAttributes(h,t),i.bind(),i.setVertexAttribPointers(h,t,n),s&&i.instanceCount&&i.setVertexAttribDivisor(h,t,s));a&&a.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function w0(t,i,r){if(!i.needsDEMTextureUpload)return;let a=t.context,n=a.gl;a.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(r.stride);let o=r.getPixels();i.demTexture?i.demTexture.update(o,{premultiply:!1}):i.demTexture=new uW(a,o,n.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}class w1{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class w2 extends w1{getDefault(){return rq.transparent.toNonPremultipliedRenderColor(null)}set(t){let i=this.current;(t.r!==i.r||t.g!==i.g||t.b!==i.b||t.a!==i.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class w3 extends w1{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class w4 extends w1{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class w5 extends w1{getDefault(){return[!0,!0,!0,!0]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class w6 extends w1{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class w8 extends w1{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class w9 extends w1{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let i=this.current;(t.func!==i.func||t.ref!==i.ref||t.mask!==i.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class w7 extends w1{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class Te extends w1{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;t?i.enable(i.STENCIL_TEST):i.disable(i.STENCIL_TEST),this.current=t,this.dirty=!1}}class Tt extends w1{getDefault(){return[0,1]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Ti extends w1{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;t?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST),this.current=t,this.dirty=!1}}class Tr extends w1{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Ta extends w1{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;t?i.enable(i.BLEND):i.disable(i.BLEND),this.current=t,this.dirty=!1}}class Tn extends w1{getDefault(){let t=this.gl;return[t.ONE,t.ZERO,t.ONE,t.ZERO]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||this.dirty)&&(this.gl.blendFuncSeparate(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class To extends w1{getDefault(){return rq.transparent.toNonPremultipliedRenderColor(null)}set(t){let i=this.current;(t.r!==i.r||t.g!==i.g||t.b!==i.b||t.a!==i.a||this.dirty)&&(this.gl.blendColor
109(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Ts extends w1{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(t,t),this.current=t,this.dirty=!1)}}class Tl extends w1{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;t?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),this.current=t,this.dirty=!1}}class Th extends w1{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Tu extends w1{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}let Tc=class extends w1{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}};class Td extends w1{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Tp extends w1{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Tf extends w1{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.bindFramebuffer(i.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class T_ extends w1{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.bindRenderbuffer(i.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Tm extends w1{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.bindTexture(i.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Tg extends w1{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.bindBuffer(i.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Ty extends w1{getDefault(){return null}set(t){let i=this.gl;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Tx extends w1{getDefault(){return null}set(t){this.gl&&(t!==this.current||this.dirty)&&(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}}class Tv extends w1{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class Tb extends w1{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Tw extends w1{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class TT extends w1{constructor(t,i){super(t),this.context=t,this.parent=i}getDefault(){return null}}class TE extends TT{constructor(t,i,r=0){super(t,i),this.attachmentPoint=t.gl.COLOR_ATTACHMENT0+r}setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferTexture2D(i.FRAMEBUFFER,this.attachmentPoint,i.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class TS extends TT{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferRenderbuffer(i.FRAMEBUFFER,this.attachment(),i.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class TI extends TT{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferTexture2D(i.FRAMEBUFFER,this.attachment(),i.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class TA extends TS{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}let TC=(t,i,r,a)=>({u_matrix:t,u_image0:0,u_image1:1,u_skirt_height:i,u_ground_shadow_factor:r,u_emissive_texture_available:a}),TM=(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g)=>({u_proj_matrix:Float32Array.from(t),u_globe_matrix:i,u_normalize_matrix:Float32Array.from(a),u_merc_matrix:r,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_image1:1,u_frustum_tl:s,u_frustum_tr:l,u_frustum_br:h,u_frustum_bl:u,u_globe_pos:c,u_globe_radius:d,u_viewport:p,u_grid_matrix:g?Float32Array.from(g):new Float32Array(9),u_skirt_height:f,u_far_z_cutoff:_,u_emissive_texture_available:m});function TR(t,i){return null!=t&&null!=i&&!(!t.hasData()||!i.hasData())&&null!=t.demTexture&&null!=i.demTexture&&t.tileID.key!==i.tileID.key}let TD=new class{constructor(){this.operations={}}newMorphing(t,i,r,a,n){if(t in this.operations){let i=this.operations[t];i.to.tileID.key!==r.tileID.key&&(i.queued=r)}else this.operations[t]={startTime:a,phase:0,duration:n,from:i,to:r,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;let i=this.operations[t];return{from:i.from,to:i.to,phase:i.phase}}update(t){for(let i in this.operations){let r=this.operations[i];for(r.phase=(t-r.startTime)/r.duration;r.phase>
109=1||!this._validOp(r);)if(!this._nextOp(r,t)){delete this.operations[i];break}}}_nextOp(t,i){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=i,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}};function TP(t,i,r){return 0===i?0:6*Math.pow(1.5,22-t)*Math.max(i,1)*(i<1&&514===r?.25/i:1)}function Tz(t,i){if(!t.style||!t.style.enable3dLights())return;let r=t.context,a=r.gl;r.activeTexture.set(a.TEXTURE1),i?i.bind(a.LINEAR,a.CLAMP_TO_EDGE):t.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE)}class TL extends vq{constructor(t){let i=b2("mock-dem",{type:"raster-dem",maxzoom:Math.ceil(t.transform.maxZoom)},t.style.dispatcher,t.style);super("mock-dem",i,null),i.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,i){t.state="loaded",i(null)}}class TO extends vq{constructor(t){let i=b2("proxy",{type:"geojson",maxzoom:Math.ceil(t.transform.maxZoom)},t.style.dispatcher,t.style);super("proxy",i,null),i.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,i,r){if(t.freezeTileCoverage)return;this.transform=t;let a=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((i,r)=>{if(i[r.key]="",!this._tiles[r.key]){let i=new xV(r,this._source.tileSize*r.overscaleFactor(),t.tileZoom,void 0,void 0,this._source.worldview);i.state="loaded",this._tiles[r.key]=i}return i},{});for(let t in this._tiles)t in a||(this.freeFBO(t),this._tiles[t].unloadVectorData(),delete this._tiles[t])}freeFBO(t){let i=this.proxyCachedFBO[t];if(void 0!==i){let r=Object.values(i);this.renderCachePool.push(...r),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach(t=>t.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class TF extends c0{constructor(t,i,r){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=i,this.projMatrix=r}}class TB extends _q{constructor(t,i){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};let[r,a,n]=function(){let t=new ll,i=new lR;t.reserve(17161),i.reserve(33800);for(let i=-64;i<8288;i+=64)for(let r=-64;r<8288;r+=64){let a=24575*(r<0||r>8224||i<0||i>8224),n=tL(Math.round(r),0,8192),o=tL(Math.round(i),0,8192);t.emplaceBack(n+a,o)}let r=(t,r)=>{let a=131*r+t;i.emplaceBack(a+1,a,a+131),i.emplaceBack(a+131,a+131+1,a+1)};for(let t=1;t<129;t++)for(let i=1;i<129;i++)r(i,t);return[0,129].forEach(t=>{for(let i=0;i<130;i++)r(i,t),r(t,i)}),[t,i,32768]}(),o=t.context;this.gridBuffer=o.createVertexBuffer(r,cs.members),this.gridIndexBuffer=o.createIndexBuffer(a),this.gridSegments=l9.simpleSegment(0,0,r.length,a.length),this.gridNoSkirtSegments=l9.simpleSegment(0,0,r.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new TO(i.map),this.orthoMatrix=ec(),eD(this.orthoMatrix,.015*("globe"===this.painter.transform.projection.name),8192,0,8192,0,1);let s=o.gl;this._overlapStencilMode=new g3({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new TL(i.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1,this._devtoolsFolder=null}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),this._style=t,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,i,r){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);let a=t.terrain.properties,n=0===t.terrain.drapeRenderMode,o=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=is.now();let s=t.terrain&&t.terrain.scope,l=a.get("source"),h=n?this._mockSourceCache:t.getSourceCache(l,s);if(!h)return void tX(`Couldn't find terrain source "${l}".`);if(this.sourceCache=h,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=o?this.calculateExaggeration(i):a.get("exaggeration"),!i.projection.requiresDraping&&o&&0===this._exaggeration)return void this._disable();this.enabled=!0;let u=()=>{this.sourceCache.used&&tX(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. 110This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);let t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),i.updateElevation(!0,r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom}else this._disable()}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);let i=this._previousCameraAltitude,r=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=r;
110let a=null!=i?r-i:Number.MAX_VALUE;if(2>Math.abs(a))return this._exaggeration;let n=t.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(n);let s=n-this._previousZoom,l=this._previousUpdateTimestamp,h=n;null!=this._evaluationZoom&&(Math.abs(n-(h=this._evaluationZoom))>.5&&(s=.5*(n-h+s)),s*a<0&&(h+=s)),this._evaluationZoom=h;let u=o.getExaggeration(h),c=u===o.getExaggeration(Math.max(0,h-.1));if(c&&.01>Math.abs(u-this._exaggeration))return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(c||u<.1||1e-4>Math.abs(s))&&(d=Math.min(.2,4*d)),rG(this._exaggeration,u,d)}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(t){"source"===t.dataType&&t.coord?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(let t in this._style._mergedSourceCaches)this._style._mergedSourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(t=>t.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){let t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;let i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(s8.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);let a=this.proxyCoords=i.getIds().map(t=>{let a=i.getTileByID(t).tileID;return a.projMatrix=r.calculateProjMatrix(a.toUnwrapped()),a});var n=this.painter;let o=n.transform.pointCoordinate(n.transform.getCameraPoint()),s=new tg(o.x,o.y);a.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;let r=new tg(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),a=new tg(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),n=s.mult(1<<t.canonical.z);return n.x-=.5,n.y-=.5,n.distSqr(r)-n.distSqr(a)});let l=this.proxyToSource||{};this.proxyToSource={},a.forEach(t=>{this.proxyToSource[t.key]={}}),this.terrainTileForTile={};let h=this._style._mergedSourceCaches;for(let i in h){let r=h[i];if(!r.used||!r.transform||(r!==this.sourceCache&&this.resetTileLookupCache(r.id),this._setupProxiedCoordsForOrtho(r,t[i],l),r.usedForTerrain))continue;let a=t[i];(r.getSource().reparseOverscaled||r._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(a)}this.proxiedCoords[i.id]=a.map(t=>new TF(t,t.key,this.orthoMatrix)),this._assignTerrainTiles(a),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(l),this.renderingToTexture=!1;let u={};for(let t of(this._visibleDemTiles=[],this.proxyCoords)){let i=this.terrainTileForTile[t.key];if(!i)continue;let r=i.tileID.key;r in u||(this._visibleDemTiles.push(i),u[r]=r)}}_assignTerrainTiles(t){this._initializing||t.forEach(t=>{if(this.terrainTileForTile[t.key])return;let i=this._findTileCoveringTileID(t,this.sourceCache);i&&(this.terrainTileForTile[t.key]=i)})}_prepareDEMTextures(){let t=this.painter.context,i=t.gl;for(let r in this.terrainTileForTile){let a=this.terrainTileForTile[r],n=a.dem;n&&(!a.demTexture||a.needsDEMTextureUpload)&&(t.activeTexture.set(i.TEXTURE1),w0(this.painter,a,n))}}_prepareDemTileUniforms(t,i,r,a){if(!i||null==i.demTexture)return!1;let n=t.tileID.canonical,o=Math.pow(2,i.tileID.canonical.z-n.z),s=a||"";return r[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],r[`u_dem_scale${s}`]=o,!0}
110get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let t=0,i=this._visibleDemTiles.reduce((i,r)=>{if(!r.dem)return i;let a=r.dem.tree.minimums[0];return a>0&&t++,i+a},0);return t?i/t:0}_updateEmptyDEMTexture(){let t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);let r=new ue({width:1,height:1},new Float32Array([this._getLoadedAreaMinimum()]));this._emptyDEMTextureDirty=!1;let a=this._emptyDEMTexture;return a?a.update(r,{premultiply:!1}):a=this._emptyDEMTexture=new uW(t,r,i.R32F,{premultiply:!1}),a}setupElevationDraw(t,i,r){var a;let n=this.painter.context,o=n.gl,s={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};s.u_exaggeration=this.exaggeration();let l=null,h=null,u=1;if(r&&r.morphing&&this._useVertexMorphing){let i=r.morphing.srcDemTile,a=r.morphing.dstDemTile;u=r.morphing.phase,i&&a&&(this._prepareDemTileUniforms(t,i,s,"_prev")&&(h=i),this._prepareDemTileUniforms(t,a,s)&&(l=a))}let c=t=>t&&t.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST,d=null;if(this.enabled?h&&l?(d=l.demTexture,n.activeTexture.set(o.TEXTURE4),h.demTexture.bind(c(h),o.CLAMP_TO_EDGE),s.u_dem_lerp=u):(l=this.terrainTileForTile[t.tileID.key],d=this._prepareDemTileUniforms(t,l,s)?l.demTexture:this.emptyDEMTexture):d=this.emptyDEMTexture,n.activeTexture.set(o.TEXTURE2),d&&(s.u_dem_size=1===(a=d).size[0]?1:a.size[0]-2,d.bind(c(l),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(r&&r.useDepthForOcclusion,i,s),r&&r.useMeterToDem&&l&&(s.u_meter_to_dem=(1<<l.tileID.canonical.z)*(1/s2(this.painter.transform.center.lat))*this.sourceCache.getSource().tileSize),r&&r.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=r.labelPlaneMatrixInv),i.setTerrainUniformValues(n,s),"globe"===this.painter.transform.projection.name){let a=this.globeUniformValues(this.painter.transform,t.tileID.canonical,r&&r.useDenormalizedUpVectorScale);i.setGlobeUniformValues(n,a)}}globeUniformValues(t,i,r){let a=t.projection;return{u_tile_tl_up:a.upVector(i,0,0),u_tile_tr_up:a.upVector(i,8192,0),u_tile_br_up:a.upVector(i,8192,8192),u_tile_bl_up:a.upVector(i,0,8192),u_tile_up_scale:r?cy(1):a.upVectorScale(i,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){let i=this.painter,r=this.painter.context;0!==t.length&&(r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),i.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,i,r,a,n){if("globe"===t.transform.projection.name)!function(t,i,r,a,n){let o,s,l=t.context,h=l.gl,u=t.transform,c=cU(t,0,u),d=(i,r)=>{if(s===r)return;let a=[];1===r&&a.push("TERRAIN_VERTEX_MORPHING"),a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("CUSTOM_ANTIALIASING");let n=t.isTileAffectedByFog(i);o=t.getOrCreateProgram("globeRaster",{defines:a,overrideFog:n}),s=r},p=t.colorModeForRenderPass(),f=new gz(h.LEQUAL,gz.ReadWrite,t.depthRangeFor3D);TD.update(n);let _=ck(u),m=[az(u.center.lng),aL(u.center.lat)],g=t.globeSharedBuffers,y=[u.width*is.devicePixelRatio,u.height*is.devicePixelRatio],x=Float32Array.from(u.globeMatrix),v={useDenormalizedUpVectorScale:!0};{let u=t.transform,c=TP(u.zoom,i.exaggeration(),i.sourceCache._source.tileSize);s=-1;let b=h.TRIANGLES;for(let s of a){let a=r.getTile(s),w=g3.disabled,T=i.prevTerrainTileForTile[s.key],E=i.terrainTileForTile[s.key];TR(T,E)&&TD.newMorphing(s.key,T,E,n,250),Tz(t,a.emissiveTexture),l.activeTexture.set(h.TEXTURE0),a.texture&&a.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE);let S=TD.getMorphValuesForProxy(s.key),I=+!!S;S&&Object.assign(v,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:tD(S.phase)}});let A=cC(s.canonical),C=cG(A.getCenter().lat),M=cj(s.canonical,A,C,u.worldSize/u._pixelsPerMercatorPixel),R=cz(cT(s.canonical)),D=+("mrt-fallback"===t.emissiveMode),P=TM(u.expandedFarZProjMatrix,x,_,R,cN(u.zoom),m,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,y,c,u._farZ,D,M);if(d(s,I),o&&(i.setupElevationDraw(a,o,v),t.uploadCommonUniforms(l,o,s.toUnwrapped()),g)){let[i,r,a]=g.getGridBuffers(C,0!==c);o.draw(t,b,f,w,p,gP.backCCW,P,"globe_raster",i,r,a)}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){let n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];for(let s of(c&&n.push("CUSTOM_ANTIALIASING"),o=t.getOrCreateProgram("globeRaster",{defines:n}),a)){let{x:a,y:n,z:c}=s.canonical,d=0===n,_=n===(1<<c)-1,[x,b,w,T]=g.getPoleBuffers(c,!1);if(T&&(d||_)){let n=r.getTile(s);Tz(t,n.emissiveTexture),l.activeTexture.set(h.TEXTURE0),n.texture&&n.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE);let g=cV(c,a,u),E=cz(cT(s.canonical)),S=+("mrt-fallback"===t.emissiveMode),I=(i,r)=>i.draw(t,h.TRIANGLES,f,g3.disabled,p,gP.disabled,TM(u.expandedFarZProjMatrix,g,g,E,0,m,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,y,0,u._farZ,S),"globe_pole_raster",r,w,T);i.setupElevationDraw(n,o,v),t.uploadCommonUniforms(l,o,s.toUnwrapped()),d&&t.renderDefaultNorthPole&&I(o,x),_&&t.renderDefaultSouthPole&&(g=ex(ec(),g,[1,-1,1]),I(o,b))}}}}(t,i,r,a,n);else{let o,s,l=t.context,h=l.gl,u=t.shadowRenderer,c=g2(t,t.longestCutoffRange),d=i=>{if(s===i)return;let r=[];1===i&&r.push("TERRAIN_VERTEX_MORPHING"),c.shouldRenderCutoff&&r.push("RENDER_CUTOFF"),u&&(r.push("RENDER_SHADOWS"),u.useNormalOffset&&r.push("NORMAL_OFFSET")),o=t.getOrCreateProgram("terrainRaster",{defines:r}),s=i},p=t.colorModeForRenderPass(),f=new gz(h.LEQUAL,gz.ReadWrite,t.depthRangeFor3D);TD.update(n);let _=t.transform,m=TP(_.zoom,i.exaggeration(),i.sourceCache._source.tileSize),g=[0,0,0];if(u){let i=t.style.directionalLight,r=t.style.ambientLight;i&&r&&(g=yn(t.style,i,r))}{s=-1;let y=h.TRIANGLES,[x,v]=[i.gridIndexBuffer,i.gridSegments];for(let s of a){let a,b=r.getTile(s),w=g3.disabled,T=i.prevTerrainTileForTile[s.key],E=i.terrainTileForTile[s.key];
110TR(T,E)&&TD.newMorphing(s.key,T,E,n,250),Tz(t,b.emissiveTexture),l.activeTexture.set(h.TEXTURE0),b.texture&&b.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE);let S=TD.getMorphValuesForProxy(s.key),I=+!!S;S&&(a={morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:tD(S.phase)}});let A=+("mrt-fallback"===t.emissiveMode),C=TC(s.projMatrix,!function(t,i){let r=1<<t.z;return!i&&(0===t.x||t.x===r-1)||0===t.y||t.y===r-1}(s.canonical,_.renderWorldCopies)?m:m/10,g,A);if(d(I),!o)continue;i.setupElevationDraw(b,o,a);let M=s.toUnwrapped();u&&u.setupShadows(M,o),t.uploadCommonUniforms(l,o,M,null,c),o.draw(t,y,f,w,p,gP.backCCW,C,"terrain_raster",i.gridBuffer,x,v)}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;let i=this.painter,r=this.painter.context,a=this.proxySourceCache,n=this.proxiedCoords[a.id],o=this._drapedRenderBatches.shift(),s=i.style.order,l=[];this._updateFBOs("mrt-fallback"===i.emissiveMode);let h=0;for(let u of n){let n,c=a.getTileByID(u.proxyTileKey),d=a.proxyCachedFBO[u.key]?a.proxyCachedFBO[u.key][t]:void 0,p=void 0!==d?a.renderCache[d]:this.pool[h++],f=void 0!==d;if(c.texture=p.tex,c.emissiveTexture=p.emissiveTex,f&&!p.dirty){l.push(c.tileID);continue}r.bindFramebuffer.set(p.fb.framebuffer);let _=r.gl;_.drawBuffers("mrt-fallback"===i.emissiveMode?[_.COLOR_ATTACHMENT0,_.COLOR_ATTACHMENT1]:[_.COLOR_ATTACHMENT0]),this.renderedToTile=!1,p.dirty&&(r.clear({color:rq.transparent,stencil:0}),p.dirty=!1);for(let t=o.start;t<=o.end;++t){let a=i.style._mergedLayers[s[t]];if(a.isHidden(i.transform.zoom))continue;let o=i.style.getLayerSourceCache(a),l=o?this.proxyToSource[u.key][o.id]:[u];l&&(r.viewport.set([0,0,p.fb.width,p.fb.height]),n!==(o?o.id:null)&&(this._setupStencil(p,l,a,o),n=o?o.id:null),i.renderLayer(i,o,a,l))}if(_.drawBuffers([_.COLOR_ATTACHMENT0]),0===this._drapedRenderBatches.length)for(let t of this._pendingGroundEffectLayers){let a=i.style._mergedLayers[s[t]];if(a.isHidden(i.transform.zoom))continue;let o=i.style.getLayerSourceCache(a),l=o?this.proxyToSource[u.key][o.id]:[u];l&&(r.viewport.set([0,0,p.fb.width,p.fb.height]),n!==(o?o.id:null)&&(this._setupStencil(p,l,a,o),n=o?o.id:null),i.renderLayer(i,o,a,l))}this.renderedToTile?(p.dirty=!0,l.push(c.tileID)):f||--h,5===h&&(h=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),o.end+1}postRender(){}isLayerOrderingCorrect(t){let i=t.order.length,r=-1,a=i;for(let n=0;n<i;++n)this._style.isLayerDraped(t._mergedLayers[t.order[n]])?r=Math.max(r,n):a=Math.min(a,n);return a>r}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter(t=>t.dem).forEach(i=>{t=Math.min(t,i.dem.tree.minimums[0])}),0===t?t:(t-30)*this._exaggeration}raycast(t,i,r){if(!this._visibleDemTiles)return null;let a=this._visibleDemTiles.filter(t=>t.dem).map(a=>{let n=a.tileID,o=1<<n.overscaledZ,{x:s,y:l}=n.canonical,h=s/o,u=(s+1)/o,c=l/o,d=(l+1)/o;return{minx:h,miny:c,maxx:u,maxy:d,t:a.dem.tree.raycastRoot(h,c,u,d,t,i,r),tile:a}});for(let n of(a.sort((t,i)=>(null!==t.t?t.t:Number.MAX_VALUE)-(null!==i.t?i.t:Number.MAX_VALUE)),a)){if(null==n.t)break;let a=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,t,i,r);if(null!=a)return a}return null}_createFBO(){let t,i=this.painter.context,r=i.gl,a=this.drapeBufferSize;i.activeTexture.set(r.TEXTURE0);let n=new uW(i,{width:a[0],height:a[1],data:null},r.RGBA8);n.bind(r.LINEAR,r.CLAMP_TO_EDGE);let o=i.createFramebuffer(a[0],a[1],1,null);return o.colorAttachment0.set(n.texture),this._emissiveTexture&&((t=new uW(i,{width:a[0],height:a[1],data:null},r.R8)).bind(r.LINEAR,r.CLAMP_TO_EDGE),o.createColorAttachment(i,1),o.colorAttachment1.set(t.texture)),o.depthAttachment=new TA(i,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=i.createRenderbuffer(i.gl.DEPTH_STENCIL,a[0],a[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),i.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),i.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax),{fb:o,tex:n,emissiveTex:t,dirty:!1}}_updateFBOs(t){if(this._emissiveTexture!==t){for(let i of this.pool)this._updateFBO(i,t);for(let i of this.proxySourceCache.renderCache)this._updateFBO(i,t);this._emissiveTexture=t}}_updateFBO(t,i){let r=t.fb,a=this.painter.context,n=a.gl,o=this.drapeBufferSize;
110if(i){let i=new uW(a,{width:o[0],height:o[1],data:null},n.R8);i.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.emissiveTex=i,r.createColorAttachment(a,1),r.colorAttachment1.set(i.texture)}else t.emissiveTex=void 0,r.removeColorAttachment(a,1);t.dirty=!0}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.hasLightTransitions())return!0;for(let t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t].hasTransition())return!0;return this._style.order.some(t=>{let i=this._style._mergedLayers[t],r=i.isHidden(this.painter.transform.zoom);return"hillshade"===i.type||"custom"===i.type?!r&&i.shouldRedrape():!r&&i.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(let i of this._style.getSources())if(i instanceof bN){t=!0;break}if(!t)return;let i={};for(let t=0;t<this._style.order.length;++t){let r=this._style._mergedLayers[this._style.order[t]],a=this._style.getLayerSourceCache(r);if(!a||i[a.id]||r.isHidden(this.painter.transform.zoom)||"line"!==r.type)continue;let n=r.widthExpression(),o=r.emissiveStrengthExpression();if(n instanceof oT||o instanceof oT)for(let t of(i[a.id]=!0,this.proxyCoords)){let i=this.proxyToSource[t.key][a.id];if(i)for(let t of i)this._clearRenderCacheForTile(a.id,t)}}}_clearRasterLayersFromRenderCache(){let t=!1;for(let i in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[i]._source instanceof vb){t=!0;break}if(!t)return;let i={};for(let t=0;t<this._style.order.length;++t){let r=this._style._mergedLayers[this._style.order[t]],a=this._style.getLayerSourceCache(r);if(!a||i[a.id]||r.isHidden(this.painter.transform.zoom)||"raster"!==r.type)continue;let n=r.paint.get("raster-fade-duration");for(let t of this.proxyCoords){let i=this.proxyToSource[t.key][a.id];if(i)for(let t of i){let i=vS(a.getTile(t),a.findLoadedParent(t,0),a,this.painter.transform,n);(1!==i.opacity||0!==i.mix)&&this._clearRenderCacheForTile(a.id,t)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();let t=this._style.order,i=t.length;if(0===i)return;let r=[];this._pendingGroundEffectLayers=[];let a,n=0,o=this._style._mergedLayers[t[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<i;)o=this._style._mergedLayers[t[n]];for(;n<i;++n){let i=this._style._mergedLayers[t[n]];i.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(i)?void 0===a&&(a=n):("fill-extrusion"===i.type&&this._pendingGroundEffectLayers.push(n),void 0!==a&&(r.push({start:a,end:n-1}),a=void 0)))}if(void 0!==a&&r.push({start:a,end:n-1}),0!==r.length){let t=r.at(-1);this._pendingGroundEffectLayers.every(i=>i>t.end)||tX("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=r}_setupRenderCache(t){let i=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,i.renderCache.length>i.renderCachePool.length){let t=Object.values(i.proxyCachedFBO);i.proxyCachedFBO={};for(let r=0;r<t.length;++r){let a=Object.values(t[r]);i.renderCachePool.push(...a)}}return}this._clearRasterLayersFromRenderCache();let r=this.proxyCoords,a=this._tilesDirty;for(let n=r.length-1;n>=0;n--){let o=r[n];if(i.getTileByID(o.key),void 0!==i.proxyCachedFBO[o.key]){let r=t[o.key],n=this.proxyToSource[o.key],s=0;for(let t in n){let i=n[t],o=r[t];if(!o||o.length!==i.length||i.some((i,r)=>i!==o[r]||a[t]&&Object.hasOwn(a[t],i.key))){s=-1;break}++s}for(let t in i.proxyCachedFBO[o.key])i.renderCache[i.proxyCachedFBO[o.key][t]].dirty=s<0||s!==Object.values(r).length}}let n=[...this._drapedRenderBatches];for(let t of(n.sort((t,i)=>i.end-i.start-(t.end-t.start)),n))for(let a of r){if(i.proxyCachedFBO[a.key])continue;let r=i.renderCachePool.pop();void 0===r&&i.renderCache.length<50&&(r=i.renderCache.length,i.renderCache.push(this._createFBO())),void 0!==r&&(i.proxyCachedFBO[a.key]={},i.proxyCachedFBO[a.key][t.start]=r,i.renderCache[r].dirty=!0)}this._tilesDirty={}}_setupStencil(t,i,r,a){let n;if(!a||!this._sourceTilesOverlap[a.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));let o=this.painter.context,s=o.gl;if(i.length<=1)return void(this._overlapStencilType=!1);if(r.isTileClipped())n=i.length,this._overlapStencilMode.test={func:s.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(i[0].overscaledZ>
110i.at(-1).overscaledZ))return void(this._overlapStencilType=!1);n=1,this._overlapStencilMode.test={func:s.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+n>255&&(o.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=n,this._overlapStencilMode.ref=this._stencilRef,r.isTileClipped()&&this._renderTileClippingMasks(i,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):g3.disabled}_renderTileClippingMasks(t,i){let r=this.painter,a=this.painter.context,n=a.gl;r._tileClippingMaskIDs={},a.setColorMode(g6.disabled),a.setDepthMode(gz.disabled);let o=r.getOrCreateProgram("clippingMask");for(let a of t){let t=r._tileClippingMaskIDs[a.key]=--i;o.draw(r,n.TRIANGLES,gz.disabled,new g3({func:n.ALWAYS,mask:0},t,255,n.KEEP,n.KEEP,n.REPLACE),g6.disabled,gP.disabled,bt(a.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(t){let i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;let r=[t.x,t.y,1,1];e9(r,r,i.pixelMatrixInverse),e6(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;let a=i._camera.position,n=1/s2(i.center.lat),o=[a[0],a[1],a[2]/n,0],s=ek([],r.slice(0,3),o);eW(s,s);let l=this.raycast(o,s,this._exaggeration);return null!==l&&l?(eG(o,o,s,l),o[3]=o[2],o[2]*=n,o):null}_setupProxiedCoordsForOrtho(t,i,r){if(t.getSource()instanceof b0)return this._setupProxiedCoordsForImageSource(t,i,r);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};let a=this.proxiedCoords[t.id]=[],n=this.proxyCoords;for(let i=0;i<n.length;i++){let o=n[i],s=this._findTileCoveringTileID(o,t);if(s){let i=this._createProxiedId(o,s,r[o.key]&&r[o.key][t.id]);a.push(i),this.proxyToSource[o.key][t.id]=[i]}}let o=!1,s=new Set;for(let n=0;n<i.length;n++){let l=t.getTile(i[n]);if(!l||!l.hasData())continue;let h=this._findTileCoveringTileID(l.tileID,this.proxySourceCache);if(h&&h.tileID.canonical.z!==l.tileID.canonical.z){let i=this.proxyToSource[h.tileID.key][t.id],n=this._createProxiedId(h.tileID,l,r[h.tileID.key]&&r[h.tileID.key][t.id]);i?i.splice(i.length-1,0,n):this.proxyToSource[h.tileID.key][t.id]=[n];let u=this.proxyToSource[h.tileID.key][t.id];s.has(u)||s.add(u),a.push(n),o=!0}}if(this._sourceTilesOverlap[t.id]=o,o)for(let t of s)t.sort((t,i)=>i.overscaledZ-t.overscaledZ)}_setupProxiedCoordsForImageSource(t,i,r){if(!t.getSource().loaded())return;let a=this.proxiedCoords[t.id]=[],n=this.proxyCoords,o=t.getSource(),s=o.tileID;if(!s)return;let l=new tg(s.x,s.y)._div(1<<s.z),h=o.coordinates.map(s8.fromLngLat).reduce((t,i)=>(t.min.x=Math.min(t.min.x,i.x-l.x),t.min.y=Math.min(t.min.y,i.y-l.y),t.max.x=Math.max(t.max.x,i.x-l.x),t.max.y=Math.max(t.max.y,i.y-l.y),t),{min:new tg(Number.MAX_VALUE,Number.MAX_VALUE),max:new tg(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,i)=>{let r=t.wrap+t.canonical.x/(1<<t.canonical.z),a=t.canonical.y/(1<<t.canonical.z),n=8192/(1<<t.canonical.z),o=i.wrap+i.canonical.x/(1<<i.canonical.z),s=i.canonical.y/(1<<i.canonical.z);return r+n<o+h.min.x||r>o+h.max.x||a+n<s+h.min.y||a>s+h.max.y};for(let o=0;o<n.length;o++){let s=n[o];for(let n=0;n<i.length;n++){let o=t.getTile(i[n]);if(!o||!o.hasData()||u(s,o.tileID))continue;let l=this._createProxiedId(s,o,r[s.key]&&r[s.key][t.id]),h=this.proxyToSource[s.key][t.id];h?h.push(l):this.proxyToSource[s.key][t.id]=[l],a.push(l)}}}_createProxiedId(t,i,r){let a=this.orthoMatrix;if(r){let t=r.find(t=>t.key===i.tileID.key);if(t)return t}if(i.tileID.key!==t.key){let r,n,o,s=t.canonical.z-i.tileID.canonical.z;a=ec();let l=i.tileID.wrap-t.wrap<<t.overscaledZ;s>0?(n=(r=8192>>s)*((i.tileID.canonical.x<<s)-t.canonical.x+l),o=r*((i.tileID.canonical.y<<s)-t.canonical.y)):(r=8192<<-s,n=8192*(i.tileID.canonical.x-(t.canonical.x+l<<-s)),o=8192*(i.tileID.canonical.y-(t.canonical.y<<-s))),eD(a,0,r,0,r,0,1),ey(a,a,[n,o,0])}return new TF(i.tileID,t.key,a)}_findTileCoveringTileID(t,i){let r=i.getTile(t);if(r&&r.hasData())return r;let a=this._findCoveringTileCache[i.id],n=a[t.key];if((r=n?i.getTileByID(n):null)&&r.hasData()||null===n)return r;let o=r?r.tileID:t,s=o.overscaledZ,l=i.getSource().minzoom,h=[];if(!n){let a=i.getSource().maxzoom;if(t.canonical.z>=a){let r=t.canonical.z-a;i.getSource().reparseOverscaled?o=new c0(s=Math.max(t.canonical.z+2,i.transform.tileZoom),t.wrap,a,t.canonical.x>>r,t.canonical.y>>r):0!==r&&(o=new c0(s=a,t.wrap,a,t.canonical.x>>r,t.canonical.y>>r))}
110o.key!==t.key&&(h.push(o.key),r=i.getTile(o))}let u=t=>{h.forEach(i=>{a[i]=t}),h.length=0};for(s-=1;s>=l&&(!r||!r.hasData());s--){r&&u(r.tileID.key);let t=o.calculateScaledKey(s);if((r=i.getTileByID(t))&&r.hasData())break;let n=a[t];if(null===n)break;void 0===n?h.push(t):r=i.getTileByID(n)}return u(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,i){let r=this._tilesDirty[t];r||(r=this._tilesDirty[t]={}),r[i.key]=!0}}let Tk=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],TN=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class TV{static cacheKey(t,i,r,a){let n=[i];for(let i of(a&&n.push(a.cacheKey),r))("string"==typeof i&&i.includes(" ")||t.usedDefines.has(i))&&n.push(i);return n.join("/")}constructor(t,i,r,a,n,o,s=!1){let l=t.gl;this.program=l.createProgram(),this._context=t,this._fixedUniformsFn=n,this._pending=!0,this._precompiled=s,this.attributes={},this.configuration=a,this.name=i,this.fixedDefines=[...o],s?t._compileStats.precompiled++:t._compileStats.onDemand++;let h=`#version 300 es 111${(a?a.defines():[]).concat(o.map(t=>`#define ${t}`)).join("\n")}`,u=[h,y1];for(let t of r.fragmentIncludes)u.push(yX[t]);u.push(r.fragmentSource);let c=u.join("\n"),d=[h,y2];for(let t of r.vertexIncludes)d.push(yX[t]);this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&r.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&d.push("uniform int u_instanceID;"),d.push(r.vertexSource);let p=d.join("\n");this.forceManualRenderingForInstanceIDShaders&&(p=p.replaceAll("gl_InstanceID","u_instanceID"));let f=l.createShader(l.FRAGMENT_SHADER);if(l.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);l.shaderSource(f,c),l.compileShader(f),l.attachShader(this.program,f);let _=l.createShader(l.VERTEX_SHADER);if(l.isContextLost())return this.failedToCreate=!0,void(this._pending=!1);l.shaderSource(_,p),l.compileShader(_),l.attachShader(this.program,_),l.linkProgram(this.program),this._fragmentShader=f,this._vertexShader=_,t.extParallelShaderCompile?t._pendingPrograms.add(this):this._finalize()}_finalize(){if(!this._pending)return;this._pending=!1;let t=this._context,i=t.gl;t._pendingPrograms.delete(this);let r=is.now(),a=i.getProgramParameter(this.program,i.LINK_STATUS),n=is.now()-r,o=t._compileStats;if(o.totalStallMs+=n,n>o.maxStallMs&&(o.maxStallMs=n),n>1){o.framesMissed+=Math.floor(60*n/1e3);let t=this.fixedDefines.join(",");o.stalls.push({name:`${this.name}${t?"/":""}${t}`,ms:n,timestamp:r})}if(this._fragmentShader&&(a||tX(`Fragment shader '${this.name}': ${i.getShaderInfoLog(this._fragmentShader)}`),i.deleteShader(this._fragmentShader),this._fragmentShader=null),this._vertexShader&&(a||tX(`Vertex shader '${this.name}': ${i.getShaderInfoLog(this._vertexShader)}`),i.deleteShader(this._vertexShader),this._vertexShader=null),!a)return tX(`Failed to link program '${this.name}': ${i.getProgramInfoLog(this.program)}`),void(this.failedToCreate=!0);this.fixedUniforms=this._fixedUniformsFn(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=this.configuration?this.configuration.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms={u_instanceID:new hs(t)});let s=this.fixedDefines,l=this.name;(s.includes("TERRAIN")||s.includes("ELEVATED")||l.includes("symbol")||l.includes("circle"))&&(this.terrainUniforms={u_dem:new hs(t),u_dem_prev:new hs(t),u_dem_tl:new hh(t),u_dem_scale:new hl(t),u_dem_tl_prev:new hh(t),u_dem_scale_prev:new hl(t),u_dem_size:new hl(t),u_dem_lerp:new hl(t),u_exaggeration:new hl(t),u_depth:new hs(t),u_depth_size_inv:new hh(t),u_depth_range_unpack:new hh(t),u_occluder_half_size:new hl(t),u_occlusion_depth_offset:new hl(t),u_meter_to_dem:new hl(t),u_label_plane_matrix_inv:new hf(t)}),s.includes("GLOBE")&&(this.globeUniforms={u_tile_tl_up:new hu(t),u_tile_tr_up:new hu(t),u_tile_br_up:new hu(t),u_tile_bl_up:new hu(t),u_tile_up_scale:new hl(t)}),s.includes("FOG")&&(this.fogUniforms={u_fog_matrix:new hf(t),u_fog_range:new hh(t),u_fog_color:new hd(t),u_fog_horizon_blend:new hl(t),u_fog_vertical_limit:new hh(t),u_fog_temporal_offset:new hl(t),u_frustum_tl:new hu(t),u_frustum_tr:new hu(t),u_frustum_br:new hu(t),u_frustum_bl:new hu(t),u_globe_pos:new hu(t),u_globe_radius:new hl(t),u_globe_transition:new hl(t),u_is_globe:new hs(t),u_viewport:new hh(t)}),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms={u_cutoff_params:new hd(t)}),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms={u_lighting_ambient_color:new hu(t),u_lighting_directional_dir:new hu(t),u_lighting_directional_color:new hu(t),u_ground_radiance:new hu(t)}),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms={u_light_matrix_0:new hf(t),u_light_matrix_1:new hf(t),u_fade_range:new hh(t),u_shadow_normal_offset:new hu(t),u_shadow_intensity:new hl(t),u_shadow_texel_size:new hl(t),u_shadow_map_resolution:new hl(t),u_shadow_direction:new hu(t),u_shadow_bias:new hu(t),u_shadowmap_0:new hs(t),u_shadowmap_1:new hs(t)})}
111maybeFinalize(){if(!this._pending)return;let t=this._context.extParallelShaderCompile;t&&!this._context.gl.getProgramParameter(this.program,t.COMPLETION_STATUS_KHR)||this._finalize()}_ensureReady(){this._pending&&(this._finalize(),this._context.sweepPendingPrograms())}getAttributeLocation(t,i){this._ensureReady();let r=this.attributes[i];return void 0===r&&(r=this.attributes[i]=t.getAttribLocation(this.program,i)),r}setTerrainUniformValues(t,i){if(this._ensureReady(),!this.terrainUniforms)return;let r=this.terrainUniforms;if(!this.failedToCreate)for(let a in t.program.set(this.program),i)r[a]&&r[a].set(this.program,a,i[a])}setGlobeUniformValues(t,i){if(this._ensureReady(),!this.globeUniforms)return;let r=this.globeUniforms;if(!this.failedToCreate)for(let a in t.program.set(this.program),i)r[a]&&r[a].set(this.program,a,i[a])}setFogUniformValues(t,i){if(this._ensureReady(),!this.fogUniforms)return;let r=this.fogUniforms;if(!this.failedToCreate)for(let a in t.program.set(this.program),i)r[a].set(this.program,a,i[a])}setCutoffUniformValues(t,i){if(this._ensureReady(),!this.cutoffUniforms)return;let r=this.cutoffUniforms;if(!this.failedToCreate)for(let a in t.program.set(this.program),i)r[a].set(this.program,a,i[a])}setLightsUniformValues(t,i){if(this._ensureReady(),!this.lightsUniforms)return;let r=this.lightsUniforms;if(!this.failedToCreate)for(let a in t.program.set(this.program),i)r[a].set(this.program,a,i[a])}setShadowUniformValues(t,i){if(this._ensureReady(),this.failedToCreate||!this.shadowUniforms)return;let r=this.shadowUniforms;for(let a in t.program.set(this.program),i)r[a].set(this.program,a,i[a])}_drawDebugWireframe(t,i,r,a,n,o,s,l,h,u){let c=t.options.wireframe;if(!1===c.terrain&&!1===c.layers2D&&!1===c.layers3D)return;let d=t.context;if(!(!(!c.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!c.layers2D||t._terrain&&t._terrain.renderingToTexture||!Tk.includes(this.name))||!(!c.layers3D||!TN.includes(this.name))))return;let p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,n,d);if(!f)return;let _=[...this.fixedDefines,"DEBUG_WIREFRAME"],m=t.getOrCreateProgram(this.name,{config:this.configuration,defines:_});m._ensureReady(),d.program.set(m.program);let g=(t,i,r)=>{if(i[t]&&r[t])for(let a in i[t])r[t][a]&&r[t][a].set(r.program,a,i[t][a].current)};h&&h.setUniforms(m.program,d,m.binderUniforms,s,{zoom:l}),g("fixedUniforms",this,m),g("terrainUniforms",this,m),g("globeUniforms",this,m),g("fogUniforms",this,m),g("lightsUniforms",this,m),g("shadowUniforms",this,m),f.bind(),d.setColorMode(new g6([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],rq.transparent,[!0,!0,!0,!1])),d.setDepthMode(new gz(i.func===p.LESS?p.LEQUAL:i.func,gz.ReadOnly,i.range)),d.setStencilMode(g3.disabled);let y=3*o.primitiveLength*2,x=3*o.primitiveOffset*4;if(this.forceManualRenderingForInstanceIDShaders){let t=u||1;for(let i=0;i<t;++i)m.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",i),p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,x)}else u&&u>1?p.drawElementsInstanced(p.LINES,y,p.UNSIGNED_SHORT,x,u):p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,x);n.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(r),d.setColorMode(a)}checkUniforms(t,i,r){if(this.fixedDefines.includes(i)){for(let a of Object.keys(r))if(!r[a].initialized)throw Error(`Program '${this.name}', from draw '${t}': uniform ${a} not set but required by ${i} being defined`)}}draw(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m){let g=t.context,y=g.gl;if(this._ensureReady(),this.failedToCreate)return;for(let[t,i]of(g.program.set(this.program),g.setDepthMode(r),g.setStencilMode(a),g.setColorMode(n),g.setCullFace(o),this.fixedUniformsEntries))i.set(this.program,t,s[t]);f&&f.setUniforms(this.program,g,this.binderUniforms,d,{zoom:p});let x={[y.POINTS]:1,[y.LINES]:2,[y.TRIANGLES]:3,[y.LINE_STRIP]:1}[i];this.checkUniforms(l,"RENDER_SHADOWS",this.shadowUniforms);let v=_||[],b=f?f.getPaintVertexBuffers():[],w=i===y.TRIANGLES&&u,T=m&&m>0?1:void 0;for(let o of c.get()){let s=o.vaos||(o.vaos={});if((s[l]||(s[l]=new wJ)).bind(g,this,h,b,u,o.vertexOffset,v,T),this.forceManualRenderingForInstanceIDShaders){let t=m||1;for(let r=0;r<t;++r)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",r),u?y.drawElements(i,o.primitiveLength*x,y.UNSIGNED_SHORT,o.primitiveOffset*x*2):y.drawArrays(i,o.vertexOffset,o.vertexLength)}else m&&m>1?y.drawElementsInstanced(i,o.primitiveLength*x,y.UNSIGNED_SHORT,o.primitiveOffset*x*2,m):u?y.drawElements(i,o.primitiveLength*x,y.UNSIGNED_SHORT,o.primitiveOffset*x*2):y.drawArrays(i,o.vertexOffset,o.vertexLength);w&&this._drawDebugWireframe(t,r,a,n,u,o,d,p,f,m)}}}let TU=(t,i,r)=>({u_matrix:t,u_emissive_strength:i,u_ground_shadow_factor:r,u_opacity_multiplier:1}),Tj=(t,i,r,a,n,o=0)=>Object.assign(TU(t,i,n),g8(r,a,o)),TG=(t,i,r,a)=>({u_matrix:t,u_world:r,u_emissive_strength:i,u_ground_shadow_factor:a,u_opacity_multiplier:1}),TH=(t,i,r,a,n,o,s=0)=>Object.assign(Tj(t,i,r,a,o,s),{u_world:n}),Tq=(t,i,r)=>({u_image:t,u_texel_size:i,u_first_pass:+!!r}),TZ=(t,i,r,a,n,o,s,l)=>{let h=8192/o.tileSize;return{u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:r.getCameraToCenterDistance(l),u_extrude_scale:[r.pixelsToGLUnits[0]/h,r.pixelsToGLUnits[1]/h],u_zoom_transition:a,u_tile_id:s,u_merc_center:n}},T$=(t,i,r,a)=>({u_matrix:t,u_inv_matrix:i,u_camera_to_center_distance:r.getCameraToCenterDistance(a),u_viewport_size:[r.width,r.height]}),TW=ec(),TX=(t,i,r,a,n,o,s)=>{let l=t.transform,h="globe"===l.projection.name,u=h?cF(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:_S(r,1,o),c={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:s,u_inv_rot_matrix:TW,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(h){c.u_inv_rot_matrix=a,c.u_merc_center=n,c.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],c.u_zoom_transition=cN(l.zoom);let t=8192*n[0],r=8192*n[1];c.u_up_dir=l.projection.upVector(new cQ(0,0,0),t,r)}return c},TY=(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w)=>({u_matrix:i,u_normalize_matrix:r,u_globe_matrix:a,u_merc_matrix:n,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:c,u_fade_t:d.mix,u_opacity:d.opacity*p.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:p.paint.get("raster-brightness-min"),u_brightness_high:
111p.paint.get("raster-brightness-max"),u_saturation_factor:it(p.paint.get("raster-saturation")),u_contrast_factor:ie(p.paint.get("raster-contrast")),u_spin_weights:function(t){let i=Math.sin(t*=Math.PI/180),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*i-r+1)/3,(Math.sqrt(3)*i-r+1)/3]}(p.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:_,u_zoom_transition:l,u_merc_center:h,u_cutoff_params:u,u_colorization_mix:xI(1024,g,x),u_colorization_offset:xA(1024,y,x),u_color_ramp:m,u_texture_offset:[b/(v+2*b),v/(v+2*b)],u_texture_res:[v+2*b,v+2*b],u_emissive_strength:w,u_zbias_factor:function(t){let i=t.terrain?t.terrain.exaggeration():1;return(t.transform.pitch<15?rG(.07,.7,tL((14-t.transform.zoom)/5,0,1)):.07)*i}(t)}),TK=ec(),TQ=(t,i,r,a,n,o,s,l,h,u,c,d,p,f,_,m,g,y,x,v,b,w,T,E,S)=>{let I=n.transform,A={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:I.getCameraToCenterDistance(v),u_rotate_symbol:+r,u_aspect_ratio:I.width/I.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+u,u_is_sdf:+c,u_elevation_from_sea:+!!h,u_pitch_with_map:+a,u_texsize:d,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:TK,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:TK,u_up_vector:[0,-1,0],u_color_adj_mat:T,u_icon_transition:E||0,u_gamma_scale:c?a?n.transform.getCameraToCenterDistance(v)*Math.cos(n.terrain?0:n.transform._pitch):1:0,u_device_pixel_ratio:is.devicePixelRatio,u_is_halo:1,u_scale_factor:S||1,u_ground_shadow_factor:b,u_inv_matrix:em(ec(),s),u_normal_scale:w,u_lutTexture:10,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_fill_color_zoom_factor:0,u_spp_halo_color_zoom_factor:0,u_spp_opacity_zoom_factor:0,u_spp_halo_width_zoom_factor:0,u_spp_halo_blur_zoom_factor:0,u_spp_emissive_strength_zoom_factor:0,u_spp_occlusion_opacity_zoom_factor:0,u_spp_z_offset_zoom_factor:0,u_spp_translate_zoom_factor:0,u_spp_zoom_fraction:0,u_opacity_multiplier:1};return"globe"===v.name&&(A.u_tile_id=[_.canonical.x,_.canonical.y,1<<_.canonical.z],A.u_zoom_transition=m,A.u_inv_rot_matrix=y,A.u_merc_center=g,A.u_camera_forward=I._camera.forward(),A.u_ecef_origin=function(t,i){let r=[0,0,0];return eQ(r,r,cz(cT(i.canonical))),eQ(r,r,t),r}(I.globeMatrix,_.toUnwrapped()),A.u_tile_matrix=I.globeMatrix,A.u_up_vector=x),A},TJ=(t,i,r,a)=>({u_matrix:t,u_emissive_strength:i,u_opacity:r,u_color:a}),T0=(t,i,r,a,n,o,s,l,h)=>Object.assign(function(t,i,r,a,n,o){let{width:s,height:l}=a.imageManager.getPixelSize(i),h=Math.pow(2,o.tileID.overscaledZ),u=o.tileSize*Math.pow(2,a.transform.tileZoom)/h,c=u*(o.tileID.canonical.x+o.tileID.wrap*h),d=u*o.tileID.canonical.y;return{u_image:0,u_pattern_tl:r.tl,u_pattern_br:r.br,u_texsize:[s,l],u_pattern_size:r.displaySize,u_pattern_units_to_pixels:n?[a.transform.width,-1*a.transform.height]:[1/_S(o,1,a.transform.tileZoom),1/_S(o,1,a.transform.tileZoom)],u_pixel_coord_upper:[c>>16,d>>16],u_pixel_coord_lower:[65535&c,65535&d]}}(0,o,s,a,l,h),{u_matrix:t,u_emissive_strength:i,u_opacity:r}),T1={fillExtrusion:t=>({u_matrix:new hf(t),u_lightpos:new hu(t),u_lightintensity:new hl(t),u_lightcolor:new hu(t),u_vertical_gradient:new hl(t),u_opacity:new hl(t),u_edge_radius:new hl(t),u_width_scale:new hl(t),u_ao:new hh(t),u_height_type:new hs(t),u_base_type:new hs(t),u_tile_id:new hu(t),u_zoom_transition:new hl(t),u_inv_rot_matrix:new hf(t),u_merc_center:new hh(t),u_up_dir:new hu(t),u_height_lift:new hl(t),u_flood_light_color:new hu(t),u_vertical_scale:new hl(t),u_flood_light_intensity:new hl(t),u_ground_shadow_factor:new hu(t),u_front_cutoff_params:new hu(t)}),fillExtrusionPattern:t=>({u_matrix:new hf(t),u_lightpos:new hu(t),u_lightintensity:new hl(t),u_lightcolor:new hu(t),u_vertical_gradient:new hl(t),u_height_factor:new hl(t),u_edge_radius:new hl(t),u_width_scale:new hl(t),u_ao:new hh(t),u_height_type:new hs(t),u_base_type:new hs(t),u_tile_id:new hu(t),u_zoom_transition:new hl(t),u_inv_rot_matrix:new hf(t),u_merc_center:new hh(t),u_up_dir:new hu(t),u_height_lift:new hl(t),u_image:new hs(t),u_texsize:new hh(t),u_pixel_coord_upper:new hh(t),u_pixel_coord_lower:new hh(t),u_tile_units_to_pixels:new hl(t),u_opacity:new hl(t),u_pattern_transition:new hl(t)}),fill:t=>({u_matrix:new hf(t),u_emissive_strength:new hl(t),u_ground_shadow_factor:new hu(t),u_opacity_multiplier:new hl(t)}),fillPattern:t=>({u_matrix:new hf(t),u_emissive_strength:new hl(t),u_image:new hs(t),u_texsize:new hh(t),u_pixel_coord_upper:new hh(t),u_pixel_coord_lower:new hh(t),u_tile_units_to_pixels:new hl(t),u_ground_shadow_factor:new hu(t),u_pattern_transition:new hl(t),u_opacity_multiplier:new hl(t)}),fillOutline:t=>({u_matrix:new hf(t),u_emissive_strength:new hl(t),u_world:new hh(t),u_ground_shadow_factor:new hu(t),u_opacity_multiplier:new hl(t)}),fillOutlinePattern:t=>({u_matrix:new hf(t),u_emissive_strength:new hl(t),u_world:new hh(t),u_image:new hs(t),u_texsize:new hh(t),u_pixel_coord_upper:new hh(t),u_pixel_coord_lower:new hh(t),u_tile_units_to_pixels:new hl(t),u_ground_shadow_factor:new hu(t),u_pattern_transition:new hl(t),u_opacity_multiplier:new hl(t)}),lineBlendComposite:t=>({u_image:new hs(t),u_opacity:new hl(t),u_blend_mode:new hs(t),u_max_density:new hl(t)}),lineBlendReduce:t=>({u_image:new hs(t),u_texel_size:new hh(t),u_first_pass:new hs(t)}),circle:t=>({u_camera_to_center_distance:new hl(t),u_extrude_scale:new hm(t),u_device_pixel_ratio:new hl(t),u_matrix:new hf(t),u_inv_rot_matrix:new hf(t),u_merc_center:new hh(t),u_tile_id:new hu(t),u_zoom_transition:new hl(t),u_up_dir:new hu(t),u_emissive_strength:new hl(t)}),collisionBox:t=>({u_matrix:new hf(t),u_inv_rot_matrix:new hf(t),u_camera_to_center_distance:new hl(t),u_extrude_scale:new hh(t),u_zoom_transition:new hl(t),u_merc_center:new hh(t),u_tile_id:new hu(t)}),collisionCircle:t=>({u_matrix:new hf(t),u_inv_matrix:new hf(t),u_camera_to_center_distance:new hl(t),u_viewport_size:new hh(t)}),debug:t=>
111({u_color:new hp(t),u_matrix:new hf(t),u_overlay:new hs(t),u_overlay_scale:new hl(t)}),clippingMask:t=>({u_matrix:new hf(t)}),heatmap:t=>({u_extrude_scale:new hl(t),u_intensity:new hl(t),u_matrix:new hf(t),u_inv_rot_matrix:new hf(t),u_merc_center:new hh(t),u_tile_id:new hu(t),u_zoom_transition:new hl(t),u_up_dir:new hu(t)}),heatmapTexture:t=>({u_image:new hs(t),u_color_ramp:new hs(t),u_opacity:new hl(t)}),hillshade:t=>({u_matrix:new hf(t),u_image:new hs(t),u_latrange:new hh(t),u_light:new hh(t),u_shadow:new hp(t),u_highlight:new hp(t),u_emissive_strength:new hl(t),u_accent:new hp(t)}),hillshadePrepare:t=>({u_matrix:new hf(t),u_image:new hs(t),u_dimension:new hh(t),u_zoom:new hl(t)}),line:t=>({u_matrix:new hf(t),u_pixels_to_tile_units:new hm(t),u_device_pixel_ratio:new hl(t),u_width_scale:new hl(t),u_floor_width_scale:new hl(t),u_units_to_pixels:new hh(t),u_dash_image:new hs(t),u_gradient_image:new hs(t),u_image_height:new hl(t),u_texsize:new hh(t),u_tile_units_to_pixels:new hl(t),u_alpha_discard_threshold:new hl(t),u_trim_offset:new hh(t),u_trim_fade_range:new hh(t),u_trim_gradient_mix_range:new hh(t),u_trim_color:new hd(t),u_zbias_factor:new hl(t),u_tile_to_meter:new hl(t),u_ground_shadow_factor:new hu(t),u_opacity_multiplier:new hl(t)}),linePattern:t=>({u_matrix:new hf(t),u_texsize:new hh(t),u_pixels_to_tile_units:new hm(t),u_device_pixel_ratio:new hl(t),u_width_scale:new hl(t),u_floor_width_scale:new hl(t),u_image:new hs(t),u_units_to_pixels:new hh(t),u_tile_units_to_pixels:new hl(t),u_alpha_discard_threshold:new hl(t),u_trim_offset:new hh(t),u_trim_fade_range:new hh(t),u_trim_gradient_mix_range:new hh(t),u_trim_color:new hd(t),u_zbias_factor:new hl(t),u_tile_to_meter:new hl(t),u_ground_shadow_factor:new hu(t),u_pattern_transition:new hl(t),u_opacity_multiplier:new hl(t)}),raster:t=>({u_matrix:new hf(t),u_normalize_matrix:new hf(t),u_globe_matrix:new hf(t),u_merc_matrix:new hf(t),u_grid_matrix:new h_(t),u_tl_parent:new hh(t),u_scale_parent:new hl(t),u_fade_t:new hl(t),u_opacity:new hl(t),u_image0:new hs(t),u_image1:new hs(t),u_brightness_low:new hl(t),u_brightness_high:new hl(t),u_saturation_factor:new hl(t),u_contrast_factor:new hl(t),u_spin_weights:new hu(t),u_perspective_transform:new hh(t),u_raster_elevation:new hl(t),u_zoom_transition:new hl(t),u_merc_center:new hh(t),u_cutoff_params:new hd(t),u_colorization_mix:new hd(t),u_colorization_offset:new hl(t),u_color_ramp:new hs(t),u_texture_offset:new hh(t),u_texture_res:new hh(t),u_emissive_strength:new hl(t),u_zbias_factor:new hl(t)}),symbol:t=>({u_is_size_zoom_constant:new hs(t),u_is_size_feature_constant:new hs(t),u_size_t:new hl(t),u_size:new hl(t),u_camera_to_center_distance:new hl(t),u_rotate_symbol:new hs(t),u_aspect_ratio:new hl(t),u_fade_change:new hl(t),u_matrix:new hf(t),u_label_plane_matrix:new hf(t),u_coord_matrix:new hf(t),u_is_text:new hs(t),u_is_sdf:new hs(t),u_elevation_from_sea:new hs(t),u_pitch_with_map:new hs(t),u_texsize:new hh(t),u_texsize_icon:new hh(t),u_texture:new hs(t),u_texture_icon:new hs(t),u_gamma_scale:new hl(t),u_device_pixel_ratio:new hl(t),u_tile_id:new hu(t),u_zoom_transition:new hl(t),u_inv_rot_matrix:new hf(t),u_merc_center:new hh(t),u_c
111amera_forward:new hu(t),u_tile_matrix:new hf(t),u_up_vector:new hu(t),u_ecef_origin:new hu(t),u_is_halo:new hs(t),u_icon_transition:new hl(t),u_color_adj_mat:new hf(t),u_scale_factor:new hl(t),u_ground_shadow_factor:new hu(t),u_inv_matrix:new hf(t),u_normal_scale:new hl(t),u_lutTexture:new hs(t),u_spp_fill_np_color:new hd(t),u_spp_halo_np_color:new hd(t),u_spp_opacity:new hl(t),u_spp_halo_width:new hl(t),u_spp_halo_blur:new hl(t),u_spp_emissive_strength:new hl(t),u_spp_occlusion_opacity:new hl(t),u_spp_z_offset:new hl(t),u_spp_translate_rotation:new hh(t),u_spp_fill_color_zoom_factor:new hl(t),u_spp_halo_color_zoom_factor:new hl(t),u_spp_opacity_zoom_factor:new hl(t),u_spp_halo_width_zoom_factor:new hl(t),u_spp_halo_blur_zoom_factor:new hl(t),u_spp_emissive_strength_zoom_factor:new hl(t),u_spp_occlusion_opacity_zoom_factor:new hl(t),u_spp_z_offset_zoom_factor:new hl(t),u_spp_translate_zoom_factor:new hl(t),u_spp_zoom_fraction:new hl(t),u_opacity_multiplier:new hl(t)}),background:t=>({u_matrix:new hf(t),u_emissive_strength:new hl(t),u_opacity:new hl(t),u_color:new hp(t)}),backgroundPattern:t=>({u_matrix:new hf(t),u_emissive_strength:new hl(t),u_opacity:new hl(t),u_image:new hs(t),u_pattern_tl:new hh(t),u_pattern_br:new hh(t),u_texsize:new hh(t),u_pattern_size:new hh(t),u_pixel_coord_upper:new hh(t),u_pixel_coord_lower:new hh(t),u_pattern_units_to_pixels:new hh(t)}),terrainRaster:t=>({u_matrix:new hf(t),u_image0:new hs(t),u_image1:new hs(t),u_skirt_height:new hl(t),u_ground_shadow_factor:new hu(t),u_emissive_texture_available:new hl(t)}),skybox:t=>({u_matrix:new hf(t),u_sun_direction:new hu(t),u_cubemap:new hs(t),u_opacity:new hl(t),u_temporal_offset:new hl(t)}),skyboxGradient:t=>({u_matrix:new hf(t),u_color_ramp:new hs(t),u_center_direction:new hu(t),u_radius:new hl(t),u_opacity:new hl(t),u_temporal_offset:new hl(t)}),skyboxCapture:t=>({u_matrix_3f:new h_(t),u_sun_direction:new hu(t),u_sun_intensity:new hl(t),u_color_tint_r:new hd(t),u_color_tint_m:new hd(t),u_luminance:new hl(t)}),globeRaster:t=>({u_proj_matrix:new hf(t),u_globe_matrix:new hf(t),u_normalize_matrix:new hf(t),u_merc_matrix:new hf(t),u_zoom_transition:new hl(t),u_merc_center:new hh(t),u_image0:new hs(t),u_image1:new hs(t),u_grid_matrix:new h_(t),u_skirt_height:new hl(t),u_far_z_cutoff:new hl(t),u_frustum_tl:new hu(t),u_frustum_tr:new hu(t),u_frustum_br:new hu(t),u_frustum_bl:new hu(t),u_globe_pos:new hu(t),u_globe_radius:new hl(t),u_viewport:new hh(t),u_emissive_texture_available:new hl(t)}),globeAtmosphere:t=>({u_frustum_tl:new hu(t),u_frustum_tr:new hu(t),u_frustum_br:new hu(t),u_frustum_bl:new hu(t),u_horizon:new hl(t),u_transition:new hl(t),u_fadeout_range:new hl(t),u_atmosphere_fog_color:new hd(t),u_high_color:new hd(t),u_space_color:new hd(t),u_temporal_offset:new hl(t),u_horizon_angle:new hl(t)}),stars:t=>({u_matrix:new hf(t),u_up:new hu(t),u_right:new hu(t),u_intensity_multiplier:new hl(t)}),occlusion:t=>({u_matrix:new hf(t),u_anchorPos:new hu(t),u_screenSizePx:new hh(t),u_occluderSizePx:new hh(t),u_color:new hd(t)})};class T2{constructor(t,i,r,a){this.id=T2.uniqueIdxCounter,T2.uniqueIdxCounter++,this.context=t;let n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=!!r,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,i.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||a||i.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){this.id=T2.uniqueIdxCounter,T2.uniqueIdxCounter++;let i=this.context.gl;this.context.unbindVAO(),this.bind(),i.bufferSubData(i.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}T2.uniqueIdxCounter=0;let T3={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class T4{constructor(t,i,r,a,n,o){this.length=i.length,this.attributes=r,this.itemSize=i.bytesPerElement,this.dynamicDraw=a,this.instanceCount=o,this.context=t;let s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,i.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||i.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){let i=this.context.gl;this.bind(),i.bufferSubData(i.ARRAY_BUFFER,0,t.arrayBuffer)}
111enableAttributes(t,i){for(let r of this.attributes){let a=i.getAttributeLocation(t,r.name);-1!==a&&t.enableVertexAttribArray(a)}}setVertexAttribPointers(t,i,r){for(let a of this.attributes){let n=i.getAttributeLocation(t,a.name);if(-1!==n){let i=a.offset+this.itemSize*(r||0);"Float32"===a.type?t.vertexAttribPointer(n,a.components,t.FLOAT,!1,this.itemSize,i):t.vertexAttribIPointer(n,a.components,t[T3[a.type]],this.itemSize,i)}}}setVertexAttribDivisor(t,i,r){for(let a=0;a<this.attributes.length;a++){let n=i.getAttributeLocation(t,this.attributes[a].name);-1!==n&&this.instanceCount&&this.instanceCount>0&&t.vertexAttribDivisor(n,r)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class T5{constructor(t,i,r,a,n){this.context=t,this.width=i,this.height=r;let o=this.framebuffer=t.gl.createFramebuffer();a>0&&(this.colorAttachment0=new TE(t,o,0)),a>1&&(this.colorAttachment1=new TE(t,o,1)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new TS(t,o):new TI(t,o))}static createWithTexture(t,i,r,a,n){let o=t.gl;if(t.activeTexture.set(o.TEXTURE1),t.viewport.set([0,0,r,a]),i&&i.width===r&&i.height===a)return o.bindTexture(o.TEXTURE_2D,i.colorAttachment0.get()),t.bindFramebuffer.set(i.framebuffer),i;i&&i.destroy();let s=t.extRenderToTextureHalfFloat||t.extColorBufferFloat?t.gl.RGBA16F:t.gl.RGBA8,l=new uW(t,{width:r,height:a,data:null},s);l.bind(o.LINEAR,o.CLAMP_TO_EDGE);let h=t.createFramebuffer(r,a,1,null);if(h.format=s,h.colorAttachment0.set(l.texture),n){let i=t.createRenderbuffer(o.DEPTH24_STENCIL8,r,a);t.bindFramebuffer.set(h.framebuffer),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,i),h._stencilRbo=i}return h}createColorAttachment(t,i){0===i?this.colorAttachment0=new TE(t,this.framebuffer,0):1===i&&(this.colorAttachment1=new TE(t,this.framebuffer,1))}removeColorAttachment(t,i){let r,a=this.context.gl;0===i?(r=this.colorAttachment0.get(),this.colorAttachment0=void 0):1===i&&(r=this.colorAttachment1.get(),this.colorAttachment1=void 0),r&&a.deleteTexture(r)}destroy(){let t=this.context.gl;if(this.colorAttachment0){let i=this.colorAttachment0.get();i&&t.deleteTexture(i)}if(this.colorAttachment1){let i=this.colorAttachment1.get();i&&t.deleteTexture(i)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){let i=this.depthAttachment.get();i&&t.deleteRenderbuffer(i)}else{let i=this.depthAttachment.get();i&&t.deleteTexture(i)}this._stencilRbo&&(t.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),t.deleteFramebuffer(this.framebuffer)}}class T6{constructor(t,i){this.gl=t,this._pendingPrograms=new Set,this._compileStats={precompiled:0,onDemand:0,totalStallMs:0,maxStallMs:0,framesMissed:0,stalls:[]},this.clearColor=new w2(this),this.clearDepth=new w3(this),this.clearStencil=new w4(this),this.colorMask=new w5(this),this.depthMask=new w6(this),this.stencilMask=new w8(this),this.stencilFunc=new w9(this),this.stencilOp=new w7(this),this.stencilTest=new Te(this),this.depthRange=new Tt(this),this.depthTest=new Ti(this),this.depthFunc=new Tr(this),this.blend=new Ta(this),this.blendFunc=new Tn(this),this.blendColor=new To(this),this.blendEquation=new Ts(this),this.cullFace=new Tl(this),this.cullFaceSide=new Th(this),this.frontFace=new Tu(this),this.program=new Tc(this),this.activeTexture=new Td(this),this.viewport=new Tp(this),this.bindFramebuffer=new Tf(this),this.bindRenderbuffer=new T_(this),this.bindTexture=new Tm(this),this.bindVertexBuffer=new Tg(this),this.bindElementBuffer=new Ty(this),this.bindVertexArrayOES=new Tx(this),this.pixelStoreUnpack=new Tv(this),this.pixelStoreUnpackPremultiplyAlpha=new Tb(this),this.pixelStoreUnpackFlipY=new Tw(this),this.options=i?{...i}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=t.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=t.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=t.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=i&&!!i.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.includes("PowerVR"),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=t.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float"),this.extColorBufferFloat=t.getExtension("EXT_color_buffer_float"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(t.getParameter(t.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=t.getExtension("WEBGL_blend_func_extended"),this.extParallelShaderCompile=t.getExtension("KHR_parallel_shader_compile")}
111sweepPendingPrograms(){if(0!==this._pendingPrograms.size)for(let t of this._pendingPrograms)t.maybeFinalize()}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,i,r){return new T2(this,t,i,r)}createVertexBuffer(t,i,r,a,n){return new T4(this,t,i,r,a,n)}createRenderbuffer(t,i,r){let a=this.gl,n=a.createRenderbuffer();return this.bindRenderbuffer.set(n),a.renderbufferStorage(a.RENDERBUFFER,t,i,r),this.bindRenderbuffer.set(null),n}createFramebuffer(t,i,r,a){return new T5(this,t,i,r,a)}clear({color:t,depth:i,stencil:r,colorMask:a}){let n=this.gl,o=0;t&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(t.toNonPremultipliedRenderColor(null)),this.colorMask.set(a||[!0,!0,!0,!0])),void 0!==i&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(i),this.depthMask.set(!0)),void 0!==r&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),n.clear(o)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){ty(t.blendFunction,g6.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}function T8(t,i,r,a,n,o,s){let l=t.context,h=l.gl,u=t.transform,c=[az(u.center.lng),aL(u.center.lat)],d=r.layout.get("symbol-placement"),p=r.layout.get("text-variable-anchor"),f="map"===r.layout.get("icon-rotation-alignment"),_="map"===r.layout.get("text-rotation-alignment"),m="point"!==d,g=[],y=0,x=0;for(let l=0;l<a.length;l++){let d=a[l],v=i.getTile(d),b=v.getBucket(r);if(!b)continue;let w=b.getProjection().createInversionMatrix(u,d.canonical),T=[],E=function(t,i,r){if(i.projection.name===r.projection.name)return t.projMatrix;let a=r.clone();return a.setProjection(i.projection),wo(a,i.getProjection(),t)}(d,b,u),S=!s&&f&&m,I=s&&_&&m,A=p&&b.hasTextData(),C=b.hasIconTextFit()&&A&&b.hasIconData(),M=S||I||s&&A||C,R="globe"===b.projection.name,D=R?cN(u.zoom):0;
111R&&(T.push("PROJECTION_GLOBE_VIEW"),M&&T.push("PROJECTED_POS_ON_VIEWPORT"));let P=t.getOrCreateProgram("collisionBox",{defines:T}),z=E;0===n[0]&&0===n[1]||(z=t.translatePosMatrix(E,v,n,o));let L=s?b.textCollisionBox:b.iconCollisionBox,O=b.collisionCircleArray;if(O.length>0){let t=ec(),i=z;eg(t,b.placementInvProjMatrix,u.glCoordMatrix),eg(t,t,b.placementViewportMatrix),g.push({circleArray:O,circleOffset:x,transform:i,invTransform:t,projection:b.getProjection()}),y+=O.length/4,x=y}if(!L)continue;t.terrain&&t.terrain.setupElevationDraw(v,P);let F=R?[d.canonical.x,d.canonical.y,1<<d.canonical.z]:[0,0,0];P.draw(t,h.LINES,gz.disabled,g3.disabled,t.colorModeForRenderPass(),gP.disabled,TZ(z,w,u,D,c,v,F,b.getProjection()),r.id,L.layoutVertexBuffer,L.indexBuffer,L.segments,null,u.zoom,null,[L.collisionVertexBuffer,L.collisionVertexBufferExt])}if(!s||!g.length)return;let v=t.getOrCreateProgram("collisionCircle"),b=new lC;b.resize(4*y),b._trim();let w=0;for(let t of g)for(let i=0;i<t.circleArray.length/4;i++){let r=4*i,a=t.circleArray[r+0],n=t.circleArray[r+1],o=t.circleArray[r+2],s=t.circleArray[r+3];b.emplace(w++,a,n,o,s,0),b.emplace(w++,a,n,o,s,1),b.emplace(w++,a,n,o,s,2),b.emplace(w++,a,n,o,s,3)}(!ee||ee.length<2*y)&&(ee=function(t){let i=2*t,r=new lR;r.resize(i),r._trim();for(let t=0;t<i;t++){let i=6*t;r.uint16[i+0]=4*t+0,r.uint16[i+1]=4*t+1,r.uint16[i+2]=4*t+2,r.uint16[i+3]=4*t+2,r.uint16[i+4]=4*t+3,r.uint16[i+5]=4*t+0}return r}(y));let T=l.createIndexBuffer(ee,!0),E=l.createVertexBuffer(b,uw.members,!0);for(let i of g){let a=T$(i.transform,i.invTransform,u,i.projection);v.draw(t,h.TRIANGLES,gz.disabled,g3.disabled,t.colorModeForRenderPass(),gP.disabled,a,r.id,E,T,l9.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,u.zoom)}E.destroy(),T.destroy()}let T9=ec();function T7(t){let i=eg([],t._camera.getWorldToCamera(t.worldSize,1),t.globeMatrix);em(i,i);let r=[0,0,0],a=[0,1,0,0];return e9(a,a,i),r[0]=a[0],r[1]=a[1],r[2]=a[2],eW(r,r),r}function Ee(t,i,r,a,n,o,s={}){let l=r.paint.get("icon-translate"),h=r.paint.get("text-translate"),u=r.paint.get("icon-translate-anchor"),c=r.paint.get("text-translate-anchor"),d=r.layout.get("icon-rotation-alignment"),p=r.layout.get("text-rotation-alignment"),f=r.layout.get("icon-pitch-alignment"),_=r.layout.get("text-pitch-alignment"),m=r.layout.get("icon-keep-upright"),g=r.layout.get("text-keep-upright"),y=r.paint.get("icon-color-saturation"),x=r.paint.get("icon-color-contrast"),v=r.paint.get("icon-color-brightness-min"),b=r.paint.get("icon-color-brightness-max"),w="sea"===r.layout.get("symbol-elevation-reference"),T="none"===r.layout.get("icon-image-use-theme"),E=t.context,S=E.gl,I=t.transform,A="map"===d,C="map"===p,M="map"===f,R="map"===_,D=void 0!==r.layout.get("symbol-sort-key").constantOr(1),P=!1,z=t.depthModeForSublayer(0,gz.ReadOnly),L=new gz(t.context.gl.LEQUAL,gz.ReadOnly,t.depthRangeFor3D),O=[az(I.center.lng),aL(I.center.lat)],F=r.layout.get("text-variable-anchor"),B="globe"===I.projection.name,k=[],N=[0,-1,0];for(let n of a){let a=i.getTile(n),o=a.getBucket(r);if(!o||"mercator"===o.projection.name&&B||o.fullyClipped)continue;let d="globe"===o.projection.name,p=d?cN(I.zoom):0,f=ws(n,o.getProjection(),I),_=I.calculatePixelsToTileUnitsMatrix(a),V=F&&o.hasTextData(),U=o.hasIconTextFit()&&V&&o.hasIconData(),j=o.getProjection().createInversionMatrix(I,n.canonical),G=(1<<a.tileID.canonical.z)*8192/t.transform.worldSize,H=i=>{let r=[0,0,0];if(i){let i=t.style.directionalLight,a=t.style.ambientLight;i&&a&&(r=yn(t.style,i,a))}return r},q=i=>{let r=Math.floor(Math.floor(t.context.maxUniformBlockSize/4)/4);i.push(`MAX_UBO_SIZE_VEC4 ${r}u`)},Z=i=>{I.depthOcclusionForSymbolsAndCircles&&(r.hasOcclusionOpacityProperties||t.terrain)&&(i.push("DEPTH_D24"),i.push("DEPTH_OCCLUSION"))},$=i=>{r.lut&&!T&&(r.lut.texture||(r.lut.texture=new uX(t.context,r.lut.image,[r.lut.image.height,r.lut.image.height,r.lut.image.height],E.gl.RGBA8)),E.activeTexture.set(E.gl.TEXTURE0+10),r.lut.texture&&r.lut.texture.bind(E.gl.LINEAR,E.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"))},W=()=>{let i=A&&"point"!==r.layout.get("symbol-placement"),s=[];Z(s),$(s);let h=i||U,c="road"===o.elevationType,g=t.shadowRenderer,T=c&&M&&!!g&&g.enabled,E=H(T),C=c&&M&&!t.terrain?L:z,R=r.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&M&&s.push("PITCH_WITH_MAP_TERRAIN"),d&&(s.push("PROJECTION_GLOBE_VIEW"),h&&s.push("PROJECTED_POS_ON_VIEWPORT")),R>0&&o.hasAnySecondaryIcon&&s.push("ICON_TRANSITION"),!o.icon.zOffsetVertexBuffer||c&&t.terrain||s.push("Z_OFFSET"),0===y&&0===x&&0===v&&1===b||s.push("COLOR_ADJUSTMENT"),T&&s.push("RENDER_SHADOWS","NORMAL_OFFSET"),c&&M&&!t.terrain&&o.icon.orientationVertexBuffer&&s.push("ELEVATED_ROADS"),q(s);let D=t.getOrCreateProgram("symbol",{defines:s}),P=a.imageAtlasTexture?a.imageAtlasTexture.size:[0,0],F=o.iconSizeData,k=uk(F,I.zoom),V=M||!I.isOrthographic,W=gU(f,a.tileID.canonical,M,A,I,o.getProjection(),_),X=gG(f,a.tileID.canonical,M,A,I,o.getProjection(),_),Y=o.icon.uboBinder&&o.icon.uboBinder.hasPerFeatureTranslate()?[0,0]:l,K=t.translatePosMatrix(X,a,Y,u,!0),Q=t.translatePosMatrix(f,a,Y,u),J=h?T9:W,ee=A&&!M&&!i,et=N;
111(B||I.mercatorFromTransition)&&!A&&(et=T7(I));let ei=d?et:N,er=r.getColorAdjustmentMatrix(y,x,v,b),ea=TQ(F.kind,k,ee,M,t,Q,J,K,w,!1,o.sdfIcons,P,[0,0],0,n,p,O,j,ei,o.getProjection(),E,G,er,R,null),en=a.imageAtlasTexture?a.imageAtlasTexture:null,eo=1!==r.layout.get("icon-size").constantOr(0)||o.iconsNeedLinear,es=o.sdfIcons||t.options.rotating||t.options.zooming||eo||V?S.LINEAR:S.NEAREST,el=o.sdfIcons&&0!==r.paint.get("icon-halo-width").constantOr(1),eh=t.terrain&&M&&i?em(ec(),W):T9;if(i&&o.icon){let i=_q.getAtTileOffsetFunc(n,I.center.lat,I.worldSize,o.getProjection()),s=gj(f,a.tileID.canonical,M,A,I,o.getProjection(),_),l=r.layout.get("icon-size-scale-range"),h=tL(t.scaleFactor,l[0],l[1]);gZ(o,f,t,!1,s,X,M,m,i,n,h)}return{program:D,buffers:o.icon,uniformValues:ea,atlasTexture:en,atlasTextureIcon:null,atlasInterpolation:es,atlasInterpolationIcon:null,isSDF:o.sdfIcons,hasHalo:el,depthMode:C,tile:a,renderWithShadows:T,labelPlaneMatrixInv:eh}},X=()=>{let i=C&&"point"!==r.layout.get("symbol-placement"),s=[],l=i||F||U,u="road"===o.elevationType,m=t.shadowRenderer,y=u&&R&&!!m&&m.enabled,x=H(y),v=u&&R&&!t.terrain?L:z;t.terrainRenderModeElevated()&&R&&s.push("PITCH_WITH_MAP_TERRAIN"),d&&(s.push("PROJECTION_GLOBE_VIEW"),l&&s.push("PROJECTED_POS_ON_VIEWPORT")),!o.text.zOffsetVertexBuffer||u&&t.terrain||s.push("Z_OFFSET"),o.iconsInText&&s.push("RENDER_TEXT_AND_SYMBOL"),y&&s.push("RENDER_SHADOWS","NORMAL_OFFSET"),u&&R&&!t.terrain&&o.text.orientationVertexBuffer&&s.push("ELEVATED_ROADS"),Z(s),q(s);let b=t.getOrCreateProgram("symbol",{defines:s}),T,E=[0,0],A=null,M=o.textSizeData;o.iconsInText&&(E=a.imageAtlasTexture?a.imageAtlasTexture.size:[0,0],A=a.imageAtlasTexture?a.imageAtlasTexture:null,T=R||!I.isOrthographic||t.options.rotating||t.options.zooming||"composite"===M.kind||"camera"===M.kind?S.LINEAR:S.NEAREST);let D=a.glyphAtlasTexture?a.glyphAtlasTexture.size:[0,0],P=r.layout.get("text-size-scale-range"),k=tL(t.scaleFactor,P[0],P[1]),V=uk(M,I.zoom,k),$=gU(f,a.tileID.canonical,R,C,I,o.getProjection(),_),W=gG(f,a.tileID.canonical,R,C,I,o.getProjection(),_),X=o.text.uboBinder&&o.text.uboBinder.hasPerFeatureTranslate()?[0,0]:h,Y=t.translatePosMatrix(W,a,X,c,!0),K=t.translatePosMatrix(f,a,X,c),Q=l?T9:$,J=C&&!R&&!i,ee=N;(B||I.mercatorFromTransition)&&!C&&(ee=T7(I));let et=TQ(M.kind,V,J,R,t,K,Q,Y,w,!0,!0,D,E,0,n,p,O,j,d?ee:N,o.getProjection(),x,G,null,null,k),ei=a.glyphAtlasTexture?a.glyphAtlasTexture:null,er=S.LINEAR,ea=0!==r.paint.get("text-halo-width").constantOr(1),en=t.terrain&&R&&i?em(ec(),$):T9;if(i&&o.text){let i=_q.getAtTileOffsetFunc(n,I.center.lat,I.worldSize,o.getProjection()),r=gj(f,a.tileID.canonical,R,C,I,o.getProjection(),_);gZ(o,f,t,!0,r,W,R,g,i,n,k)}return{program:b,buffers:o.text,uniformValues:et,atlasTexture:ei,atlasTextureIcon:A,atlasInterpolation:er,atlasInterpolationIcon:T,isSDF:!0,hasHalo:ea,depthMode:v,tile:a,renderWithShadows:y,labelPlaneMatrixInv:en}},Y=o.icon.segments.get().length,K=o.text.segments.get().length,Q=Y&&!s.onlyText?W():null,J=K&&!s.onlyIcons?X():null,ee=r.paint.get("icon-opacity").constantOr(1),et=r.paint.get("text-opacity").constantOr(1);if(D&&o.canOverlap){P=!0;let t=ee&&!s.onlyText?o.icon.segments.get():[],i=et&&!s.onlyIcons?o.text.segments.get():[];for(let i of t)k.push({segments:new l9([i]),sortKey:i.sortKey,state:Q});for(let t of i)k.push({segments:new l9([t]),sortKey:t.sortKey,state:J})}else s.onlyText||k.push({segments:ee?o.icon.segments:new l9([]),sortKey:0,state:Q}),s.onlyIcons||k.push({segments:et?o.text.segments:new l9([]),sortKey:0,state:J})}for(let i of(P&&k.sort((t,i)=>t.sortKey-i.sortKey),k)){let a=i.state;if(a)if(t.terrain?t.terrain.setupElevationDraw(a.tile,a.program,{useDepthForOcclusion:I.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:a.labelPlaneMatrixInv}):t.setupDepthForOcclusion(I.depthOcclusionForSymbolsAndCircles,a.program),E.activeTexture.set(S.TEXTURE0),a.atlasTexture&&a.atlasTexture.bind(a.atlasInterpolation,S.CLAMP_TO_EDGE,!0),a.atlasTextureIcon&&(E.activeTexture.set(S.TEXTURE1),a.atlasTextureIcon&&a.atlasTextureIcon.bind(a.atlasInterpolationIcon,S.CLAMP_TO_EDGE,!0)),a.renderWithShadows&&t.shadowRenderer.setupShadows(a.tile.tileID.toUnwrapped(),a.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,a.program),a.hasH
111alo){let s=a.uniformValues;s.u_is_halo=1,Et(a.buffers,i.segments,r,t,a.program,a.depthMode,n,o,s,2),s.u_is_halo=0}else{if(a.isSDF){let s=a.uniformValues;a.hasHalo&&(s.u_is_halo=1,Et(a.buffers,i.segments,r,t,a.program,a.depthMode,n,o,s,1)),s.u_is_halo=0}Et(a.buffers,i.segments,r,t,a.program,a.depthMode,n,o,a.uniformValues,1)}}}function Et(t,i,r,a,n,o,s,l,h,u){let c=a.context,d=c.gl,p=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.iconTransitioningVertexBuffer,t.globeExtVertexBuffer,t.zOffsetVertexBuffer,t.orientationVertexBuffer];t.featureIdBuffer&&p.push(t.featureIdBuffer);let f=t.uboBinder?null:t.programConfigurations.get(r.id);if(t.uboBinder){t.uboBinder.layer=r;let i=a.transform.zoom,n=a.style.getBrightness?a.style.getBrightness():null,o=t.uboBinder.getConstantUniformValues(i,n);h.u_spp_fill_np_color=o.fill_np_color,h.u_spp_halo_np_color=o.halo_np_color,h.u_spp_opacity=o.opacity,h.u_spp_halo_width=o.halo_width,h.u_spp_halo_blur=o.halo_blur,h.u_spp_emissive_strength=o.emissive_strength,h.u_spp_occlusion_opacity=o.occlusion_opacity,h.u_spp_z_offset=o.z_offset;let s=o.zoomFactors;h.u_spp_fill_color_zoom_factor=s[0],h.u_spp_halo_color_zoom_factor=s[1],h.u_spp_opacity_zoom_factor=s[2],h.u_spp_halo_width_zoom_factor=s[3],h.u_spp_halo_blur_zoom_factor=s[4],h.u_spp_emissive_strength_zoom_factor=s[5],h.u_spp_occlusion_opacity_zoom_factor=s[6],h.u_spp_z_offset_zoom_factor=s[7],h.u_spp_translate_zoom_factor=s[8],h.u_spp_zoom_fraction=i-Math.floor(i);let l=r.paint.get(t.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),u=t.uboBinder.hasPerFeatureTranslate()&&"map"===l?a.transform.angle:0;h.u_spp_translate_rotation=[Math.cos(u),Math.sin(u)]}let{batchIndices:_,batchSegments:m}=t.getBatchGrouping(i);for(let i of _){let _=m.get(i);t.uboBinder&&t.uboBinder.bind(c,n.program,i),n.draw(a,d.TRIANGLES,o,s,l,gP.disabled,h,r.id,t.layoutVertexBuffer,t.indexBuffer,_,r.paint,a.transform.zoom,f,p,u)}}function Ei(t,i,r,a,n,o){let s,l=r.paint.get("line-width"),h=r.paint.get("line-emissive-strength").isConstant(),u=r.paint.get("line-emissive-strength").constantOr(0),c=r.paint.get("line-occlusion-opacity"),d=r.layout.get("line-elevation-reference"),p="meters"===r.layout.get("line-width-unit"),f=!(!t.terrain||!t.terrain.enabled),_=t.context,m=_.gl;if(r.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;let g=r.layout.get("line-cross-slope"),y=n||t.colorModeForDrapableLayerRenderPass(h?u:null),x=t.terrain&&t.terrain.renderingToTexture||o,v=x?1:is.devicePixelRatio,b=r.paint.get("line-dasharray"),w=b.constantOr(1),T=r.layout.get("line-cap"),E=b.constantOr(null),S=T.constantOr(null),I=r.paint.get("line-pattern"),A=I.constantOr(1),C=r.paint.get("line-pattern-cross-fade"),M=I.constantOr(null),R=r.paint.get("line-opacity").constantOr(1),D=!A&&1!==R||t.depthOcclusion&&c>0&&c<1,P=r.paint.get("line-gradient"),z=A?"linePattern":"line",L=_R(r);if(x&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(D=!1),0!==c&&t.depthOcclusion){let t=r.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?s=t.value:tX(`Occlusion opacity for layer ${r.id} is supported only when line-opacity isn't data-driven.`)}"constant"!==l.value.kind&&!1===l.value.isLineProgressConstant&&L.push("VARIABLE_LINE_WIDTH");let O=r.paint.get("line-emissive-strength");A||"constant"===O.value.kind||!1!==O.value.isLineProgressConstant||L.push("VARIABLE_LINE_EMISSIVE_STRENGTH"),t._debugParams.showElevationIdDebug&&L.push("DEBUG_ELEVATION_ID"),x&&("dual-source-blending"!==t.emissiveMode||h?"mrt-fallback"===t.emissiveMode&&L.push("USE_MRT1"):L.push("DUAL_SOURCE_BLENDING"));let F={},B=[],k=(a,n,o,l,h,u)=>{for(let d of a){let a,f=i.getTile(d);if(A&&!f.patternsLoaded())continue;let g=f.getBucket(r);if(!g||"none"!==g.elevationType&&!h||"none"===g.elevationType&&h)continue;t.prepareDrawTile();let b=[...n],T="road"===g.elevationType,I=t.shadowRenderer,L=T&&!!I&&I.enabled,O=[0,0,0];if(L){let i=t.style.directionalLight,r=t.style.ambientLight;i&&r&&(O=yn(t.style,i,r)),b.push("RENDER_SHADOWS","NORMAL_OFFSET")}let k=g.programConfigurations.get(r.id),N=!1;if(M&&f.imageAtlas){let t=au.from(M),i=t.getPrimary().scaleSelf(v).toString(),r=f.imageAtlas.patternPositions.get(i),a=t.getSecondary(),n=a?f.imageAtlas.patternPositions.get(a.scaleSelf(v).toString()):null;N=!!r&&!!n,r&&k.setConstantPatternPositions(r,n)}C>0&&(N||k.getPatternTransitionVertexBuffer("line-pattern"))&&b.push("LINE_PATTERN_TRANSITION"),g.elevationGroundScaleVertexBuffer&&b.push("ELEVATION_GROUND_SCALE");let V=t.isTileAffectedByFog(d),U=t.getOrCreateProgram(z,{config:k,defines:b,overrideFog:V});if(!A&&E&&S&&f.lineAtlas){let t=f.lineAtlas.getDash(E,S);t&&k.setConstantPatternPositions(t)}L&&I.setupShadows(f.tileID.toUnwrapped(),U,"vector-tile");let[j,G]=r.paint.get("line-trim-offset");("round"===S||"square"===S)&&j!==G&&(0===j&&(j-=1),1===G&&(G+=1));let H=x?d.projMatrix:null,q=p?1/g.tileToMeter/_S(f,1,t.transform.zoom):1,Z=p?1/g.tileToMeter/_S(f,1,Math.floor(t.transform.zoom)):1,$=w?r.paint._values["line-floorwidth"]:null;if($&&"constant"===$.value.kind){let i=g.zoom;i in F||(F[i]=Math.max(.01,r.widthExpression().evaluate({zoom:i}))),a=$.value.value;let n=Math.floor(t.transform.zoom);
111$.value.value=F[i]*Math.pow(2,n-f.tileID.overscaledZ)}let W=A?_A(t,f,r,H,v,q,Z,[j,G],O,C):_I(t,f,r,H,g.lineClipsArray.length,v,q,Z,[j,G],O);if(P){let a=g.gradients[r.id],n=a.texture;if(r.gradientVersion!==a.version){let o=256;if(r.stepInterpolant){let r=i.getSource().maxzoom,a=d.canonical.z===r?Math.ceil(1<<t.transform.maxZoom-d.canonical.z):1;o=tL(tU(g.maxLineLength/8192*1024*a),256,_.maxTextureSize)}let s="none"===r.paint.get("line-gradient-use-theme").constantOr("default");a.gradient=_y({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:o,image:a.gradient||void 0,clips:g.lineClipsArray,lut:s?null:r.lut}),a.texture?a.texture.update(a.gradient):a.texture=new uW(_,a.gradient,m.RGBA8),a.version=r.gradientVersion,n=a.texture}_.activeTexture.set(m.TEXTURE1),n.bind(r.stepInterpolant?m.NEAREST:m.LINEAR,m.CLAMP_TO_EDGE)}w&&(_.activeTexture.set(m.TEXTURE0),f.lineAtlasTexture&&f.lineAtlasTexture.bind(m.LINEAR,m.REPEAT),k.updatePaintBuffers()),A&&(_.activeTexture.set(m.TEXTURE0),f.imageAtlasTexture&&f.imageAtlasTexture.bind(m.LINEAR,m.CLAMP_TO_EDGE),k.updatePaintBuffers()),h&&!T&&t.terrain.setupElevationDraw(f,U),t.uploadCommonUniforms(_,U,d.toUnwrapped());let X=bM?bM(t,g,d,h,W,k,U,o,y,B):null,Y=(i,a,n)=>{a&&0!==a.get().length&&(null!=s&&(s.value=R*c),void 0!==n&&(W.u_opacity_multiplier=n),U.draw(t,m.TRIANGLES,o,i,y,gP.disabled,W,r.id,g.layoutVertexBuffer,g.indexBuffer,a,r.paint,t.transform.zoom,k,[g.layoutVertexBuffer2,g.patternVertexBuffer,g.zOffsetVertexBuffer,g.elevationIdColVertexBuffer,g.elevationGroundScaleVertexBuffer]),void 0!==n&&(W.u_opacity_multiplier=1),null!=s&&(s.value=R))},K=t=>{X&&X.active&&bR?bR(g,X,t,Y):Y(t,g.segments)};if(D&&!h){let i=t.stencilModeForClipping(d).ref;0===i&&x&&_.clear({stencil:0});let r={func:m.EQUAL,mask:255};W.u_alpha_discard_threshold=.8,K(new g3(r,i,255,m.KEEP,m.KEEP,m.INVERT)),W.u_alpha_discard_threshold=0,K(new g3(r,i,255,m.KEEP,m.KEEP,m.KEEP))}else W.u_alpha_discard_threshold=D&&h&&u?.8:0,K(h?l:t.stencilModeForClipping(d));X&&bD&&bD(t,g,d,X,h,l,Y),void 0!==a&&($.value.value=a)}},N=t.depthModeForSublayer(0,gz.ReadOnly),V=new gz(t.depthOcclusion?m.GREATER:m.LEQUAL,gz.ReadOnly,t.depthRangeFor3D);if(r.hasNonElevatedBuckets){let i=!x&&t.terrain;0!==c&&i?tX(`Occlusion opacity for layer ${r.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?tX(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${r.id}.`):k(a,L,N,g3.disabled,!1,!0)}if(r.hasElevatedBuckets){"hd-road-markup"===d?f||(N=V,L.push("ELEVATED_ROADS")):(L.push("ELEVATED"),N=V,void 0!==g&&L.push(g<1?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),"sea"===d&&L.push("ELEVATION_REFERENCE_SEA"));let i=D?t.stencilModeFor3D():g3.disabled;"hd-road-markup"!==d&&(t.forceTerrainMode=!0),k(a,L,N,i,!0,!0),D&&k(a,L,N,i,!0,!1),"hd-road-markup"!==d&&(t.forceTerrainMode=!1)}bP&&bP(t,r,B),D&&(t.resetStencilClippingMasks(),x&&_.clear({stencil:0})),0===c||t.depthOcclusion||x||t.layersWithOcclusionOpacity.push(t.currentLayer)}class Er{destroy(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.drapeFbo&&(this.drapeFbo.destroy(),this.drapeFbo=null)}}class Ea{constructor(t){this.pbo=t.createBuffer(),this.sync=null,this.fboA=null,this.fboB=null,this.maxDensity=0}destroy(t){this.sync&&(t.deleteSync(this.sync),this.sync=null),t.deleteBuffer(this.pbo),this.fboA&&(this.fboA.destroy(),this.fboA=null),this.fboB&&(this.fboB.destroy(),this.fboB=null)}}let En={additive:{clearColor:new rq(0,0,0,0),colorMode:g6.additiveAlphaWeighted,compositeUniformValue:1},multiply:{clearColor:new rq(1,1,1,1),colorMode:g6.multiply,compositeUniformValue:0}};function Eo(t){return!(!t.extRenderToTextureHalfFloat&&!t.extColorBufferFloat)}function Es(t,i){return"additive"===t&&Eo(i)?g6.additiveAlphaWeightedUnboundedAlpha:En[t].colorMode}function El(t,i,r){let a=t.context,n=a.gl,o=r.width,s=r.height,l=r.colorAttachment0.get();i.lineBlendDensityReadback||(i.lineBlendDensityReadback=new Ea(n));let h=i.lineBlendDensityReadback,u=0,c=!0;for(;o>1||s>1;){let r=Math.max(1,Math.floor(o/2)),d=Math.max(1,Math.floor(s/2)),p=0===u?"fboA":"fboB";h[p]=T5.createWithTexture(a,h[p],r,d,!1);let f=h[p];a.bindFramebuffer.set(f.framebuffer),a.viewport.set([0,0,r,d]),a.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,l),t.getOrCreateProgram("lineBlendReduce").draw(t,n.TRIANGLES,gz.disabled,g3.disabled,g6.unblended,gP.disabled,Tq(0,[1/o,1/s],c),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom),o=r,s=d,l=f.colorAttachment0.get(),u=1-u,c=!1}let d=Eo(a);h.sync&&(n.deleteSync(h.sync),h.sync=null),n.bindBuffer(n.PIXEL_PACK_BUFFER,h.pbo),n.bufferData(n.PIXEL_PACK_BUFFER,d?16:4,n.STREAM_READ),n.readPixels(0,0,1,1,n.RGBA,d?n.FLOAT:n.UNSIGNED_BYTE,0),n.bindBuffer(n.PIXEL_PACK_BUFFER,null),h.sync=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0),a.viewport.set([0,0,t.width,t.height])}function Eh(t,i,r){if(!Eo(t.context))return;let a=i.lineBlendDensityReadback;a&&a.sync?(function(t,i,r){if(t.sync&&i.getSyncParameter(t.sync,i.SYNC_STATUS)===i.SIGNALED){if(i.deleteSync(t.sync),t.sync=null,i.bindBuffer(i.PIXEL_PACK_BUFFER,t.pbo),Eo(r)){let r=new Float32Array(4);i.getBufferSubData(i.PIXEL_PACK_BUFFER,0,r);let a=r[1];t.maxDensity=Math.max(2*(a>0?r[0]/a:0),1)}else t.maxDensity=1;i.bindBuffer(i.PIXEL_PACK_BUFFER,null)}}
111(a,t.context.gl,t.context),a.sync||(El(t,i,r),t.style.map.triggerRepaint())):(El(t,i,r),t.style.map.triggerRepaint())}function Eu(t,i,r,a,n,o){let s=t.context,l=s.gl,h="additive"===r?1:i.paint.get("line-opacity").constantOr(1),u="additive"===r?function(t,i){let r=i.paint.get("line-blend-additive-clamp");if(r>0)return r;let a=i.lineBlendDensityReadback;return a&&0!==a.maxDensity?a.maxDensity:null}(0,i):1;if(null===u)return;s.bindFramebuffer.set(n),o&&s.viewport.set([0,0,o[0],o[1]]),s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,a.colorAttachment0.get());let c=Es(r,t.context);t.getOrCreateProgram("lineBlendComposite").draw(t,l.TRIANGLES,gz.disabled,g3.disabled,c,gP.disabled,{u_image:0,u_opacity:h,u_blend_mode:En[r].compositeUniformValue,u_max_density:u},i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}function Ec(t,i,r,a){let{painter:n,sourceCache:o,layer:s,coords:l,colorMode:h,elevationType:u,terrainEnabled:c,pass:d}=t,p=n.context.gl,f=s.paint.get("fill-pattern"),_=s.paint.get("fill-pattern-cross-fade"),m=f.constantOr(null),g=u;"road"!==u||i&&!c||(g="none");let y="road"===g,x=t.painter.shadowRenderer,v=y&&!!x&&x.enabled,b=new gz(n.context.gl.LEQUAL,gz.ReadOnly,n.depthRangeFor3D),w=[0,0,0];if(v){let t=n.style.directionalLight,i=n.style.ambientLight;t&&i&&(w=yn(n.style,t,i))}let T=f&&f.constantOr(1),E=n.terrain&&n.terrain.renderingToTexture,S=(t,d)=>{let f,g,S,I,A;d?(f=T&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",S=p.LINES):(f=T?"fillPattern":"fill",S=p.TRIANGLES);let C=[];for(let M of l){let l=o.getTile(M);if(T&&!l.patternsLoaded())continue;let R=l.getBucket(s);if(!R)continue;let D=i?R.hdExt&&R.hdExt.elevationBufferData:R.bufferData;if(!D||D.isEmpty())continue;n.prepareDrawTile();let P=D.programConfigurations.get(s.id),z=n.isTileAffectedByFog(M),L=[],O=[];y&&(L.push("ELEVATED_ROADS"),O.push(D.elevatedLayoutVertexBuffer)),v&&L.push("RENDER_SHADOWS","NORMAL_OFFSET"),E&&r&&L.push("USE_MRT1"),T&&(n.context.activeTexture.set(p.TEXTURE0),l.imageAtlasTexture&&l.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),P.updatePaintBuffers());let F=!1;if(m&&l.imageAtlas){let t=l.imageAtlas,i=au.from(m),r=i.getPrimary().scaleSelf(is.devicePixelRatio).toString(),a=i.getSecondary(),n=t.patternPositions.get(r),o=a?t.patternPositions.get(a.scaleSelf(is.devicePixelRatio).toString()):null;F=!!n&&!!o,n&&P.setConstantPatternPositions(n,o)}_>0&&(F||P.getPatternTransitionVertexBuffer("fill-pattern"))&&L.push("FILL_PATTERN_TRANSITION");let B=n.getOrCreateProgram(f,{config:P,overrideFog:z,defines:L}),k=n.translatePosMatrix(M.projMatrix,l,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));v&&x.setupShadows(l.tileID.toUnwrapped(),B,"vector-tile");let N=s.paint.get("fill-emissive-strength");if(d){I=D.lineIndexBuffer,A=D.lineSegments;let t=n.terrain&&n.terrain.renderingToTexture?n.terrain.drapeBufferSize:[p.drawingBufferWidth,p.drawingBufferHeight];g="fillOutlinePattern"===f&&T?TH(k,N,n,l,t,w,_):TG(k,N,t,w)}else I=D.indexBuffer,A=D.triangleSegments,g=T?Tj(k,N,n,l,w,_):TU(k,N,w);n.uploadCommonUniforms(n.context,B,M.toUnwrapped());let V=t;if(("road"!==u||c)&&"offset"!==u||(V=b),!A||A.get&&0===A.get().length)continue;let U=a||n.stencilModeForClipping(M),j="fallthrough";!d&&bA&&(j=bA({painter:n,layer:s,bucket:R,coord:M,elevatedGeometry:i,program:B,programConfiguration:P,uniformValues:g,drawMode:S,depthMode:V,stencilMode:U,colorMode:h,bufferData:D,indexBuffer:I,segments:A,dynamicBuffers:O,polygonCoverageTiles:C})),"fallthrough"===j&&B.draw(n,S,V,U,h,gP.disabled,g,s.id,D.layoutVertexBuffer,I,A,s.paint,n.transform.zoom,P,O)}!d&&bC&&bC(n,s,C,S,h)};n.renderPass===d&&S(n.depthModeForSublayer(1,"opaque"===n.renderPass?gz.ReadWrite:gz.ReadOnly),!1),"none"===g&&"translucent"===n.renderPass&&s.paint.get("fill-antialias")&&S(n.depthModeForSublayer(2*!!s.getPaintProperty("fill-outline-color"),gz.ReadOnly),!0)}function Ed(t){return[.0039101094886591446*t[0],.0039101094886591446*t[1],.0039101094886591446*t[2],0]}function Ep(t,i,r,a,n,o,s,l,h){let u,c,d,p,f,_,m,g,y=a.getSource(),x=r.globeSharedBuffers;if(!x||(i&&(u=a.getTile(i)),y instanceof b0?(c=y.texture,d=cV(0,0,r.transform)):u&&i&&(c=u.texture,d=cV(i.canonical.z,i.canonical.x,r.transform)),!c||!d))return;t||(d=ex(ec(),d,[1,-1,1]));let v=r.context,b=v.gl,w="nearest"===n.paint.get("raster-resampling")?b.NEAREST:b.LINEAR,T=r.colorModeForDrapableLayerRenderPass(o),E=s.defines;E.push("GLOBE_POLES");let S=new gz(b.LEQUAL,gz.ReadWrite,r.depthRangeFor3D),I=r.transform.expandedFarZProjMatrix,A=Float32Array.from(cz(cT(new cQ(0,0,0))));r.terrain&&r.terrain.prepareDrawTile(),v.activeTexture.set(b.TEXTURE0),c.bind(w,b.CLAMP_TO_EDGE),v.activeTexture.set(b.TEXTURE1),c.bind(w,b.CLAMP_TO_EDGE),"useMipmap"in c&&v.extTextureFilterAnisotropic&&r.transform.pitch>20&&b.texParameterf(b.TEXTURE_2D,v.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,v.extTextureFilterAnisotropicMax);let[C,M,R,D]=i?x.getPoleBuffers(i.canonical.z,!1):x.getPoleBuffers(0,!0),P=n.paint.get("raster-elevation");t?(p=C,r.renderDefaultNorthPole=0!==P):(p=M,r.renderDefaultSouthPole=0!==P);let z=Ed(s.mix),L=(f=d,_=cN(r.transform.zoom),m=s.offset,g=s.range,TY(r,I,A,f,new Float32Array(16),new Float32Array(9),[0,0],_,[0,0],[0,0,0,0],1,{opacity:1,mix:0},n,[0,0],P,2,z,m,g,1,0,o)),O=r.getOrCreateProgram("raster",{defines:E});r.uploadCommonUniforms(v,O,null),O.draw(r,b.TRIANGLES,S,h,T,l,L,n.id,p,R,D)}let Ef=ef(new Float32Array(16)),E_=new rq(1,0,0,1),Em=new rq(0,1,0,1),Eg=new rq(0,0,1,1),Ey=new rq(1,0,1,1),Ex=new rq(0,1,1,1);function Ev(t,i,r,a){Ew(t,0,i+r/2,t.transform.width,r,a)}function Eb(t,i,r,a){Ew(t,i-r/2,0,r,t.transform.height,a)}function Ew(t,i,r,a,n,o){let s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*is.devicePixelRatio,r*is.devicePixelRatio,a*is.devicePixelRatio,n*is.devicePixelRatio),s.clear({color:o}),l.disable(l.SCISSOR_TEST)}let{members:ET}=lo([{name:"a_pos_3f",components:3,type:"Float32"}]);function EE(t,i,r,a){t.emplaceBack(i,r,a)}class ES{constructor(t){this.vertexArray=new lg,this.indices=new lR,EE(this.vertexArray,-1,-1,1),EE(this.vertexArray,1,-1,1),EE(this.vertexArray,-1,1,1),EE(this.vertexArray,1,1,1),EE(this.vertexArray,-1,-1,-1),EE(this.vertexArray,1,-1,-1),EE(this.vertexArray,-1,1,-1),EE(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,ET),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=l9.simpleSegment(0,0,36,12)}}function EI(t,i,r,a,n,o){let s,l,h,u=t.context.gl,c=i.paint.get("sky-atmosphere-color"),d=i.paint.get("sky-atmosphere-halo-color"),p=i.paint.get("sky-atmosphere-sun-intensity"),f=(s=es(eo(),a),l=c.toPremultipliedRenderColor(null),h=d.toPremultipliedRenderColor(null),{u_matrix_3f:s,u_sun_direction:n,u_sun_intensity:p,u_color_tint_r:[l.r,l.g,l.b,l.a],u_color_tint_m:[h.r,h.g,h.b,h.a],u_luminance:5e-5});u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_CUBE_MAP_POSITIVE_X+o,i.skyboxTexture,0),r.draw(t,u.TRIANGLES,gz.disabled,g3.disabled,g6.unblended,gP.frontCW,f,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}let EA=lo([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class EC{constructor(t){let i=new lL;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);let r=new lR;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,EA.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=l9.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}let EM=lo([{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 ER{constructor(){this.colorModeAlphaBlendedWriteRGB=new g6([1,771,1,771],rq.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new g6([1,0,1,0],rq.transparent,[!1,!1,!1,!0]),this.params={starsCount:16e3,sizeMultiplier:.15,sizeRange:100,intensityRange:200},this.updateNeeded=!0,this._painter=null,this._devtoolsFolder=null}update(t){this._painter=t;let i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new EC(i);let t=this.params,r=t.sizeRange,a=t.intensityRange,n=function(t){let i=n5(30),r=[];for(let a=0;a<t;
111++a){let t=2*Math.PI*i(),a=Math.acos(1-2*i())-.5*Math.PI;r.push(eO(Math.cos(a)*Math.cos(t),Math.cos(a)*Math.sin(t),Math.sin(a)))}return r}(t.starsCount),o=n5(300),s=new lO,l=new lR,h=0;for(let t=0;t<n.length;++t){let i=ej([],n[t],200),u=Math.max(0,1+.01*r*(o()-.5)),c=Math.max(0,1+.01*a*(o()-.5));s.emplaceBack(i[0],i[1],i[2],-1,-1,u,c),s.emplaceBack(i[0],i[1],i[2],1,-1,u,c),s.emplaceBack(i[0],i[1],i[2],1,1,u,c),s.emplaceBack(i[0],i[1],i[2],-1,1,u,c),l.emplaceBack(h+0,h+1,h+2),l.emplaceBack(h+0,h+2,h+3),h+=4}this.starsVx=i.createVertexBuffer(s,EM.members),this.starsIdx=i.createIndexBuffer(l),this.starsSegments=l9.simpleSegment(0,0,s.length,l.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy(),this._painter=null}drawAtmosphereGlow(t,i){let r=t.context,a=r.gl,n=t.transform,o=new gz(a.LEQUAL,gz.ReadOnly,[0,1]),s=cN(n.zoom),l=t.style.getLut(i.scope),h="none"===i.properties.get("color-use-theme"),u=i.properties.get("color").toNonPremultipliedRenderColor(h?null:l),c="none"===i.properties.get("high-color-use-theme"),d=i.properties.get("high-color").toNonPremultipliedRenderColor(c?null:l),p="none"===i.properties.get("space-color-use-theme"),f=i.properties.get("space-color").toNonPremultipliedRenderColor(p?null:l),_=tL((i.properties.get("horizon-blend")-0)/1*.2495+5e-4,5e-4,.25),m=cU(t,0,n)&&5e-4===_?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,g=t.frameCounter/1e3%1,y=eL(n.globeCenterInViewSpace),x=Math.acos(Math.sqrt(Math.pow(y,2)-Math.pow(m,2))/y),v=i=>{let l,h,c,p,m,y="globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];i&&y.push("ALPHA_PASS");let v=t.getOrCreateProgram("globeAtmosphere",{defines:y}),b=(l=n.frustumCorners.TL,h=n.frustumCorners.TR,c=n.frustumCorners.BR,p=n.frustumCorners.BL,m=n.frustumCorners.horizon,{u_frustum_tl:l,u_frustum_tr:h,u_frustum_br:c,u_frustum_bl:p,u_horizon:m,u_transition:s,u_fadeout_range:_,u_atmosphere_fog_color:u.toArray01(),u_high_color:d.toArray01(),u_space_color:f.toArray01(),u_temporal_offset:g,u_horizon_angle:x});t.uploadCommonUniforms(r,v);let w=this.atmosphereBuffer;w&&v.draw(t,a.TRIANGLES,o,g3.disabled,i?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,gP.backCW,b,i?"atmosphere_glow_alpha":"atmosphere_glow",w.vertexBuffer,w.indexBuffer,w.segments)};v(!1),v(!0)}drawStars(t,i){var r,a,n,o,s,l,h,u,c,d,p,f,_,m,g;let y=tL(i.properties.get("star-intensity"),0,1);if(0===y)return;let x=t.context,v=x.gl,b=t.transform,w=t.getOrCreateProgram("stars"),T=te([]);tt(T,T,-b._pitch),tr(T,T,-b.angle),tt(T,T,b._center.lat*tA),ti(T,T,-(b._center.lng*tA));let E=eM(new Float32Array(16),T),S=eg([],b.starsProjMatrix,E),I=(r=[],(g=(n=(a=es([],E))[0])*(f=(p=a[8])*(h=a[4])-(u=a[5])*(d=a[7]))+(o=a[1])*(_=-p*(l=a[3])+u*(c=a[6]))+(s=a[2])*(m=d*l-h*c))?(r[0]=f*(g=1/g),r[1]=(-p*o+s*d)*g,r[2]=(u*o-s*h)*g,r[3]=_*g,r[4]=(p*n-s*c)*g,r[5]=(-u*n+s*l)*g,r[6]=m*g,r[7]=(-d*n+o*c)*g,r[8]=(h*n-o*l)*g,r):null),A=this.params.sizeMultiplier,C=[0,1,0];eJ(C,C,I),ej(C,C,A);let M=[1,0,0];eJ(M,M,I),ej(M,M,A);let R={u_matrix:Float32Array.from(S),u_up:C,u_right:M,u_intensity_multiplier:y};t.uploadCommonUniforms(x,w),this.starsVx&&this.starsIdx&&w.draw(t,v.TRIANGLES,gz.disabled,g3.disabled,this.colorModeAlphaBlendedWriteRGB,gP.disabled,R,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class ED{}class EP{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,i,r){{let r=this._storage.get(i.id);if(r)return r.lastUsedFrameIdx=t,r.buf}let a=r.gl,n=a.getBufferParameter(a.ELEMENT_ARRAY_BUFFER,a.BUFFER_SIZE),o=new ArrayBuffer(n),s=new Int16Array(o);a.getBufferSubData(a.ELEMENT_ARRAY_BUFFER,0,new Int16Array(o));let l=new lS;for(let t=0;t<n/2;t+=3){let i=s[t],r=s[t+1],a=s[t+2];l.emplaceBack(i,r),l.emplaceBack(r,a),l.emplaceBack(a,i)}let h=r.bindVertexArrayOES.current,u=new ED;return u.buf=new T2(r,l),u.lastUsedFrameIdx=t,this._storage.set(i.id,u),r.bindVertexArrayOES.set(h),u.buf}update(t){for(let[i,r]of this._storage)t-r.lastUsedFrameIdx>30&&(r.buf.destroy(),this._storage.delete(i))}destroy(){for(let[t,i]of this._storage)i.buf.destroy(),this._storage.delete(t)}}class Ez{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}
111let EL={symbol:function(t,i,r,a,n){if("translucent"!==t.renderPass)return;let o=g3.disabled,s=t.colorModeForRenderPass(),l=r.layout.get("text-variable-anchor"),h=r.layout.get("text-size-scale-range"),u=tL(t.scaleFactor,h[0],h[1]);l&&function(t,i,r,a,n,o,s,l){let h=i.transform,u="map"===n,c="map"===o;for(let i of t){let t=a.getTile(i),n=t.getBucket(r);if(!n||!n.text||!n.text.segments.get().length)continue;let o=uk(n.textSizeData,h.zoom,l),d=ws(i,n.getProjection(),h),p=h.calculatePixelsToTileUnitsMatrix(t),f=gU(d,t.tileID.canonical,c,u,h,n.getProjection(),p),_=n.hasIconTextFit()&&n.hasIconData();o&&function(t,i,r,a,n,o,s,l,h,u){let c=t.text.placedSymbolArray,d=t.text.dynamicLayoutVertexArray,p=t.icon.dynamicLayoutVertexArray,f={},_=t.getProjection(),m=ws(s,_,n),g=n.elevation,y=_.upVectorScale(s.canonical,n.center.lat,n.worldSize).metersToTile;d.clear();for(let p=0;p<c.length;p++){let x=c.get(p),{tileAnchorX:v,tileAnchorY:b,numGlyphs:w}=x,T=x.hidden||!x.crossTileID||t.allowVerticalPlacement&&!x.placedOrientation?null:a[x.crossTileID];if(T){let a=0,c=0,E=0,S="road"===t.elevationType;if(g||S){let i=S&&t.hdExt?t.hdExt.getElevationFeatureForPlacedSymbol(t,t.text,p):null,r=_q.getAtTileOffset(s,new tg(v,b),g,i),[n,o,l]=_.upVector(s.canonical,v,b);a=r*n*y,c=r*o*y,E=r*l*y}let[I,A,C,M]=gH(x.projectedAnchorX+a,x.projectedAnchorY+c,x.projectedAnchorZ+E,r?m:o),R=gq(n.getCameraToCenterDistance(_),M),D=uB(t.textSizeData,h,x)*R/24;r&&(D*=t.tilePixelRatio/l);let P=function({width:t,height:i,anchor:r,textOffset:a,textScale:n},o){let{horizontalAlign:s,verticalAlign:l}=uO(r),h=ci(r,a);return new tg((-(s-.5)*t/n+h[0])*o,(-(l-.5)*i/n+h[1])*o)}(T,D);r?({x:I,y:A,z:C}=_.projectTilePoint(v+P.x,b+P.y,s.canonical),[I,A,C]=gH(I+a,A+c,C+E,o)):(i&&P._rotate(-n.angle),I+=P.x,A+=P.y,C=0);let z=t.allowVerticalPlacement&&x.placedOrientation===uL.vertical?Math.PI/2:0;for(let t=0;t<w;t++)dL(d,I,A,C,z);u&&x.associatedIconIndex>=0&&(f[x.associatedIconIndex]={x:I,y:A,z:C,angle:z})}else gJ(w,d)}if(u){p.clear();let i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){let r=i.get(t),{numGlyphs:a}=r,n=f[t];if(r.hidden||!n)gJ(a,p);else{let{x:t,y:i,z:r,angle:o}=n;for(let n=0;n<a;n++)dL(p,t,i,r,o)}}t.icon.dynamicLayoutVertexBuffer.updateData(p)}t.text.dynamicLayoutVertexBuffer.updateData(d)}(n,u,c,s,h,f,i,Math.pow(2,h.zoom-t.tileID.overscaledZ),o,_)}}(a,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),n,u);let c=0!==r.paint.get("icon-opacity").constantOr(1),d=0!==r.paint.get("text-opacity").constantOr(1);void 0!==r.layout.get("symbol-sort-key").constantOr(1)&&(c||d)?Ee(t,i,r,a,o,s):(c&&Ee(t,i,r,a,o,s,{onlyIcons:!0}),d&&Ee(t,i,r,a,o,s,{onlyText:!0})),i.map.showCollisionBoxes&&(T8(t,i,r,a,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),T8(t,i,r,a,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,r,a){if("translucent"!==t.renderPass)return;let n=r.paint.get("circle-opacity"),o=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1),h=r.paint.get("circle-emissive-strength");if(0===n.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;let u=t.context,c=u.gl,d=t.transform,p=!(!t.terrain||!t.terrain.enabled),f=r.layout.get("circle-elevation-reference"),_=t.depthModeForSublayer(0,gz.ReadOnly),m=new gz(t.context.gl.LEQUAL,gz.ReadOnly,t.depthRangeFor3D),g="none"===f||p?_:m,y=g3.disabled,x=t.colorModeForDrapableLayerRenderPass(h),v="globe"===d.projection.name,b=[az(d.center.lng),aL(d.center.lat)],w=[];for(let n=0;n<a.length;n++){let o=a[n],s=i.getTile(o),h=s.getBucket(r);if(!h||h.projection.name!==d.projection.name)continue;let u=h.programConfigurations.get(r.id),c=h.layoutVertexBuffer,p=h.globeExtVertexBuffer,f=h.indexBuffer,_=_p(r),m=[p],g=t.isTileAffectedByFog(o);v&&_.push("PROJECTION_GLOBE_VIEW"),_.push("DEPTH_D24"),t.terrain&&d.depthOcclusionForSymbolsAndCircles&&_.push("DEPTH_OCCLUSION"),h.hdExt&&h.hdExt.hasElevation&&!t.terrain&&(_.push("ELEVATED_ROADS"),m.push(h.hdExt.elevatedLayoutVertexBuffer));let y=t.getOrCreateProgram("circle",{config:u,defines:_,overrideFog:g}),x=d.projection.createInversionMatrix(d,o.canonical),T={programConfiguration:u,program:y,layoutVertexBuffer:c,dynamicBuffers:m,indexBuffer:f,uniformValues:_d(t,o,s,x,b,r),tile:s};if(l)for(let t of h.segments.get())w.push({segments:new l9([t]),sortKey:t.sortKey,state:T});else w.push({segments:h.segments,sortKey:0,state:T})}l&&w.sort((t,i)=>t.sortKey-i.sortKey);let T={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(let i of w){let{programConfiguration:a,program:n,layoutVertexBuffer:o,dynamicBuffers:s,indexBuffer:l,uniformValues:h,tile:p}=i.state,f=i.segments;t.terrain&&t.terrain.setupElevationDraw(p,n,T),t.uploadCommonUniforms(u,n,p.tileID.toUnwrapped()),n.draw(t,c.TRIANGLES,g,y,x,gP.disabled,h,r.id,o,l,f,r.paint,d.zoom,a,s)}},heatmap:function(t,i,r,a){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){let n=t.context,o=n.gl,s=g3.disabled,l=new g6([o.ONE,o.ONE,o.ONE,o.ONE],rq.transparent,[!0,!0,!0,!0]),h="globe"===t.transform.projection.name?.5:.25;r.heatmapFbo=T5.createWithTexture(n,r.heatmapFbo,t.width*h,t.height*h),n.clear({color:rq.transparent});let u=t.transform,c="globe"===u.projection.name,d=c?["PROJECTION_GLOBE_VIEW"]:[],p=c?gP.frontCCW:gP.disabled,f=[az(u.center.lng),aL(u.center.lat)];for(let h=0;h<a.length;h++){let _=a[h];if(i.hasRenderableParent(_))continue;let m=i.getTile(_),g=m.getBucket(r);
111if(!g||g.projection.name!==u.projection.name)continue;let y=t.isTileAffectedByFog(_),x=g.programConfigurations.get(r.id),v=t.getOrCreateProgram("heatmap",{config:x,defines:d,overrideFog:y}),{zoom:b}=t.transform;t.terrain&&t.terrain.setupElevationDraw(m,v),t.uploadCommonUniforms(n,v,_.toUnwrapped());let w=u.projection.createInversionMatrix(u,_.canonical);v.draw(t,o.TRIANGLES,gz.disabled,s,l,p,TX(t,_,m,w,f,b,r.paint.get("heatmap-intensity")),r.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,r.paint,t.transform.zoom,x,c?[g.globeExtVertexBuffer]:null)}n.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){let r=t.context,a=r.gl,n=i.heatmapFbo;if(!n)return;r.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,n.colorAttachment0.get()),r.activeTexture.set(a.TEXTURE1);let o=i.colorRampTexture;o||(o=i.colorRampTexture=new uW(r,i.colorRamp,a.RGBA8)),o.bind(a.LINEAR,a.CLAMP_TO_EDGE),t.getOrCreateProgram("heatmapTexture").draw(t,a.TRIANGLES,gz.disabled,g3.disabled,t.colorModeForRenderPass(),gP.disabled,{u_image:0,u_color_ramp:1,u_opacity:i.paint.get("heatmap-opacity")},i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,r))},line:function(t,i,r,a){let n=r.paint.get("line-opacity"),o=r.paint.get("line-width");if(0===n.constantOr(1)||0===o.constantOr(1))return;let s=r.paint.get("line-blend-mode"),l=t.terrain&&t.terrain.renderingToTexture;if("default"===s||"globe"===t.transform.projection.name)"translucent"===t.renderPass&&Ei(t,i,r,a);else{if(l)return void function(t,i,r,a,n){if("translucent"!==t.renderPass)return;let o=t.context,s=o.gl,l=t.terrain;if(!l)return;let h=o.bindFramebuffer.current,u="mrt-fallback"===t.emissiveMode,c=l.drapeBufferSize[0],d=l.drapeBufferSize[1];r.lineBlendFbos||(r.lineBlendFbos=new Er),r.lineBlendFbos.drapeFbo=T5.createWithTexture(o,r.lineBlendFbos.drapeFbo,c,d,!0),u&&s.drawBuffers([s.COLOR_ATTACHMENT0]),o.clear({color:En[n].clearColor,depth:1,stencil:0});let p=t.currentStencilSource,f=t._tileClippingMaskIDs,_=t.nextStencilID;t.currentStencilSource=void 0,t._tileClippingMaskIDs={},t.nextStencilID=1;let m=t._terrain;t._terrain=null,t._renderTileClippingMasks(r,i,a),Ei(t,i,r,a,Es(n,t.context),!0),t._terrain=m,t.currentStencilSource=p,t._tileClippingMaskIDs=f,t.nextStencilID=_,u&&s.drawBuffers([s.COLOR_ATTACHMENT0,s.COLOR_ATTACHMENT1]);let g=l.drapeBufferSize,y=r.lineBlendFbos&&r.lineBlendFbos.drapeFbo;y&&("additive"===n&&Eh(t,r,y),Eu(t,r,n,y,h,g))}(t,i,r,a,s);if("offscreen"===t.renderPass)return void function(t,i,r,a,n){let o=t.context,s=Math.ceil(t.width),l=Math.ceil(t.height);r.lineBlendFbos||(r.lineBlendFbos=new Er),r.lineBlendFbos.fbo=T5.createWithTexture(o,r.lineBlendFbos.fbo,s,l,!0),o.clear({color:En[n].clearColor,depth:1,stencil:0});let h=t.currentStencilSource,u=t._tileClippingMaskIDs,c=t.nextStencilID;t.currentStencilSource=void 0,t._tileClippingMaskIDs={},t.nextStencilID=1,t._renderTileClippingMasks(r,i,a);let d=t.renderPass;t.renderPass="translucent",Ei(t,i,r,a,Es(n,t.context)),t.renderPass=d,t.currentStencilSource=h,t._tileClippingMaskIDs=u,t.nextStencilID=c,o.viewport.set([0,0,t.width,t.height]),"additive"===n&&Eh(t,r,r.lineBlendFbos.fbo)}(t,i,r,a,s);if("translucent"===t.renderPass){let i=r.lineBlendFbos&&r.lineBlendFbos.fbo;return void(i&&Eu(t,r,s,i,null))}}},fill:function(t,i,r,a){let n=r.paint.get("fill-color"),o=r.paint.get("fill-opacity");if(0===o.constantOr(1))return;let s=r.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(s),h=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!h.constantOr(1)&&1===n.constantOr(rq.transparent).a&&1===o.constantOr(0)?"opaque":"translucent",c="none";"none"!==r.layout.get("fill-elevation-reference")?c="road":0!==r.paint.get("fill-z-offset").constantOr(1)&&(c="offset");let d=!(!t.terrain||!t.terrain.enabled),p={painter:t,sourceCache:i,layer:r,coords:a,colorMode:l,elevationType:c,terrainEnabled:d,pass:u};if("shadow"===t.renderPass)return void(t.shadowRenderer&&"road"===c&&!d&&bf&&bf(p));let f="mrt-fallback"===t.emissiveMode;if("offset"!==c){if(Ec(p,!1,f),"road"===c){let n=!d&&"translucent"===t.renderPass;n&&b_&&b_(t,i,r,a,"geometry"),Ec(p,!0,f,g3.disabled),n&&bp&&bp(p)}}else Ec(p,!1,f,t.stencilModeFor3D())},"fill-extrusion":function(t,i,r,a){let n=r.paint.get("fill-extrusion-opacity"),o=t.context,s=o.gl,l=t.terrain,h=l&&l.renderingToTexture;if(0===n)return;let u="mrt-fallback"===t.emissiveMode,c=t.conflationActive&&t.style.isLayerClipped(r,i.getSource()),d=t.style.order.indexOf(r.fqid);if(c&&function(t,i,r,a,n){for(let o of a){let a=i.getTile(o).getBucket(r);a&&(a.updateReplacement(o,t.replacementSource,n),a.uploadCentroid(t.context))}}(t,i,r,a,d),l||c)for(let n of a){let a=i.getTile(n).getBucket(r);a&&function(t,i,r,a,n,o,s){0===a.centroidVertexArray.length&&a.createCentroidsBuffer();let l=o?o.findDEMTileFor(r):null;if(!(l&&l.dem||s))return;o&&l&&l.dem&&a.selfDEMTileTimestamp!==l.dem._timestamp&&(a.borderDoneWithNeighborZ=[-1,-1,-1,-1],a.selfDEMTileTimestamp=l.dem._timestamp);let h=(t,i)=>{(t.flags|i.flags)&0x80000000?(t.flags|=0x80000000,i.flags|=0x80000000):(t.flags&=0x7fffffff,i.flags&=0x7fffffff)},u=t=>new tg(Math.ceil(7*(t+450)),0),c=(t,i,r)=>new tg(Math.ceil(7*(t+450)),Math.floor(Math.max(0,Math.min(8191,r))/4)<<5|(3&i)<<3|7),d=t=>{let r=i.getSource().minzoom,a=t=>{let r=i.getTileByID(t);if(r&&r.hasData())return r.getBucket(n)};
111for(let i of[0,-1,1]){if(t.overscaledZ+i<r)continue;let n=a(t.calculateScaledKey(t.overscaledZ+i));if(n)return n}},p=[0,0,0],f=(t,i)=>(p[0]=Math.min(t.min.y,i.min.y),p[1]=Math.max(t.max.y,i.max.y),p[2]=8192-i.min.x>t.max.x?i.min.x-8192:t.max.x,p),_=(t,i)=>(p[0]=Math.min(t.min.x,i.min.x),p[1]=Math.max(t.max.x,i.max.x),p[2]=8192-i.min.y>t.max.y?i.min.y-8192:t.max.y,p),m=[(t,i)=>f(t,i),(t,i)=>f(i,t),(t,i)=>_(t,i),(t,i)=>_(i,t)],g=(t,i,a,n,s,h,u)=>{if(!o)return 0;let c=[[h?a:t,h?t:a,0],[h?a:i,h?i:a,0]],d=u<0?8192+u:u,p=[h?d:(t+i)/2,h?(t+i)/2:d,0];return 0===a&&u<0||0!==a&&u>0?o.getForTilePoints(s,[p],!0,n):c.push(p),o.getForTilePoints(r,c,!0,l),Math.max(c[0][2],c[1][2],p[2])/o.exaggeration()};for(let t=0;t<4;t++){let i=a.borderFeatureIndices[t];if(0===i.length)continue;let n=c2[t](r),l=d(n);if(!(l&&l instanceof fK))continue;let p=o?o.findDEMTileFor(n):null;if(!(p&&p.dem||s)||(o&&p&&p.dem&&a.borderDEMTileTimestamp[t]!==p.dem._timestamp&&(a.borderDoneWithNeighborZ[t]=-1,a.borderDEMTileTimestamp[t]=p.dem._timestamp),a.borderDoneWithNeighborZ[t]===l.canonical.z))continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();let f=(t<2?1:5)-t,_=l.borderDoneWithNeighborZ[f]!==a.canonical.z,y=l.borderFeatureIndices[f],x=0;if(a.canonical.z!==l.canonical.z){for(let t of i)a.showCentroid(a.featuresOnBorder[t]);if(_)for(let t of y)l.showCentroid(l.featuresOnBorder[t]);a.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=a.canonical.z;continue}let v=new Map,b=new Set,w=new Set;for(let t=0;t<y.length;t++){let i=l.featuresOnBorder[y[t]];void 0!==i.buildingId&&v.set(i.buildingId,t)}for(let r of i){let i=a.featuresOnBorder[r],o=a.centroidData.get(i.centroidDataIndex);if(void 0===i.buildingId)continue;let u=v.get(i.buildingId);if(void 0===u)continue;let d=l.featuresOnBorder[y[u]],_=l.centroidData.get(d.centroidDataIndex);b.add(r),w.add(u),s&&h(o,_);let x=0!==o.groupCentroidPos.x||0!==o.groupCentroidPos.y?o.groupCentroidPos:i.centroid(),T=0!==_.groupCentroidPos.x||0!==_.groupCentroidPos.y?_.groupCentroidPos:d.centroid(),E=t<2?Math.round((x.y+T.y)/2):Math.round((x.x+T.x)/2),S=i.intersectsCount()>1||d.intersectsCount()>1;{let i=0;if(p&&p.dem&&!S){let r=m[t](o,_),a=t%2?8191:0;i=g(r[0],Math.min(8191,r[1]),a,p,n,t<2,r[2])}o.centroidXY=c(i,t,E),_.centroidXY=c(i,f,E)}if(a.writeCentroidToBuffer(o),l.writeCentroidToBuffer(_),void 0!==i.buildingId){for(let t of a.centroidData)t.buildingId===i.buildingId&&t!==o&&(t.centroidXY=o.centroidXY,a.writeCentroidToBuffer(t));for(let t of l.centroidData)t.buildingId===i.buildingId&&t!==_&&(t.centroidXY=_.centroidXY,l.writeCentroidToBuffer(t))}}for(let r of i){let i;if(b.has(r))continue;let o=a.featuresOnBorder[r],c=a.centroidData.get(o.centroidDataIndex),d=o.borders[t];for(;x<y.length;){if(w.has(x)){x++;continue}let t=(i=l.featuresOnBorder[y[x]]).borders[f];if(t[1]>d[0]+3||t[0]>d[0]-3)break;l.showCentroid(i),x++}if(i&&x<y.length){let r=x,_=0;for(;;)if(w.has(x)){if(++x===y.length)break;i=l.featuresOnBorder[y[x]]}else{if(i.borders[f][0]>d[1]-3||(_++,++x===y.length))break;i=l.featuresOnBorder[y[x]]}for(;r<y.length&&w.has(r);)r++;if(r>=y.length){a.showCentroid(o);continue}i=l.featuresOnBorder[y[r]];let v=!1;if(_>=1){let t=i.borders[f];3>Math.abs(d[0]-t[0])&&3>Math.abs(d[1]-t[1])&&(_=1,v=!0,x=r+1)}else if(0===_){a.showCentroid(o);continue}let b=l.centroidData.get(i.centroidDataIndex);s&&v&&h(c,b);let T=o.intersectsCount()>1||i.intersectsCount()>1;if(_>1)x=r,c.centroidXY=b.centroidXY=new tg(0,0);else if(p&&p.dem&&!T){let i=m[t](c,b),r=t%2?8191:0;c.centroidXY=b.centroidXY=u(g(i[0],Math.min(8191,i[1]),r,p,n,t<2,i[2]))}else T?c.centroidXY=b.centroidXY=new tg(0,0):(c.centroidXY=a.encodeBorderCentroid(o),b.centroidXY=l.encodeBorderCentroid(i));a.writeCentroidToBuffer(c),l.writeCentroidToBuffer(b)}else a.showCentroid(o)}a.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[f]=a.canonical.z}(a.needsCentroidUpdate||!a.centroidVertexBuffer&&0!==a.centroidVertexArray.length)&&a.uploadCentroid(t)}(t.context,i,n,a,r,l,c)}if("shadow"===t.renderPass&&t.shadowRenderer){if(l&&n<.65&&r._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof oT)return;let o=t.shadowRenderer.getShadowPassDepthMode();xc(t,i,r,a,o,g3.disabled,g6.disabled,c)}else if("translucent"===t.renderPass){let d=!r.paint.get("fill-extrusion-pattern").constantOr(1),p=r.paint.get("fill-extrusion-color").constantOr(rq.white);
111if(!h&&0!==p.a){let o=new gz(t.context.gl.LEQUAL,gz.ReadWrite,t.depthRangeFor3D);1===n&&d?xc(t,i,r,a,o,g3.disabled,g6.unblended,c):(xc(t,i,r,a,o,g3.disabled,g6.disabled,c),xc(t,i,r,a,o,t.stencilModeFor3D(),t.colorModeForRenderPass(),c),t.resetStencilClippingMasks())}let f=t.style.enable3dLights()&&d&&(!l&&"globe"!==t.transform.projection.name||h);if(f&&!g5&&xu(),f&&g5){let n=r.paint.get("fill-extrusion-opacity"),d=r.paint.get("fill-extrusion-ambient-occlusion-intensity"),p=r.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),f=r.paint.get("fill-extrusion-flood-light-intensity"),_="none"===r.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=r.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(_?null:r.lut).toArray01().slice(0,3),g=d>0&&p>0,y=f>0,x=new xd;x.translate=r.paint.get("fill-extrusion-translate"),x.translateAnchor=r.paint.get("fill-extrusion-translate-anchor"),x.edgeRadius=r.layout.get("fill-extrusion-edge-radius"),x.cutoffFadeRange=r.paint.get("fill-extrusion-cutoff-fade-range");let v=o=>{let l=t.depthModeForSublayer(1,gz.ReadOnly,s.LEQUAL,!0),h=rG(.1,3,r.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation")),u=t._showOverdrawInspector;if(!u){let u=new g3({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE);g5(x,t,i,r,a,l,u,new g6([s.ONE,s.ONE,s.ONE,s.ONE],rq.transparent,[!1,!1,!1,!0],s.MIN),gP.disabled,o,"sdf",n,d,p,f,m,h,c,!1)}{let _=u?g3.disabled:new g3({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),g=u?t.colorModeForRenderPass():new g6([s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA,s.ONE,s.ONE],rq.transparent,[!0,!0,!0,!0]);g5(x,t,i,r,a,l,_,g,gP.disabled,o,"color",n,d,p,f,m,h,c,!1)}};if(h){let h=()=>{let t=l.drapeBufferSize[0],i=l.drapeBufferSize[1],r=l.framebufferCopyTexture;return r&&(!r||r.size[0]===t&&r.size[1]===i)||(r&&r.destroy(),r=l.framebufferCopyTexture=new uW(o,new h7({width:t,height:i}),s.RGBA8)),r.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,0,0,t,i),r},_=(o,l,_)=>{let g=t.depthModeForSublayer(1,gz.ReadOnly,s.LEQUAL,!1),y=rG(.1,3,r.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"));{let h=new g6([s.ONE,s.ONE,s.ONE,s.ONE],rq.transparent,[!1,!1,!1,!0]);g5(x,t,i,r,a,g,g3.disabled,h,gP.disabled,o,"clear",n,d,p,f,m,y,c,l)}{let h=new g3({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE);g5(x,t,i,r,a,g,h,new g6([s.ONE,s.ONE,s.ONE,s.ONE],rq.transparent,[!1,!1,!1,!0],s.MIN),gP.disabled,o,"sdf",n,d,p,f,m,y,c,l)}u&&!o&&(_=h());{let h=o?s.ZERO:s.ONE_MINUS_DST_ALPHA,u=new g3({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR);g5(x,t,i,r,a,g,u,new g6([h,s.DST_ALPHA,s.ONE_MINUS_DST_ALPHA,s.ZERO],rq.transparent,[!0,!0,!0,!0]),gP.disabled,o,"color",n,d,p,f,m,y,c,l)}if(!u||o){let h=new g6([s.ONE,s.ONE,s.ONE,o?s.ZERO:s.ONE],rq.transparent,[!1,!1,!1,!0],o?s.FUNC_ADD:s.MAX);g5(x,t,i,r,a,g,g3.disabled,h,gP.disabled,o,"clear",n,d,p,f,m,y,c,l,_)}else{s.drawBuffers([s.NONE,s.COLOR_ATTACHMENT1]);let h=new g3({func:s.EQUAL,mask:255},254,255,s.KEEP,s.DECR,s.DECR);g5(x,t,i,r,a,g,h,new g6([s.ONE,s.ONE,s.ONE,s.ONE],rq.transparent,[!0,!1,!1,!1],s.MAX),gP.disabled,o,"emissive",n,d,p,f,m,y,c,l,_),s.drawBuffers([s.COLOR_ATTACHMENT0])}};if(g||y){let i;t.prepareDrawTile(),u&&!g||(i=h()),g&&_(!0,!1,i),y&&_(!1,!0,i)}}else g&&v(!0),y&&v(!1),(g||y)&&t.resetStencilClippingMasks()}}},hillshade:function(t,i,r,a){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass||t.style.disableElevatedTerrain)return;let n=t.context,o=t.terrain&&t.terrain.renderingToTexture,[s,l]="translucent"!==t.renderPass||o?[{},a]:t.stencilConfigForOverlap(a);for(let a of l){let n=i.getTile(a);if(n.needsHillshadePrepare&&"offscreen"===t.renderPass)!function(t,i,r){let a=t.context,n=a.gl;if(!i.dem)return;let o=i.dem;if(a.activeTexture.set(n.TEXTURE1),w0(t,i,o),!i.demTexture)return;i.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE);let s=o.dim;a.activeTexture.set(n.TEXTURE0);let l=i.hillshadeFBO;if(!l){let t=new uW(a,{width:s,height:s,data:null},n.RGBA8);t.bind(n.LINEAR,n.CLAMP_TO_EDGE),(l=i.hillshadeFBO=a.createFramebuffer(s,s,1,"renderbuffer")).colorAttachment0.set(t.texture)}a.bindFramebuffer.set(l.framebuffer),a.viewport.set([0,0,s,s]);let{tileBoundsBuffer:h,tileBoundsIndexBuffer:u,tileBoundsSegments:c}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&d.push("USE_MRT1"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,n.TRIANGLES,gz.disabled,g3.disabled,g6.unblended,gP.disabled,((t,i)=>{let r=i.stride,a=ec();return eD(a,0,8192,-8192,0,0,1),ey(a,a,[0,-8192,0]),{u_matrix:a,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ}})(i.tileID,o),r.id,h,u,c),i.needsHillshadePrepare=!1}(t,n,r);else if("translucent"===t.renderPass){let i=t.depthModeForSublayer(0,gz.ReadOnly),l=r.paint.get("hillshade-emissive-strength"),h=t.colorModeForDrapableLayerRenderPass(l),u=o&&t.terrain?t.terrain.stencilModeForRTTOverlap(a):s[a.overscaledZ];!function(t,i,r,a,n,o,s){let l=t.context,h=l.gl,u=r.hillshadeFBO;if(!u)return;t.prepareDrawTile();let c=t.isTileAffectedByFog(i),d=[];t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&d.push("USE_MRT1");let p=t.getOrCreateProgram("hillshade",{overrideFog:c,defines:d});l.activeTexture.set(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,u.colorAttachment0.get());let f=((t,i,r,a)=>{let n=r.paint.get("hillshade-shadow-color"),o="none"===r.paint.get("hillshade-shadow-color-use-theme").
111constantOr("default"),s=r.paint.get("hillshade-highlight-color"),l="none"===r.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),h=r.paint.get("hillshade-accent-color"),u="none"===r.paint.get("hillshade-accent-color-use-theme").constantOr("default"),c=r.paint.get("hillshade-emissive-strength"),d=r.paint.get("hillshade-illumination-direction")*tA;if("viewport"===r.paint.get("hillshade-illumination-anchor"))d-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){let i=t.style.directionalLight.properties.get("direction");d=tQ(i.x,i.y,i.z)[1]*tA}let p=!t.options.moving;return{u_matrix:a||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),p),u_image:0,u_latrange:function(t,i){let r=Math.pow(2,i.canonical.z),a=i.canonical.y;return[new s8(0,a/r).toLngLat().lat,new s8(0,(a+1)/r).toLngLat().lat]}(0,i.tileID),u_light:[r.paint.get("hillshade-exaggeration"),d],u_shadow:n.toPremultipliedRenderColor(o?null:r.lut),u_highlight:s.toPremultipliedRenderColor(l?null:r.lut),u_emissive_strength:c,u_accent:h.toPremultipliedRenderColor(u?null:r.lut)}})(t,r,a,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,p,i.toUnwrapped());let{tileBoundsBuffer:_,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(r);p.draw(t,h.TRIANGLES,n,o,s,gP.disabled,f,a.id,_,m,g)}(t,a,n,r,i,u,h)}}n.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,i,r,a,n,o){if("translucent"!==t.renderPass)return;let s=r.paint.get("raster-opacity");if(0===s)return;let l="globe"===t.transform.projection.name,h=0!==r.paint.get("raster-elevation"),u=h&&l,c=t.terrain&&t.terrain.exaggeration()>0&&h&&"ground"===r.paint.get("raster-elevation-reference"),d=!l&&c;if(t.renderElevatedRasterBackface&&!u)return;let p=t.context,f=p.gl,_=i.getSource(),m=function(t,i,r,a,n){let o=i.paint.get("raster-color"),s="raster-array"===t.type,l=[],h=i.paint.get("raster-resampling"),u=i.paint.get("raster-color-mix"),c=i.paint.get("raster-color-range"),d=[u[0],u[1],u[2],0],p=u[3],f="nearest"===h?a.NEAREST:a.LINEAR;if(s&&(l.push("RASTER_ARRAY"),o||l.push("RASTER_COLOR"),"linear"===h&&l.push("RASTER_ARRAY_LINEAR"),f=a.NEAREST,!c&&t.rasterLayers)){let r=t.rasterLayers.find(({id:t})=>t===i.sourceLayer);r&&r.fields&&r.fields.range&&(c=r.fields.range)}if(c=c||[0,1],o){l.push("RASTER_COLOR"),r.activeTexture.set(a.TEXTURE2),i.updateColorRamp(c);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new uW(r,i.colorRamp,a.RGBA8)),t.bind(f,a.CLAMP_TO_EDGE)}return n&&l.push("USE_MRT1"),{mix:d,range:c,offset:p,defines:l,resampling:f}}(_,r,p,f,t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode);if(_ instanceof b0&&!a.length&&!l)return;let g=r.paint.get("raster-emissive-strength"),y=t.colorModeForDrapableLayerRenderPass(g),x=t.terrain&&t.terrain.renderingToTexture,v=!t.options.moving,b="nearest"===r.paint.get("raster-resampling")?f.NEAREST:f.LINEAR;if(_ instanceof b0&&!a.length&&(_.onNorthPole||_.onSouthPole)){let a=h?t.stencilModeFor3D():g3.disabled;return void Ep(!!_.onNorthPole,null,t,i,r,g,m,gP.disabled,a)}if(!a.length)return;let[w,T]=_ instanceof b0||x?[{},a]:t.stencilConfigForOverlap(a),E=T.at(-1).overscaledZ;u&&m.defines.push("PROJECTION_GLOBE_VIEW"),h&&m.defines.push("RENDER_CUTOFF","ELEVATED"),c&&m.defines.push("ELEVATION_REFERENCE_GROUND");let S=(a,n,T)=>{for(let S of a){let a,I,A,C,M,R=S.toUnwrapped(),D=i.getTile(S);if(x&&(!D||!D.hasData()))continue;p.activeTexture.set(f.TEXTURE0);let P=function(t,i,r,a){if(t)return i instanceof vw&&t instanceof vc?i.getTextureDescriptor(t,r,!0):{texture:t.texture,mix:Ed(a.mix),offset:a.offset,buffer:0,tileSize:1}}(D,_,r,m);if(!P||!P.texture)continue;let{texture:z,mix:L,offset:O,tileSize:F,buffer:B}=P;x?(a=gz.disabled,I=S.projMatrix):h?(a=new gz(f.LEQUAL,gz.ReadWrite,t.depthRangeFor3D),I=l?t.transform.expandedFarZProjMatrix:t.transform.calculateProjMatrix(R,v)):(a=t.depthModeForSublayer(S.overscaledZ-E,1===s?gz.ReadWrite:gz.ReadOnly,f.LESS),I=t.transform.calculateProjMatrix(R,v));let k=t.terrain&&x?t.terrain.stencilModeForRTTOverlap(S):w[S.overscaledZ],N=o?0:r.paint.get("raster-fade-duration");D.registerFadeDuration(N);let V=i.findLoadedParent(S,0),U=vS(D,V,i,t.transform,N);!U.isFading&&D.refreshedUponExpiration&&(D.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),p.activeTexture.set(f.TEXTURE0),z.bind(b,f.CLAMP_TO_EDGE),p.activeTexture.set(f.TEXTURE1),V?(V.texture&&V.texture.bind(b,f.CLAMP_TO_EDGE),A=Math.pow(2,V.tileID.overscaledZ-D.tileID.overscaledZ
111),C=[D.tileID.canonical.x*A%1,D.tileID.canonical.y*A%1]):z.bind(b,f.CLAMP_TO_EDGE),"useMipmap"in z&&p.extTextureFilterAnisotropic&&t.transform.pitch>20&&f.texParameterf(f.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let j=t.transform,G=h?function(t){if(t.isOrthographic)return[0,0,0,0];let i=t._nearZ,r=t.projection.farthestPixelDistance(t),a=r-i,n=.2*t.height,o=i+n;return[i,r,(o-n-i)/a,(o-i)/a]}(j):[0,0,0,0],H,q,Z,$,W,X=0;if(u&&_ instanceof b0&&_.coordinates.length>3)H=Float32Array.from(cz(cT(new cQ(0,0,0)))),q=Float32Array.from(j.globeMatrix),Z=Float32Array.from(ck(j)),$=[az(j.center.lng),aL(j.center.lat)],M=_.elevatedGlobePerspectiveTransform,W=_.elevatedGlobeGridMatrix||new Float32Array(9);else if(u){let t=cC(S.canonical);X=cG(t.getCenter().lat),H=Float32Array.from(cz(cT(S.canonical))),q=Float32Array.from(j.globeMatrix),Z=Float32Array.from(ck(j)),$=[az(j.center.lng),aL(j.center.lat)],M=[0,0],W=Float32Array.from(cj(S.canonical,t,X,j.worldSize/j._pixelsPerMercatorPixel))}else M=_ instanceof b0?_.perspectiveTransform:[0,0],H=new Float32Array(16),q=new Float32Array(9),Z=new Float32Array(16),$=[0,0],W=new Float32Array(9);let Y=TY(t,I,H,q,Z,W,C||[0,0],cN(t.transform.zoom),$,G,A||1,U,r,M,h?r.paint.get("raster-elevation"):0,2,L,O,m.range,F,B,g),K=t.isTileAffectedByFog(S),Q=t.getOrCreateProgram("raster",{defines:m.defines,overrideFog:K});if(t.uploadCommonUniforms(p,Q,R),_ instanceof b0){let i=_.elevatedGlobeVertexBuffer,o=_.elevatedGlobeIndexBuffer;if(x||!l)_.boundsBuffer&&_.boundsSegments&&Q.draw(t,f.TRIANGLES,a,g3.disabled,y,gP.disabled,Y,r.id,_.boundsBuffer,t.quadTriangleIndexBuffer,_.boundsSegments);else if(i&&o){let s=j.zoom<=5?_.elevatedGlobeSegments:_.getSegmentsForLongitude(j.center.lng);s&&Q.draw(t,f.TRIANGLES,a,g3.disabled,y,n,Y,r.id,i,o,s)}}else if(u){a=new gz(f.LEQUAL,gz.ReadOnly,t.depthRangeFor3D);let i=t.globeSharedBuffers;if(i){c&&(t.terrain.setupElevationDraw(D,Q),t.uploadCommonUniforms(p,Q,D.tileID.toUnwrapped()));let[o,s,l]=i.getGridBuffers(X,!1),h=Q.getAttributeLocation(f,"a_texture_pos");-1!==h&&f.vertexAttribI4ui(h,0,0,0,0),Q.draw(t,f.TRIANGLES,a,T||k,t.colorModeForRenderPass(),n,Y,r.id,o,s,l)}}else if(d)a=new gz(f.LEQUAL,gz.ReadWrite,t.depthRangeFor3D),t.terrain.setupElevationDraw(D,Q),t.uploadCommonUniforms(p,Q,D.tileID.toUnwrapped()),j.pitch>20&&Q.draw(t,f.TRIANGLES,a,g3.disabled,g6.disabled,gP.frontCCW,Y,r.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments),Q.draw(t,f.TRIANGLES,a,k,y,gP.backCCW,Y,r.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments);else{let{tileBoundsBuffer:i,tileBoundsIndexBuffer:n,tileBoundsSegments:o}=t.getTileBoundsBuffers(D);Q.draw(t,f.TRIANGLES,a,k,y,gP.disabled,Y,r.id,i,n,o)}}if(!(_ instanceof b0)&&u)for(let o of a){let a=o.canonical.y===(1<<o.canonical.z)-1;0===o.canonical.y&&Ep(!0,o,t,i,r,g,m,n,T||g3.disabled),a&&Ep(!1,o,t,i,r,g,m,n===gP.frontCW?gP.backCW:gP.frontCW,T||g3.disabled)}};u?S(T,t.renderElevatedRasterBackface?gP.backCW:gP.frontCW,t.stencilModeFor3D()):S(T,gP.disabled,void 0),t.resetStencilClippingMasks()},background:function(t,i,r,a){let n,o=r.paint.get("background-color"),s="none"===r.paint.get("background-color-use-theme").constantOr("default"),l=r.paint.get("background-opacity"),h=r.paint.get("background-emissive-strength"),u="viewport"===r.paint.get("background-pitch-alignment");if(0===l)return;let c=t.context,d=c.gl,p=t.transform,f=p.tileSize,_=r.paint.get("background-pattern");if(void 0!==_&&(null===_||!(n=t.imageManager.getPattern(rk.from(_.toString()),r.scope,t.style.getLut(r.scope)))))return;let m=!_&&1===o.a&&1===l&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==m)return;let g=g3.disabled,y=t.depthModeForSublayer(0,"opaque"===m?gz.ReadWrite:gz.ReadOnly),x=t.colorModeForDrapableLayerRenderPass(h),v=_?"backgroundPattern":"background",b,w=a;w||(w=Object.values(b=t.getBackgroundTiles()).map(t=>t.tileID)),_&&(c.activeTexture.set(d.TEXTURE0),t.imageManager.bind(t.context,r.scope));let T=[];if(t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&T.push("USE_MRT1"),u){let i=t.getOrCreateProgram(v,{overrideFog:!1,overrideRtt:!0,defines:T}),a=new c0(0,0,0,0,0),c=_?T0(Ef,h,l,t,0,r.scope,n,u,{tileID:a,tileSize:f}):TJ(Ef,h,l,o.toPremultipliedRenderColor(s?null:r.lut));return void i.draw(t,d.TRIANGLES,y,g,x,gP.disabled,c,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}for(let m of w){let w=t.isTileAffectedByFog(m),E=t.getOrCreateProgram(v,{overrideFog:w,defines:T}),S=m.toUnwrapped(),I=a?m.projMatrix:t.transform.calculateProjMatrix(S);t.prepareDrawTile();let A=i?i.getTile(m):b?b[m.key]:new xV(m,f,p.zoom,t),C=_?T0(I,h,l,t,0,r.scope,n,u,{tileID:m,tileSize:f}):TJ(I,h,l,o.toPremultipliedRenderColor(s?null:r.lut));t.uploadCommonUniforms(c,E,S);let{tileBoundsBuffer:M,tileBoundsIndexBuffer:R,tileBoundsSegments:D}=t.getTileBoundsBuffers(A);E.draw(t,d.TRIANGLES,y,g,x,gP.disabled,C,r.id,M,R,D)}},sky:function(t,i,r){let a=t._atmosphere?cN(t.transform.zoom):1,n=r.paint.get("sky-opacity")*a;if(0===n)return;let o=t.context,s=r.paint.get("sky-type"),l=new gz(o.gl.LEQUAL,gz.ReadOnly,[0,1]),h=t.frameCounter/1e3%1;"atmosphere"===s?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,i){let r=t.context,a=r.gl,n=i.skyboxFbo;if(!n){n=i.skyboxFbo=r.createFramebuffer(32,32,1,null),i.skyboxGeometry=new ES(r),i.skyboxTexture=r.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let t=0;t<6;++t)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null)}r.bindFramebuffer.set(n.framebuffer),r.viewport.set([0,0,32,32]);let o=i.getCenter(t,!0),s=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);eA(l,-(.5*Math.PI)),EI(t,i,s,l,o,0),eA(l,.5*Math.PI),EI(t,i,s,l,o,1),eI(l,-(.5*Math.PI)),EI(t,i,s,l,o,2),eI(l,.5*Math.PI),EI(t,i,s,l,o,3),ef(l),EI(t,i,s,l,o,4),eA(l,Math.PI),EI(t,i,s,l,o,5),r.viewport.set([0,0,t.width,t.height])}(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,i,r,a,n){let o,s=t.context,l=s.gl,h=t.transform,u=t.getOrCreateProgram("skybox");s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_CUBE_MAP,i.skyboxTexture);let c=(o=h.skyboxMatrix,{u_matrix:o,u_sun_direction:i.getCenter(t,!1),u_cubemap:0,u_opacity:a,u_temporal_offset:n});t.uploadCommonUniforms(s,u),u.draw(t,l.TRIANGLES,r,g3.disabled,t.colorModeForRenderPass(),gP.backCW,c,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,r,l,n,h):"gradient"===s&&"sky"===t.renderPass&&function(t,i,r,a,n){var o,s;let l=t.context,h=l.gl,u=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new ES(l)),l.activeTexture.set(h.TEXTURE0);let d=i.colorRampTexture;d||(d=i.colorRampTexture=new uW(l,i.colorRamp,h.RGBA8)),d.bind(h.LINEAR,h.CLAMP_TO_EDGE);let p=(o=u.skyboxMatrix,s=i.getCenter(t,!1),{u_matrix:o,u_color_ramp:0,u_center_direction:s,u_radius:i.paint.get("sky-gradient-radius")*tA,u_opacity:a,u_temporal_offset:n});t.uploadCommonUniforms(l,c),c.draw(t,h.TRIANGLES,r,g3.disabled,t.colorModeForRenderPass(),gP.backCW,p,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,r,l,n,h)},custom:function(t,i,r,a){let n=t.context,o=r.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&r.isDraped(i)){if("offscreen"===t.renderPass){let i=o.prerender;if(i){if(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){let r=t.transform.pointMerc;i.call(o,n.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),cN(t.transform.zoom),[r.x,r.y],t.transform.pixelsPerMeterRatio)}else i.call(o,n.gl,t.transform.customLayerMatrix());n.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){let i=o.renderToTile;if(i){let r=a[0].canonical,s={x:r.x+a[0].wrap*(o.wrapTileId?0:1<<r.z),y:r.y,z:r.z};n.setDepthMode(gz.disabled),n.setStencilMode(g3.disabled),n.setColorMode(t.colorModeForRenderPass()),t.setCustomLayerDefaults();let l=n.gl;"mrt-fallback"===t.emissiveMode&&l.drawBuffers([l.COLOR_ATTACHMENT0]),i.call(o,n.gl,s),"mrt-fallback"===t.emissiveMode&&l.drawBuffers([l.COLOR_ATTACHMENT0,l.COLOR_ATTACHMENT1]),n.setDirty(),t.setBaseState()}return}t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),n.setStencilMode(g3.disabled);let i="3d"===o.renderingMode?new gz(t.context.gl.LEQUAL,gz.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,gz.ReadOnly);if(n.setDepthMode(i),"globe"===t.transform.projection.name){let i=t.transform.pointMerc;o.render(n.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),cN(t.transform.zoom),[i.x,i.y],t.transform.pixelsPerMeterRatio)}else o.render(n.gl,t.transform.customLayerMatrix());n.setDirty(),t.setBaseState(),n.bindFramebuffer.set(null)}}else tX("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")}},EO={line:function(t,i,r){if(t.hasElevatedBuckets=!1,t.hasNonElevatedBuckets=!1,void 0!==t._unevaluatedLayout.getValue("line-elevation-reference")||void 0!==t._unevaluatedLayout.getValue("line-z-offset")){if(i)for(let r of i.getVisibleCoordinates()){let a=i.getTile(r).getBucket(t);
111if(a&&("none"!==a.elevationType?t.hasElevatedBuckets=!0:t.hasNonElevatedBuckets=!0,t.hasElevatedBuckets&&t.hasNonElevatedBuckets))break}}else t.hasNonElevatedBuckets=!0},raster:function(t,i,r){let a=i.getSource();if(!(a instanceof vw&&a.loaded()))return;let n=t.sourceLayer||a.rasterLayerIds&&a.rasterLayerIds[0];if(!n)return;let o=t.paint.get("raster-array-band")||a.getInitialBand(n);if(null!=o)for(let r of i.getIds().map(t=>i.getTileByID(t)))r.updateNeeded(t.id,o)&&a.prepareTile(r,n,t.id,o)}};async function EF(t){await xu(),Object.assign(EL,{model:xo}),Object.assign(EO,{model:xs}),t&&!t._shadowRenderer&&xh&&(t._shadowRenderer=new xh(t))}class EB{constructor(t,i,r,a,n){this.context=new T6(t,i),this.transform=r,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.frcCoverageSnapshot=null,this.elevationCoverageSnapshot=null,this.elevationProvidersReady=void 0,this.frcCoverageFadeRange=null,this.frcCoverageSourceLayers=[],this.frcCoverageRenderer=bI?new bI: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 Ez,this.setup(),this.numSublayers=vq.maxUnderzooming+vq.maxOverzooming+1,this.depthEpsilon=1/65536,this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this.frameTimeDelta=0,this.lastPaintStartTimeStamp=0,this._shadowCullCache=null,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new dy,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._wireframeDebugCache=new EP,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];let o=new h7({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new uW(this.context,o,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=a,this.maxFrontCutoffRawStart=0,this.worldview=n,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(t,i){let r=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(r||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new TB(this,t));let a=this._terrain;this.transform.elevation=r?a:null,a.update(t,this.transform,i),this.transform.elevation&&!a.enabled&&(this.transform.elevation=null)}_updateFog(t){let i=t.fog;if(!i||"globe"===this.transform.projection.name||1>i.getOpacity(this.transform.pitch)||.03>i.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);let[r,a]=i.getRangeForProjection();if(r>a)return void(this.transform.fogCullDistSq=null);let n=r+.78*(a-r);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(t){t&&!this._terrain&&(this._terrain=new TB(this,this.style)),this._forceTerrainMode=t}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*is.devicePixelRatio,this.height=i*is.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let t of this.style.order)this.style._mergedLayers[t].resize()}setup(){let t=this.context,i=new ll;i.emplaceBack(0,0),i.emplaceBack(8192,0),i.emplaceBack(0,8192),i.emplaceBack(8192,8192),this.tileExtentBuffer=t.createVertexBuffer(i,cs.members),this.tileExtentSegments=l9.simpleSegment(0,0,4,2);let r=new ll;r.emplaceBack(0,0),r.emplaceBack(8192,0),r.emplaceBack(0,8192),r.emplaceBack(8192,8192),this.debugBuffer=t.createVertexBuffer(r,cs.members),this.debugSegments=l9.simpleSegment(0,0,4,5);let a=new ll;a.emplaceBack(-1,-1),a.emplaceBack(1,-1),a.emplaceBack(-1,1),a.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(a,cs.members),this.viewportSegments=l9.simpleSegment(0,0,4,2);let n=new lu;n.emplaceBack(0,0,0,0),n.emplaceBack(8192,0,8192,0),n.emplaceBack(0,8192,0,8192),n.emplaceBack(8192,8192,8192,8192),this.mercatorBoundsBuffer=t.createVertexBuffer(n,xB.members),this.mercatorBoundsSegments=l9.simpleSegment(0,0,4,2);let o=new lR;o.emplaceBack(0,1,2),o.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(o);let s=new lV;for(let t of[0,1,3,2,0])s.emplaceBack(t);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new uW(t,new h7({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=ec();let l=this.context.gl;this.stencilClearMode=new g3({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){let t=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,t.TRIANGLES,gz.disabled,this.stencilClearMode,g6.disabled,gP.disabled,bt(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,i,r){if(!i||this.currentStencilSource===i.id||!t.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let t=!1;for(let i of r)if(void 0===this._tileClippingMaskIDs[i.key]){t=!0;break}if(!t)return}this.currentStencilSource=i.id;let a=this.context,n=a.gl;this.nextStencilID+r.length>256&&this.clearStencil(),a.setColorMode(g6.disabled),a.setDepthMode(gz.disabled);let o=this.getOrCreateProgram("clippingMask");for(let t of(this._tileClippingMaskIDs={},r)){let r=i.getTile(t),a=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:l,tileBoundsSegments:h}=this.getTileBoundsBuffers(r);o.draw(this,n.TRIANGLES,gz.disabled,new g3({func:n.ALWAYS,mask:0},a,255,n.KEEP,n.KEEP,n.REPLACE),g6.disabled,gP.disabled,bt(t.projMatrix),"$clipping",s,l,h)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,i=this.context.gl;return new g3({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);let i=this.context.gl;return new g3({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(t){let i=this.context.gl,r=t.sort((t,i)=>
111i.overscaledZ-t.overscaledZ),a=r.at(-1).overscaledZ,n=r[0].overscaledZ-a+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();let t={};for(let r=0;r<n;r++)t[r+a]=new g3({func:i.GEQUAL,mask:255},r+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=n,[t,r]}return[{[a]:g3.disabled},r]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let i=1/8;return new g6([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new rq(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?g6.unblended:g6.alphaBlended}colorModeForDrapableLayerRenderPass(t){let i=this.context.gl;return this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture&&"translucent"===this.renderPass?null!=t&&"mrt-fallback"!==this.emissiveMode||"constant"===this.emissiveMode?new g6([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new rq(0,0,0,null!=t?t:0),[!0,!0,!0,!0]):"dual-source-blending"===this.emissiveMode?new g6([i.ONE,i.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,i.ONE_MINUS_SRC_ALPHA],rq.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(t,i,r,a=!1){if(this.depthOcclusion)return new gz(this.context.gl.GREATER,gz.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!a)return gz.disabled;let n=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new gz(r||this.context.gl.LEQUAL,i,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){let t=this.context.gl,i=Math.ceil(this.width),r=Math.ceil(this.height),a=this.context.bindFramebuffer.get(),n=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===i&&this.depthFBO.height===r||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),0!==i&&0!==r&&(this.depthFBO=new T5(this.context,i,r,0,"texture"),this.depthTexture=new uW(this.context,{width:i,height:r,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(a),t.bindTexture(t.TEXTURE_2D,n),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,i,r,0,0,i,r,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current))}render(t,i){this.context.sweepPendingPrograms(),this.frameTimeDelta=0===this.lastPaintStartTimeStamp?0:i.paintStartTimeStamp-this.lastPaintStartTimeStamp,this.lastPaintStartTimeStamp=i.paintStartTimeStamp,this._wireframeDebugCache.update(this.frameCounter),this.style=t,this.options=i,this.frcCoverageSnapshot&&!this.frcCoverageSnapshot.empty()&&(!this.frcCoverageRenderer&&bI&&(this.frcCoverageRenderer=new bI),this.frcCoverageRenderer&&this.frcCoverageRenderer.update(this.context,this.frcCoverageSnapshot.tiles));let r=this.style._mergedLayers,a=!(!this.terrain||!this.terrain.enabled),n=()=>this.style._getOrder(a),o=n(),s=!1,l=!1,h=null,u=0,c=!1;for(let t of o){let i=r[t];"none"!==i.visibility&&("circle"===i.type?s=!0:"building"===i.type?(h=i,++u):"symbol"===i.type&&(i.hasOcclusionOpacityProperties?l=!0:s=!0))}this.updateEmissiveMode();let d=o.map(t=>r[t]),p=this.style._mergedSourceCaches;for(let i in this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(is.now()),this.imageManager.beginFrame(),p){let t=p[i];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++u)}let f=!1;for(let t of d)t.isHidden(this.transform.zoom)||("clip"===t.type&&(f=!0),this.prepareLayer(t));let _={},m={},g={},y={},x={};for(let t in p){let i=p[t];_[t]=i.getVisibleCoordinates(),m[t]=_[t].slice().reverse(),g[t]=i.getVisibleCoordinates(!0).reverse(),y[t]=i.getShadowCasterCoordinates(),x[t]=i.sortCoordinatesByDistance(_[t])}let v=t=>{let i=this.style.getLayerSourceCache(t);return i&&i.used?i.getSource():null};if(u||f||this._clippingActiveLastFrame){let t=[],i=[],r=0;for(let a of d)this.isSourceForClippingOrConflation(a,v(a))&&(t.push(a),i.push(r)),r++;if(t&&(f||t.length>1)||this._clippingActiveLastFrame){f=!1;let r=[];for(let a=0;a<t.length;a++){let n=t[a],o=i[a],s=this.style.getLayerSourceCache(n);if(!s||!s.used||!s.getSource().usedInConflation&&"clip"!==n.type&&"building"!==n.type)continue;let l=d_,h=0,u=[],c=!0;if("building"===n.type)l=dm;else if("clip"===n.type)if(l=o,n.isHidden(this.transform.zoom))c=!1;else{if(!n.layout){c=!1;continue}
111for(let t of n.layout.get("clip-layer-types"))h|="model"===t?1:"symbol"===t?2:4;for(let t of n.layout.get("clip-layer-scope"))u.push(sy(t,n.scope));f=!0}c&&r.push({layer:n.fqid,cache:s,order:l,clipMask:h,clipScope:u})}this.replacementSource.setSources(r),c=!0}}this._clippingActiveLastFrame=f,c||this.replacementSource.clear(),this.conflationActive=c,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let t=0;t<d.length;t++){let i=d[t];if("none"===i.visibility)continue;let r=i.cutoffRange();if(this.longestCutoffRange=Math.max(r,this.longestCutoffRange),r>0){let t=v(i);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),i.minzoom&&(this.minCutoffZoom=Math.max(i.minzoom,this.minCutoffZoom))}i.is3D(a)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=t),this._lastOcclusionLayer=t)}let b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(g),this.opaquePassCutoff=0,d=(o=n()).map(t=>r[t])),this.style.enable3dLights()&&!this._shadowRenderer&&EF(this);let w=this._shadowRenderer;if(w)for(let t in w.updateShadowParameters(this.transform,this.style.directionalLight),p)for(let i of _[t]){let t={min:0,max:0};this.terrain&&(t=this.terrain.getMinMaxForTile(i)||t),w.addShadowReceiver(i.toUnwrapped(),t.min,t.max)}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new cY(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new ER),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);let T=!(!this.style||!this.style.snow),E=!(!this.style||!this.style.rain);if(T&&!this._snow&&bc&&(this._snow=new bc),!T&&this._snow&&(this._snow.destroy(),delete this._snow),E&&!this._rain&&bu&&(this._rain=new bu),!E&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),h&&(!this.buildingTileBorderManager&&bs&&(this.buildingTileBorderManager=new bs),this.buildingTileBorderManager)){let t=this.style.getLayerSourceCache(h);this.buildingTileBorderManager.updateBorders(t,h)}if(!rR.has(this.context.gl))return;for(let i of(this.renderPass="offscreen",d)){let r=t.getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;let a=r?m[r.id]:void 0;("custom"===i.type||"raster"===i.type||"raster-particle"===i.type||i.isSky()||a&&a.length)&&this.renderLayer(this,r,i,a)}this.depthRangeFor3D=[0,1-(d.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]);let S="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),I=(()=>{if(i.showOverdrawInspector)return rq.black;let t=this.style.fog;if(t&&this.transform.projection.supportsFog){let i=this.style.getLut(t.scope);if(!S){let r="none"===t.properties.get("color-use-theme");return new rq(...t.properties.get("color").toNonPremultipliedRenderColor(r?null:i).toArray01())}if(S){let r="none"===t.properties.get("space-color-use-theme");return new rq(...t.properties.get("space-color").toNonPremultipliedRenderColor(r?null:i).toArray01())}}return rq.transparent})();if(this.context.clear({color:I,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&S&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){let i=d[this.currentLayer],r=t.getLayerSourceCache(i);if(i.isSky())continue;let n=r?(i.is3D(a)?x:m)[r.id]:void 0;this._renderTileClippingMasks(i,r,n),this.renderLayer(this,r,i,n)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&S&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||cN(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isH
111orizonVisible()))for(this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){let i=d[this.currentLayer],r=t.getLayerSourceCache(i);i.isSky()&&this.renderLayer(this,r,i,r?m[r.id]:void 0)}function A(t,i){let r;return i&&(r=("symbol"===t.type?g:t.is3D(a)?x:m)[i.id]),r}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<o.length;){let i=d[this.currentLayer];if("raster"===i.type||"raster-particle"===i.type){let r=t.getLayerSourceCache(i);this.renderLayer(this,r,i,A(i,r))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let C=w?w.getGroundShadowLayerIndex():-1,M=!1,R=-1;for(let t=0;t<o.length;++t){let i=d[t];i.isHidden(this.transform.zoom)||i.is3D(a)&&(R=t)}l&&-1===R&&(s=!0);let D=!1;for(;this.currentLayer<o.length;){let i=d[this.currentLayer],r=t.getLayerSourceCache(i);if(i.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(i)){if(i.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer)}else{if(!D&&i.is3D(a)&&!a){let t=this.currentLayer,i=t=>{for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){let i=d[this.currentLayer];if("fill"===i.type&&b_){let r=this.style.getLayerSourceCache(i);b_(this,r,i,A(i,r),t)}}};i("initialize"),i("reset"),this.currentLayer=t,D=!0}if(s&&!M&&this.terrain&&!this.transform.isOrthographic&&(M=!0,this.blitDepth()),l&&-1!==R&&this.currentLayer===R+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(i,r,r?_[r.id]:void 0),this.renderLayer(this,r,i,A(i,r)),!this.terrain&&w&&this.currentLayer===C){{this.clearStencil(),this.resetStencilClippingMasks();let t=this.currentLayer;for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){let t=d[this.currentLayer];if("fill"===t.type&&bm){let i=this.style.getLayerSourceCache(t);bm(this,i,t,A(t,i))}}this.currentLayer=t}if(w.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){let i=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=i;this.currentLayer++){let i=d[this.currentLayer];if(!i.hasLightBeamPass())continue;let r=t.getLayerSourceCache(i);this.renderLayer(this,r,i,r?m[r.id]:void 0)}this.currentLayer=i,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){let i=this.currentLayer;for(let i of(this.depthOcclusion=!0,this.layersWithOcclusionOpacity)){this.currentLayer=i;let r=d[this.currentLayer],a=t.getLayerSourceCache(r),n=a?m[a.id]:void 0;this.terrain||this._renderTileClippingMasks(r,a,a?_[a.id]:void 0),this.renderLayer(this,a,r,n)}this.depthOcclusion=!1,this.currentLayer=i,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 i=null;d.forEach(r=>{let a=t.getLayerSourceCache(r);a&&!r.isHidden(this.transform.zoom)&&a.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom<a.getSource().maxzoom)&&(i=a)}),i&&this.options.showTileBoundaries&&function(t,i,r,a,n,o){for(let n=0;n<r.length;n++)!function(t,i,r,a,n,o,s){let l=t.context,h=t.transform,u=l.gl,c="globe"===h.projection.name,d=ed(r.projMatrix);if(c&&cN(h.zoom)>0){let t=cL(cS(r.canonical,h));d=eg(new Float32Array(16),h.globeMatrix,t),eg(d,h.projMatrix,d)}let p=ec();p[12]+=0/(is.devicePixelRatio*h.width),p[13]+=0/(is.devicePixelRatio*h.height),eg(d,p,d);let f=t.getOrCreateProgram("debug",{defines:c?["PROJECTION_GLOBE_VIEW"]:[]}),_=i.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(_,f);let m=gz.disabled,g=g3.disabled,y=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),c?_._makeGlobeTileDebugBuffers(t.context,h):_._makeDebugTileBoundsBuffers(t.context,h.projection);let v=_._tileDebugBuffer||t.debugBuffer,b=_._tileDebugIndexBuffer||t.debugIndexBuffer,w=_._tileDebugSegments||t.debugSegments;if(f.draw(t,u.LINE_STRIP,m,g,y,gP.disabled,yu(d,a.toPremultipliedRenderColor(null)),x,v,b,w,null,null,null,[_._globeTileDebugBorderBuffer]),s){let i=_.latestRawTileData,a=Math.floor((i&&i.byteLength||0)/1024),n=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(n+=` => ${r.overscaledZ}`),n+=` ${_.state}`,function(t,i){t.initDebugOverlayCanvas();let r=t.debugOverlayCanvas,a=t.context.gl,n=t.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,r.width,r.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(i,5,5),n.strokeText(i,5,5),t.debugOverlayTexture.update(r),t.debugOverlayTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE)}
111(t,n+=` ${a}kb`)}let T=512/Math.min(i.getTile(r).tileSize,512)*(r.overscaledZ/h.zoom)*.5,E=_._tileDebugTextBuffer||t.debugBuffer,S=_._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,I=_._tileDebugTextSegments||t.debugSegments;f.draw(t,u.TRIANGLES,m,g,g6.alphaBlended,gP.disabled,yu(d,rq.transparent.toPremultipliedRenderColor(null),T),x,E,S,I,null,null,null,[_._globeTileDebugTextBuffer])}(t,i,r[n],a,0,0,o)}(this,i,i.getVisibleCoordinates(),rq.red,0,this.options.showParseStatus)}this.options.showPadding&&function(t){var i,r;let a=t.transform.padding;Ev(t,t.transform.height-(a.top||0),3,E_),Ev(t,a.bottom||0,3,Em),Eb(t,a.left||0,3,Eg),Eb(t,t.transform.width-(a.right||0),3,Ey);let n=t.transform.centerPoint;i=n.x,r=t.transform.height-n.y,Ew(t,i-1,r-10,2,20,Ex),Ew(t,i-10,r-1,20,2,Ex)}(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()),c||(this.conflationActive=!1)}prepareLayer(t){this.gpuTimingStart(t);let{unsupportedLayers:i}=this.transform.projection,r=!i||!i.includes(t.type);if(EO[t.type]&&(r||this.terrain&&"custom"===t.type)){let i=this.style.getLayerSourceCache(t);EO[t.type](t,i,this)}this.gpuTimingEnd()}renderLayer(t,i,r,a){r.isHidden(this.transform.zoom)||("background"===r.type||"sky"===r.type||"custom"===r.type||"model"===r.type||"raster"===r.type||"raster-particle"===r.type||a&&a.length)&&(this.id=r.id,this.gpuTimingStart(r),(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes(r.type)||t.terrain&&"custom"===r.type)&&"clip"!==r.type&&"slot"!==r.type&&EL[r.type]&&EL[r.type](t,i,r,a,this.style.placement.variableOffsets,this.options.isInitialLoad),EL[r.type]||(r.mayUse("HD")&&async function(){await bz(),Object.assign(EL,{building:bo,"raster-particle":bl}),Object.assign(EO,{"raster-particle":bh})}(),r.mayUse("Standard")&&EF(t)),this.gpuTimingEnd())}gpuTimingStart(t){if(!this.options.gpuTiming)return;let i=this.context.extTimerQuery,r=this.context.gl,a=this.gpuTimers[t.id];a||(a=this.gpuTimers[t.id]={calls:0,cpuTime:0,query:r.createQuery()}),a.calls++,r.beginQuery(i.TIME_ELAPSED_EXT,a.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){let t=this.context.extTimerQuery,i=this.context.gl,r=i.createQuery();this.deferredRenderGpuTimeQueries.push(r),i.beginQuery(t.TIME_ELAPSED_EXT,r)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){let t=this.gpuTimers;return this.gpuTimers={},t}collectDeferredRenderGpuQueries(){let t=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],t}queryGpuTimers(t){let i={};for(let r in t){let a=t[r],n=this.context.extTimerQuery,o=n.getQueryParameter(a.query,this.context.gl.QUERY_RESULT)/1e6;n.deleteQueryEXT(a.query),i[r]=o}return i}queryGpuTimeDeferredRender(t){if(!this.options.gpuTimingDeferredRender)return 0;let i=this.context.gl,r=0;for(let a of t)r+=i.getQueryParameter(a,i.QUERY_RESULT)/1e6,i.deleteQuery(a);return r}translatePosMatrix(t,i,r,a,n){if(!r[0]&&!r[1])return t;let o=n?"map"===a?this.transform.angle:0:"viewport"===a?-this.transform.angle:0;if(o){let t=Math.sin(o),i=Math.cos(o);r=[r[0]*i-r[1]*t,r[0]*t+r[1]*i]}let s=[n?r[0]:_S(i,r[0],this.transform.zoom),n?r[1]:_S(i,r[1],this.transform.zoom),0],l=new Float32Array(16);return ey(l,t,s),l}saveTileTexture(t){if(t.context!==this.context)return;let i=t.size[0],r=this._tileTextures[i];r?r.push(t):this._tileTextures[i]=[t]}getTileTexture(t){let i=this._tileTextures[t];return i&&i.length>0?i.pop():null}terrainRenderModeElevated(){return this.style&&this.style.hasTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(t,i,r,a,n){let o=void 0===r?this.terrain&&this.terrain.renderingToTexture:r,s=void 0===a?this.terrainRenderModeElevated():a,l=void 0===n?"globe"===this.transform.projection.name:n,h=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===t||"terrainRaster"===t?(h.push("LIGHTING_3D_MODE"),h.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):o||h.push("LIGHTING_3D_MODE")),s&&(h.push("TERRAIN"),this.linearFloatFilteringSupported()&&h.push("TERRAIN_DEM_FLOAT_FORMAT")),l&&h.push("GLOBE"),this._fogVisible&&!o&&(void 0===i||i)&&h.push("FOG"),o&&h.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&h.push("OVERDRAW_INSPECTOR"),h}getOrCreateProgram(t,i){this.cache=this.cache||{};let{defines:r,config:a,overrideFog:n,overrideRtt:o,overrideTerrain:s,overrideGlobe:l,precompiled:h}=i||{},u=this.currentGlobalDefines(t,n,o,s,l).concat(r||[]),c=this.getShaderSource(t),d=T1[t]||bd&&bd[t]||xl&&xl[t],p=TV.cacheKey(c,t,u,a);
111return this.cache[p]||(this.cache[p]=new TV(this.context,t,c,a,d,u,h)),this.cache[p]}getShaderSource(t){return y3[t]||vA&&vA[t]||y8&&y8[t]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new uW(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i,r){if(this.style.enable3dLights()){let a=this.style.directionalLight,n=this.style.ambientLight;if(a&&n){let o=((t,i,r,a)=>{let n=t.properties.get("direction"),o="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toNonPremultipliedRenderColor(o?null:r.getLut(t.scope)).toArray01(),l=t.properties.get("intensity"),h="none"===i.properties.get("color-use-theme"),u=i.properties.get("color").toNonPremultipliedRenderColor(h?null:r.getLut(i.scope)).toArray01(),c=i.properties.get("intensity"),d=[n.x,n.y,n.z];a&&(void 0!==a.ambientIntensity&&(c=a.ambientIntensity),void 0!==a.directionalIntensity&&(l=a.directionalIntensity),void 0!==a.ambientColor&&(u[0]=a.ambientColor[0],u[1]=a.ambientColor[1],u[2]=a.ambientColor[2]),void 0!==a.directionalColor&&(s[0]=a.directionalColor[0],s[1]=a.directionalColor[1],s[2]=a.directionalColor[2]));let p=t6(u,c),f=t6(s,l);return{u_lighting_ambient_color:p,u_lighting_directional_dir:d,u_lighting_directional_color:f,u_ground_radiance:function(t,i,r){let a=function(t,i,r){let a=eX(i,t),n=rG(1-.3*Math.min(eX(r,[.2126,.7152,.0722]),1),1,Math.min(a+1,1));return rG(.92,1,Math.asin(tL(i[2],-1,1))/Math.PI+.5)*n}(t,[0,0,1],i),n=[0,0,0];ej(n,r.slice(0,3),a);let o=[0,0,0];ej(o,i.slice(0,3),t[2]);let s=[0,0,0];return eB(s,n,o),t8(s)}(d,f,p)}})(a,n,this.style,r);i.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,i,r,a,n,o){if(this.uploadCommonLightUniforms(t,i,o),this.terrain&&this.terrain.renderingToTexture)return;let s=this.style.fog;if(s){let n=s.getOpacity(this.transform.pitch),o=((t,i,r,a,n,o,s,l,h,u,c,d)=>{let p=t.transform,f="none"===i.properties.get("color-use-theme"),_=i.properties.get("color").toNonPremultipliedRenderColor(f?null:t.style.getLut(i.scope)).toArray01();_[3]=a;let m=t.frameCounter/1e3%1,[g,y]=i.properties.get("vertical-range");return{u_fog_matrix:r?p.calculateFogTileMatrix(r):d||t.identityMat,u_fog_range:i.getRangeForProjection(),u_fog_color:_,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,y),y],u_fog_temporal_offset:m,u_frustum_tl:n,u_frustum_tr:o,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:h,u_globe_radius:u,u_viewport:c,u_globe_transition:cN(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,r,n,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*is.devicePixelRatio,this.transform.height*is.devicePixelRatio],a);i.setFogUniformValues(t,o)}n&&i.setCutoffUniformValues(t,n.uniformValues)}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){let t=this.canvasCopy();t&&(this.frameCopies.push(t),this.tileLoaded=!1)}canvasCopy(){let t=this.context.gl,i=t.createTexture();return t.bindTexture(t.TEXTURE_2D,i),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),i}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;let t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}
111getBackgroundTiles(){let t=this._backgroundTiles,i=this._backgroundTiles={};for(let r of this.transform.coveringTiles({tileSize:512}))i[r.key]=t[r.key]||new xV(r,512,this.transform.tileZoom,this,void 0,this.worldview);return i}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(t,i){return!(!t.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==t.type&&"building"!==t.type&&(t.minzoom&&t.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==t.sourceLayer&&"procedural_buildings"!==t.sourceLayer)&&(!i||"batched-model"!==i.type)))}isTileAffectedByFog(t){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let i=this._cachedTileFogOpacities[t.key];return i||(this._cachedTileFogOpacities[t.key]=i=this.style.fog.getOpacityForTile(t)),i[0]>=.05||i[1]>=.05}setupDepthForOcclusion(t,i,r){var a;let n=this.context,o=n.gl,s=!!r;r||(r={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}),n.activeTexture.set(o.TEXTURE3),t&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),r.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],r.u_depth_range_unpack=[2/((a=this.depthRangeFor3D)[1]-a[0]),-1-2*a[0]/(a[1]-a[0])],r.u_occluder_half_size=.5*this.occlusionParams.occluderSize,r.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE0),s||i.setTerrainUniformValues(n,r)}updateEmissiveMode(){if(this._forceEmissiveMode)return;let t=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=t?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function Ek(t,i){let r=!1,a=null,n=()=>{a=null,r&&(t(),a=setTimeout(n,i),r=!1)};return()=>(r=!0,a||n(),a)}let EN=/(#.+)?$/;class EV{constructor(t){this._hashName=t&&encodeURIComponent(t),tG(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Ek(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map&&(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0),this}getHashString(){let t=this._map;if(!t)return"";let i=EU(t);if(this._hashName){let t=this._hashName,r=!1,a=location.hash.slice(1).split("&").map(a=>{let n=a.split("=")[0];return n===t?(r=!0,`${n}=${i}`):a}).filter(t=>t);return r||a.push(`${t}=${i}`),`#${a.join("&")}`}return`#${i}`}_getCurrentHash(){let t=location.hash.replace("#","");if(this._hashName){let i;return t.split("&").map(t=>t.split("=")).forEach(t=>{t[0]===this._hashName&&(i=t)}),(i&&i[1]||"").split("/")}return t.split("/")}_onHashChange(){let t=this._map;if(!t)return!1;let i=this._getCurrentHash();if(i.length>=3&&!i.some(t=>isNaN(Number(t)))){let r=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(i[3]||0):t.getBearing();return t.jumpTo({center:[+i[2],+i[1]],zoom:+i[0],bearing:r,pitch:+(i[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(EN,this.getHashString()))}}function EU(t,i){let r=t.getCenter(),a=Math.round(100*t.getZoom())/100,n=Math.pow(10,Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10)),o=Math.round(r.lng*n)/n,s=Math.round(r.lat*n)/n,l=t.getBearing(),h=t.getPitch(),u=i?`/${o}/${s}/${a}`:`${a}/${s}/${o}`;return(l||h)&&(u+="/"+Math.round(10*l)/10),h&&(u+=`/${Math.round(h)}`),u}let Ej={linearity:.3,easing:tm(0,0,.3,1)},EG={deceleration:2500,maxSpeed:1400,...Ej},EH={deceleration:20,maxSpeed:1400,...Ej},Eq={deceleration:1e3,maxSpeed:360,...Ej},EZ={deceleration:1e3,maxSpeed:90,...Ej};class E${constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:is.now(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,i=is.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;let i={zoom:0,bearing:0,pitch:0,pan:new tg(0,0),pinchAround:void 0,around:void 0};for(let{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);let r=this._inertiaBuffer.at(-1).time-this._inertiaBuffer[0].time,a={};if(i.pan.mag()){let n=EX(i.pan.mag(),r,{...EG,...t||{}});a.offset=i.pan.mult(n.amount/i.pan.mag()),a.center=this._map.transform.center,EW(a,n)}if(i.zoom){let t=EX(i.zoom,r,EH);a.zoom=this._map.transform.zoom+t.amount,EW(a,t)}if(i.bearing){let t=EX(i.bearing,r,Eq);
111a.bearing=this._map.transform.bearing+tL(t.amount,-179,179),EW(a,t)}if(i.pitch){let t=EX(i.pitch,r,EZ);a.pitch=this._map.transform.pitch+t.amount,EW(a,t)}if(a.zoom||a.bearing){let t=void 0===i.pinchAround?i.around:i.pinchAround;a.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),a.noMoveStart=!0,a}}function EW(t,i){(!t.duration||t.duration<i.duration)&&(t.duration=i.duration,t.easing=i.easing)}function EX(t,i,r){let{maxSpeed:a,linearity:n,deceleration:o}=r,s=tL(t*n/(i/1e3),-a,a),l=Math.abs(s)/(o*n);return{easing:r.easing,duration:1e3*l,amount:l/2*s}}class EY extends rz{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r,a={}){let n=ix(i.getCanvasContainer(),r);super(t,{point:n,lngLat:i.unproject(n),originalEvent:r,...a}),this._defaultPrevented=!1,this.target=i}}class EK extends rz{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r){let a="touchend"===t?r.changedTouches:r.touches,n=iv(i.getCanvasContainer(),a),o=n.map(t=>i.unproject(t)),s=n.reduce((t,i,r,a)=>t.add(i.div(a.length)),new tg(0,0));super(t,{points:n,point:s,lngLats:o,lngLat:i.unproject(s),originalEvent:r}),this._defaultPrevented=!1}}class EQ extends rz{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i){super("wheel",{originalEvent:i}),this._defaultPrevented=!1}}class EJ{constructor(t,i){this._map=t,this._clickTolerance=i.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new EQ(this._map,t))}mousedown(t,i){return this._mousedownPos=i,this._firePreventable(new EY(t.type,this._map,t))}mouseup(t){this._map.fire(new EY(t.type,this._map,t))}preclick(t){let i=new MouseEvent("preclick",t);this._map.fire(new EY(i.type,this._map,i))}click(t,i){this._mousedownPos&&this._mousedownPos.dist(i)>=this._clickTolerance||(this.preclick(t),this._map.fire(new EY(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new EY(t.type,this._map,t))}mouseover(t){this._map.fire(new EY(t.type,this._map,t))}mouseout(t){this._map.fire(new EY(t.type,this._map,t))}touchstart(t){return this._firePreventable(new EK(t.type,this._map,t))}touchmove(t){this._map.fire(new EK(t.type,this._map,t))}touchend(t){this._map.fire(new EK(t.type,this._map,t))}touchcancel(t){this._map.fire(new EK(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class E0{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new EY(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new EY("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new EY(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class E1{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=i.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,i){this.isEnabled()&&t.shiftKey&&0===t.button&&(i_(),this._startPos=this._lastPos=i,this._active=!0)}mousemoveWindow(t,i){if(!this._active)return;let r=this._startPos,a=this._lastPos;if(!r||!a||a.equals(i)||!this._box&&i.dist(r)<this._clickTolerance)return;this._lastPos=i,this._box||(this._box=iu("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",t));let n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),s=Math.min(r.y,i.y),l=Math.max(r.y,i.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${n}px,${s}px)`,this._box.style.width=o-n+"px",this._box.style.height=l-s+"px")})}mouseupWindow(t,i){if(!this._active)return;let r=this._startPos;if(r&&0===t.button){if(this.reset(),iy(),r.x!==i.x||r.y!==i.y)return this._map.fire(new rz("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(r,i,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),im(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new rz(t,{originalEvent:i}))}}function E2(t,i){let r={};for(let a=0;a<t.length;a++)r[t[a].identifier]=i[a];return r}class E3{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){let i=new tg(0,0);for(let r of t)i._add(r);return i.div(t.length)}(i),this.touches=E2(r,i)))}touchmove(t,i,r){if(this.aborted||!this.centroid)return;let a=E2(r,i);for(let t in this.touches){let i=a[t];(!i||i.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,i,r){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){let t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class E4{constructor(t){this.singleTap=new E3(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,i,r){this.singleTap.touchstart(t,i,r)}touchmove(t,i,r){this.singleTap.touchmove(t,i,r)}touchend(t,i,r){let a=this.singleTap.touchend(t,i,r);
111if(a){let i=t.timeStamp-this.lastTime<500,r=!this.lastTap||30>this.lastTap.dist(a);if(i&&r||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class E5{constructor(){this._zoomIn=new E4({numTouches:1,numTaps:2}),this._zoomOut=new E4({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,i,r){this._zoomIn.touchstart(t,i,r),this._zoomOut.touchstart(t,i,r)}touchmove(t,i,r){this._zoomIn.touchmove(t,i,r),this._zoomOut.touchmove(t,i,r)}touchend(t,i,r){let a=this._zoomIn.touchend(t,i,r),n=this._zoomOut.touchend(t,i,r);return a?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:i.getZoom()+1,around:i.unproject(a)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:i.getZoom()-1,around:i.unproject(n)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}let E6={0:1,2:2},E8={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class E9{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,i){return!1}_move(t,i){return{}}mousedown(t,i){if(this._lastPoint)return;let r=ib(t);this._correctButton(t,r)&&(this._lastPoint=i,this._eventButton=r)}mousemoveWindow(t,i){let r=this._lastPoint;if(r){if(t.preventDefault(),null!=this._eventButton&&function(t,i){let r=E6[i];return void 0===t.buttons||(t.buttons&r)!==r}(t,this._eventButton))this.reset();else if(this._moved||!(i.dist(r)<this._clickTolerance))return this._moved=!0,this._lastPoint=i,this._move(r,i)}}mouseupWindow(t){this._lastPoint&&ib(t)===this._eventButton&&(this._moved&&iy(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class E7 extends E9{mousedown(t,i){super.mousedown(t,i),this._lastPoint&&(this._active=!0)}_correctButton(t,i){return 0===i&&!t.ctrlKey}_move(t,i){return{around:i,panDelta:i.sub(t)}}}class Se extends E9{constructor(t){super(t),this._pitchRotateKey=t.pitchRotateKey?E8[t.pitchRotateKey]:void 0}_correctButton(t,i){return this._pitchRotateKey?0===i&&t[this._pitchRotateKey]:0===i&&t.ctrlKey||2===i}_move(t,i){let r=.8*(i.x-t.x);if(r)return this._active=!0,{bearingDelta:r}}contextmenu(t){this._pitchRotateKey||t.preventDefault()}}class St extends E9{constructor(t){super(t),this._pitchRotateKey=t.pitchRotateKey?E8[t.pitchRotateKey]:void 0}_correctButton(t,i){return this._pitchRotateKey?0===i&&t[this._pitchRotateKey]:0===i&&t.ctrlKey||2===i}_move(t,i){let r=-.5*(i.y-t.y);if(r)return this._active=!0,{pitchDelta:r}}contextmenu(t){this._pitchRotateKey||t.preventDefault()}}class Si{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),tG(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new tg(0,0)}touchstart(t,i,r){return this._calculateTransform(t,i,r)}touchmove(t,i,r){if(this._active&&!(r.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===r.length&&!t2())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,i,r)}}touchend(t,i,r){this._calculateTransform(t,i,r),this._active&&r.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,r){r.length>0&&(this._active=!0);let a=E2(r,i),n=new tg(0,0),o=new tg(0,0),s=0;for(let t in a){let i=a[t],r=this._touches[t];r&&(n._add(i),o._add(i.sub(r)),s++,a[t]=i)}if(this._touches=a,s<this._minTouches||!o.mag())return;let l=o.div(s);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(s),panDelta:l}}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=iu("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 Sr{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,i,r){return{}}touchstart(t,i,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([i[0],i[1]]))}touchmove(t,i,r){let a=this._firstTwoTouches;if(!a)return;t.preventDefault();let[n,o]=a,s=Sa(r,i,n),l=Sa(r,i,o);if(!s||!l)return;let h=this._aroundCenter?null:s.add(l).div(2);return this._move([s,l],h,t)}touchend(t,i,r){if(!this._firstTwoTouches)return;
111let[a,n]=this._firstTwoTouches,o=Sa(r,i,a),s=Sa(r,i,n);o&&s||(this._active&&iy(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Sa(t,i,r){for(let a=0;a<t.length;a++)if(t[a].identifier===r)return i[a]}function Sn(t,i){return Math.log2(t/i)}class So extends Sr{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,i){let r=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(.1>Math.abs(Sn(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:Sn(this._distance,r),pinchAround:i}}}function Ss(t,i){return 180*t.angleWith(i)/Math.PI}class Sl extends Sr{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,i){let r=this._vector;if(this._vector=t[0].sub(t[1]),r&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Ss(this._vector,r),pinchAround:i}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let i=25/(Math.PI*this._minDiameter)*360,r=this._startVector;return!!r&&Math.abs(Ss(t,r))<i}}function Sh(t){return Math.abs(t.y)>Math.abs(t.x)}class Su extends Sr{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Sh(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,i,r){let a=this._lastPoints;if(!a)return;let n=t[0].sub(a[0]),o=t[1].sub(a[1]);return this._map._cooperativeGestures&&!t2()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:-((n.y+o.y)/2*.5)})}gestureBeginsVertically(t,i,r){if(void 0!==this._valid)return this._valid;let a=t.mag()>=2,n=i.mag()>=2;if(!a&&!n)return;if(!a||!n)return null==this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;let o=t.y>0==i.y>0;return Sh(t)&&Sh(i)&&o}}let Sc=100,Sd=15,Sp=10;class Sf{constructor(){this._panStep=Sc,this._bearingStep=Sd,this._pitchStep=Sp,this._rotationDisabled=!1,this._panDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let i=0,r=0,a=0,n=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?a=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?a=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,a=0),this._panDisabled&&(n=0,o=0),{cameraAnimation:s=>{let l=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:S_,zoom:i?Math.round(l)+i*(t.shiftKey?2:1):l,bearing:s.getBearing()+r*this._bearingStep,pitch:s.getPitch()+a*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}disablePan(){this._panDisabled=!0}enablePan(){this._panDisabled=!1}}function S_(t){return t*(2-t)}let Sm=1/450,Sg=/(Mac|iPad)/i;class Sy{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Sm,tG(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||t2()))return void this._showBlockerAlert();
111"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,r=is.now(),a=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%4.000244140625==0?this._type="wheel":0!==i&&4>Math.abs(i)?this._type="trackpad":a>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=200>Math.abs(a*i)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let i=ix(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:i,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;let t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);let i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){let r="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,a=2/(1+Math.exp(-Math.abs(this._delta*r)));this._delta<0&&0!==a&&(a=1/a);let n=i(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*a))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}let r="number"==typeof this._targetZoom?this._targetZoom:i(),a=this._startZoom,n=this._easing,o,s=!1;if("wheel"===this._type&&a&&n){let t=Math.min((is.now()-this._lastWheelEventTime)/200,1);o=rG(a,r,n(t)),t<1?this._frameId||(this._frameId=!0):s=!0}else o=r,s=!0;this._active=!0,s&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let l=o-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!s,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=tz;if(this._prevEase){let t=this._prevEase,r=(is.now()-t.start)/t.duration,a=t.easing(r+.01)-t.easing(r),n=.27/Math.sqrt(a*a+1e-4)*.01;i=tm(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:is.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=iu("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=Sg.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 Sx{constructor(t,i){this._clickZoom=t,this._tapZoom=i}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 Sv{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,i){return t.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:r.getZoom()+(t.shiftKey?-1:1),around:r.unproject(i)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Sb{constructor(){this._tap=new E4({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,i,r){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?r.length>0&&(this._swipePoint=i[0],this._swipeTouch=r[0].identifier):this._tap.touchstart(t,i,r))}touchmove(t,i,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;let a=i[0],n=a.y-this._swipePoint.y;return this._swipePoint=a,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,i,r)}touchend(t,i,r){this._tapTime?this._swipePoint&&0===r.length&&this.reset():this._tap.touchend(t,i,r)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Sw{constructor(t,i,r){this._el=t,this._mousePan=i,this._touchPan=r}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class ST{constructor(t,i,r){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=i,this._mousePitch=r,this._pitchDisabled=!1}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&!this._pitchDisabled&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._pitchDisabled||this._mousePitch.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()}}class SE{constructor(t,i,r,a){this._el=t,this._touchZoom=i,this._touchRotate=r,this._tapDragZoom=a,this._rotationDisabled=!1,this._tapDragZoomDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),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()}disableTapDragZoom(){this._tapDragZoomDisabled=!0,this._tapDragZoom.disable()}enableTapDragZoom(){this._tapDragZoomDisabled=!1,this._touchZoom.isEnabled()&&this._tapDragZoom.enable()}}let SS=t=>t.zoom||t.drag||t.pitch||t.rotate;class SI extends rz{}class SA{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){let r=ek([],i,t);this.radius=eL(r[2]<0?e3([],r,this.constants):[r[0],r[1],0])}projectRay(t){e3(t,t,this.constants),eW(t,t),eN(t,t,this.constants);let i=ej([],t,this.radius);if(i[2]>0){let t=ej([],[0,0,1],eX(i,[0,0,1])),r=ej([],eW([],[i[0],i[1],0]),this.radius),a=eB([],i,ej([],ek([],eB([],r,t),i),2));i[0]=a[0],i[1]=a[1]}return i}}function SC(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class SM{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new E$(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new SA,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),tG(["handleEvent","handleWindowEvent"],this);let r=this._el;for(let[t,i,a]of(this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]],this._listeners)){let r=t===document?this.handleWindowEvent:this.handleEvent;t.addEventListener(i,r,a)}}destroy(){for(let[t,i,r]of this._listeners){let a=t===document?this.handleWindowEvent:this.handleEvent;t.removeEventListener(i,a,r)}}_addDefaultHandlers(t){let i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new EJ(i,t));let a=i.boxZoom=new E1(i,t);this._add("boxZoom",a);let n=new E5,o=new Sv;i.doubleClickZoom=new Sx(o,n),this._add("tapZoom",n),this._add("clickZoom",o);let s=new Sb;this._add("tapDragZoom",s);let l=i.touchPitch=new Su(i);this._add("touchPitch",l);let h=new Se(t),u=new St(t);i.dragRotate=new ST(t,h,u),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);let c=new E7(t),d=new Si(i,t);i.dragPan=new Sw(r,c,d),this._add("mousePan",c),this._add("touchPan",d,["touchZoom","touchRotate"]);let p=new Sl,f=new So;i.touchZoomRotate=new SE(r,f,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new E0(i));let _=i.scrollZoom=new Sy(i,this);this._add("scrollZoom",_,["mousePan"]);let m=i.keyboard=new Sf;for(let r of(this._add("keyboard",m),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"]))t.interactive&&t[r]&&i[r].enable(t[r])}_add(t,i,r){this._handlers.push({handlerName:t,handler:i,allowed:r}),this._handlersById[t]=i}stop(t){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[],this._originalZoom=void 0}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!SS(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(t,i,r){for(let a in t)if(!(a===r||i&&i.includes(a)))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){let i=[];for(let r of t)this._el.contains(r.target)&&i.push(r);return i}handleEvent(t,i){this._updatingCamera=!0;let r="renderFrame"===t.type,a=r?void 0:t,n={needsRenderFrame:!1},o={},s={},l=t.touches?this._getMapTouches(t.touches):void 0,h=l?iv(this._el,l):r?void 0:ix(this._el,t);for(let{handlerName:r,handler:u,allowed:c}of this._handlers){let d;u.isEnabled()&&(this._blockedByActive(s,c,r)?u.reset():u[i||t.type]&&(d=u[i||t.type](t,h,l),this.mergeHandlerResult(n,o,d,r,a),d&&d.needsRenderFrame&&this._triggerRe
111nderFrame()),(d||u.isActive())&&(s[r]=u))}let u={};for(let t in this._previousActiveHandlers)s[t]||(u[t]=a);this._previousActiveHandlers=s,(Object.keys(u).length||SC(n))&&(this._changes.push([n,o,u]),this._triggerRenderFrame()),(Object.keys(s).length||SC(n))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:c}=n;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))}mergeHandlerResult(t,i,r,a,n){if(!r)return;Object.assign(t,r);let o={handlerName:a,originalEvent:r.originalEvent||n};void 0!==r.zoomDelta&&(i.zoom=o),void 0!==r.panDelta&&(i.drag=o),void 0!==r.pitchDelta&&(i.pitch=o),void 0!==r.bearingDelta&&(i.rotate=o)}_applyChanges(){let t={},i={},r={};for(let[a,n,o]of this._changes)a.panDelta&&(t.panDelta=(t.panDelta||new tg(0,0))._add(a.panDelta)),a.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+a.zoomDelta),a.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+a.bearingDelta),a.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+a.pitchDelta),void 0!==a.around&&(t.around=a.around),void 0!==a.aroundCoord&&(t.aroundCoord=a.aroundCoord),void 0!==a.pinchAround&&(t.pinchAround=a.pinchAround),a.noInertia&&(t.noInertia=a.noInertia),Object.assign(i,n),Object.assign(r,o);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,i,r){let a=this._map,n=a.transform,o=t=>[t.x,t.y,t.z];if((()=>{let t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!SC(t)){let t=n.zoom;n.cameraElevationReference="sea",null!=this._originalZoom&&n._orthographicProjectionAtLowPitch&&"globe"!==n.projection.name&&0===n.pitch?(n.cameraElevationReference="ground",n.zoom=this._originalZoom):(n.recenterOnTerrain(),n.cameraElevationReference="ground"),t!==n.zoom&&this._map._update(!0)}if(n._isCameraConstrained&&a._stop(!0),!SC(t))return void this._fireEvents(i,r,!0);let{panDelta:s,zoomDelta:l,bearingDelta:h,pitchDelta:u,around:c,aroundCoord:d,pinchAround:p}=t;n._isCameraConstrained&&(l>0&&(l=0),n._isCameraConstrained=!1),void 0!==p&&(c=p),(l||i.drag&&!this._eventsInProgress.drag)&&c&&(this._dragOrigin=o(n.pointCoordinate3D(c)),this._originalZoom=n.zoom,this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",a._stop(!0),c=c||a.transform.centerPoint,h&&(n.bearing+=h),u&&(n.pitch+=u),n._updateCameraState();let f=[0,0,0];if(s)if("mercator"===n.projection.name){let t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(c).dir),i=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(c.sub(s)).dir);f[0]=i[0]-t[0],f[1]=i[1]-t[1]}else{let t=n.pointCoordinate(c);if("globe"===n.projection.name){s=s.rotate(-n.angle);let i=n._pixelsPerMercatorPixel/n.worldSize;f[0]=-s.x*s5(aF(t.y))*i,f[1]=-s.y*s5(n.center.lat)*i}else{let i=n.pointCoordinate(c.sub(s));t&&i&&(f[0]=i.x-t.x,f[1]=i.y-t.y)}}let _=n.zoom,m=[0,0,0];if(l){let t=o(d||n.pointCoordinate3D(c)),i={dir:eW([],ek([],t,n._camera.position))};if(i.dir[2]<0){let r=n.zoomDeltaToMovement(t,l);ej(m,i.dir,r)}}let g=eB(f,f,m);n._translateCameraConstrained(g),l&&Math.abs(n.zoom-_)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,r,!0)}_fireEvents(t,i,r){let a,n=SS(this._eventsInProgress),o=SS(t),s={};for(let i in t){let{originalEvent:r}=t[i];this._eventsInProgress[i]||(s[`${i}start`]=r),this._eventsInProgress[i]=t[i]}for(let t in!n&&o&&this._fireEvent("movestart",o.originalEvent),s)this._fireEvent(t,s[t]);for(let i in o&&this._fireEvent("move",o.originalEvent),t){let{originalEvent:r}=t[i];this._fireEvent(i,r)}let l={};for(let t in this._eventsInProgress){let{handlerName:r,originalEvent:n}=this._eventsInProgress[t];this._handlersById[r].isActive()||(delete this._eventsInProgress[t],a=i[r]||n,l[`${t}end`]=a)}for(let t in l)this._fireEvent(t,l[t]);let h=SS(this._eventsInProgress);if(r&&(n||o)&&!h){this._updatingCamera=!0;let t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;
111t?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:a})):(this._map.fire(new rz("moveend",{originalEvent:a})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new rz(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{this._frameId=void 0,this.handleEvent(new SI("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}let SR="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class SD extends rB{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,tG(["_renderFrameCallback"],this)}getCenter(){return new s0(this.transform.center.lng,this.transform.center.lat)}setCenter(t,i){return this.jumpTo({center:t},i)}panBy(t,i,r){return t=tg.convert(t).mult(-1),this.panTo(this.transform.center,{offset:t,...i},r)}panTo(t,i,r){return this.easeTo({center:t,...i},r)}getZoom(){return this.transform.zoom}setZoom(t,i){return this.jumpTo({zoom:t},i),this}zoomTo(t,i,r){return this.easeTo({zoom:t,...i},r)}zoomIn(t,i){return this.zoomTo(this.getZoom()+1,t,i),this}zoomOut(t,i){return this.zoomTo(this.getZoom()-1,t,i),this}getBearing(){return this.transform.bearing}setBearing(t,i){return this.jumpTo({bearing:t},i),this}getPadding(){return this.transform.padding}setPadding(t,i){return this.jumpTo({padding:t},i),this}rotateTo(t,i,r){return this.easeTo({bearing:t,...i},r)}resetNorth(t,i){return this.rotateTo(0,{duration:1e3,...t},i),this}resetNorthPitch(t,i){return this.easeTo({bearing:0,pitch:0,duration:1e3,...t},i),this}snapToNorth(t,i){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,i):this}getPitch(){return this.transform.pitch}setPitch(t,i){return this.jumpTo({pitch:t},i),this}cameraForBounds(t,i){t=s1.convert(t);let r=i&&i.bearing||0,a=i&&i.pitch||0,n=t.getNorthWest(),o=t.getSouthEast();return this._cameraForBounds(this.transform,n,o,r,a,i)}_extendPadding(t){let i={top:0,right:0,bottom:0,left:0};return null==t?{...i,...this.transform.padding}:"number"==typeof t?{top:t,bottom:t,right:t,left:t}:{...i,...t}}_extendCameraOptions(t){return(t={offset:[0,0],maxZoom:this.transform.maxZoom,...t}).padding=this._extendPadding(t.padding),t}_minimumAABBFrustumDistance(t,i){let r=i.max[0]-i.min[0],a=i.max[1]-i.min[1];return r/a>t.aspect?r/(2*Math.tan(.5*t.fovX)*t.aspect):a/(2*Math.tan(.5*t.fovY)*t.aspect)}_cameraForBoundsOnGlobe(t,i,r,a,n,o){let s=t.clone(),l=this._extendCameraOptions(o);s.bearing=a,s.pitch=n;let h=s0.convert(i),u=s0.convert(r),c=.5*(h.lat+u.lat),d=.5*(h.lng+u.lng),p=sQ(c,d),f=eW([],p),_=eW([],eY([],f,[0,1,0])),m=eY([],_,f),g=[_[0],_[1],_[2],0,m[0],m[1],m[2],0,f[0],f[1],f[2],0,0,0,0,1],y=[p,sQ(h.lat,h.lng),sQ(u.lat,h.lng),sQ(u.lat,u.lng),sQ(h.lat,u.lng),sQ(c,h.lng),sQ(c,u.lng),sQ(h.lat,d),sQ(u.lat,d)],x=cg.fromPoints(y.map(t=>[eX(_,t),eX(m,t),eX(f,t)])),v=eQ([],x.center,g);0===eZ(v)&&eF(v,0,0,1),eW(v,v),ej(v,v,sW),s.center=function([t,i,r]){let a=Math.hypot(t,i,r);return new s0(Math.atan2(t,r)*tC,(.5*Math.PI-Math.acos(-i/a))*tC)}(v);let b=s.getWorldToCameraMatrix(),w=em(new Float64Array(16),b);x=cg.applyTransform(x,eg([],b,g));let T=this._extendAABB(x,s,l,a);if(!T)return void tX("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T,eQ(v,v,b);let E=.5*(x.max[2]-x.min[2]),S=this._minimumAABBFrustumDistance(s,x),I=ej([],[0,0,1],E),A=eB(I,v,I),C=S+(0===s.pitch?0:eH(v,A)),M=s.globeCenterInViewSpace,R=ek([],v,[M[0],M[1],M[2]]);eW(R,R),ej(R,R,C);let D=eB([],v,R);eQ(D,D,w);let P=6371008.8/sW,z=Math.max(eL(D)*P-6371008.8,Number.EPSILON)/s2(0),L=Math.min(s.zoomFromMercatorZAdjusted(z),l.maxZoom);return L>5.5?(s.setProjection({name:"mercator"}),s.zoom=L,this._cameraForBounds(s,i,r,a,n,o)):{center:s.center,zoom:L,bearing:a,pitch:n}}_extendAABB(t,i,r,a){let n=.5*((r.padding.left||0)+(r.padding.right||0)),o=.5*((r.padding.top||0)+(r.padding.bottom||0)),s=i.width-(n+n),l=i.height-(o+o),h=ek([],t.max,t.min),u=Math.min(s/h[0],l/h[1]),c=Math.min(i.scaleZoom(i.scale*u),r.maxZoom);if(isNaN(c))return null;let d=i.scale/i.zoomScale(c),p=new cg([t.min[0]-n*d,t.min[1]-o*d,t.min[2]],[t.max[0]+n*d,t.max[1]+o*d,t.max[2]]),f=("number"==typeof r.offset.x&&"number"==typeof r.offset.y?new tg(r.offset.x,r.offset.y):tg.convert(r.offset)).rotate(-(a*tA));return p.center[0]-=f.x*d,p.center[1]+=f.y*d,p}queryTerrainElevation(t,i){let r=this.transform.elevation;return r?(i={exaggerated:!0,...i},r.getAtPoint(s8.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,r,a,n,o){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,r,a,n,o);let s=t.clone(),l=this._extendCameraOptions(o);s.bearing=a,s.pitch=n;let h=s0.convert(i),u=s0.convert(r),c=new s0(h.lng,u.lat),d=new s0(u.lng,h.lat),p=s.project(h),f=s.project(u),_=this.queryTerrainElevation(h),m=this.queryTerrainElevation(u),g=this.queryTerrainElevation(c),y=this.queryTerrainElevation(d),x=[[p.x,p.y,Math.min(_||0,m||0,g||0,y||0)],[f.x,f.y,Math.max(_||0,m||0,g||0,y||0)]],v=cg.fromPoints(x),b=s.getWorldToCameraMatrix(),w=em(new Float64Array(16),b);v=cg.applyTransform(v,b);let T=this._extendAABB(v,s,l,a);if(!T)return void tX("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let E=.5*ek([],(v=T).max,v.min)[2],S=this._minimumAABBFrustumDistance(s,v),I=[0,0,1,0];e9(I,I,b),e8(I,I);let A=ej([],I,S+E),C=eB([],v.center,A);eQ(v.center,v.center,w),eQ(C,C,w);let M=s.unproject(new tg(v.center[0],v.center[1])),R=Math.pow(2,p0(s.projection,M)),D=Math.min(s._zoomFromMercatorZ(C[2]*s.pixelsPerMeter*R/s.worldSize),l.maxZoom);return s.mercatorFromTransition&&D<5.5?(s.setProjection({name:"globe"}),s.zoom=D,this._cameraForBounds(s,i,r,a,n,o)):{center:M,zoom:D,bearing:a,pitch:n}}fitBounds(t,i,r){let a=this.cameraForBounds(t,i);return this._fitInternal(a,i,r)}fitScreenCoordinates(t,i,r,a,n){let o=tg.convert(t),s=tg.convert(i),l=new tg(Math.min(o.x,s.x),Math.min(o.y,s.y)),h=new tg(Math.max(o.x,s.x),Math.max(o.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,s))return this;let u=this.transform.pointLocation3D(l),c=this.transform.pointLocation3D(h),d=this.transform.pointLocation3D(new tg(l.x,h.y)),p=this.transform.pointLocation3D(new tg(h.x,l.y)),f=[Math.min(u.lng,c.lng,d.lng,p.lng),Math.min(u.lat,c.lat,d.lat,p.lat)],_=[Math.max(u.lng,c.lng,d.lng,p.lng),Math.max(u.lat,c.lat,d.lat,p.lat)],m=a&&a.pitch?a.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,_,r,m,a);return this._fitInternal(g,a,n)}_fitInternal(t,i,r){return t?(i=Object.assign(t,i)).linear?this.easeTo(i,r):this.flyTo(i,r):this}jumpTo(t,i){this.stop();let r=t.preloadOnly?this.transform.clone():this.transform,a=!1,n=!1,o=!1;"zoom"in t&&r.zoom!==+t.zoom&&(a=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=s0.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(n=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(o=!0,r.pitch=+t.pitch);let s="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!r.isPaddingEqual(s))if(!1===t.retainPadding){let t=r.clone();t.padding=s,r.setLocationAtPoint(r.center,t.centerPoint)}else r.padding=s;return t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new rz("movestart",i)).fire(new rz("move",i)),a&&this.fire(new rz("zoomstart",i)).fire(new rz("zoom",i)).fire(new rz("zoomend",i)),n&&this.fire(new rz("rotatestart",i)).fire(new rz("rotate",i)).fire(new rz("rotateend",i)),o&&this.fire(new rz("pitchstart",i)).fire(new rz("pitch",i)).fire(new rz("pitchend",
111i)),this.fire(new rz("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||tX(SR),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){let r=this.transform;if(!r.projection.supportsFreeCamera)return tX(SR),this;this.stop();let a=r.zoom,n=r.pitch,o=r.bearing;r.setFreeCameraOptions(t);let s=a!==r.zoom,l=n!==r.pitch,h=o!==r.bearing;return this.fire(new rz("movestart",i)).fire(new rz("move",i)),s&&this.fire(new rz("zoomstart",i)).fire(new rz("zoom",i)).fire(new rz("zoomend",i)),h&&this.fire(new rz("rotatestart",i)).fire(new rz("rotate",i)).fire(new rz("rotateend",i)),l&&this.fire(new rz("pitchstart",i)).fire(new rz("pitch",i)).fire(new rz("pitchend",i)),this.fire(new rz("moveend",i)),this}easeTo(t,i){let r,a,n,o,s;this._stop(!1,t.easeId),(!1===(t={offset:[0,0],duration:500,easing:tz,...t}).animate||this._prefersReducedMotion(t))&&(t.duration=0);let l=this.transform,h=this.getZoom(),u=this.getBearing(),c=this.getPitch(),d=this.getPadding(),p="zoom"in t?+t.zoom:h,f="bearing"in t?this._normalizeBearing(t.bearing,u):u,_="pitch"in t?+t.pitch:c,m=this._extendPadding(t.padding),g=tg.convert(t.offset);if("globe"===l.projection.name){let i=s8.fromLngLat(l.center),o=g.rotate(-l.angle);i.x+=o.x/l.worldSize,i.y+=o.y/l.worldSize;let s=i.toLngLat(),h=s0.convert(t.center||s);this._normalizeCenter(h),r=l.centerPoint.add(o),a=new tg(i.x,i.y).mult(l.worldSize),n=new tg(az(h.lng),aL(h.lat)).mult(l.worldSize).sub(a)}else{r=l.centerPoint.add(g);let i=l.pointLocation(r),o=s0.convert(t.center||i);this._normalizeCenter(o),a=l.project(i),n=l.project(o).sub(a)}let y=l.zoomScale(p-h);t.around&&(o=s0.convert(t.around),s=l.locationPoint(o));let x=this._zooming||p!==h,v=this._rotating||u!==f,b=this._pitching||_!==c,w=!l.isPaddingEqual(m),T=!1===t.retainPadding?l.clone():l,E=l=>E=>{if(x&&(l.zoom=rG(h,p,E)),v&&(l.bearing=rG(u,f,E)),b&&(l.pitch=rG(c,_,E)),w&&(T.interpolatePadding(d,m,E),r=T.centerPoint.add(g)),o)l.setLocationAtPoint(o,s);else{let t=l.zoomScale(l.zoom-h),i=Math.pow(p>h?Math.min(2,y):Math.max(.5,y),1-E),o=l.unproject(a.add(n.mult(E*i)).mult(t));l.setLocationAtPoint(l.renderWorldCopies?o.wrap():o,r)}return t.preloadOnly||this._fireMoveEvents(i),l};if(t.preloadOnly){let i=this._emulate(E,t.duration,l);return this._preloadTiles(i),this}let S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,S),this._ease(E(l),t=>{"sea"===l.cameraElevationReference&&l.recenterOnTerrain(),this._afterEase(i,t)},t),this}_prepareEase(t,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||r.moving||this.fire(new rz("movestart",t)),this._zooming&&!r.zooming&&this.fire(new rz("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new rz("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new rz("pitchstart",t))}_fireMoveEvents(t){this.fire(new rz("move",t)),this._zooming&&this.fire(new rz("zoom",t)),this._rotating&&this.fire(new rz("rotate",t)),this._pitching&&this.fire(new rz("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";let r=this._zooming,a=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new rz("zoomend",t)),a&&this.fire(new rz("rotateend",t)),n&&this.fire(new rz("pitchend",t)),this.fire(new rz("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){let r=tk(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(r,i)}this.stop(),t={offset:[0,0],speed:1.2,curve:1.42,easing:tz,...t};let r=this.transform,a=this.getZoom(),n=this.getBearing(),o=this.getPitch(),s=this.getPadding(),l="zoom"in t?tL(+t.zoom,r.minZoom,r.maxZoom):a,h="bearing"in t?this._normalizeBearing(t.bearing,n):n,u="pitch"in t?+t.pitch:o,c=this._extendPadding(t.padding),d=r.zoomScale(l-a),p=tg.convert(t.offset),f=r.centerPoint.add(p),_=r.pointLocation(f),m=s0.convert(t.center||_);this._normalizeCenter(m);let g=r.project(_),y=r.project(m).sub(g),x=t.curve,v=Math.max(r.width,r.height),b=v/d,w=y.mag();if("minZoom"in t){let i=tL(Math.min(t.minZoom,a,l),r.minZoom,r.maxZoom);x=Math.sqrt(v/r.zoomScale(i-a)/w*2)}let T=x*x;function E(t){let i=(b*b-v*v+(t?-1:1)*T*T*w*w)/(2*(t?b:v)*T*w);return Math.log(Math.sqrt(i*i+1)-i)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function I(t){return(Math.exp(t)+Math.exp(-t))/2}let A=E(0),C=function(t){return I(A)/I(A+x*t)},M=function(t){var i;return v*((I(A)*(S(i=A+x*t)/I(i))-S(A))/T)/w},R=(E(1)-A)/x;if(1e-6>Math.abs(w)||!isFinite(R)){if(1e-6>Math.abs(v-b))return this.easeTo(t,i);let r=b<v?-1:1;R=Math.abs(Math.log(b/v))/x,M=function(){return 0},C=function(t){return Math.exp(r*x*t)}}t.duration="duration"in t?+t.duration:1e3*R/("screenSpeed"in t?t.screenSpeed/x:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);let D=n!==h,P=u!==o,z=!r.isPaddingEqual(c),L=!1===t.retainPadding?r.clone():r,O=r=>d=>{let _=d*R,x=1/C(_);r.zoom=1===d?l:a+r.scaleZoom(x),D&&(r.bearing=rG(n,h,d)),P&&(r.pitch=rG(o,u,d)),z&&(L.interpolatePadding(s,c,d),f=L.centerPoint.add(p));let v=1===d?m:r.unproject(g.add(y.mult(M(_))).mult(x));return r.setLocationAtPoint(r.renderWorldCopies?v.wrap():v,f),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){let i=this._emulate(O,t.duration,r);return this._preloadTiles(i),this}return this._zooming=!0,this._rotating=D,this._pitching=P,this._padding=z,this._prepareEase(i,!1),this._ease(O(r),()=>this._afterEase(i),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(t){}_cancelRenderFrame(t){}_stop(t,i){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){let t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,i)}if(!t){let t=this.handlers;t&&t.stop(!1)}return this}_ease(t,i,r){!1===r.animate||0===r.duration?(t(1),i()):(this._easeStart=is.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){let t=Math.min((is.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){let r=Math.abs((t=tF(t,-180,180))-i);return Math.abs(t-360-i)<r&&(t-=360),Math.abs(t+360-i)<r&&(t+=360),t}_normalizeCenter(t){let i=this.transform;if(i.maxBounds||"globe"!==i.projection.name&&!i.renderWorldCopies)return;let r=t.lng-i.center.lng;t.lng+=r>180?-360:360*(r<-180)}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&is.prefersReducedMotion&&!(t&&t.essential)}_emulate(t,i,r){let a=Math.ceil(15*i/1e3),n=[],o=t(r.clone());for(let t=0;t<=a;t++){let i=o(t/a);n.push(i.clone())}return n}_preloadTiles(t,i){}}let SP=/^(https?:|mailto:)/i;class Sz{constructor(t={}){this.options=t,tG(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){let i=this.options&&this.options.compact,r=t._getUIString("AttributionControl.ToggleAttribution");this._map=t,this._container=iu("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=iu("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",r);let a=iu("span","mapboxgl-ctrl-icon",this._compactButton);return a.setAttribute("aria-hidden","true"),a.setAttribute("title",r),this._innerContainer=iu("div","mapboxgl-ctrl-attrib-inner",this._container),i&&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),void 0===i&&(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","fal
111se")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));let i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||iT.ACCESS_TOKEN}];if(t){let r=i.reduce((t,r,a)=>(r.value&&(t+=`${r.key}=${r.value}${a<i.length-1?"&":""}`),t),"?");t.href=`${iT.FEEDBACK_URL}/${r}#${EU(this._map,!0)}`,t.rel="noopener nofollow"}}_updateData(t){t&&("source"===t.dataType&&("metadata"===t.sourceDataType||"visibility"===t.sourceDataType)||"style"===t.dataType)&&(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let t=[];if(this._map.style.stylesheet){let t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}let i=this._map.style._mergedSourceCaches;for(let r in i){let a=i[r];if(a.used){let i=a.getSource();i.attribution&&!t.includes(i.attribution)&&t.push(i.attribution)}}t.sort((t,i)=>t.length-i.length),t=t.filter((i,r)=>{for(let a=r+1;a<t.length;a++)if(t[a].includes(i))return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));let r=t.map(t=>(function(t){let i=(new DOMParser).parseFromString(t,"text/html");return Array.from(i.body.querySelectorAll("*")).reverse().forEach(t=>{let r=t.textContent||"";if("A"!==t.tagName)return void t.replaceWith(...t.childNodes);let a=t.getAttribute("href");if(!a||!SP.test(a))return void t.replaceWith(i.createTextNode(r));let n=i.createElement("a");n.href=a,n.textContent=r,n.rel="noopener nofollow";let o=t.getAttribute("class");o&&(n.className=o),t.replaceWith(n)}),i.body.innerHTML})(t)).join(" | ");r!==this._attribHTML&&(this._attribHTML=r,t.length?(this._innerContainer.innerHTML=r,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 SL{constructor(){tG(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=iu("div","mapboxgl-ctrl");let i=iu("a","mapboxgl-ctrl-logo");return i.target="_blank",i.rel="noopener nofollow",i.href="https://www.mapbox.com/",i.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),i.setAttribute("rel","noopener nofollow"),this._container.appendChild(i),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;let t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(let i in t){let r=t[i].getSource();if(Object.hasOwn(r,"mapbox_logo")&&!r.mapbox_logo)return!1}return!0}_updateCompact(){let t=this._container.children;if(t.length){let i=t[0];this._map.getCanvasContainer().offsetWidth<250?i.classList.add("mapboxgl-compact"):i.classList.remove("mapboxgl-compact")}}}class SO{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let i=++this._id;return this._queue.push({callback:t,id:i,cancelled:!1}),i}remove(t){let i=this._currentlyRunning;for(let r of i?this._queue.concat(i):this._queue)if(r.id===t)return void(r.cancelled=!0)}run(t=0){let i=this._currentlyRunning=this._queue;for(let r of(this._queue=[],i))if(!r.cancelled&&(r.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class SF{constructor(t){this.jumpTo(t)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;let i=tD((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,i,r){this._start=this.getValue(i),this._end=t,this._startTime=i,this._endTime=i+r}}let SB={"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 Sk extends rz{constructor(t,i,r,a){let{point:n,lngLat:o,originalEvent:s,target:l}=t;super(t.type,{point:n,lngLat:o,originalEvent:s,target:l}),this.preventDefault=()=>{t.preventDefault()},this.id=i,this.interaction=r,this.feature=a}}class SN{constructor(t){this.map=t,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}
111add(t,i){if(this.typeById.has(t))throw Error(`Interaction id "${t}" already exists.`);let r=i.filter,a=i.type;r&&this.filters.set(t,sh(r)),"mouseover"===a&&(a="mouseenter"),"mouseout"===a&&(a="mouseleave");let n=this.interactionsByType.get(a)||new Map;"mouseenter"===a||"mouseleave"===a?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===n.size&&this.map.on(a,this.handleType),0===n.size&&this.interactionsByType.set(a,n),n.set(t,i),this.typeById.set(t,a)}get(t){let i=this.typeById.get(t);if(!i)return;let r=this.interactionsByType.get(i);return r?r.get(t):void 0}remove(t){let i=this.typeById.get(t);if(!i)return;this.typeById.delete(t),this.filters.delete(t);let r=this.interactionsByType.get(i);r&&(r.delete(t),"mouseenter"===i||"mouseleave"===i?(this.delegatedInteractions.delete(t),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===r.size&&this.map.off(i,this.handleType))}queryTargets(t,i){let r=[];for(let[t,a]of i)a.target&&r.push({targetId:t,target:a.target,filter:this.filters.get(t)});return this.map.style.queryRenderedTargets(t,r,this.map.transform)}handleMove(t){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;let i=this.queryTargets(t.point,Array.from(this.delegatedInteractions).reverse());i.length&&(t.type="mouseenter",this.handleType(t,i));let r=new Map;for(let[t,{feature:i}]of this.prevHoveredFeatures)this.hoveredFeatures.has(t)||r.set(i.id,i);r.size&&(t.type="mouseleave",this.handleType(t,Array.from(r.values())
111))}handleOut(t){let i=Array.from(this.hoveredFeatures.values()).map(({feature:t})=>t);i.length&&(t.type="mouseleave",this.handleType(t,i)),this.hoveredFeatures.clear()}handleType(t,i){let r="mouseenter"===t.type;if(r&&!this.interactionsByType.has(t.type))return void tX("mouseenter interaction required for mouseleave to work.");let a=Array.from(this.interactionsByType.get(t.type)).reverse(),n=!!i;i=i||this.queryTargets(t.point,a);let o=!1,s=new Set;for(let l of i){for(let[i,h]of a){if(!h.target)continue;let a=l.variants?l.variants[i]:null;if(a){for(let u of a){if(b4(u,l,s,i))continue;let a=new _5(l,u),c=b3(u,l,i);n&&void 0!==a.id&&(a.state=this.map.getFeatureState(a));let d=r?this.prevHoveredFeatures.get(c):null,p=new Sk(t,i,h,a),f=d?d.stop:h.handler(p);if(r&&this.hoveredFeatures.set(c,{feature:l,stop:f}),!1!==f){o=!0;break}}if(o)break}}if(o)break}if(!o)for(let[i,r]of a){let{handler:a,target:n}=r;if(!n&&!1!==a(new Sk(t,i,r,null)))break}}}let SV=/matrix.*\((.+)\)/,SU={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},Sj={showCompass:!0,showZoom:!0,visualizePitch:!1};class SG{constructor(t,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Se({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new St({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),tG(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(t,i){this.mouseRotate.mousedown(t,i),this.mousePitch&&this.mousePitch.mousedown(t,i),i_()}move(t,i){let r=this.map,a=this.mouseRotate.mousemoveWindow(t,i),n=a&&a.bearingDelta;if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){let a=this.mousePitch.mousemoveWindow(t,i),n=a&&a.pitchDelta;n&&r.setPitch(r.getPitch()+n)}}off(){let t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){im(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down({...t,button:t.button,type:t.type,ctrlKey:!0,preventDefault:()=>t.preventDefault()},ix(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,ix(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=iv(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=iv(this.element,t.targetTouches)[0],this.move({buttons:1,preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&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 SH(t,i,r){if(t=new s0(t.lng,t.lat),i){let a=new s0(t.lng-360,t.lat),n=new s0(t.lng+360,t.lat),o=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),s=r.locationPoint3D(t).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint3D(a).distSqr(i)<s&&(l||Math.abs(a.lng-r.center.lng)<o)?t=a:r.locationPoint3D(n).distSqr(i)<s&&(l||Math.abs(n.lng-r.center.lng)<o)&&(t=n)}for(;Math.abs(t.lng-r.center.lng)>180;){let i=r.locationPoint3D(t);
111if(i.x>=0&&i.y>=0&&i.x<=r.width&&i.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}let Sq={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%)"},SZ=/\s+/,S$="auto",SW="auto";class SX extends rB{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t={element:t,...i}),tG(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);let{anchor:r="center",color:a="#3FB1CE",scale:n=1,draggable:o=!1,clickTolerance:s=0,rotation:l=0,rotationAlignment:h=S$,pitchAlignment:u=SW,occludedOpacity:c=.2,altitude:d=0}=t||{};this._anchor=r,this._color=a,this._scale=n,this._draggable=o,this._clickTolerance=s,this._rotation=l,this._rotationAlignment=h,this._pitchAlignment=u,this._occludedOpacity=c,this._altitude=d,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=tg.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=tg.convert(t&&t.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",t=>{t.preventDefault()}),this._element.addEventListener("mousedown",t=>{t.preventDefault()});let p=this._element.classList;for(let t in Sq)p.remove(`mapboxgl-marker-anchor-${t}`);p.add(`mapboxgl-marker-anchor-${this._anchor}`),t&&t.className&&p.add(...t.className.trim().split(SZ)),this._popup=null}_createDefaultMarker(){let t=iu("div"),i=ic("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},t);this._svgElement=i;let r=ic("radialGradient",{id:"shadowGradient"},ic("defs",{},i));ic("stop",{offset:"10%","stop-opacity":.4},r),ic("stop",{offset:"100%","stop-opacity":.05},r);let a=ic("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"});return this._shadowElement=a,0===this._altitude&&i.insertBefore(a,i.firstChild),ic("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"},i),ic("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"},i),ic("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},i),t}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){let t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=s0.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(t){if(t===this._altitude)return this;let i=this._altitude;return this._altitude=t||0,this._defaultMarker&&0===i!=(0===this._altitude)&&(0===this._altitude?this._svgElement.insertBefore(this._shadowElement,this._svgElement.firstChild):this._shadowElement.remove()),this._update(),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){let i=Math.sqrt(91.125);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[
1110,-38.1],"bottom-left":[i,-1*(24.6+i)],"bottom-right":[-i,-1*(24.6+i)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=t,t._marker=this,t._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(t){let i=t.code,r=t.charCode||t.keyCode;"Space"!==i&&"Enter"!==i&&32!==r&&13!==r||this.togglePopup()}_onMapClick(t){let i=t.originalEvent.target,r=this._element;this._popup&&(i===r||r.contains(i))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){let t=this._popup;return t&&(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_behindTerrain(){let t=this._map,i=this._pos;if(!t||!i)return!1;let r=t.unproject(i,this._altitude),a=t.getFreeCameraOptions();if(!a.position)return!1;let n=a.position.toLngLat();return n.distanceTo(r)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){let t,i=this._map;if(!i)return;let r=this._pos;if(!r||r.x<0||r.x>i.transform.width||r.y<0||r.y>i.transform.height)return void this._clearFadeTimer();let a=i.unproject(r,this._altitude);i._showingGlobe()&&cZ(i.transform,this._lngLat)?t=0:(t=1-i._queryFogOpacity(a),i.transform._terrainEnabled()&&i.style&&i.style.hasTerrain()&&this._behindTerrain()&&(t*=this._occludedOpacity)),this._element.style.opacity=`${t}`,this._element.style.pointerEvents=t>0?"auto":"none",this._popup&&this._popup._setOpacity(t),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){let t=this._pos;if(!t||!this._map)return;let i=this._offset.mult(this._scale);this._element.style.transform=` 112 translate(${t.x}px,${t.y}px) 113 ${Sq[this._anchor]} 114 ${this._calculateXYTransform()} ${this._calculateZTransform()} 115 translate(${i.x}px,${i.y}px) 116 `}_calculateXYTransform(){let t=this._pos,i=this._map,r=this.getPitchAlignment();if(!i||!t||"map"!==r)return"";if(!i._showingGlobe()){let t=i.getPitch();return t?`rotateX(${t}deg)`:""}let a=cq(i.transform,this._lngLat)*tC,n=t.sub(cH(i.transform)),o=Math.abs(n.x)+Math.abs(n.y);if(0===o)return"";let s=a/o;return`rotateX(${-n.y*s}deg) rotateY(${n.x*s}deg)`}_calculateZTransform(){let t=this._pos,i=this._map;if(!i||!t)return"";let r=0,a=this.getRotationAlignment();if("map"===a)if(i._showingGlobe()){let t=i.project(new s0(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),a=i.project(new s0(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);r=Math.atan2(a.y,a.x)*tC-90}else r=-i.getBearing();else if("horizon"===a){let a=tO(4,6,i.getZoom()),n=cH(i.transform);n.y+=a*i.transform.height;let o=t.sub(n),s=Math.atan2(o.y,o.x)*tC;r=(s>90?s-270:s+90)*(1-a)}return(r+=this._rotation)?`rotateZ(${r}deg)`:""}_update(t){cancelAnimationFrame(this._updateFrameId);let i=this._map;
116i&&(i.transform.renderWorldCopies&&(this._lngLat=SH(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat,this._altitude),!0===t?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),i._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._showingGlobe()||i.style&&i.style.hasTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=tg.convert(t),this._update(),this}addClassName(t){return this._element.classList.add(t),this}removeClassName(t){return this._element.classList.remove(t),this}toggleClassName(t){return this._element.classList.toggle(t)}_onMove(t){let i=this._map;if(!i)return;let r=this._pointerdownPos,a=this._positionDelta;if(r&&a){if(!this._isDragging){let a=this._clickTolerance||i._clickTolerance;if(t.point.dist(r)<a)return;this._isDragging=!0}this._pos=t.point.sub(a),this._lngLat=i.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new rz("dragstart"))),this.fire(new rz("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;let t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new rz("dragend")),this._state="inactive"}_addDragHandler(t){let i=this._map,r=this._pos;i&&r&&this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(r),this._pointerdownPos=t.point,this._state="pending",i.on("mousemove",this._onMove),i.on("touchmove",this._onMove),i.once("mouseup",this._onUp),i.once("touchend",this._onUp))}setDraggable(t){this._draggable=!!t;let i=this._map;return i&&(t?(i.on("mousedown",this._addDragHandler),i.on("touchstart",this._addDragHandler)):(i.off("mousedown",this._addDragHandler),i.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||S$,this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t||SW,this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(t){return this._occludedOpacity=t||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}let SY={OFF:[],WAITING_ACTIVE:["waiting","active"],ACTIVE_LOCK:["active"],ACTIVE_ERROR:["waiting","active-error"],BACKGROUND:["background"],BACKGROUND_ERROR:["waiting","background-error"]},SK=t=>`mapboxgl-ctrl-geolocate-${t}`,SQ=["waiting","active","active-error","background","background-error"].map(SK),SJ={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},S0={maxWidth:100,unit:"metric"},S1={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},S2=/\s+/,S3={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0};function S4(t=new tg(0,0),i="bottom"){if("number"==typeof t){let r=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case"top":return new tg(0,t);case"top-left":return new tg(r,r);case"top-right":return new tg(-r,r);case"bottom":return new tg(0,-t);case"bottom-left":return new tg(r,-r);case"bottom-right":return new tg(-r,-r);case"left":return new tg(t,0);case"right":return new tg(-t,0)}return new tg(0,0)}return t instanceof tg||Array.isArray(t)?tg.convert(t):tg.convert(t[i]||[0,0])}let S5="undefined"!=typeof document?document.currentScript:null;return rp=S5&&S5.src&&iZ(S5.src)?"cdn":"other",{version:er,supported:function(r){return"undefined"!=typeof window&&"undefined"!=typeof document&&!!Object.hasOwn&&!!function(){let t=document.createElement("canvas");t.width=t.height=1;let i=t.getContext("2d");return!!i&&i.getImageData(0,0,1,1).width===t.width}()&&((r?(void 0===i&&(i=ei(!0)),!!i):(void 0===t&&(t=ei(!1)),!!t))||!1)},setRTLTextPlugin:function(t,i,r=!1){if(oq===oU||oq===oj||oq===oG)throw Error("setRTLTextPlugin cannot be called multiple times.");oZ=is.resolveURL(t),oq=oU,oH=i,oW(),r||oK()},getRTLTextPluginStatus:oY,setSdkInfo:function(t){"string"!=typeof t||t.length>64||!rd.test(t)?tX(`Invalid SDK info "${t}"; expected a "Name/version" string. Ignoring.`):f=t},addTileProvider:function(t,i){if(!t||!i)throw Error("TileProvider name and URL are required");iT.TILE_PROVIDER_URLS[t]=is.resolveURL(i)},Map:class extends SD{constructor(t){i8.mark(i6.create);let i=t;if(null!=(t={...SU,...t}
116).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw Error("maxPitch must be less than or equal to 85");super(new g1(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._placementAlgorithm=t.placementAlgorithm||"default",this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new SO,this._domRenderTaskQueue=new SO,this._controls=[],this._markers=[],this._popups=[],this._mapId=tN++,this._locale={...SB,...t.locale},this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new SF(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new rn(t.transformRequest,t.accessToken,t.testMode);let r=ru(t.accessToken||iT.ACCESS_TOKEN);if(r&&"atlas"in r&&"number"==typeof r.atlas&&(this._tokenExpiration=r.atlas),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...t.contextCreateOptions}:{},"string"==typeof t.container){let i=document.getElementById(t.container);if(!i)throw Error(`Container '${t.container.toString()}' not found.`);this._container=i}else{if(!(t.container instanceof HTMLElement))throw Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&tX("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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._spriteFormat="auto",tG(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw 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 SM(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,this._fontstackCompositing=t.fontstackCompositing,(t.style||!t.testMode)&&this.setStyle(t.style||iT.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,fontstackCompositing:this._fontstackCompositing}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new EV("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==i.center&&null==i.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});
116let r=t.bounds;r&&(this.resize(),this.fitBounds(r,{...t.fitBoundsOptions,duration:0}))}this.resize(),t.attributionControl&&this.addControl(new Sz({customAttribution:t.customAttribution})),this._logoControl=new SL,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new rz(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new rz(`${t.dataType}dataloading`,t))}),this._interactions=new SN(this)}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new rL(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let r=t.onAdd(this);this._controls.push(t);let a=this._controlPositions[i];return i.includes("bottom")?a.insertBefore(r,a.firstChild):a.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new rL(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.includes(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));let i=!this._moving;return i&&this.fire(new rz("movestart",t)).fire(new rz("move",t)),this.fire(new rz("resize",t)),i&&this.fire(new rz("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(s1.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new rz("zoomstart")).fire(new rz("zoom")).fire(new rz("zoomend")),this;throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=t??22)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new rz("zoomstart")).fire(new rz("zoom")).fire(new rz("zoomend")),this;throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new rz("pitchstart")).fire(new rz("pitch")).fire(new rz("pitchend")),this;throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=t??85)>85)throw Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new rz("pitchstart")).fire(new rz("pitch")).fire(new rz("pitchend")),this;throw Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(t){return this._scaleFactor=t,this.painter.scaleFactor=t,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(t=>"symbol"===t.type),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(t){return"auto"===t?navigator.language:Array.isArray(t)?0===t.length?void 0:t.map(t=>"auto"===t?navigator.language:t):t}setLanguage(t){let i=this._parseLanguage(t);if(!this.style||i===this._language)return this;for(let t of(this._language=i,this.style.reloadSources(),this._controls))t._setLanguage&&t._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(t){return this.style&&t!==this._worldview&&(this._worldview=t,this._styleDirty=!0,this.style.setWorldview(t)),this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(t){return this._lazyInitEmptyStyle(),t?"string"==typeof t&&(t={name:t}):t=null,this._useExplicitProjection=!!t,this._prioritizeAndUpdateProjection(t,this.style.projection)}_updateProjectionTransition(){let t;if("globe"!==this.getProjection().name)return;let i=this.transform,r=i.projection.name;"globe"===r&&i.zoom>=6?(i.setMercatorFromTransition(),t=!0):"mercator"===r&&i.zoom<6&&(i.setProjection({name:"globe"}),t=!0),t&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayer
116Update(),this._update(!0))}_prioritizeAndUpdateProjection(t,i){return this._updateProjection(t||i||{name:"mercator"})}_updateProjection(t){let i,r=this.transform.mercatorFromTransition;i="globe"===t.name&&this.transform.zoom>=6?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();let a="mercator"===this.transform.getProjection().name&&r!==this.transform.mercatorFromTransition;return(i||a)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(s0.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(tg.convert(t),i)}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(t,i,r){let a=t=>{let r=[];if(Array.isArray(i)){let a=i.filter(t=>this.getLayer(t));r=a.length?this.queryRenderedFeatures(t,{layers:a}):[]}else r=this.queryRenderedFeatures(t,{target:i});return r};if("mouseenter"===t||"mouseover"===t){let n=!1,o=i=>{let o=a(i.point);o.length?n||(n=!0,r.call(this,new EY(t,this,i.originalEvent,{features:o}))):n=!1};return{listener:r,targets:i,delegates:{mousemove:o,mouseout:()=>{n=!1}}}}if("mouseleave"===t||"mouseout"===t){let n=!1,o=i=>{a(i.point).length?n=!0:n&&(n=!1,r.call(this,new EY(t,this,i.originalEvent)))},s=i=>{n&&(n=!1,r.call(this,new EY(t,this,i.originalEvent)))};return{listener:r,targets:i,delegates:{mousemove:o,mouseout:s}}}{let n=t=>{let i=a(t.point);i.length&&(t.features=i,r.call(this,t),delete t.features)};return{listener:r,targets:i,delegates:{[t]:n}}}}on(t,i,r){if("function"==typeof i||void 0===r)return super.on(t,i);if("string"==typeof i&&(i=[i]),!this._areTargetsValid(i))return this;let a=this._createDelegatedListener(t,i,r);for(let i in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(a),a.delegates)this.on(i,a.delegates[i]);return this}once(t,i,r){if("function"==typeof i||void 0===r)return super.once(t,i);if("string"==typeof i&&(i=[i]),!this._areTargetsValid(i))return this;let a=this._createDelegatedListener(t,i,r);for(let t in a.delegates)this.once(t,a.delegates[t]);return this}off(t,i,r){if("function"==typeof i||void 0===r)return super.off(t,i);if("string"==typeof i&&(i=[i]),!this._areTargetsValid(i))return this;let a=this._delegatedListeners?this._delegatedListeners[t]:void 0;return a&&(t=>{for(let a=0;a<t.length;a++){let n=t[a];if(n.listener===r&&function(t,i){if(Array.isArray(t)&&Array.isArray(i)){let r=new Set(t),a=new Set(i);return r.size===a.size&&t.every(t=>a.has(t))}return ty(t,i)}(n.targets,i)){for(let t in n.delegates)this.off(t,n.delegates[t]);return t.splice(a,1),this}}})(a),this}queryRenderedFeatures(t,i){if(!this.style)return[];if(void 0===t||t instanceof tg||Array.isArray(t)||void 0!==i||(i=t,t=void 0),t=t||[[0,0],[this.transform.width,this.transform.height]],!i){let i=this.style.queryRenderedFeatures(t,void 0,this.transform),r=this.style.queryRenderedFeatureset(t,void 0,this.transform);return i.concat(r)}let r=!0;if(i.target&&(r=this._isTargetValid(i.target))&&!i.layers)return this.style.queryRenderedFeatureset(t,i,this.transform);let a=!0;if(i.layers&&Array.isArray(i.layers)){for(let t of i.layers)if(!this._isValidId(t)){a=!1;break}if(a&&!i.target)return this.style.queryRenderedFeatures(t,i,this.transform)}let n=[];return a&&(n=n.concat(this.style.queryRenderedFeatures(t,i,this.transform))),r&&(n=n.concat(this.style.queryRenderedFeatureset(t,i,this.transform))),n}querySourceFeatures(t,i){return t&&("string"!=typeof t||this._isValidId(t))?this.style.querySourceFeatures(t,i):[]}queryRasterValue(t,i,r){return this._isValidId(t)?this.style.queryRasterValue(t,i,r):Promise.resolve(null)}isPointOnSurface(t){let{name:i}=this.transform.projection;return"globe"!==i&&"mercator"!==i&&tX(`${i} projection does not support isPointOnSurface, this API may behave unex
116pectedly.`),this.transform.isPointOnSurface(tg.convert(t))}addInteraction(t,i){return this._interactions.add(t,i),this}removeInteraction(t){return this._interactions.remove(t),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(t){return this._cooperativeGestures=t,this}setStyle(t,i){return i={localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,fontstackCompositing:this._fontstackCompositing,...i},this.style&&t&&!1!==i.diff&&i.localFontFamily===this._localFontFamily&&i.localIdeographFontFamily===this._localIdeographFontFamily&&i.fontstackCompositing===this._fontstackCompositing&&!i.config?(this.style._diffStyle(t,(r,a)=>{r?(tX(`Unable to perform style diff: ${"string"==typeof r?r:r instanceof Error?r.message:r.error}. Rebuilding the style from scratch.`),this._updateStyle(t,i)):a&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._fontstackCompositing=i.fontstackCompositing,this._updateStyle(t,i))}_getUIString(t){let i=this._locale[t];if(null==i)throw Error(`Missing UI string '${t}'`);return i}_updateStyle(t,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){let r={...i};i&&i.config&&(r.initialConfig=i.config,delete r.config),this.style=new wQ(this,r).load(t),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new wQ(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():(tX("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new rL(Error("IDs can't be empty."))),!1):!sg(t)||(this.fire(new rL(Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isTargetValid(t){return"featuresetId"in t?this._isValidId("importId"in t?t.importId:t.featuresetId):"layerId"in t&&this._isValidId(t.layerId)}_areTargetsValid(t){if(Array.isArray(t)){for(let i of t)if(!this._isValidId(i))return!1;return!0}return this._isTargetValid(t)}addSource(t,i){return this._isValidId(t)?(this._lazyInitEmptyStyle(),this.style.addSource(t,i),this._update(!0)):this}isSourceLoaded(t){return!!this._isValidId(t)&&!!this.style&&this.style._isSourceCacheLoaded(t)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(t,i,r){this._lazyInitEmptyStyle(),this.style.addSourceType(t,i,r)}removeSource(t){return this._isValidId(t)?(this.style.removeSource(t),this._updateTerrain(),this._update(!0)):this}getSource(t){return this._isValidId(t)?this.style.getOwnSource(t):null}addImage(t,i,{pixelRatio:r=1,sdf:a=!1,stretchX:n,stretchY:o,content:s}={}){this._lazyInitEmptyStyle();let l=rk.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){let{width:t,height:h,data:u}=is.getImageData(i);this.style.addImage(l,{data:new h7({width:t,height:h},u),pixelRatio:r,stretchX:n,stretchY:o,content:s,sdf:a,version:0,usvg:!1})}else if(void 0===i.width||void 0===i.height)this.fire(new rL(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{let{width:h,height:u}=i;this.style.addImage(l,{data:new h7({width:h,height:u},new Uint8Array(i.data)),pixelRatio:r,stretchX:n,stretchY:o,content:s,sdf:a,usvg:!1,version:0,userImage:i}),i.onAdd&&i.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();let r=rk.from(t),a=this.style.getImage(r);if(!a)return void this.fire(new rL(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:n,height:o,data:s}=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?is.getImageData(i):i;if(void 0===n||void 0===o)return void this.fire(new rL(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(n!==(a.usvg?a.icon.usvg_tree.width:a.data.width)||o!==(a.usvg?a.icon.usvg_tree.height:a.data.height))return void this.fire(new rL(Error(`The width and height of the updated image (${n}, ${o}) 117 must be that same as the previous version of the image 118 (${a.data.width}, ${a.data.height})`)));let l=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap),h=!1;a.usvg?(a.data=new h7({width:n,height:o},new Uint8Array(s)),a.usvg=!1,a.icon=void 0,h=!0):a.data.replace(s,l),this.style.updateImage(r,a,h)}hasImage(t){return t?!!this.style&&!!this.style.getImage(rk.from(t)):(this.fire(new rL(Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(rk.from(t))}loadImage(t,i){(async()=>{let i=await this._requestManager.transformRequest(t,iX.Image),{data:r}=await i5(i);return r})().then(t=>i(null,t)).catch(i)}listImages(){return this.style.listImages().map(t=>t.name)}addModel(t,i){this._lazyInitEmptyStyle(),this.style.addModel(t,i)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new rL(Error("Missing required model id"))),!1)}removeModel(t){this.style.removeModel(t)}listModels(){return this.style.listModels()}addLayer(t,i){return this._isValidId(t.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(t,i),this._update(!0)):this}getSlot(t){let i=this.getLayer(t);return i&&i.slot||null}setSlot(t,i){return this.style.setSlot(t,i),this.style.mergeLayers(),this._update(!0)}
118addImport(t,i){return this.style.addImport(t,i).catch(t=>this.fire(new rL(Error("Failed to add import",t)))),this}updateImport(t,i){return"string"!=typeof i&&i.id!==t?(this.removeImport(t),this.addImport(i)):(this.style.updateImport(t,i),this._update(!0))}removeImport(t){return this.style.removeImport(t),this}moveImport(t,i){return this.style.moveImport(t,i),this._update(!0)}moveLayer(t,i){return this._isValidId(t)?(this.style.moveLayer(t,i),this._update(!0)):this}removeLayer(t){return this._isValidId(t)?(this.style.removeLayer(t),this._update(!0)):this}getLayer(t){if(!this._isValidId(t))return null;let i=this.style.getOwnLayer(t);return i?"custom"===i.type?i.implementation:i.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(t,i,r){return this._isValidId(t)?(this.style.setLayerZoomRange(t,i,r),this._update(!0)):this}setFilter(t,i,r={}){return this._isValidId(t)?(this.style.setFilter(t,i,r),this._update(!0)):this}getFilter(t){return this._isValidId(t)?this.style.getFilter(t):null}setPaintProperty(t,i,r,a={}){return this._isValidId(t)?(this.style.setPaintProperty(t,i,r,a),this._update(!0)):this}getPaintProperty(t,i){return this._isValidId(t)?this.style.getPaintProperty(t,i):null}setLayoutProperty(t,i,r,a={}){return this._isValidId(t)?(this.style.setLayoutProperty(t,i,r,a),this._update(!0)):this}getLayoutProperty(t,i){return this._isValidId(t)?this.style.getLayoutProperty(t,i):null}getLayerProperty(t,i){return this._isValidId(t)?this.style.getLayerProperty(t,i):null}setLayerProperty(t,i,r,a={}){return this._isValidId(t)?("appearances"===i&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(t,i,r,a),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(t){return this.style.setGlyphsUrl(t),this._update(!0)}getSchema(t){return this.style.getSchema(t)}setSchema(t,i){return this.style.setSchema(t,i),this._update(!0)}getConfig(t){return this.style.getConfig(t)}setConfig(t,i){return this.style.setConfig(t,i),this._update(!0)}getConfigProperty(t,i){return this.style.getConfigProperty(t,i)}setConfigProperty(t,i,r){return this.style.setConfigProperty(t,i,r),this._update(!0)}getFeaturesetDescriptors(t){return this.style.getFeaturesetDescriptors(t)}setLights(t){if(this._lazyInitEmptyStyle(),t&&1===t.length&&"flat"===t[0].type){let i=t[0];i.properties?this.style.setFlatLight(i.properties,i.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(t),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){let t=this.style.getLights()||[];return 0===t.length&&t.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),t}setLight(t,i={}){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:t}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(t){return this._lazyInitEmptyStyle(),!t&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(t){return this._lazyInitEmptyStyle(),this.style.setSnow(t),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(t){return this._lazyInitEmptyStyle(),this.style.setRain(t),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(t){return this._lazyInitEmptyStyle(),this.style.setColorTheme(t),this._update(!0)}setImportColorTheme(t,i){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(t,i),this._update(!0)}setCamera(t){return this.style.setCamera(t),this._triggerCameraUpdate(t)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(t){let i=this.transform.nearClipOffset!==t;return this.transform.nearClipOffset=t,this._update(i)}_triggerCameraUpdate(t){return this._update(this.transform.setOrthogra
118phicProjectionAtLowPitch("orthographic"===t["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(s0.convert(t),this.transform):0}setFeatureState(t,i){return t.source&&!this._isValidId(t.source)?this:(this.style.setFeatureState(t,i),this._update())}removeFeatureState(t,i){return t.source&&!this._isValidId(t.source)?this:(this.style.removeFeatureState(t,i),this._update())}getFeatureState(t){return t.source&&!this._isValidId(t.source)?null:this.style.getFeatureState(t)}_selectIndoorFloor(t){this.style.indoorManager&&this.style.indoorManager.selectFloor(t)}_setIndoorActiveFloorsVisibility(t){this.style.indoorManager&&this.style.indoorManager.setActiveFloorsVisibility(t)}getIndoorTileOptions(t,i){return this.style&&this.style.isIndoorEnabled()&&this.style.indoorManager?this.style.indoorManager.getIndoorTileOptions(t,i):null}_updateContainerDimensions(){if(!this._container)return;let t=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300,r,a,n,o=this._container;for(;o&&(!a||!n);){let t=window.getComputedStyle(o).transform;t&&"none"!==t&&((r=t.match(SV)[1].split(", "))[0]&&"0"!==r[0]&&"1"!==r[0]&&(a=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(n=r[3])),o=o.parentElement}this._containerWidth=a?Math.abs(t/a):t,this._containerHeight=n?Math.abs(i/n):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&tX("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){let t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=iu("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();let i=this._canvasContainer=iu("div","mapboxgl-canvas-container",t);this._canvas=iu("canvas","mapboxgl-canvas",i),this._interactive&&(i.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);let r=this._controlContainer=iu("div","mapboxgl-control-container",t),a=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(t=>{a[t]=iu("div",`mapboxgl-ctrl-${t}`,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){let r=is.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_addMarker(t){this._markers.push(t)}_removeMarker(t){let i=this._markers.indexOf(t);-1!==i&&this._markers.splice(i,1)}_addPopup(t){this._popups.push(t)}_removePopup(t){let i=this._popups.indexOf(t);-1!==i&&this._popups.splice(i,1)}_setupPainter(){let t={...et,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},i=this._canvas.getContext("webgl2",t);i?(rD(i,!0),this.painter=new EB(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",t=>{if("source"===t.dataType){let i=this.transform.elevation?this.transform.elevation._source():null;i&&t.sourceCacheId===i.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0)}}),iA.testSupport(i)):this.fire(new rL(Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.style&&this.style.handleContextLost(),this.fire(new rz("webglcontextlost",{originalEvent:t}))}_contextRestored(t){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 rz("webglcontextrestored",{originalEvent:t}))}_onMapScroll(t){if(t.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(t){return this.style&&(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.loaded()||this.loaded()&&!this.isMoving()?t():this._domRenderTaskQueue.add(t)}_render(t){let i;this.fire(new rz("renderstart")),++this._frameId;let r=this.painter.context.extTimerQuery,a=is.now(),n=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=n.createQuery(),n.beginQuery(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&
118(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();let o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;let t=this.transform.zoom,i=this.transform.pitch,r=new o0(t,{now:is.now(),fadeDuration:o,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(r)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(a),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(a),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,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:o,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming,paintStartTimeStamp:t}),this.fire(new rz("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,i8.mark(i6.load),this.fire(new rz("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){let t=is.now()-a;n.endQuery(r.TIME_ELAPSED_EXT),setTimeout(()=>{let r=n.getQueryParameter(i,n.QUERY_RESULT)/1e6;n.deleteQuery(i),this.fire(new rz("gpu-timing-frame",{cpuTime:t,gpuTime:r}))},50)}if(this.listens("gpu-timing-layer")){let t=this.painter.collectGpuTimers();setTimeout(()=>{let i=this.painter.queryGpuTimers(t);this.fire(new rz("gpu-timing-layer",{layerTimes:i}))},50)}if(this.listens("gpu-timing-deferred-render")){let t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{let i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new rz("gpu-timing-deferred-render",{gpuTime:i}))},50)}let l=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(l||this._repaint)this.triggerRepaint();else{let t=this.idle();if(t&&(s=this._updateAverageElevation(a,!0)),s)this.triggerRepaint();else{if(this._triggerFrame(!1),t&&(this.fire(new rz("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){let t=this._calculateSpeedIndex();this.fire(new rz("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}t&&this.style&&this.style.handleIdle()}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,i8.mark(i6.fullLoad),this._performanceMetricsCollection&&rA(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(t){for(let i of this._markers)t&&!this.getRenderWorldCopies()&&(i._lngLat=i._lngLat.wrap()),i._update();for(let i of this._popups)!t||this.getRenderWorldCopies()||i._trackPointer||(i._lngLat=i._lngLat.wrap()),i._update()}_updateAverageElevation(t,i=!1){let r=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&r(0);let a=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(a||(i||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){let i=this.transform.averageElevation,n=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=t;let o=Math.abs(i-n);if(o>1){if(this._isInitialLoad||a)return this._averageElevation.jumpTo(n),r(n);this._averageElevation.easeTo(n,t,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),r(n)}return!!this._averageElevation.isEasing(t)&&r(this._averageElevation.getValue(t))}_isTokenExpired(){return null!=this._tokenExpiration&&Date.now()>this._tokenExpiration}_revokeAuth(){let t=this.painter.context.gl;rD(t,!1),this._logoControl instanceof SL&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new rL(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(){rM(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{t&&(t.message!==ra&&401!==t.status||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),rx(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&rb(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&rT(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){rS(this._requestManager._customAccessToken)}_updateTerrain(){let t=this._isDragging();this.painter.updateTerrain(this.style,t)}_calculateSpeedIndex(){let t=this.painter.canvasCopy(),i=this.painter.getCanvasCopiesAndTimestamps();i.timeStamps.push(performance.now());let r=this.painter.context.gl,a=r.createFramebuffer();function n(t){r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0);let i=new Uint8Array(r.drawingBufferWidth*r.drawingBufferHeight*4);return r.readPixels(0,0,r.drawingBufferWidth,r.drawingBufferHeight,r.RGBA,r.UNSIGNED_BYTE,i),i}return r.bindFramebuffer(r.FRAMEBUFFER,a),this._canvasPixelComparison(n(t),i.canvasCopies.map(n),i.timeStamps)}_canvasPixelComparison(t,i,r){let a=r[1]-r[0],n=t.length/4;for(let o=0;o<i.length;o++){let s=i[o],l=0;for(let i=0;i<s.length;i+=4)s[i]===t[i]&&s[i+1]===t[i+1]&&s[i+2]===t[i+2]&&s[i+3]===t[i+3]&&(l+=1);a+=(r[o+2]-r[o+1])*(1-l/n)}return a}remove(){if(this._removed)return;for(let t of(this._hash&&this._hash.remove(),this._controls))t.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);let t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.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),rR.delete(this.painter.context.gl),rC.remove(),ry.remove(),this._removed=!0,this.fire(new rz("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=is.frame(t=>{let i=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,i&&this._render(t)}))}_preloadTiles(t){return tB(this.style?this.style.getSourceCaches():[],(i,r)=>i._preloadTiles(t,r),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(t){this._showParseStatus!==t&&(this._showParseStatus=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(t){this._showLayers2DWireframe!==t&&(this._showLayers2DWireframe=t,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(t){this._showLayers3DWireframe!==t&&(this._showLayers3DWireframe=t,this._update())}get showElevationIdDebug(){return!!this.painter&&this.painter._debugParams.showElevationIdDebug}set showElevationIdDebug(t){this.painter&&this.painter._debugParams.showElevationIdDebug!==t&&(this.painter._debugParams.showElevationIdDebug=t,this.style&&t?this.style._reloadSources():this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,this.style&&t?this.style._reloadSources():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(t){this._showTileAABBs!==t&&(this._showTileAABBs=t,t&&this._update())}_setCacheLimits(t,i){iB=t,ik=i}get version(){return er}},NavigationControl:class{constructor(t={}){this.options={...Sj,...t},this._container=iu("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(tG(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",t=>{this._map&&this._map.zoomIn({},{originalEvent:t})}),iu("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",t=>{this._map&&this._map.zoomOut({},{originalEvent:t})}),iu("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(tG(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",t=>{let i=this._map;i&&(this.options.visualizePitch?i.resetNorthPitch({},{originalEvent:t}):i.resetNorth({},{originalEvent:t}))}),this._compassIcon=iu("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){let t=this._map;if(!t)return;
vendor: 7,717 bytes, line 118
118let i=t.getZoom(),r=i===t.getMaxZoom(),a=i===t.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())}_rotateCompassArrow(){let t=this._map;if(!t)return;let i=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=i)})}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),t.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&t.on("pitch",this._rotateCompassArrow),t.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new SG(t,this._compass,this.options.visualizePitch)),this._container}onRemove(){let t=this._map;t&&(this._container.remove(),this.options.showZoom&&t.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&t.off("pitch",this._rotateCompassArrow),t.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(t,i){let r=iu("button",t,this._container);return r.type="button",r.addEventListener("click",i),r}_setButtonTitle(t,i){if(!this._map)return;let r=this._map._getUIString(`NavigationControl.${i}`);t.setAttribute("aria-label",r),t.firstElementChild&&t.firstElementChild.setAttribute("title",r)}},GeolocateControl:class extends rB{constructor(t={}){super();let i=navigator.geolocation;this.options={geolocation:i,...SJ,...t},tG(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Ek(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(t){return this._map=t,this._container=iu("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),void 0!==this._geolocationWatchID&&(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(t){let i=(i=!!this.options.geolocation)=>{this._supportsGeolocation=i,t(i)};void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(t=>i("denied"!==t.state)).catch(()=>i()):i()}_isOutOfMapMaxBounds(t){let i=this._map.getMaxBounds(),r=t.coords;return!!i&&(r.longitude<i.getWest()||r.longitude>i.getEast()||r.latitude<i.getSouth()||r.latitude>i.getNorth())}_setWatchState(t){this._watchState=t;let i=this._geolocateButton.classList;for(let r of(i.remove(...SQ),SY[t]))i.add(SK(r))}_setButtonTitle(t){let i=this._map._getUIString(t);this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i)}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":this._setWatchState("ACTIVE_ERROR");break;case"BACKGROUND":this._setWatchState("BACKGROUND_ERROR")}}_onSuccess(t){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new rz("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this._lastKnownPosition=t,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&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.followUserLocation&&(!this.options.trackUserLocation||"ACTIVE_LOCK"===this._watchState)&&this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new rz("geolocate",{coords:t.coords,timestamp:t.timestamp,...t.toJSON?{toJSON:t.toJSON.bind(t)}:{}})),this._finish()}}_updateCamera(t){let i=new s0(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,a={bearing:this._map.getBearing(),...this.options.fitBoundsOptions};this._map.fitBounds(i.toBounds(r),a,{geolocateSource:!0})}_updateMarker(t){if(t){let i=new s0(t.coords.longitude,t.coords.latitude);this.options.showAccuracyCircle?this._accuracyCircleMarker.setLngLat(i).addTo(this._map):this._accuracyCircleMarker.remove(),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){let t=this._map.transform,i=1/s2(t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(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(t){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(1===t.code)this._setWatchState("OFF"),this._geolocateButton.disabled=!0,this._setButtonTitle("GeolocateControl.LocationNotAvailable"),void 0!==this._geolocationWatchID&&this._clearWatch();else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new rz("error",{code:t.code,message:t.message,PERMISSION_DENIED:t.PERMISSION_DENIED,POSITION_UNAVAILABLE:t.POSITION_UNAVAILABLE,TIMEOUT:t.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();let t=this.options.positionOptions.timeout;t&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},t))}_clearRequestTimeout(){void 0!==this._requestTimeoutId&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(t){void 0!==this._map&&(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=iu("button","mapboxgl-ctrl-geolocate",this._container),iu("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t?(tX("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","fal
118se"),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",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._setWatchState("BACKGROUND"),this.fire(new rz("trackuserlocationend")))}),this.fire(new rz("ready")))}_onDeviceOrientation(t){this._userLocationDotMarker&&(t.webkitCompassHeading?this._heading=t.webkitCompassHeading:!0===t.absolute&&(this._heading=-1*t.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return tX("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 rz("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 rz("trackuserlocationend"));break;case"BACKGROUND":this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new rz("trackuserlocationstart"))}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add(SK("waiting")),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(t={maximumAge:6e5,timeout:0},this._noTimeout=!0):(t=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,t),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(t){return this.options.followUserLocation=null!=t?t:SJ.followUserLocation,this.options.trackUserLocation&&"OFF"!==this._watchState&&(this.options.followUserLocation?"BACKGROUND"!==this._watchState&&"BACKGROUND_ERROR"!==this._watchState||(this._setWatchState("ACTIVE_LOCK"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new rz("trackuserlocationstart"))):"ACTIVE_LOCK"!==this._watchState&&"ACTIVE_ERROR"!==this._watchState||(this._setWatchState("BACKGROUND"),this.fire(new rz("trackuserlocationend")))),this}setShowAccuracyCircle(t){if(this.options.showAccuracyCircle=null!=t?t:SJ.showAccuracyCircle,!this._accuracyCircleMarker)return this;if(this.options.showAccuracyCircle){if(this.options.showUserLocation&&this._lastKnownPosition){let{longitude:t,latitude:i,accuracy:r}=this._lastKnownPosition.coords;this._accuracy=r,this._accuracyCircleMarker.setLngLat(new s0(t,i)).addTo(this._map),this._updateCircleRadius()}}else this._accuracyCircleMarker.remove();return this}setShowUserHeading(t){return this.options.showUserHeading=null!=t?t:SJ.showUserHeading,this._setup&&(this.options.showUserHeading?void 0!==this._geolocationWatchID&&this._addDeviceOrientationListener():(this._removeDeviceOrientationListener(),this._heading=void 0,this._userLocationDotMarker&&this._updateMarkerRotation())),this}setFitBoundsOptions(t){return this.options.fitBoundsOptions=null!=t?t:SJ.fitBoundsOptions,this}setShowUserLocation(t){return this.options.showUserLocation=null!=t?t:SJ.showUserLocation,this._setup&&(this.options.showUserLocation?(this._userLocationDotMarker||(this._createUserLocationMarkers(),this._map.on("zoom",this._onZoom)),this._lastKnownPosition&&(void 0===this._watchState||"OFF"!==this._watchState)&&this._updateMarker(this._lastKnownPosition)):(this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this._accuracyCircleMarker&&this._accuracyCircleMarker.remove())),this}_addDeviceOrientationListener(){let t=()=>{let t="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(t,this._onDeviceOrientation)};"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(i=>{"granted"===i&&t()}).catch(console.error):t()}_removeDeviceOrientationListener(){window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation)}_createUserLocationMarkers(){this._dotElement=iu("div","mapboxgl-user-location"),this._dotElement.appendChild(iu("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(iu("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new SX({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=iu("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new SX({element:this._circleElement,pitchAlignment:"map"})}_clearWatch(){this._clearRequestTimeout(),this.options.geolocation.clearWatch(this._geolocationWatchID),this._removeDeviceOrientationListener(),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(SK("waiting")),this._geolocateButton.setAttribute("aria-pressed","fal
118se"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Sz,ScaleControl:class{constructor(t={}){this.options={...S0,...t},tG(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){let t=this.options.maxWidth||100,i=this._map,r=i._containerHeight/2,a=i._containerWidth/2-t/2,n=i.unproject([a,r]),o=i.unproject([a+t,r]),s=n.distanceTo(o);if("imperial"===this.options.unit){let i=3.2808*s;i>5280?this._setScale(t,i/5280,"mile"):this._setScale(t,i,"foot")}else"nautical"===this.options.unit?this._setScale(t,s/1852,"nautical-mile"):s>=1e3?this._setScale(t,s/1e3,"kilometer"):this._setScale(t,s,"meter")}_setScale(t,i,r){this._map._requestDomTask(()=>{let a=function(t){let i=Math.pow(10,`${Math.floor(t)}`.length-1),r=t/i;return i*(r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:function(t){let i=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*i)/i}(r))}(i),n=a/i;this._container.innerHTML="nautical-mile"!==r?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:r}).format(a):`${a} ${S1[r]}`,this._container.style.width=t*n+"px"})}onAdd(t){return this._map=t,this._language=t.getLanguage(),this._container=iu("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.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(t){this._language=t,this._update()}setUnit(t){this.options.unit=t,this._update()}},FullscreenControl:class{constructor(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:tX("Full screen control 'container' must be a DOM element.")),tG(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=iu("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",tX("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){let t=this._fullscreenButton=iu("button","mapboxgl-ctrl-fullscreen",this._controlContainer);iu("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){let t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",t)}_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(){tG(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(t){return this._map=t,this._container=iu("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){let t=this._map.style.indoorManager;t.off("selector-update",this._onIndoorUpdate),t.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(t.getControlState()),this._map.off("idle",this._onStyleData)}}_createButton(t,i){let r=iu("button",t,this._container);return r.type="button",r.addEventListener("click",i),r}_setButtonTitle(t,i){t.setAttribute("aria-label",i),t.textContent=i}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(t){if(!t||!t.floors||0===t.floors.length)return this._model=t,void(this._container.style.display="none");let i=this._model;this._model=t,this._container.style.display="inline-block";let r=!i||i.floors.length!==t.floors.length||i.floors.some((i,r)=>i.id!==t.floors[r].id);if(r&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),t.selectedFloorId){if(t.selectedFloorId!==this._lastSelectedFloorId||r){let i=t.floors.findIndex(i=>i.id===t.selectedFloorId);if(-1!==i){let r,a,n=t.floors.length;n<=5?(r=0,a=n-1):0===this._visibleFloorStart?(r=0,a=3):this._visibleFloorStart>=n-3?(r=n-3-1,a=n-1):(r=this._visibleFloorStart,a=this._visibleFloorStart+3-1),i<r?this._visibleFloorStart=i:i>
118a&&(this._visibleFloorStart=i-2)}}this._lastSelectedFloorId=t.selectedFloorId}this._render()}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";let t=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);iu("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(t);let i=this._model.floors,r=i.length;if(r<=5)return void i.forEach(t=>this._createFloorButton(t));let a=0===this._visibleFloorStart,n=this._visibleFloorStart>=r-3;if(a)this._createFloorButton(i[0]);else{let t=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);iu("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),this._container.appendChild(t)}if((a?i.slice(1,4):n?i.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):i.slice(this._visibleFloorStart,this._visibleFloorStart+3)).forEach(t=>this._createFloorButton(t)),n)this._createFloorButton(i[r-1]);else{let t=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);iu("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),this._container.appendChild(t)}}_createFloorButton(t){let i=this._createButton("mapboxgl-ctrl-level-button",()=>{let i=t.id;this._model&&this._model.selectedFloorId===i&&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(i))}),r=(t.name||"").trim(),a=t.zIndex.toString(),n=r?Array.from(r).slice(0,3).join(""):a;this._setButtonTitle(i,n),this._model&&this._model.activeFloorsVisible&&t.id===this._model.selectedFloorId&&i.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(i)}_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--,1===this._visibleFloorStart&&(this._visibleFloorStart=0);let t=this._model&&this._model.floors||[];if(t.length>3){let i=t.length-3;this._visibleFloorStart===i-1&&(this._visibleFloorStart=i-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){let t=this._model.floors.length-3;this._visibleFloorStart<t&&(this._visibleFloorStart++,1===this._visibleFloorStart&&(this._visibleFloorStart=2),this._visibleFloorStart===t-1&&(this._visibleFloorStart=t),this._visibleFloorStart>t&&(this._visibleFloorStart=t),this._render())}}},Popup:class extends rB{constructor(t){super(),this.options=Object.assign(Object.create(S3),t),this._altitude=this.options.altitude,tG(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(S2):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new rz("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);let t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new rz("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=s0.convert(t),this._pos=null,this._trackPointer=!1,this._update();let i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(t){return this._altitude=t,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();let t=this._map;return t&&(t.off("move",this._update),t.on("mousemove",this._onMouseEvent),t.on("drag",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){let i,r=document.createDocumentFragment(),a=document.createElement("body");for(a.innerHTML=t;i=a.firstChild;)r.appendChild(i);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){let i=this._content;if(i)for(;i.hasChildNodes();)i.firstChild&&i.removeChild(i.firstChild);else i=this._content=iu("div","mapboxgl-popup-content",this._container||void 0);if(i.appendChild(t),this.options.closeButton){let t=this._closeButton=iu("button","mapboxgl-popup-close-button",i);t.type="button",t.setAttribute("aria-label","Close popup"),t.innerHTML='<span aria-hidden="true">×</span>',t.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(t){return this._classList.add(t),this._updateClassList(),this}removeClassName(t){return this._classList.delete(t),this._updateClassList(),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){let i;return this._classList.delete(t)?i=!1:(this._classList.add(t),i=!0),this._updateClassList(),i}_onMouseEvent(t){this._update(t.point)}_getAnchor(t){if(this.options.anchor)return this.options.anchor;let i=this._map,r=this._container,a=this._pos;if(!i||!r||!a)return"bottom";let n=r.offsetWidth,o=r.offsetHeight,s=a.x<n/2,l=a.x>i.transform.width-n/2;if(a.y+t<o)return s?"top-left":l?"top-right":"top";if(a.y>i.transform.height-o){if(s)return"bottom-left";if(l)return"bottom-right"}return s?"left":l?"right":"bottom"}_updateClassList(){let t=this._container;if(!t)return;let i=[...this._classList];i.push("mapboxgl-popup"),this._anchor&&i.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&i.push("mapboxgl-popup-track-pointer"),t.className=i.join(" ")}_update(t){let i=this._map,r=this._content;if(!i||!this._lngLat&&!this._trackPointer||!r)return;let a=this._container;if(a||(a=this._container=iu("div","mapboxgl-popup",i.getContainer()),this._tip=iu("div","mapboxgl-popup-tip",a),a.appendChild(r)),this.options.maxWidth&&a.style.maxWidth!==this.options.maxWidth&&(a.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=SH(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){let r=this._pos=this._trackPointer&&t instanceof tg?t:i.project(this._lngLat,this._altitude),a=S4(this.options.offset),n=this._anchor=this._getAnchor(a.y),o=S4(this.options.offset,n),s=r.add(o).round();i._requestDomTask(()=>{this._container&&n&&(this._container.style.transform=`${Sq[n]} translate(${s.x}px,${s.y}px)`)})}if(!this._marker&&i._showingGlobe()){let t=+!cZ(i.transform,this._lngLat);this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;
118let t=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._container&&(this._container.style.opacity=`${t}`),this._content&&(this._content.style.pointerEvents=t?"auto":"none")}},Marker:SX,Style:wQ,LngLat:s0,LngLatBounds:s1,Point:tg,MercatorCoordinate:s8,FreeCameraOptions:gk,Evented:rB,config:iT,prewarm:function(){b8().acquire(gT)},clearPrewarmedResources:function(){let t=J;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(gT),J=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 iT.ACCESS_TOKEN},set accessToken(e){iT.ACCESS_TOKEN=e},get baseApiUrl(){return iT.API_URL},set baseApiUrl(e){iT.API_URL=e},get workerCount(){return gE.workerCount},set workerCount(e){gE.workerCount=e},get maxParallelImageRequests(){return iT.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){iT.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(t){!function(t){let i=iV();if(!i)return;let r=i.delete(iF);t&&r.then(()=>t()).catch(t)}(t)},get workerUrl(){return gw.workerUrl},set workerUrl(e){gw.workerUrl=e},get workerClass(){return gw.workerClass},set workerClass(e){gw.workerClass=e},get dracoUrl(){return iE()},set dracoUrl(e){iT.DRACO_URL=is.resolveURL(e)},get meshoptUrl(){return iS()},set meshoptUrl(e){let t=is.resolveURL(e);
118iT.MESHOPT_URL=t,iT.MESHOPT_SIMD_URL=t},get buildingGenUrl(){return iI()},set buildingGenUrl(e){iT.BUILDING_GEN_URL=is.resolveURL(e)},setNow:is.setNow,restoreNow:is.restoreNow}}()}}]);
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.